Mercurial > lcfOS
diff python/ppci/c3/visitor.py @ 306:b145f8e6050b
Start on c3 rewrite
author | Windel Bouwman |
---|---|
date | Mon, 09 Dec 2013 19:00:21 +0100 |
parents | 158068af716c |
children | e609d5296ee9 |
line wrap: on
line diff
--- a/python/ppci/c3/visitor.py Fri Dec 06 13:50:38 2013 +0100 +++ b/python/ppci/c3/visitor.py Mon Dec 09 19:00:21 2013 +0100 @@ -12,7 +12,7 @@ self.do(node) def do(self, node): - # Run visitor: + # Run pre function: if self.f_pre: self.f_pre(node) @@ -23,6 +23,7 @@ elif type(node) is Function: for s in node.declarations: self.do(s) + self.do(node.typ) self.do(node.body) elif type(node) is CompoundStatement: for s in node.statements: @@ -30,11 +31,11 @@ elif type(node) is IfStatement: self.do(node.condition) self.do(node.truestatement) - if node.falsestatement: - self.do(node.falsestatement) + self.do(node.falsestatement) elif type(node) is FunctionCall: for arg in node.args: self.do(arg) + self.do(node.proc) elif type(node) is Assignment: self.do(node.lval) self.do(node.rval) @@ -49,14 +50,26 @@ self.do(node.ex) elif type(node) is TypeCast: self.do(node.a) - elif type(node) is FieldRef: + elif type(node) is Member: self.do(node.base) elif type(node) is Deref: self.do(node.ptr) elif type(node) is Constant: self.do(node.value) - elif type(node) in [VariableUse, Variable, Literal, FunctionType, - DefinedType, FormalParameter, LocalVariable]: + elif type(node) is DefinedType: + self.do(node.typ) + elif isinstance(node, Variable): + self.do(node.typ) + elif type(node) is PointerType: + self.do(node.ptype) + elif type(node) is StructureType: + for m in node.mems: + self.do(m.typ) + elif type(node) is FunctionType: + for pt in node.parametertypes: + self.do(pt) + self.do(node.returntype) + elif type(node) in [Identifier, Literal, EmptyStatement]: # Those nodes do not have child nodes. pass elif type(node) is WhileStatement: