# Verify that this is a method of the object
if not var.type.methodExist(methodId):
- error("%s: Type '%s' does not have a method '%s'" % \
- ("Invalid method call", var.type, methodId))
+ self.error("%s: Type '%s' does not have a method '%s'" % \
+ ("Invalid method call", var.type, methodId))
expected_size = len(var.type.methodParamType(methodId))
if len(self.expr_vec) != expected_size:
# Verify that this is a valid field name for this type
if self.field not in return_type.data_members:
- error("Invalid object field: " +
- "Type '%s' does not have data member %s" % \
- (return_type, self.field))
+ self.error("Invalid object field: " +
+ "Type '%s' does not have data member %s" % \
+ (return_type, self.field))
# Return the type of the field
return return_type.data_members[self.field].type
# Verify that this is a method of the object
if methodId not in obj_type.methods:
- error("Invalid method call: Type '%s' does not have a method '%s'",
- obj_type, methodId)
+ self.error("Invalid method call: Type '%s' does not have a method '%s'",
+ obj_type, methodId)
if len(self.expr_ast_vec) != \
len(obj_type.methods[methodId].param_types):
# Right number of parameters
- error("Wrong number of parameters for function name: '%s', " + \
- "expected: , actual: ", proc_name,
+ self.error("Wrong number of parameters for function name: '%s', " + \
+ "expected: , actual: ", proc_name,
len(obj_type.methods[methodId].param_types),
len(self.expr_ast_vec))
for actual_type, expected_type in \
zip(paramTypes, obj_type.methods[methodId].param_types):
if actual_type != expected_type:
- error("Type mismatch: expected: %s actual: %s",
- expected_type, actual_type)
+ self.error("Type mismatch: expected: %s actual: %s",
+ expected_type, actual_type)
# Return the return type of the method
return obj_type.methods[methodId].return_type
# Is return valid here?
if return_type is None:
- error("Invalid 'return' statement")
+ self.error("Invalid 'return' statement")
# The return type must match
if return_type != actual_type:
def generate(self, type):
# Add enumeration
if not type.enumAdd(self.field_id, self.pairs_ast.pairs):
- error("Duplicate enumeration: %s:%s" % (type, self.field_id))
+ self.error("Duplicate enumeration: %s:%s" % (type, self.field_id))
# Fill machine info
machine = self.symtab.state_machine
if str(type) == "State":
if not machine:
- error("State declaration not part of a machine.")
+ self.error("State declaration not part of a machine.")
s = State(self.symtab, self.field_id, self.location, self.pairs)
machine.addState(s)
if str(type) == "Event":
if not machine:
- error("Event declaration not part of a machine.")
+ self.error("Event declaration not part of a machine.")
e = Event(self.symtab, self.field_id, self.location, self.pairs)
machine.addEvent(e)
if not type.dataMemberAdd(self.field_id, field_type, self.pairs,
init_code):
- error("Duplicate data member: %s:%s" % (type_ptr, field_id))
+ self.error("Duplicate data member: %s:%s" % (type_ptr, field_id))
# Add method
if not type.methodAdd(self.ident, return_type, types):
- error("Duplicate method: %s:%s()" % (type, self.ident))
+ self.error("Duplicate method: %s:%s()" % (type, self.ident))