IfStatementAST.py (6999:f226c098c393) IfStatementAST.py (7839:9e556fb25900)
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;

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

50 self.cond.error("Condition of if stmt must be bool, type was '%s'",
51 ctype)
52
53 # Conditional
54 code.indent()
55 code('if ($cond_code) {')
56 # Then part
57 code.indent()
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;

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

50 self.cond.error("Condition of if stmt must be bool, type was '%s'",
51 ctype)
52
53 # Conditional
54 code.indent()
55 code('if ($cond_code) {')
56 # Then part
57 code.indent()
58 self.symtab.pushFrame()
58 self.then.generate(code, return_type)
59 self.then.generate(code, return_type)
60 self.symtab.popFrame()
59 code.dedent()
60 # Else part
61 if self.else_:
62 code('} else {')
63 code.indent()
61 code.dedent()
62 # Else part
63 if self.else_:
64 code('} else {')
65 code.indent()
66 self.symtab.pushFrame()
64 self.else_.generate(code, return_type)
67 self.else_.generate(code, return_type)
68 self.symtab.popFrame()
65 code.dedent()
66 code('}') # End scope
67
68 def findResources(self, resources):
69 # Take a worse case look at both paths
70 self.then.findResources(resources)
71 if self.else_ is not None:
72 self.else_.findResources(resources)
69 code.dedent()
70 code('}') # End scope
71
72 def findResources(self, resources):
73 # Take a worse case look at both paths
74 self.then.findResources(resources)
75 if self.else_ is not None:
76 self.else_.findResources(resources)