Implemented infinite loops

This commit is contained in:
2024-06-24 11:00:32 +02:00
parent dd495fab4e
commit 41f5dcbe62
9 changed files with 198 additions and 113 deletions

33
src/build/FunctionCall.go Normal file
View 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() == "λ"
}