@@ -16,20 +16,24 @@ import (
1616
1717type AddInstruction struct {}
1818
19- func (i * AddInstruction ) PossibleNextSteps () (gen.StepInfo , core.ResultList ) {
19+ func (AddInstruction ) PossibleNextSteps (* gen. InstructionInfo ) (gen.StepInfo , core.ResultList ) {
2020 return gen.StepInfo {PossibleContinue : true }, core.ResultList {}
2121}
2222
23- func (i * AddInstruction ) Operator () string {
23+ func (AddInstruction ) Operator (* gen. InstructionInfo ) string {
2424 return "ADD"
2525}
2626
27+ func (AddInstruction ) Validate (info * gen.InstructionInfo ) core.ResultList {
28+ return core.ResultList {}
29+ }
30+
2731type AddInstructionDefinition struct {}
2832
2933func (AddInstructionDefinition ) BuildInstruction (
3034 info * gen.InstructionInfo ,
31- ) (gen.BaseInstruction , core.ResultList ) {
32- return gen .BaseInstruction ( & AddInstruction {}), core.ResultList {}
35+ ) (gen.InstructionDefinition , core.ResultList ) {
36+ return gen .InstructionDefinition ( AddInstruction {}), core.ResultList {}
3337}
3438
3539func (AddInstructionDefinition ) InferTargetTypes (
@@ -71,20 +75,24 @@ func (AddInstructionDefinition) InferTargetTypes(
7175
7276type RetInstruction struct {}
7377
74- func (i * RetInstruction ) PossibleNextSteps () (gen.StepInfo , core.ResultList ) {
78+ func (RetInstruction ) PossibleNextSteps (* gen. InstructionInfo ) (gen.StepInfo , core.ResultList ) {
7579 return gen.StepInfo {PossibleReturn : true }, core.ResultList {}
7680}
7781
78- func (i * RetInstruction ) Operator () string {
82+ func (RetInstruction ) Operator (* gen. InstructionInfo ) string {
7983 return "RET"
8084}
8185
86+ func (RetInstruction ) Validate (* gen.InstructionInfo ) core.ResultList {
87+ return core.ResultList {}
88+ }
89+
8290type RetInstructionDefinition struct {}
8391
8492func (RetInstructionDefinition ) BuildInstruction (
8593 info * gen.InstructionInfo ,
86- ) (gen.BaseInstruction , core.ResultList ) {
87- return gen .BaseInstruction ( & RetInstruction {}), core.ResultList {}
94+ ) (gen.InstructionDefinition , core.ResultList ) {
95+ return gen .InstructionDefinition ( RetInstruction {}), core.ResultList {}
8896}
8997
9098func (RetInstructionDefinition ) InferTargetTypes (
@@ -97,28 +105,30 @@ func (RetInstructionDefinition) InferTargetTypes(
97105
98106// MARK: Jump
99107
100- type JumpInstruction struct {
101- * gen.InstructionInfo
102- }
108+ type JumpInstruction struct {}
103109
104- func (i * JumpInstruction ) PossibleNextSteps () (gen.StepInfo , core.ResultList ) {
110+ func (JumpInstruction ) PossibleNextSteps (i * gen. InstructionInfo ) (gen.StepInfo , core.ResultList ) {
105111 return gen.StepInfo {
106112 PossibleBranches : []* gen.LabelInfo {
107113 i .Arguments [0 ].(* gen.LabelArgumentInfo ).Label ,
108114 },
109115 }, core.ResultList {}
110116}
111117
112- func (i * JumpInstruction ) Operator () string {
118+ func (JumpInstruction ) Operator (* gen. InstructionInfo ) string {
113119 return "JMP"
114120}
115121
122+ func (JumpInstruction ) Validate (info * gen.InstructionInfo ) core.ResultList {
123+ return core.ResultList {}
124+ }
125+
116126type JumpInstructionDefinition struct {}
117127
118128func (JumpInstructionDefinition ) BuildInstruction (
119129 info * gen.InstructionInfo ,
120- ) (gen.BaseInstruction , core.ResultList ) {
121- return gen .BaseInstruction ( & JumpInstruction {info }), core.ResultList {}
130+ ) (gen.InstructionDefinition , core.ResultList ) {
131+ return gen .InstructionDefinition ( JumpInstruction {}), core.ResultList {}
122132}
123133
124134func (JumpInstructionDefinition ) InferTargetTypes (
@@ -132,28 +142,30 @@ func (JumpInstructionDefinition) InferTargetTypes(
132142// MARK: Jump Zero
133143
134144// JZ %condition .label
135- type JumpZeroInstruction struct {
136- * gen.InstructionInfo
137- }
145+ type JumpZeroInstruction struct {}
138146
139- func (i * JumpZeroInstruction ) PossibleNextSteps () (gen.StepInfo , core.ResultList ) {
147+ func (JumpZeroInstruction ) PossibleNextSteps (i * gen. InstructionInfo ) (gen.StepInfo , core.ResultList ) {
140148 label := i .Arguments [1 ].(* gen.LabelArgumentInfo ).Label
141149 return gen.StepInfo {
142150 PossibleBranches : []* gen.LabelInfo {label },
143151 PossibleContinue : true ,
144152 }, core.ResultList {}
145153}
146154
147- func (i * JumpZeroInstruction ) Operator () string {
155+ func (JumpZeroInstruction ) Operator (* gen. InstructionInfo ) string {
148156 return "JZ"
149157}
150158
159+ func (JumpZeroInstruction ) Validate (info * gen.InstructionInfo ) core.ResultList {
160+ return core.ResultList {}
161+ }
162+
151163type JumpZeroInstructionDefinition struct {}
152164
153165func (JumpZeroInstructionDefinition ) BuildInstruction (
154166 info * gen.InstructionInfo ,
155- ) (gen.BaseInstruction , core.ResultList ) {
156- return gen .BaseInstruction ( & JumpZeroInstruction {info }), core.ResultList {}
167+ ) (gen.InstructionDefinition , core.ResultList ) {
168+ return gen .InstructionDefinition ( JumpZeroInstruction {}), core.ResultList {}
157169}
158170
159171func (JumpZeroInstructionDefinition ) InferTargetTypes (
@@ -172,15 +184,15 @@ func (m *InstructionMap) GetInstructionDefinition(
172184 name string ,
173185 node parse.InstructionNode ,
174186) (gen.InstructionDefinition , core.ResultList ) {
175- instDef , ok := (* m )[name ]
187+ inst , ok := (* m )[name ]
176188 if ! ok {
177189 return nil , list .FromSingle (core.Result {{
178190 Type : core .ErrorResult ,
179191 Message : "undefined instruction" ,
180192 Location : & node .Operator ,
181193 }})
182194 }
183- return instDef , core.ResultList {}
195+ return inst , core.ResultList {}
184196}
185197
186198func PrepareTestForInstructionGeneration (
0 commit comments