Simplified expression evaluation

This commit is contained in:
2025-02-28 16:07:10 +01:00
parent b67361c035
commit a5a8f0f503
17 changed files with 153 additions and 322 deletions

View File

@ -1,10 +1,8 @@
package core
import (
"git.urbach.dev/cli/q/src/asm"
"git.urbach.dev/cli/q/src/ast"
"git.urbach.dev/cli/q/src/errors"
"git.urbach.dev/cli/q/src/expression"
"git.urbach.dev/cli/q/src/token"
"git.urbach.dev/cli/q/src/types"
)
@ -48,27 +46,5 @@ func (f *Function) CompileDefinition(node *ast.Define) error {
return errors.New(errors.NotImplemented, f.File, node.Expression.Token.Position)
}
count := 0
types, err := f.CompileCall(right)
if err != nil {
return err
}
return left.EachLeaf(func(leaf *expression.Expression) error {
variable, err := f.Define(leaf)
if err != nil {
return err
}
if count < len(types) {
variable.Value.Typ = types[count]
}
f.RegisterRegister(asm.MOVE, variable.Value.Register, f.CPU.Output[count])
f.AddVariable(variable)
count++
return nil
})
return f.MultiDefine(left, right)
}