Implemented infinite loops
This commit is contained in:
33
src/build/FunctionCall.go
Normal file
33
src/build/FunctionCall.go
Normal file
@ -0,0 +1,33 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/token"
|
||||
)
|
||||
|
||||
// CompileFunctionCall compiles a top-level function call.
|
||||
func (f *Function) CompileFunctionCall(expr *expression.Expression) error {
|
||||
funcName := expr.Children[0].Token.Text()
|
||||
parameters := expr.Children[1:]
|
||||
|
||||
for i, parameter := range parameters {
|
||||
err := f.ExpressionToRegister(parameter, f.CPU.Syscall[i])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if funcName == "syscall" {
|
||||
f.Assembler.Syscall()
|
||||
} else {
|
||||
f.Assembler.Call(funcName)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// isFunctionCall returns true if the expression is a function call.
|
||||
func isFunctionCall(expr *expression.Expression) bool {
|
||||
return expr.Token.Kind == token.Operator && expr.Token.Text() == "λ"
|
||||
}
|
Reference in New Issue
Block a user