Implemented negation
This commit is contained in:
parent
c2f6aa1a08
commit
4ded8260b3
11 changed files with 136 additions and 21 deletions
|
@ -1,6 +1,8 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/asm"
|
||||
"git.akyoto.dev/cli/q/src/build/ast"
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
|
@ -24,8 +26,19 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
|
|||
return err
|
||||
}
|
||||
|
||||
if len(node.Children) < 2 {
|
||||
return errors.New(errors.MissingOperand, f.File, node.Token.End())
|
||||
if len(node.Children) == 1 {
|
||||
if !node.Token.IsUnaryOperator() {
|
||||
fmt.Println(node.String(f.File.Bytes), node.Token.Kind)
|
||||
return errors.New(errors.MissingOperand, f.File, node.Token.End())
|
||||
}
|
||||
|
||||
err := f.ExpressionToRegister(node.Children[0], register)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return f.ExecuteRegister(node.Token, register)
|
||||
}
|
||||
|
||||
left := node.Children[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue