Reduced token size
This commit is contained in:
@ -9,27 +9,27 @@ import (
|
||||
|
||||
// ExecuteRegisterNumber performs an operation on a register and a number.
|
||||
func (f *Function) ExecuteRegisterNumber(operation token.Token, register cpu.Register, number int) error {
|
||||
switch operation.Text() {
|
||||
case "+", "+=":
|
||||
switch operation.Kind {
|
||||
case token.Add, token.AddAssign:
|
||||
f.RegisterNumber(asm.ADD, register, number)
|
||||
|
||||
case "-", "-=":
|
||||
case token.Sub, token.SubAssign:
|
||||
f.RegisterNumber(asm.SUB, register, number)
|
||||
|
||||
case "*", "*=":
|
||||
case token.Mul, token.MulAssign:
|
||||
f.RegisterNumber(asm.MUL, register, number)
|
||||
|
||||
case "/", "/=":
|
||||
case token.Div, token.DivAssign:
|
||||
f.RegisterNumber(asm.DIV, register, number)
|
||||
|
||||
case "==", "!=", "<", "<=", ">", ">=":
|
||||
case token.Equal, token.NotEqual, token.Less, token.LessEqual, token.Greater, token.GreaterEqual:
|
||||
f.RegisterNumber(asm.COMPARE, register, number)
|
||||
|
||||
case "=":
|
||||
case token.Assign:
|
||||
f.RegisterNumber(asm.MOVE, register, number)
|
||||
|
||||
default:
|
||||
return errors.New(&errors.InvalidOperator{Operator: operation.Text()}, f.File, operation.Position)
|
||||
return errors.New(&errors.InvalidOperator{Operator: operation.Text(f.File.Bytes)}, f.File, operation.Position)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user