comparison python/c3/analyse.py @ 225:1c7364bd74c7

Fixed pointer deref
author Windel Bouwman
date Thu, 11 Jul 2013 07:42:30 +0200
parents c3f1ce8b638f
children 240111e0456f
comparison
equal deleted inserted replaced
224:5af52987f5bd 225:1c7364bd74c7
42 sym.scope = self.currentScope 42 sym.scope = self.currentScope
43 43
44 # Add symbols to current scope: 44 # Add symbols to current scope:
45 if isinstance(sym, Symbol): 45 if isinstance(sym, Symbol):
46 self.addSymbol(sym) 46 self.addSymbol(sym)
47 if isinstance(sym, DefinedType):
48 self.addSymbol(sym)
47 49
48 # Create subscope: 50 # Create subscope:
49 if type(sym) in [Package, Function]: 51 if type(sym) in [Package, Function]:
50 newScope = Scope(self.currentScope) 52 newScope = Scope(self.currentScope)
51 self.scopeStack.append(newScope) 53 self.scopeStack.append(newScope)
76 if type(t) is PointerType: 78 if type(t) is PointerType:
77 t.ptype = self.resolveType(t.ptype, scope) 79 t.ptype = self.resolveType(t.ptype, scope)
78 return t 80 return t
79 elif type(t) is Designator: 81 elif type(t) is Designator:
80 return self.resolveDesignator(t, scope) 82 return self.resolveDesignator(t, scope)
83 elif isinstance(t, Type):
84 # Already resolved??
85 return t
81 else: 86 else:
82 print('ERR resolve type!') 87 raise Exception('Error resolving type {} {}'.format(t, type(t)))
83 88
84 def findRefs(self, sym): 89 def findRefs(self, sym):
85 if type(sym) in [Variable, Constant]: 90 if type(sym) in [Variable, Constant]:
86 sym.typ = self.resolveType(sym.typ, sym.scope) 91 sym.typ = self.resolveType(sym.typ, sym.scope)
87 elif type(sym) is TypeCast: 92 elif type(sym) is TypeCast: