Simplified expression evaluation
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user