diff options
author | Michael Pavone <pavone@retrodev.com> | 2019-01-30 09:32:01 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2019-01-30 09:32:01 -0800 |
commit | 60fe3ec2c24eb664c95cd4aac3fef7c986c015d1 (patch) | |
tree | 650d10fb50decf3944bacc2854b1fa720a70e8f2 /cpu_dsl.py | |
parent | 62a92e53aa6a9657ee6435ecbe2965de2f4b061a (diff) |
Better error reporting when an instruction is given an insufficient number of parameters
Diffstat (limited to 'cpu_dsl.py')
-rwxr-xr-x | cpu_dsl.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -272,6 +272,14 @@ class Op: 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 @@ class NormalOp: #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): |