def __init__(self, filename, line, *args): CodeItemBase.__init__(self, filename, line, *args) argdict = {} for arg in self.args: if '.' in arg.name: self.error("Illegal argument name: '.' is not allowed. Found '%s'" % arg.name) if arg.datatype == 'void': self.error("Illegal data type: 'void' is not a valid data type for arguments") if arg.name in argdict: self.error("Duplicate argument name: '%s'" % arg.name) argdict[arg.name] = arg self.argdict = argdict localdict = {} for local in self.locals: if '.' in local.name: self.error("Illegal local variable name: '.' is not allowed. Found '%s'" % local.name) if local.datatype == 'void': self.error("Illegal data type: 'void' is not a valid data type for local variables") if local.name in localdict or local.name in argdict: self.error("Duplicate variable name: '%s'" % local.name) localdict[local.name] = local self.localdict = localdict
def __init__(self, filename, line, *args): CodeItemBase.__init__(self, filename, line, *args) if len(self.args) + len(self.locals) > 6: self.error("Function '%s' has %d arguments and local variables. At most 6 arguments and local variables are allowed" % (name, len(args) + len(locals))) argdict = {} for arg in self.args: if '.' in arg.name: self.error("Illegal argument name: '.' is not allowed. Found '%s'" % arg.name) if arg.datatype == 'void': self.error("Illegal data type: 'void' is not a valid data type for arguments") if arg.name in argdict: self.error("Duplicate argument name: '%s'" % arg.name) argdict[arg.name] = arg self.argdict = argdict localdict = {} for local in self.locals: if '.' in local.name: self.error("Illegal local variable name: '.' is not allowed. Found '%s'" % local.name) if local.datatype == 'void': self.error("Illegal data type: 'void' is not a valid data type for local variables") if local.name in localdict or local.name in argdict: self.error("Duplicate variable name: '%s'" % local.name) localdict[local.name] = local self.localdict = localdict
def verifyIdentifiers(self, datafields, functions, containingFunction): CodeItemBase.verifyIdentifiers(self, datafields, functions, containingFunction) if self.target not in containingFunction.argdict and self.target not in containingFunction.localdict and self.target not in datafields: qualName = '%s.%s' % (self.containingModule, self.target) if qualName in datafields: self.target = qualName else: self.error("Data field '%s' not found" % self.target)
def verifyIdentifiers(self, datafields, functions, containingFunction): CodeItemBase.verifyIdentifiers(self, datafields, functions, containingFunction) if self.target not in containingFunction.identifiers: qualName = '%s.%s' % (self.containingModule, self.target) if qualName in datafields: self.target = qualName else: self.error("Data field '%s' not found" % self.target) containingFunction.identifiers[self.target].assigned = True
def resolveIdentifiers(self, containingModule): CodeItemBase.resolveIdentifiers(self, containingModule) if self.bit > 7 or self.bit < 0: self.error("Bit '%d' out of range" % self.bit)
def resolveIdentifiers(self, containingModule): if self.hasStatementBlock: CodeItemBase.resolveIdentifiers(self, containingModule) self.name = containingModule.name + '.' + self.name
def resolveIdentifiers(self, containingModule): CodeItemBase.resolveIdentifiers(self, containingModule) for statement in self.statements: statement.resolveIdentifiers(containingModule)
def verifyIdentifiers(self, datafields, functions, containingFunction): CodeItemBase.verifyIdentifiers(self, datafields, functions, containingFunction) for statement in self.statements: statement.verifyIdentifiers(datafields, functions, containingFunction)