From a765561b3aee07bfd0286fc2824dfecbc03a91c2 Mon Sep 17 00:00:00 2001 From: Anthony De Meulemeester Date: Fri, 26 Oct 2018 16:02:32 +0200 Subject: [PATCH] implemented bitwise instructions and fixed loading constants of type uint (CityOfZion/neo-storm#49) Imported from CityOfZion/neo-storm (b8a9b14dacc4fd6a62c236b2e89545684435a8fb). --- pkg/vm/compiler/codegen.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/vm/compiler/codegen.go b/pkg/vm/compiler/codegen.go index 223688ad3..0071bf131 100644 --- a/pkg/vm/compiler/codegen.go +++ b/pkg/vm/compiler/codegen.go @@ -58,7 +58,7 @@ func (c *codegen) emitLoadConst(t types.TypeAndValue) { switch typ := t.Type.Underlying().(type) { case *types.Basic: switch typ.Kind() { - case types.Int, types.UntypedInt: + case types.Int, types.UntypedInt, types.Uint: val, _ := constant.Int64Val(t.Value) emitInt(c.prog, val) case types.String, types.UntypedString: @@ -686,6 +686,16 @@ func (c *codegen) convertToken(tok token.Token) { emitOpcode(c.prog, vm.INC) case token.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: log.Fatalf("compiler could not convert token: %s", tok) }