LocalVariableAST.py (8644:acf68e5a8cd7) | LocalVariableAST.py (10966:198726a3c723) |
---|---|
1# | 1# |
2# Copyright (c) 2013 Advanced Micro Devices, Inc. |
|
2# Copyright (c) 2011 Mark D. Hill and David A. Wood 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; 9# redistributions in binary form must reproduce the above copyright --- 28 unchanged lines hidden (view full) --- 38 39 def __repr__(self): 40 return "[LocalVariableAST: %r %r]" % (self.type_ast, self.ident) 41 42 @property 43 def name(self): 44 return self.var_name 45 | 3# Copyright (c) 2011 Mark D. Hill and David A. Wood 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright --- 28 unchanged lines hidden (view full) --- 39 40 def __repr__(self): 41 return "[LocalVariableAST: %r %r]" % (self.type_ast, self.ident) 42 43 @property 44 def name(self): 45 return self.var_name 46 |
47 def inline(self, get_type=False): 48 code = self.slicc.codeFormatter(fix_newlines=False) 49 return_type = self.generate(code) 50 if get_type: 51 return return_type, code 52 else: 53 return code 54 |
|
46 def generate(self, code): 47 type = self.type_ast.type; 48 ident = "%s" % self.ident; 49 50 # Add to symbol table 51 v = Var(self.symtab, self.ident, self.location, type, ident, 52 self.pairs) 53 self.symtab.newSymbol(v) 54 if self.pointer or str(type) == "TBE" or ( 55 "interface" in type and ( 56 type["interface"] == "AbstractCacheEntry" or 57 type["interface"] == "AbstractEntry")): 58 code += "%s* %s" % (type.c_ident, ident) 59 else: 60 code += "%s %s" % (type.c_ident, ident) 61 return type | 55 def generate(self, code): 56 type = self.type_ast.type; 57 ident = "%s" % self.ident; 58 59 # Add to symbol table 60 v = Var(self.symtab, self.ident, self.location, type, ident, 61 self.pairs) 62 self.symtab.newSymbol(v) 63 if self.pointer or str(type) == "TBE" or ( 64 "interface" in type and ( 65 type["interface"] == "AbstractCacheEntry" or 66 type["interface"] == "AbstractEntry")): 67 code += "%s* %s" % (type.c_ident, ident) 68 else: 69 code += "%s %s" % (type.c_ident, ident) 70 return type |