FuncDeclAST.py (10307:6df951dcd7d9) FuncDeclAST.py (10984:a86f453a7caa)
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;

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

69 body = self.slicc.codeFormatter()
70 if self.statements is None:
71 self["external"] = "yes"
72 else:
73 rtype = self.statements.generate(body, return_type)
74
75 self.symtab.popFrame()
76
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;

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

69 body = self.slicc.codeFormatter()
70 if self.statements is None:
71 self["external"] = "yes"
72 else:
73 rtype = self.statements.generate(body, return_type)
74
75 self.symtab.popFrame()
76
77 func_name_args = self.ident
78
79 if parent is None:
80 for arg in self.formals:
81 from slicc.ast import FormalParamAST
82 if isinstance(arg, FormalParamAST):
83 arg_name = arg.type_ast.ident
84 else:
85 arg_name = arg
86 func_name_args += "_" + str(arg_name)
87
77 machine = self.state_machine
88 machine = self.state_machine
78 func = Func(self.symtab, self.ident, self.location, return_type,
79 types, params, str(body), self.pairs)
89 func = Func(self.symtab, func_name_args, self.ident, self.location,
90 return_type, types, params, str(body), self.pairs)
80
81 if parent is not None:
82 if not parent.addFunc(func):
83 self.error("Duplicate method: %s:%s()" % (parent, self.ident))
84 func.class_name = parent.c_ident
85
86 elif machine is not None:
87 machine.addFunc(func)
88 func.isInternalMachineFunc = True
89 func.class_name = "%s_Controller" % machine
90 else:
91 self.symtab.newSymbol(func)
91
92 if parent is not None:
93 if not parent.addFunc(func):
94 self.error("Duplicate method: %s:%s()" % (parent, self.ident))
95 func.class_name = parent.c_ident
96
97 elif machine is not None:
98 machine.addFunc(func)
99 func.isInternalMachineFunc = True
100 func.class_name = "%s_Controller" % machine
101 else:
102 self.symtab.newSymbol(func)