IfStatementAST.py (7839:9e556fb25900) IfStatementAST.py (9628:195d92059654)
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;

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

43 return "[IfStatement: %r%r%r]" % (self.cond, self.then, self.else_)
44
45 def generate(self, code, return_type):
46 cond_code = self.slicc.codeFormatter()
47 cond_type = self.cond.generate(cond_code)
48
49 if cond_type != self.symtab.find("bool", Type):
50 self.cond.error("Condition of if stmt must be bool, type was '%s'",
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;

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

43 return "[IfStatement: %r%r%r]" % (self.cond, self.then, self.else_)
44
45 def generate(self, code, return_type):
46 cond_code = self.slicc.codeFormatter()
47 cond_type = self.cond.generate(cond_code)
48
49 if cond_type != self.symtab.find("bool", Type):
50 self.cond.error("Condition of if stmt must be bool, type was '%s'",
51 ctype)
51 cond_type)
52
53 # Conditional
54 code.indent()
55 code('if ($cond_code) {')
56 # Then part
57 code.indent()
58 self.symtab.pushFrame()
59 self.then.generate(code, return_type)

--- 17 unchanged lines hidden ---
52
53 # Conditional
54 code.indent()
55 code('if ($cond_code) {')
56 # Then part
57 code.indent()
58 self.symtab.pushFrame()
59 self.then.generate(code, return_type)

--- 17 unchanged lines hidden ---