Simplified file structure

This commit is contained in:
2024-08-07 19:39:10 +02:00
parent 1b13539b22
commit 66569446b1
219 changed files with 453 additions and 457 deletions

38
src/core/NewFunction.go Normal file
View File

@ -0,0 +1,38 @@
package core
import (
"git.akyoto.dev/cli/q/src/arch/x64"
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/cpu"
"git.akyoto.dev/cli/q/src/fs"
"git.akyoto.dev/cli/q/src/register"
"git.akyoto.dev/cli/q/src/scope"
"git.akyoto.dev/cli/q/src/token"
)
// NewFunction creates a new function.
func NewFunction(pkg string, name string, file *fs.File, body []token.Token) *Function {
return &Function{
Package: pkg,
Name: name,
UniqueName: pkg + "." + name,
File: file,
Body: body,
Machine: register.Machine{
Assembler: asm.Assembler{
Instructions: make([]asm.Instruction, 0, 8),
},
Stack: scope.Stack{
Scopes: []*scope.Scope{{}},
},
CPU: cpu.CPU{
All: x64.AllRegisters,
General: x64.GeneralRegisters,
Input: x64.InputRegisters,
Output: x64.OutputRegisters,
SyscallInput: x64.SyscallInputRegisters,
SyscallOutput: x64.SyscallOutputRegisters,
},
},
}
}