FormalParamAST.py (11030:17240f381d6a) FormalParamAST.py (11049:dfb0aa3f0649)
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;

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

41
42 @property
43 def name(self):
44 return self.ident
45
46 def generate(self):
47 type = self.type_ast.type
48 param = "param_%s" % self.ident
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;

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

41
42 @property
43 def name(self):
44 return self.ident
45
46 def generate(self):
47 type = self.type_ast.type
48 param = "param_%s" % self.ident
49 proto = ""
50 body = ""
51 default = False
52
53 # Add to symbol table
54 v = Var(self.symtab, self.ident, self.location, type, param,
55 self.pairs)
56 self.symtab.newSymbol(v)
57
58 if self.pointer or str(type) == "TBE" or (
59 "interface" in type and (
60 type["interface"] == "AbstractCacheEntry" or
61 type["interface"] == "AbstractEntry")):
49
50 # Add to symbol table
51 v = Var(self.symtab, self.ident, self.location, type, param,
52 self.pairs)
53 self.symtab.newSymbol(v)
54
55 if self.pointer or str(type) == "TBE" or (
56 "interface" in type and (
57 type["interface"] == "AbstractCacheEntry" or
58 type["interface"] == "AbstractEntry")):
62 proto = "%s* %s" % (type.c_ident, param)
63 body = proto
64 elif self.default != None:
65 value = ""
66 if self.default == True:
67 value = "true"
68 elif self.default == False:
69 value = "false"
70 else:
71 value = "%s" % self.default
72 proto = "const %s& %s = %s" % (type.c_ident, param, value)
73 body = "const %s& %s" % (type.c_ident, param)
74 default = True
59 return type, "%s* %s" % (type.c_ident, param)
75 else:
60 else:
76 proto = "const %s& %s" % (type.c_ident, param)
77 body = proto
78
79 return type, proto, body, default
61 return type, "const %s& %s" % (type.c_ident, param)