Skip to content

Commit 497c6bd

Browse files
committed
Rename opcodes
1 parent 5cfbf51 commit 497c6bd

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

compiler/compiler.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ func (c *compiler) NilNode(_ *ast.NilNode) {
196196

197197
func (c *compiler) IdentifierNode(node *ast.IdentifierNode) {
198198
if c.mapEnv {
199-
c.emit(OpEnvFast, c.addConstant(node.Value))
199+
c.emit(OpLoadFast, c.addConstant(node.Value))
200200
} else if len(node.FieldIndex) > 0 {
201-
c.emit(OpEnvField, c.addConstant(&runtime.Field{
201+
c.emit(OpLoadField, c.addConstant(&runtime.Field{
202202
Index: node.FieldIndex,
203203
Path: []string{node.Value},
204204
}))
205205
} else if node.Method {
206-
c.emit(OpEnvMethod, c.addConstant(&runtime.Method{
206+
c.emit(OpLoadMethod, c.addConstant(&runtime.Method{
207207
Name: node.Value,
208208
Index: node.MethodIndex,
209209
}))
210210
} else {
211-
c.emit(OpEnvConst, c.addConstant(node.Value))
211+
c.emit(OpLoadConst, c.addConstant(node.Value))
212212
}
213213
if node.Deref {
214214
c.emit(OpDeref)
@@ -454,7 +454,7 @@ func (c *compiler) MemberNode(node *ast.MemberNode) {
454454
}
455455
index = append(ident.FieldIndex, index...)
456456
path = append([]string{ident.Value}, path...)
457-
c.emitLocation(ident.Location(), OpEnvField, c.addConstant(
457+
c.emitLocation(ident.Location(), OpLoadField, c.addConstant(
458458
&runtime.Field{Index: index, Path: path},
459459
))
460460
goto deref

compiler/compiler_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func TestCompile(t *testing.T) {
159159
},
160160
},
161161
Bytecode: []vm.Opcode{
162-
vm.OpEnvField,
162+
vm.OpLoadField,
163163
},
164164
Arguments: []int{0},
165165
},
@@ -178,7 +178,7 @@ func TestCompile(t *testing.T) {
178178
},
179179
},
180180
Bytecode: []vm.Opcode{
181-
vm.OpEnvField,
181+
vm.OpLoadField,
182182
vm.OpJumpIfNil,
183183
vm.OpFetchField,
184184
},
@@ -199,7 +199,7 @@ func TestCompile(t *testing.T) {
199199
},
200200
},
201201
Bytecode: []vm.Opcode{
202-
vm.OpEnvField,
202+
vm.OpLoadField,
203203
vm.OpJumpIfNil,
204204
vm.OpFetchField,
205205
},
@@ -221,7 +221,7 @@ func TestCompile(t *testing.T) {
221221
},
222222
},
223223
Bytecode: []vm.Opcode{
224-
vm.OpEnvField,
224+
vm.OpLoadField,
225225
vm.OpPush,
226226
vm.OpFetch,
227227
vm.OpFetchField,

vm/opcodes.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const (
77
OpPushInt
88
OpPop
99
OpRot
10-
OpEnvConst
11-
OpEnvField
12-
OpEnvFast
13-
OpEnvMethod
10+
OpLoadConst
11+
OpLoadField
12+
OpLoadFast
13+
OpLoadMethod
1414
OpFetch
1515
OpFetchField
1616
OpMethod

vm/program.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ func (program *Program) Disassemble() string {
7272
case OpRot:
7373
code("OpRot")
7474

75-
case OpEnvConst:
76-
constant("OpEnvConst")
75+
case OpLoadConst:
76+
constant("OpLoadConst")
7777

78-
case OpEnvField:
79-
constant("OpEnvField")
78+
case OpLoadField:
79+
constant("OpLoadField")
8080

81-
case OpEnvFast:
82-
constant("OpEnvFast")
81+
case OpLoadFast:
82+
constant("OpLoadFast")
8383

84-
case OpEnvMethod:
85-
constant("OpEnvMethod")
84+
case OpLoadMethod:
85+
constant("OpLoadMethod")
8686

8787
case OpFetch:
8888
code("OpFetch")

vm/vm.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ func (vm *VM) Run(program *Program, env interface{}) (out interface{}, err error
100100
vm.push(b)
101101
vm.push(a)
102102

103-
case OpEnvConst:
103+
case OpLoadConst:
104104
vm.push(runtime.Fetch(env, program.Constants[arg]))
105105

106-
case OpEnvField:
106+
case OpLoadField:
107107
vm.push(runtime.FetchField(env, program.Constants[arg].(*runtime.Field)))
108108

109-
case OpEnvFast:
109+
case OpLoadFast:
110110
vm.push(env.(map[string]interface{})[program.Constants[arg].(string)])
111111

112-
case OpEnvMethod:
112+
case OpLoadMethod:
113113
vm.push(runtime.FetchMethod(env, program.Constants[arg].(*runtime.Method)))
114114

115115
case OpFetch:

0 commit comments

Comments
 (0)