Skip to content

Commit 20062f4

Browse files
committed
Check components of super/macro ops
1 parent 1aafac8 commit 20062f4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Tools/cases_generator/generate_cases.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(self, sup: parser.Super):
188188
self.context = sup.context
189189

190190
def analyze(self, a: "Analyzer") -> None:
191-
components = [a.instrs[name] for name in self.ops]
191+
components = self.check_components(a)
192192
self.stack, self.initial_sp = self.super_macro_analysis(a, components)
193193
sp = self.initial_sp
194194
self.parts = []
@@ -206,6 +206,20 @@ def analyze(self, a: "Analyzer") -> None:
206206
self.parts.append(SuperComponent(instr, input_mapping, output_mapping))
207207
self.final_sp = sp
208208

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+
209223
def super_macro_analysis(
210224
self, a: "Analyzer", components: list[Instruction]
211225
) -> tuple[list[str], int]:

0 commit comments

Comments
 (0)