Implemented compilation finished events
This commit is contained in:
44
src/build/Call.go
Normal file
44
src/build/Call.go
Normal file
@ -0,0 +1,44 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/config"
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
)
|
||||
|
||||
// CompileFunctionCall executes a function call.
|
||||
func (f *Function) CompileFunctionCall(expr *expression.Expression) error {
|
||||
funcName := expr.Children[0].Token.Text()
|
||||
|
||||
if funcName == "syscall" {
|
||||
return f.CompileSyscall(expr)
|
||||
}
|
||||
|
||||
function := f.functions[funcName]
|
||||
|
||||
if function != f {
|
||||
function.Wait()
|
||||
}
|
||||
|
||||
parameters := expr.Children[1:]
|
||||
registers := f.cpu.Call[:len(parameters)]
|
||||
|
||||
err := f.ExpressionsToRegisters(parameters, registers)
|
||||
|
||||
if config.Verbose {
|
||||
f.Logf("call: %s", funcName)
|
||||
}
|
||||
|
||||
f.assembler.Call(funcName)
|
||||
f.sideEffects += function.sideEffects
|
||||
return err
|
||||
}
|
||||
|
||||
// CompileSyscall executes a syscall.
|
||||
func (f *Function) CompileSyscall(expr *expression.Expression) error {
|
||||
parameters := expr.Children[1:]
|
||||
registers := f.cpu.Syscall[:len(parameters)]
|
||||
err := f.ExpressionsToRegisters(parameters, registers)
|
||||
f.assembler.Syscall()
|
||||
f.sideEffects++
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user