File tree 1 file changed +22
-21
lines changed
1 file changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ type VM struct {
43
43
44
44
func NewVM (debug bool ) * VM {
45
45
vm := & VM {
46
+ stack : make ([]interface {}, 0 , 2 ),
46
47
debug : debug ,
47
48
}
48
49
if vm .debug {
@@ -61,27 +62,6 @@ func (vm *VM) SetEnv(env interface{}) {
61
62
vm .env = env
62
63
}
63
64
64
- func (vm * VM ) Stack () []interface {} {
65
- return vm .stack
66
- }
67
-
68
- func (vm * VM ) Scope () Scope {
69
- if len (vm .scopes ) > 0 {
70
- return vm .scopes [len (vm .scopes )- 1 ]
71
- }
72
- return nil
73
- }
74
-
75
- func (vm * VM ) Step () {
76
- if vm .ip < len (vm .bytecode ) {
77
- vm .step <- struct {}{}
78
- }
79
- }
80
-
81
- func (vm * VM ) Position () chan int {
82
- return vm .curr
83
- }
84
-
85
65
func (vm * VM ) Run () interface {} {
86
66
for vm .ip < len (vm .bytecode ) {
87
67
@@ -355,3 +335,24 @@ func (vm *VM) arg() uint16 {
355
335
vm .ip += 2
356
336
return arg
357
337
}
338
+
339
+ func (vm * VM ) Stack () []interface {} {
340
+ return vm .stack
341
+ }
342
+
343
+ func (vm * VM ) Scope () Scope {
344
+ if len (vm .scopes ) > 0 {
345
+ return vm .scopes [len (vm .scopes )- 1 ]
346
+ }
347
+ return nil
348
+ }
349
+
350
+ func (vm * VM ) Step () {
351
+ if vm .ip < len (vm .bytecode ) {
352
+ vm .step <- struct {}{}
353
+ }
354
+ }
355
+
356
+ func (vm * VM ) Position () chan int {
357
+ return vm .curr
358
+ }
You can’t perform that action at this time.
0 commit comments