fixed error message generation bug in SLICC ast files
This commit is contained in:
parent
1b2d75d6d2
commit
0fdfc82bde
7 changed files with 17 additions and 17 deletions
|
@ -85,7 +85,7 @@ 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))
|
||||||
|
|
|
@ -47,7 +47,7 @@ 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))
|
||||||
|
|
||||||
|
|
|
@ -55,13 +55,13 @@ 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))
|
||||||
|
@ -69,7 +69,7 @@ class MethodCallExprAST(ExprAST):
|
||||||
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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue