fixed error message generation bug in SLICC ast files

This commit is contained in:
Brad Beckmann 2009-10-26 17:06:32 -07:00
parent 1b2d75d6d2
commit 0fdfc82bde
7 changed files with 17 additions and 17 deletions

View file

@ -85,8 +85,8 @@ class ChipMethodAccessAST(ChipComponentAccessAST):
# Verify that this is a method of the object # Verify that this is a method of the object
if not var.type.methodExist(methodId): if not var.type.methodExist(methodId):
error("%s: Type '%s' does not have a method '%s'" % \ self.error("%s: Type '%s' does not have a method '%s'" % \
("Invalid method call", var.type, methodId)) ("Invalid method call", var.type, methodId))
expected_size = len(var.type.methodParamType(methodId)) expected_size = len(var.type.methodParamType(methodId))
if len(self.expr_vec) != expected_size: if len(self.expr_vec) != expected_size:

View file

@ -47,9 +47,9 @@ class MemberExprAST(ExprAST):
# Verify that this is a valid field name for this type # Verify that this is a valid field name for this type
if self.field not in return_type.data_members: if self.field not in return_type.data_members:
error("Invalid object field: " + self.error("Invalid object field: " +
"Type '%s' does not have data member %s" % \ "Type '%s' does not have data member %s" % \
(return_type, self.field)) (return_type, self.field))
# Return the type of the field # Return the type of the field
return return_type.data_members[self.field].type return return_type.data_members[self.field].type

View file

@ -55,22 +55,22 @@ class MethodCallExprAST(ExprAST):
# Verify that this is a method of the object # Verify that this is a method of the object
if methodId not in obj_type.methods: if methodId not in obj_type.methods:
error("Invalid method call: Type '%s' does not have a method '%s'", self.error("Invalid method call: Type '%s' does not have a method '%s'",
obj_type, methodId) obj_type, methodId)
if len(self.expr_ast_vec) != \ if len(self.expr_ast_vec) != \
len(obj_type.methods[methodId].param_types): len(obj_type.methods[methodId].param_types):
# Right number of parameters # Right number of parameters
error("Wrong number of parameters for function name: '%s', " + \ self.error("Wrong number of parameters for function name: '%s', " + \
"expected: , actual: ", proc_name, "expected: , actual: ", proc_name,
len(obj_type.methods[methodId].param_types), len(obj_type.methods[methodId].param_types),
len(self.expr_ast_vec)) len(self.expr_ast_vec))
for actual_type, expected_type in \ for actual_type, expected_type in \
zip(paramTypes, obj_type.methods[methodId].param_types): zip(paramTypes, obj_type.methods[methodId].param_types):
if actual_type != expected_type: if actual_type != expected_type:
error("Type mismatch: expected: %s actual: %s", self.error("Type mismatch: expected: %s actual: %s",
expected_type, actual_type) expected_type, actual_type)
# Return the return type of the method # Return the return type of the method
return obj_type.methods[methodId].return_type return obj_type.methods[methodId].return_type

View file

@ -42,7 +42,7 @@ class ReturnStatementAST(StatementAST):
# Is return valid here? # Is return valid here?
if return_type is None: if return_type is None:
error("Invalid 'return' statement") self.error("Invalid 'return' statement")
# The return type must match # The return type must match
if return_type != actual_type: if return_type != actual_type:

View file

@ -41,19 +41,19 @@ class TypeFieldEnumAST(TypeFieldAST):
def generate(self, type): def generate(self, type):
# Add enumeration # Add enumeration
if not type.enumAdd(self.field_id, self.pairs_ast.pairs): 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 # Fill machine info
machine = self.symtab.state_machine machine = self.symtab.state_machine
if str(type) == "State": if str(type) == "State":
if not machine: 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) s = State(self.symtab, self.field_id, self.location, self.pairs)
machine.addState(s) machine.addState(s)
if str(type) == "Event": if str(type) == "Event":
if not machine: 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) e = Event(self.symtab, self.field_id, self.location, self.pairs)
machine.addEvent(e) machine.addEvent(e)

View file

@ -54,4 +54,4 @@ class TypeFieldMemberAST(TypeFieldAST):
if not type.dataMemberAdd(self.field_id, field_type, self.pairs, if not type.dataMemberAdd(self.field_id, field_type, self.pairs,
init_code): init_code):
error("Duplicate data member: %s:%s" % (type_ptr, field_id)) self.error("Duplicate data member: %s:%s" % (type_ptr, field_id))

View file

@ -47,4 +47,4 @@ class TypeFieldMethodAST(TypeFieldAST):
# Add method # Add method
if not type.methodAdd(self.ident, return_type, types): 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))