FuncDeclAST.py (8478:435179113834) | FuncDeclAST.py (9298:9a087e046c58) |
---|---|
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; --- 29 unchanged lines hidden (view full) --- 38 self.statements = statements 39 40 def __repr__(self): 41 return "[FuncDecl: %s]" % self.ident 42 43 def files(self, parent=None): 44 return set() 45 | 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; --- 29 unchanged lines hidden (view full) --- 38 self.statements = statements 39 40 def __repr__(self): 41 return "[FuncDecl: %s]" % self.ident 42 43 def files(self, parent=None): 44 return set() 45 |
46 def generate(self): | 46 def generate(self, parent = None): |
47 types = [] 48 params = [] 49 void_type = self.symtab.find("void", Type) 50 51 # Generate definition code 52 self.symtab.pushFrame() 53 54 # Lookup return type --- 11 unchanged lines hidden (view full) --- 66 self["external"] = "yes" 67 else: 68 rtype = self.statements.generate(body, return_type) 69 70 self.symtab.popFrame() 71 72 machine = self.state_machine 73 func = Func(self.symtab, self.ident, self.location, return_type, | 47 types = [] 48 params = [] 49 void_type = self.symtab.find("void", Type) 50 51 # Generate definition code 52 self.symtab.pushFrame() 53 54 # Lookup return type --- 11 unchanged lines hidden (view full) --- 66 self["external"] = "yes" 67 else: 68 rtype = self.statements.generate(body, return_type) 69 70 self.symtab.popFrame() 71 72 machine = self.state_machine 73 func = Func(self.symtab, self.ident, self.location, return_type, |
74 types, params, str(body), self.pairs, machine) | 74 types, params, str(body), self.pairs) |
75 | 75 |
76 if machine is not None: | 76 if parent is not None: 77 if not parent.addFunc(func): 78 self.error("Duplicate method: %s:%s()" % (parent, self.ident)) 79 func.class_name = parent.c_ident 80 81 elif machine is not None: |
77 machine.addFunc(func) | 82 machine.addFunc(func) |
83 func.isInternalMachineFunc = True 84 func.class_name = "%s_Controller" % machine |
|
78 else: 79 self.symtab.newSymbol(func) | 85 else: 86 self.symtab.newSymbol(func) |