Func.py (8337:b9ba22cb23f2) Func.py (8478:435179113834)
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;

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

59 return_type += "&"
60 elif "return_by_pointer" in self and self.return_type != void_type:
61 return_type += "*"
62
63 return "%s %s(%s);" % (return_type, self.c_ident,
64 ", ".join(self.param_strings))
65
66 def writeCodeFiles(self, path):
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;

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

59 return_type += "&"
60 elif "return_by_pointer" in self and self.return_type != void_type:
61 return_type += "*"
62
63 return "%s %s(%s);" % (return_type, self.c_ident,
64 ", ".join(self.param_strings))
65
66 def writeCodeFiles(self, path):
67 return
68
69 def generateCode(self):
67 '''This write a function of object Chip'''
68 if "external" in self:
70 '''This write a function of object Chip'''
71 if "external" in self:
69 return
72 return ""
70
71 code = self.symtab.codeFormatter()
72
73
74 code = self.symtab.codeFormatter()
75
73 # Header
74 code('''
75/** Auto generated C++ code started by $__file__:$__line__ */
76
77#include "debug/RubySlicc.hh"
78#include "mem/protocol/Types.hh"
79''')
80
81 if self.isInternalMachineFunc:
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 += "&"
90 if "return_by_pointer" in self and self.return_type != void_type:
91 return_type += "*"
92

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

99
100 code('''
101$return_type
102${klass}::${{self.c_ident}}($params)
103{
104${{self.body}}
105}
106''')
76 # Generate function header
77 void_type = self.symtab.find("void", Type)
78 return_type = self.return_type.c_ident
79 if "return_by_ref" in self and self.return_type != void_type:
80 return_type += "&"
81 if "return_by_pointer" in self and self.return_type != void_type:
82 return_type += "*"
83

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

90
91 code('''
92$return_type
93${klass}::${{self.c_ident}}($params)
94{
95${{self.body}}
96}
97''')
107 if self.isInternalMachineFunc:
108 code.write(path, "%s_%s.cc" % (self.machineStr,self.c_ident))
109 else:
110 code.write(path, "%s.cc" % self.c_ident)
98 return str(code)
111
112__all__ = [ "Func" ]
99
100__all__ = [ "Func" ]