package core import ( "git.urbach.dev/cli/q/src/arm" "git.urbach.dev/cli/q/src/asm" "git.urbach.dev/cli/q/src/config" "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/wasm" "git.urbach.dev/cli/q/src/x86" ) // NewFunction creates a new function. func NewFunction(pkg string, name string, file *fs.File) *Function { var c *cpu.CPU switch config.TargetArch { case config.ARM: c = &arm.CPU case config.WASM: c = &wasm.CPU case config.X86: c = &x86.CPU } 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: c, }, } }