Added call registers

This commit is contained in:
2024-06-27 14:25:53 +02:00
parent 735057ac74
commit dc497ba4fb
8 changed files with 53 additions and 44 deletions

View File

@ -113,7 +113,7 @@ func (f *Function) CompileInstruction(line token.List) error {
}
if isFunctionCall(expr) {
return f.CompileFunctionCall(expr)
return f.ExecuteFunctionCall(expr)
}
return errors.New(&errors.InvalidInstruction{Instruction: expr.Token.Text()}, f.File, expr.Token.Position)
@ -139,6 +139,19 @@ func (f *Function) ExpressionToRegister(root *expression.Expression, register cp
return f.Execute(operation, register, right)
}
// ExpressionsToRegisters moves multiple expressions into the specified registers.
func (f *Function) ExpressionsToRegisters(expressions []*expression.Expression, registers []cpu.Register) error {
for i := len(expressions) - 1; i >= 0; i-- {
err := f.ExpressionToRegister(expressions[i], registers[i])
if err != nil {
return err
}
}
return nil
}
// TokenToRegister moves a token into a register.
// It only works with identifiers, numbers and strings.
func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {