22 lines
533 B
Go
22 lines
533 B
Go
package core
|
|
|
|
import (
|
|
"git.urbach.dev/cli/q/src/asm"
|
|
"git.urbach.dev/cli/q/src/cpu"
|
|
"git.urbach.dev/cli/q/src/errors"
|
|
"git.urbach.dev/cli/q/src/token"
|
|
)
|
|
|
|
// ExecuteRegister performs an operation on a single register.
|
|
func (f *Function) ExecuteRegister(operation token.Token, register cpu.Register) error {
|
|
switch operation.Kind {
|
|
case token.Negate:
|
|
f.Register(asm.NEGATE, register)
|
|
|
|
default:
|
|
return errors.New(&errors.InvalidOperator{Operator: operation.Text(f.File.Bytes)}, f.File, operation.Position)
|
|
}
|
|
|
|
return nil
|
|
}
|