diff options
Diffstat (limited to 'src/mem/slicc/symbols/Func.py')
-rw-r--r-- | src/mem/slicc/symbols/Func.py | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py index 695450b9c..d50d0309f 100644 --- a/src/mem/slicc/symbols/Func.py +++ b/src/mem/slicc/symbols/Func.py @@ -30,19 +30,16 @@ from slicc.symbols.Type import Type class Func(Symbol): def __init__(self, table, ident, name, location, return_type, param_types, - proto_param_strings, body_param_strings, body, - pairs, default_count = 0): + param_strings, body, pairs): super(Func, self).__init__(table, ident, location, pairs) self.return_type = return_type self.param_types = param_types - self.proto_param_strings = proto_param_strings - self.body_param_strings = body_param_strings + self.param_strings = param_strings self.body = body self.isInternalMachineFunc = False self.c_ident = ident self.c_name = name self.class_name = "" - self.default_count = default_count def __repr__(self): return "" @@ -60,33 +57,11 @@ class Func(Symbol): return_type += "*" return "%s %s(%s);" % (return_type, self.c_name, - ", ".join(self.proto_param_strings)) + ", ".join(self.param_strings)) def writeCodeFiles(self, path, includes): return - def checkArguments(self, args): - if len(args) + self.default_count < len(self.param_types) or \ - len(args) > len(self.param_types): - self.error("Wrong number of arguments passed to function: '%s'" + \ - " Expected at least: %d, got: %d", self.c_ident, - len(self.param_types) - self.default_count, len(args)) - - cvec = [] - type_vec = [] - for expr,expected_type in zip(args, self.param_types): - # Check the types of the parameter - actual_type,param_code = expr.inline(True) - if str(actual_type) != 'OOD' and \ - str(actual_type) != str(expected_type) and \ - str(actual_type["interface"]) != str(expected_type): - expr.error("Type mismatch: expected: %s actual: %s" % \ - (expected_type, actual_type)) - cvec.append(param_code) - type_vec.append(expected_type) - - return cvec, type_vec - def generateCode(self): '''This write a function of object Chip''' if "external" in self: @@ -95,14 +70,14 @@ class Func(Symbol): code = self.symtab.codeFormatter() # Generate function header - return_type = self.return_type.c_ident void_type = self.symtab.find("void", Type) + return_type = self.return_type.c_ident if "return_by_ref" in self and self.return_type != void_type: return_type += "&" if "return_by_pointer" in self and self.return_type != void_type: return_type += "*" - params = ', '.join(self.body_param_strings) + params = ', '.join(self.param_strings) code(''' $return_type |