implemented bitwise instructions and fixed loading constants of type uint (CityOfZion/neo-storm#49)

Imported from CityOfZion/neo-storm (b8a9b14dacc4fd6a62c236b2e89545684435a8fb).
This commit is contained in:
Anthony De Meulemeester 2018-10-26 16:02:32 +02:00 committed by Roman Khimov
parent 459d3654a2
commit a765561b3a

View file

@ -58,7 +58,7 @@ func (c *codegen) emitLoadConst(t types.TypeAndValue) {
switch typ := t.Type.Underlying().(type) { switch typ := t.Type.Underlying().(type) {
case *types.Basic: case *types.Basic:
switch typ.Kind() { switch typ.Kind() {
case types.Int, types.UntypedInt: case types.Int, types.UntypedInt, types.Uint:
val, _ := constant.Int64Val(t.Value) val, _ := constant.Int64Val(t.Value)
emitInt(c.prog, val) emitInt(c.prog, val)
case types.String, types.UntypedString: case types.String, types.UntypedString:
@ -686,6 +686,16 @@ func (c *codegen) convertToken(tok token.Token) {
emitOpcode(c.prog, vm.INC) emitOpcode(c.prog, vm.INC)
case token.NOT: case token.NOT:
emitOpcode(c.prog, vm.NOT) emitOpcode(c.prog, vm.NOT)
case token.AND:
emitOpcode(c.prog, vm.AND)
case token.OR:
emitOpcode(c.prog, vm.OR)
case token.SHL:
emitOpcode(c.prog, vm.SHL)
case token.SHR:
emitOpcode(c.prog, vm.SHR)
case token.XOR:
emitOpcode(c.prog, vm.XOR)
default: default:
log.Fatalf("compiler could not convert token: %s", tok) log.Fatalf("compiler could not convert token: %s", tok)
} }