# HG changeset patch # User Michael Pavone # Date 1548869521 28800 # Node ID 04cafe6261189917f3389efbfd7ee56612698f1c # Parent 4fd84c3efc72d831a1eb9bfc0f10a84190df417c Better error reporting when an instruction is given an insufficient number of parameters diff -r 4fd84c3efc72 -r 04cafe626118 cpu_dsl.py --- a/cpu_dsl.py Tue Jan 29 23:56:48 2019 -0800 +++ b/cpu_dsl.py Wed Jan 30 09:32:01 2019 -0800 @@ -272,6 +272,14 @@ return not self.evalFun is None def numArgs(self): return self.evalFun.__code__.co_argcount + def numParams(self): + if self.outOp: + params = max(self.outOp) + 1 + else: + params = 0 + if self.evalFun: + params = max(params, self.numArgs()) + return params def generate(self, otype, prog, params, rawParams, flagUpdates): if self.impls[otype].__code__.co_argcount == 2: return self.impls[otype](prog, params) @@ -586,6 +594,8 @@ #TODO: Disassembler pass elif not opDef is None: + if opDef.numParams() > len(procParams): + raise Exception('Insufficient params for ' + self.op + ' (' + ', '.join(self.params) + ')') if opDef.canEval() and allParamsConst: #do constant folding if opDef.numArgs() >= len(procParams):