forked from TrueCloudLab/neoneo-go
vm: reorder stack opcodes
Leave *ALTSTACK opcodes for now as they are needed in compiler while slot opcodes are not yet here.
This commit is contained in:
parent
115919aaf7
commit
525527f750
6 changed files with 153 additions and 148 deletions
|
@ -47,18 +47,18 @@ type rpcTestCase struct {
|
||||||
check func(t *testing.T, e *executor, result interface{})
|
check func(t *testing.T, e *executor, result interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
const testContractHash = "642e2f47cc6883f0c196cf0dd3dcbb2333300173"
|
const testContractHash = "5d49c5a1127c23ad64a2ede6259b8ca61cc9f2fb"
|
||||||
|
|
||||||
var rpcTestCases = map[string][]rpcTestCase{
|
var rpcTestCases = map[string][]rpcTestCase{
|
||||||
"getapplicationlog": {
|
"getapplicationlog": {
|
||||||
{
|
{
|
||||||
name: "positive",
|
name: "positive",
|
||||||
params: `["9872fd330d63d64beba7122fcc9678e7f380d2163acff6a7d4f67a3c01cd67d1"]`,
|
params: `["3f056daab3c7824a6bf2cc863b5d4a0089bb3561316d65bf5e344278c0311901"]`,
|
||||||
result: func(e *executor) interface{} { return &result.ApplicationLog{} },
|
result: func(e *executor) interface{} { return &result.ApplicationLog{} },
|
||||||
check: func(t *testing.T, e *executor, acc interface{}) {
|
check: func(t *testing.T, e *executor, acc interface{}) {
|
||||||
res, ok := acc.(*result.ApplicationLog)
|
res, ok := acc.(*result.ApplicationLog)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
expectedTxHash, err := util.Uint256DecodeStringLE("9872fd330d63d64beba7122fcc9678e7f380d2163acff6a7d4f67a3c01cd67d1")
|
expectedTxHash, err := util.Uint256DecodeStringLE("3f056daab3c7824a6bf2cc863b5d4a0089bb3561316d65bf5e344278c0311901")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||||
assert.Equal(t, 1, len(res.Executions))
|
assert.Equal(t, 1, len(res.Executions))
|
||||||
|
|
BIN
pkg/rpc/server/testdata/test_contract.avm
vendored
BIN
pkg/rpc/server/testdata/test_contract.avm
vendored
Binary file not shown.
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -65,31 +65,35 @@ const (
|
||||||
CALL Opcode = 0x34
|
CALL Opcode = 0x34
|
||||||
CALLL Opcode = 0x35
|
CALLL Opcode = 0x35
|
||||||
|
|
||||||
// Legacy
|
// Stack
|
||||||
OLDPUSH1 Opcode = 0x51
|
DEPTH Opcode = 0x43
|
||||||
|
DROP Opcode = 0x45
|
||||||
|
NIP Opcode = 0x46
|
||||||
|
XDROP Opcode = 0x48
|
||||||
|
// CLEAR Opcode = 0x49
|
||||||
|
DUP Opcode = 0x4A
|
||||||
|
OVER Opcode = 0x4B
|
||||||
|
PICK Opcode = 0x4D
|
||||||
|
TUCK Opcode = 0x4E
|
||||||
|
SWAP Opcode = 0x50
|
||||||
|
OLDPUSH1 Opcode = 0x51 // FIXME remove #927
|
||||||
|
ROT Opcode = 0x51
|
||||||
|
ROLL Opcode = 0x52
|
||||||
|
// REVERSE3 Opcode = 0x53
|
||||||
|
// REVERSE4 Opcode = 0x54
|
||||||
|
// REVERSEN Opcode = 0x55
|
||||||
|
|
||||||
RET Opcode = 0x66
|
RET Opcode = 0x66
|
||||||
APPCALL Opcode = 0x67
|
APPCALL Opcode = 0x67
|
||||||
SYSCALL Opcode = 0x68
|
SYSCALL Opcode = 0x68
|
||||||
TAILCALL Opcode = 0x69
|
TAILCALL Opcode = 0x69
|
||||||
|
|
||||||
// Stack
|
// Old stack opcodes
|
||||||
DUPFROMALTSTACK Opcode = 0x6A
|
DUPFROMALTSTACK Opcode = 0x6A
|
||||||
TOALTSTACK Opcode = 0x6B
|
TOALTSTACK Opcode = 0x6B
|
||||||
FROMALTSTACK Opcode = 0x6C
|
FROMALTSTACK Opcode = 0x6C
|
||||||
XDROP Opcode = 0x6D
|
|
||||||
XSWAP Opcode = 0x72
|
XSWAP Opcode = 0x72
|
||||||
XTUCK Opcode = 0x73
|
XTUCK Opcode = 0x73
|
||||||
DEPTH Opcode = 0x74
|
|
||||||
DROP Opcode = 0x75
|
|
||||||
DUP Opcode = 0x76
|
|
||||||
NIP Opcode = 0x77
|
|
||||||
OVER Opcode = 0x78
|
|
||||||
PICK Opcode = 0x79
|
|
||||||
ROLL Opcode = 0x7A
|
|
||||||
ROT Opcode = 0x7B
|
|
||||||
SWAP Opcode = 0x7C
|
|
||||||
TUCK Opcode = 0x7D
|
|
||||||
|
|
||||||
// Splice
|
// Splice
|
||||||
CAT Opcode = 0x7E
|
CAT Opcode = 0x7E
|
||||||
|
|
|
@ -59,7 +59,18 @@ func _() {
|
||||||
_ = x[JMPLEL-51]
|
_ = x[JMPLEL-51]
|
||||||
_ = x[CALL-52]
|
_ = x[CALL-52]
|
||||||
_ = x[CALLL-53]
|
_ = x[CALLL-53]
|
||||||
|
_ = x[DEPTH-67]
|
||||||
|
_ = x[DROP-69]
|
||||||
|
_ = x[NIP-70]
|
||||||
|
_ = x[XDROP-72]
|
||||||
|
_ = x[DUP-74]
|
||||||
|
_ = x[OVER-75]
|
||||||
|
_ = x[PICK-77]
|
||||||
|
_ = x[TUCK-78]
|
||||||
|
_ = x[SWAP-80]
|
||||||
_ = x[OLDPUSH1-81]
|
_ = x[OLDPUSH1-81]
|
||||||
|
_ = x[ROT-81]
|
||||||
|
_ = x[ROLL-82]
|
||||||
_ = x[RET-102]
|
_ = x[RET-102]
|
||||||
_ = x[APPCALL-103]
|
_ = x[APPCALL-103]
|
||||||
_ = x[SYSCALL-104]
|
_ = x[SYSCALL-104]
|
||||||
|
@ -67,19 +78,8 @@ func _() {
|
||||||
_ = x[DUPFROMALTSTACK-106]
|
_ = x[DUPFROMALTSTACK-106]
|
||||||
_ = x[TOALTSTACK-107]
|
_ = x[TOALTSTACK-107]
|
||||||
_ = x[FROMALTSTACK-108]
|
_ = x[FROMALTSTACK-108]
|
||||||
_ = x[XDROP-109]
|
|
||||||
_ = x[XSWAP-114]
|
_ = x[XSWAP-114]
|
||||||
_ = x[XTUCK-115]
|
_ = x[XTUCK-115]
|
||||||
_ = x[DEPTH-116]
|
|
||||||
_ = x[DROP-117]
|
|
||||||
_ = x[DUP-118]
|
|
||||||
_ = x[NIP-119]
|
|
||||||
_ = x[OVER-120]
|
|
||||||
_ = x[PICK-121]
|
|
||||||
_ = x[ROLL-122]
|
|
||||||
_ = x[ROT-123]
|
|
||||||
_ = x[SWAP-124]
|
|
||||||
_ = x[TUCK-125]
|
|
||||||
_ = x[CAT-126]
|
_ = x[CAT-126]
|
||||||
_ = x[SUBSTR-127]
|
_ = x[SUBSTR-127]
|
||||||
_ = x[LEFT-128]
|
_ = x[LEFT-128]
|
||||||
|
@ -89,6 +89,7 @@ func _() {
|
||||||
_ = x[OR-146]
|
_ = x[OR-146]
|
||||||
_ = x[XOR-147]
|
_ = x[XOR-147]
|
||||||
_ = x[EQUAL-151]
|
_ = x[EQUAL-151]
|
||||||
|
_ = x[NOTEQUAL-152]
|
||||||
_ = x[SIGN-153]
|
_ = x[SIGN-153]
|
||||||
_ = x[ABS-154]
|
_ = x[ABS-154]
|
||||||
_ = x[NEGATE-155]
|
_ = x[NEGATE-155]
|
||||||
|
@ -139,7 +140,7 @@ func _() {
|
||||||
_ = x[THROWIFNOT-241]
|
_ = x[THROWIFNOT-241]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _Opcode_name = "PUSHINT8PUSHINT16PUSHINT32PUSHINT64PUSHINT128PUSHINT256PUSHNULLPUSHDATA1PUSHDATA2PUSHDATA4PUSHM1PUSH0PUSH1PUSH2PUSH3PUSH4PUSH5PUSH6PUSH7PUSH8PUSH9PUSH10PUSH11PUSH12PUSH13PUSH14PUSH15PUSH16NOPJMPJMPLJMPIFJMPIFLJMPIFNOTJMPIFNOTLJMPEQJMPEQLJMPNEJMPNELJMPGTJMPGTLJMPGEJMPGELJMPLTJMPLTLJMPLEJMPLELCALLCALLLOLDPUSH1RETAPPCALLSYSCALLTAILCALLDUPFROMALTSTACKTOALTSTACKFROMALTSTACKXDROPXSWAPXTUCKDEPTHDROPDUPNIPOVERPICKROLLROTSWAPTUCKCATSUBSTRLEFTRIGHTINVERTANDORXOREQUALSIGNABSNEGATEINCDECADDSUBMULDIVMODSHLSHRNOTBOOLANDBOOLORNZNUMEQUALNUMNOTEQUALLTLTEGTGTEMINMAXWITHINPACKUNPACKNEWARRAY0NEWARRAYNEWARRAYTNEWSTRUCT0NEWSTRUCTNEWMAPSIZEHASKEYKEYSVALUESPICKITEMAPPENDSETITEMREVERSEITEMSREMOVECLEARITEMSISNULLISTYPECONVERTTHROWTHROWIFNOT"
|
const _Opcode_name = "PUSHINT8PUSHINT16PUSHINT32PUSHINT64PUSHINT128PUSHINT256PUSHNULLPUSHDATA1PUSHDATA2PUSHDATA4PUSHM1PUSH0PUSH1PUSH2PUSH3PUSH4PUSH5PUSH6PUSH7PUSH8PUSH9PUSH10PUSH11PUSH12PUSH13PUSH14PUSH15PUSH16NOPJMPJMPLJMPIFJMPIFLJMPIFNOTJMPIFNOTLJMPEQJMPEQLJMPNEJMPNELJMPGTJMPGTLJMPGEJMPGELJMPLTJMPLTLJMPLEJMPLELCALLCALLLDEPTHDROPNIPXDROPDUPOVERPICKTUCKSWAPOLDPUSH1ROLLRETAPPCALLSYSCALLTAILCALLDUPFROMALTSTACKTOALTSTACKFROMALTSTACKXSWAPXTUCKCATSUBSTRLEFTRIGHTINVERTANDORXOREQUALNOTEQUALSIGNABSNEGATEINCDECADDSUBMULDIVMODSHLSHRNOTBOOLANDBOOLORNZNUMEQUALNUMNOTEQUALLTLTEGTGTEMINMAXWITHINPACKUNPACKNEWARRAY0NEWARRAYNEWARRAYTNEWSTRUCT0NEWSTRUCTNEWMAPSIZEHASKEYKEYSVALUESPICKITEMAPPENDSETITEMREVERSEITEMSREMOVECLEARITEMSISNULLISTYPECONVERTTHROWTHROWIFNOT"
|
||||||
|
|
||||||
var _Opcode_map = map[Opcode]string{
|
var _Opcode_map = map[Opcode]string{
|
||||||
0: _Opcode_name[0:8],
|
0: _Opcode_name[0:8],
|
||||||
|
@ -191,84 +192,84 @@ var _Opcode_map = map[Opcode]string{
|
||||||
51: _Opcode_name[286:292],
|
51: _Opcode_name[286:292],
|
||||||
52: _Opcode_name[292:296],
|
52: _Opcode_name[292:296],
|
||||||
53: _Opcode_name[296:301],
|
53: _Opcode_name[296:301],
|
||||||
81: _Opcode_name[301:309],
|
67: _Opcode_name[301:306],
|
||||||
102: _Opcode_name[309:312],
|
69: _Opcode_name[306:310],
|
||||||
103: _Opcode_name[312:319],
|
70: _Opcode_name[310:313],
|
||||||
104: _Opcode_name[319:326],
|
72: _Opcode_name[313:318],
|
||||||
105: _Opcode_name[326:334],
|
74: _Opcode_name[318:321],
|
||||||
106: _Opcode_name[334:349],
|
75: _Opcode_name[321:325],
|
||||||
107: _Opcode_name[349:359],
|
77: _Opcode_name[325:329],
|
||||||
108: _Opcode_name[359:371],
|
78: _Opcode_name[329:333],
|
||||||
109: _Opcode_name[371:376],
|
80: _Opcode_name[333:337],
|
||||||
114: _Opcode_name[376:381],
|
81: _Opcode_name[337:345],
|
||||||
115: _Opcode_name[381:386],
|
82: _Opcode_name[345:349],
|
||||||
116: _Opcode_name[386:391],
|
102: _Opcode_name[349:352],
|
||||||
117: _Opcode_name[391:395],
|
103: _Opcode_name[352:359],
|
||||||
118: _Opcode_name[395:398],
|
104: _Opcode_name[359:366],
|
||||||
119: _Opcode_name[398:401],
|
105: _Opcode_name[366:374],
|
||||||
120: _Opcode_name[401:405],
|
106: _Opcode_name[374:389],
|
||||||
121: _Opcode_name[405:409],
|
107: _Opcode_name[389:399],
|
||||||
122: _Opcode_name[409:413],
|
108: _Opcode_name[399:411],
|
||||||
123: _Opcode_name[413:416],
|
114: _Opcode_name[411:416],
|
||||||
124: _Opcode_name[416:420],
|
115: _Opcode_name[416:421],
|
||||||
125: _Opcode_name[420:424],
|
126: _Opcode_name[421:424],
|
||||||
126: _Opcode_name[424:427],
|
127: _Opcode_name[424:430],
|
||||||
127: _Opcode_name[427:433],
|
128: _Opcode_name[430:434],
|
||||||
128: _Opcode_name[433:437],
|
129: _Opcode_name[434:439],
|
||||||
129: _Opcode_name[437:442],
|
144: _Opcode_name[439:445],
|
||||||
144: _Opcode_name[442:448],
|
145: _Opcode_name[445:448],
|
||||||
145: _Opcode_name[448:451],
|
146: _Opcode_name[448:450],
|
||||||
146: _Opcode_name[451:453],
|
147: _Opcode_name[450:453],
|
||||||
147: _Opcode_name[453:456],
|
151: _Opcode_name[453:458],
|
||||||
151: _Opcode_name[456:461],
|
152: _Opcode_name[458:466],
|
||||||
153: _Opcode_name[461:465],
|
153: _Opcode_name[466:470],
|
||||||
154: _Opcode_name[465:468],
|
154: _Opcode_name[470:473],
|
||||||
155: _Opcode_name[468:474],
|
155: _Opcode_name[473:479],
|
||||||
156: _Opcode_name[474:477],
|
156: _Opcode_name[479:482],
|
||||||
157: _Opcode_name[477:480],
|
157: _Opcode_name[482:485],
|
||||||
158: _Opcode_name[480:483],
|
158: _Opcode_name[485:488],
|
||||||
159: _Opcode_name[483:486],
|
159: _Opcode_name[488:491],
|
||||||
160: _Opcode_name[486:489],
|
160: _Opcode_name[491:494],
|
||||||
161: _Opcode_name[489:492],
|
161: _Opcode_name[494:497],
|
||||||
162: _Opcode_name[492:495],
|
162: _Opcode_name[497:500],
|
||||||
168: _Opcode_name[495:498],
|
168: _Opcode_name[500:503],
|
||||||
169: _Opcode_name[498:501],
|
169: _Opcode_name[503:506],
|
||||||
170: _Opcode_name[501:504],
|
170: _Opcode_name[506:509],
|
||||||
171: _Opcode_name[504:511],
|
171: _Opcode_name[509:516],
|
||||||
172: _Opcode_name[511:517],
|
172: _Opcode_name[516:522],
|
||||||
177: _Opcode_name[517:519],
|
177: _Opcode_name[522:524],
|
||||||
179: _Opcode_name[519:527],
|
179: _Opcode_name[524:532],
|
||||||
180: _Opcode_name[527:538],
|
180: _Opcode_name[532:543],
|
||||||
181: _Opcode_name[538:540],
|
181: _Opcode_name[543:545],
|
||||||
182: _Opcode_name[540:543],
|
182: _Opcode_name[545:548],
|
||||||
183: _Opcode_name[543:545],
|
183: _Opcode_name[548:550],
|
||||||
184: _Opcode_name[545:548],
|
184: _Opcode_name[550:553],
|
||||||
185: _Opcode_name[548:551],
|
185: _Opcode_name[553:556],
|
||||||
186: _Opcode_name[551:554],
|
186: _Opcode_name[556:559],
|
||||||
187: _Opcode_name[554:560],
|
187: _Opcode_name[559:565],
|
||||||
192: _Opcode_name[560:564],
|
192: _Opcode_name[565:569],
|
||||||
193: _Opcode_name[564:570],
|
193: _Opcode_name[569:575],
|
||||||
194: _Opcode_name[570:579],
|
194: _Opcode_name[575:584],
|
||||||
195: _Opcode_name[579:587],
|
195: _Opcode_name[584:592],
|
||||||
196: _Opcode_name[587:596],
|
196: _Opcode_name[592:601],
|
||||||
197: _Opcode_name[596:606],
|
197: _Opcode_name[601:611],
|
||||||
198: _Opcode_name[606:615],
|
198: _Opcode_name[611:620],
|
||||||
200: _Opcode_name[615:621],
|
200: _Opcode_name[620:626],
|
||||||
202: _Opcode_name[621:625],
|
202: _Opcode_name[626:630],
|
||||||
203: _Opcode_name[625:631],
|
203: _Opcode_name[630:636],
|
||||||
204: _Opcode_name[631:635],
|
204: _Opcode_name[636:640],
|
||||||
205: _Opcode_name[635:641],
|
205: _Opcode_name[640:646],
|
||||||
206: _Opcode_name[641:649],
|
206: _Opcode_name[646:654],
|
||||||
207: _Opcode_name[649:655],
|
207: _Opcode_name[654:660],
|
||||||
208: _Opcode_name[655:662],
|
208: _Opcode_name[660:667],
|
||||||
209: _Opcode_name[662:674],
|
209: _Opcode_name[667:679],
|
||||||
210: _Opcode_name[674:680],
|
210: _Opcode_name[679:685],
|
||||||
211: _Opcode_name[680:690],
|
211: _Opcode_name[685:695],
|
||||||
216: _Opcode_name[690:696],
|
216: _Opcode_name[695:701],
|
||||||
217: _Opcode_name[696:702],
|
217: _Opcode_name[701:707],
|
||||||
219: _Opcode_name[702:709],
|
219: _Opcode_name[707:714],
|
||||||
240: _Opcode_name[709:714],
|
240: _Opcode_name[714:719],
|
||||||
241: _Opcode_name[714:724],
|
241: _Opcode_name[719:729],
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i Opcode) String() string {
|
func (i Opcode) String() string {
|
||||||
|
|
82
pkg/vm/vm.go
82
pkg/vm/vm.go
|
@ -589,25 +589,6 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
case opcode.DUPFROMALTSTACK:
|
case opcode.DUPFROMALTSTACK:
|
||||||
v.estack.Push(v.astack.Dup(0))
|
v.estack.Push(v.astack.Dup(0))
|
||||||
|
|
||||||
case opcode.DUP:
|
|
||||||
v.estack.Push(v.estack.Dup(0))
|
|
||||||
|
|
||||||
case opcode.SWAP:
|
|
||||||
err := v.estack.Swap(1, 0)
|
|
||||||
if err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
case opcode.TUCK:
|
|
||||||
a := v.estack.Dup(0)
|
|
||||||
if a == nil {
|
|
||||||
panic("no top-level element found")
|
|
||||||
}
|
|
||||||
if v.estack.Len() < 2 {
|
|
||||||
panic("can't TUCK with a one-element stack")
|
|
||||||
}
|
|
||||||
v.estack.InsertAt(a, 2)
|
|
||||||
|
|
||||||
case opcode.CAT:
|
case opcode.CAT:
|
||||||
b := v.estack.Pop().Bytes()
|
b := v.estack.Pop().Bytes()
|
||||||
a := v.estack.Pop().Bytes()
|
a := v.estack.Pop().Bytes()
|
||||||
|
@ -652,16 +633,6 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
s := v.estack.Pop().Bytes()
|
s := v.estack.Pop().Bytes()
|
||||||
v.estack.PushVal(s[len(s)-l:])
|
v.estack.PushVal(s[len(s)-l:])
|
||||||
|
|
||||||
case opcode.XDROP:
|
|
||||||
n := int(v.estack.Pop().BigInt().Int64())
|
|
||||||
if n < 0 {
|
|
||||||
panic("invalid length")
|
|
||||||
}
|
|
||||||
e := v.estack.RemoveAt(n)
|
|
||||||
if e == nil {
|
|
||||||
panic("bad index")
|
|
||||||
}
|
|
||||||
|
|
||||||
case opcode.XSWAP:
|
case opcode.XSWAP:
|
||||||
n := int(v.estack.Pop().BigInt().Int64())
|
n := int(v.estack.Pop().BigInt().Int64())
|
||||||
err := v.estack.Swap(n, 0)
|
err := v.estack.Swap(n, 0)
|
||||||
|
@ -683,21 +654,34 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
}
|
}
|
||||||
v.estack.InsertAt(a, n)
|
v.estack.InsertAt(a, n)
|
||||||
|
|
||||||
case opcode.ROT:
|
|
||||||
err := v.estack.Roll(2)
|
|
||||||
if err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
case opcode.DEPTH:
|
case opcode.DEPTH:
|
||||||
v.estack.PushVal(v.estack.Len())
|
v.estack.PushVal(v.estack.Len())
|
||||||
|
|
||||||
|
case opcode.DROP:
|
||||||
|
if v.estack.Len() < 1 {
|
||||||
|
panic("stack is too small")
|
||||||
|
}
|
||||||
|
v.estack.Pop()
|
||||||
|
|
||||||
case opcode.NIP:
|
case opcode.NIP:
|
||||||
elem := v.estack.RemoveAt(1)
|
elem := v.estack.RemoveAt(1)
|
||||||
if elem == nil {
|
if elem == nil {
|
||||||
panic("no second element found")
|
panic("no second element found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case opcode.XDROP:
|
||||||
|
n := int(v.estack.Pop().BigInt().Int64())
|
||||||
|
if n < 0 {
|
||||||
|
panic("invalid length")
|
||||||
|
}
|
||||||
|
e := v.estack.RemoveAt(n)
|
||||||
|
if e == nil {
|
||||||
|
panic("bad index")
|
||||||
|
}
|
||||||
|
|
||||||
|
case opcode.DUP:
|
||||||
|
v.estack.Push(v.estack.Dup(0))
|
||||||
|
|
||||||
case opcode.OVER:
|
case opcode.OVER:
|
||||||
a := v.estack.Dup(1)
|
a := v.estack.Dup(1)
|
||||||
if a == nil {
|
if a == nil {
|
||||||
|
@ -716,6 +700,28 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
}
|
}
|
||||||
v.estack.Push(a)
|
v.estack.Push(a)
|
||||||
|
|
||||||
|
case opcode.TUCK:
|
||||||
|
a := v.estack.Dup(0)
|
||||||
|
if a == nil {
|
||||||
|
panic("no top-level element found")
|
||||||
|
}
|
||||||
|
if v.estack.Len() < 2 {
|
||||||
|
panic("can't TUCK with a one-element stack")
|
||||||
|
}
|
||||||
|
v.estack.InsertAt(a, 2)
|
||||||
|
|
||||||
|
case opcode.SWAP:
|
||||||
|
err := v.estack.Swap(1, 0)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
case opcode.ROT:
|
||||||
|
err := v.estack.Roll(2)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
case opcode.ROLL:
|
case opcode.ROLL:
|
||||||
n := int(v.estack.Pop().BigInt().Int64())
|
n := int(v.estack.Pop().BigInt().Int64())
|
||||||
err := v.estack.Roll(n)
|
err := v.estack.Roll(n)
|
||||||
|
@ -723,12 +729,6 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
case opcode.DROP:
|
|
||||||
if v.estack.Len() < 1 {
|
|
||||||
panic("stack is too small")
|
|
||||||
}
|
|
||||||
v.estack.Pop()
|
|
||||||
|
|
||||||
// Bit operations.
|
// Bit operations.
|
||||||
case opcode.INVERT:
|
case opcode.INVERT:
|
||||||
// inplace
|
// inplace
|
||||||
|
|
Loading…
Reference in a new issue