IsValidPtrExprAST.py (7839:9e556fb25900) | IsValidPtrExprAST.py (8192:be38f7b6ad9e) |
---|---|
1# 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; --- 29 unchanged lines hidden (view full) --- 38 def __repr__(self): 39 return "[IsValidPtrExprAST: %r]" % self.variable 40 41 def generate(self, code): 42 # Make sure the variable is valid 43 fix = code.nofix() 44 code("(") 45 var_type, var_code = self.variable.inline(True); | 1# 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; --- 29 unchanged lines hidden (view full) --- 38 def __repr__(self): 39 return "[IsValidPtrExprAST: %r]" % self.variable 40 41 def generate(self, code): 42 # Make sure the variable is valid 43 fix = code.nofix() 44 code("(") 45 var_type, var_code = self.variable.inline(True); |
46 var_code_str = str(var_code).replace('*','') | |
47 if self.flag: | 46 if self.flag: |
48 code("${var_code_str} != NULL)") | 47 code("${var_code} != NULL)") |
49 else: | 48 else: |
50 code("${var_code_str} == NULL)") | 49 code("${var_code} == NULL)") |
51 code.fix(fix) 52 type = self.symtab.find("bool", Type) 53 return type | 50 code.fix(fix) 51 type = self.symtab.find("bool", Type) 52 return type |