@@ -188,7 +188,7 @@ def __init__(self, sup: parser.Super):
188
188
self .context = sup .context
189
189
190
190
def analyze (self , a : "Analyzer" ) -> None :
191
- components = [ a . instrs [ name ] for name in self .ops ]
191
+ components = self .check_components ( a )
192
192
self .stack , self .initial_sp = self .super_macro_analysis (a , components )
193
193
sp = self .initial_sp
194
194
self .parts = []
@@ -206,6 +206,20 @@ def analyze(self, a: "Analyzer") -> None:
206
206
self .parts .append (SuperComponent (instr , input_mapping , output_mapping ))
207
207
self .final_sp = sp
208
208
209
+ def check_components (self , a : "Analyzer" ) -> list [Instruction ]:
210
+ components : list [Instruction ] = []
211
+ if not self .ops :
212
+ a .error (f"{ self .kind .capitalize ()} -instruction has no operands" , self )
213
+ for name in self .ops :
214
+ if name not in a .instrs :
215
+ a .error (f"Unknown instruction { name !r} " , self )
216
+ else :
217
+ instr = a .instrs [name ]
218
+ if self .kind == "super" and instr .kind != "inst" :
219
+ a .error (f"Super-instruction operand { instr .name } must be inst, not op" , instr )
220
+ components .append (instr )
221
+ return components
222
+
209
223
def super_macro_analysis (
210
224
self , a : "Analyzer" , components : list [Instruction ]
211
225
) -> tuple [list [str ], int ]:
0 commit comments