FormalParamAST.py (6877:2a1a3d916ca8) | FormalParamAST.py (6882:898047a3672c) |
---|---|
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; --- 15 unchanged lines hidden (view full) --- 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28from slicc.ast.AST import AST 29from slicc.symbols import Var 30 31class FormalParamAST(AST): | 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; --- 15 unchanged lines hidden (view full) --- 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28from slicc.ast.AST import AST 29from slicc.symbols import Var 30 31class FormalParamAST(AST): |
32 def __init__(self, slicc, type_ast, ident, default = None): | 32 def __init__(self, slicc, type_ast, ident, default = None, pointer = False): |
33 super(FormalParamAST, self).__init__(slicc) 34 self.type_ast = type_ast 35 self.ident = ident 36 self.default = default | 33 super(FormalParamAST, self).__init__(slicc) 34 self.type_ast = type_ast 35 self.ident = ident 36 self.default = default |
37 self.pointer = pointer |
|
37 38 def __repr__(self): 39 return "[FormalParamAST: %s]" % self.ident 40 41 @property 42 def name(self): 43 return self.ident 44 45 def generate(self): 46 type = self.type_ast.type 47 param = "param_%s" % self.ident 48 49 # Add to symbol table 50 v = Var(self.symtab, self.ident, self.location, type, param, 51 self.pairs) 52 self.symtab.newSymbol(v) 53 return type, "%s %s" % (type.c_ident, param) | 38 39 def __repr__(self): 40 return "[FormalParamAST: %s]" % self.ident 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 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 return type, "%s %s" % (type.c_ident, param) |