Func.py (7055:4e24742201d7) Func.py (7839:9e556fb25900)
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 46 unchanged lines hidden (view full) ---

55 def prototype(self):
56 if "external" in self:
57 return ""
58
59 return_type = self.return_type.c_ident
60 void_type = self.symtab.find("void", Type)
61 if "return_by_ref" in self and self.return_type != void_type:
62 return_type += "&"
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 46 unchanged lines hidden (view full) ---

55 def prototype(self):
56 if "external" in self:
57 return ""
58
59 return_type = self.return_type.c_ident
60 void_type = self.symtab.find("void", Type)
61 if "return_by_ref" in self and self.return_type != void_type:
62 return_type += "&"
63 elif "return_by_pointer" in self and self.return_type != void_type:
64 return_type += "*"
63
64 return "%s %s(%s);" % (return_type, self.c_ident,
65 ", ".join(self.param_strings))
66
67 def writeCodeFiles(self, path):
68 '''This write a function of object Chip'''
69 if "external" in self:
70 return

--- 11 unchanged lines hidden (view full) ---

82 code('#include "mem/protocol/${{self.machineStr}}_Controller.hh"')
83
84 code('using namespace std;')
85 # Generate function header
86 void_type = self.symtab.find("void", Type)
87 return_type = self.return_type.c_ident
88 if "return_by_ref" in self and self.return_type != void_type:
89 return_type += "&"
65
66 return "%s %s(%s);" % (return_type, self.c_ident,
67 ", ".join(self.param_strings))
68
69 def writeCodeFiles(self, path):
70 '''This write a function of object Chip'''
71 if "external" in self:
72 return

--- 11 unchanged lines hidden (view full) ---

84 code('#include "mem/protocol/${{self.machineStr}}_Controller.hh"')
85
86 code('using namespace std;')
87 # Generate function header
88 void_type = self.symtab.find("void", Type)
89 return_type = self.return_type.c_ident
90 if "return_by_ref" in self and self.return_type != void_type:
91 return_type += "&"
92 if "return_by_pointer" in self and self.return_type != void_type:
93 return_type += "*"
90
91 if self.isInternalMachineFunc:
92 klass = "%s_Controller" % self.machineStr
93 else:
94 klass = "Chip"
95
96 params = ', '.join(self.param_strings)
97
98 code('''
99$return_type
100${klass}::${{self.c_ident}}($params)
101{
102${{self.body}}
103}
104''')
105 code.write(path, "%s.cc" % self.c_ident)
106
107__all__ = [ "Func" ]
94
95 if self.isInternalMachineFunc:
96 klass = "%s_Controller" % self.machineStr
97 else:
98 klass = "Chip"
99
100 params = ', '.join(self.param_strings)
101
102 code('''
103$return_type
104${klass}::${{self.c_ident}}($params)
105{
106${{self.body}}
107}
108''')
109 code.write(path, "%s.cc" % self.c_ident)
110
111__all__ = [ "Func" ]