37 lines
885 B
Go
37 lines
885 B
Go
package core
|
|
|
|
import (
|
|
"git.urbach.dev/cli/q/src/asm"
|
|
"git.urbach.dev/cli/q/src/cpu"
|
|
"git.urbach.dev/cli/q/src/fs"
|
|
"git.urbach.dev/cli/q/src/register"
|
|
"git.urbach.dev/cli/q/src/scope"
|
|
"git.urbach.dev/cli/q/src/x86"
|
|
)
|
|
|
|
// NewFunction creates a new function.
|
|
func NewFunction(pkg string, name string, file *fs.File) *Function {
|
|
return &Function{
|
|
Package: pkg,
|
|
Name: name,
|
|
UniqueName: pkg + "." + name,
|
|
File: file,
|
|
Machine: register.Machine{
|
|
Assembler: asm.Assembler{
|
|
Instructions: make([]asm.Instruction, 0, 8),
|
|
},
|
|
Stack: scope.Stack{
|
|
Scopes: []*scope.Scope{{}},
|
|
},
|
|
CPU: cpu.CPU{
|
|
General: x86.GeneralRegisters,
|
|
Input: x86.InputRegisters,
|
|
Output: x86.OutputRegisters,
|
|
SyscallInput: x86.SyscallInputRegisters,
|
|
SyscallOutput: x86.SyscallOutputRegisters,
|
|
NumRegisters: 16,
|
|
},
|
|
},
|
|
}
|
|
}
|