From 60fe3ec2c24eb664c95cd4aac3fef7c986c015d1 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 30 Jan 2019 09:32:01 -0800 Subject: Better error reporting when an instruction is given an insufficient number of parameters --- cpu_dsl.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cpu_dsl.py') diff --git a/cpu_dsl.py b/cpu_dsl.py index 6baf18b..9254af5 100755 --- a/cpu_dsl.py +++ b/cpu_dsl.py @@ -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): -- cgit v1.2.3