diff options
author | Peter Wu <lekensteyn@gmail.com> | 2011-12-03 14:30:41 +0000 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2011-12-03 14:30:41 +0000 |
commit | 4b297842f3b45c7857623c1c309654c339b28d85 (patch) | |
tree | f7b2c0085a456f7602370d502f93f89a38bfa2f7 /pp2cc.py | |
parent | cbb589740133d53224fcd66c4c2decf43a7eca6e (diff) | |
download | pp2cc-4b297842f3b45c7857623c1c309654c339b28d85.tar.gz |
Support for static functions
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-x | pp2cc.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -150,6 +150,10 @@ class Parse(object): " node, but also found " + str(thing), linked_node=linked_node) self.codeSegment += self.parseStatement(thing, root_node) + # hack: static functions are local to a file, so remove them + for funcname, function in self.functions.items(): + if function.isStatic(): + del self.functions[funcname] def compileASM(self): """Processes lines of assembly and merge it into the output""" for label in self.asm_node.labels: @@ -212,8 +216,6 @@ class Parse(object): lbl_func = function.labelBegin() lbl_end = function.labelEnd() - self.addLabel(lbl_func) - self.addLabel(lbl_end) linked_node.setFunction(function) # save Base Pointer lines = [self.asm.push(self.registers.BP, lbl_func)] @@ -1225,7 +1227,9 @@ class Parse(object): node = linked_node.node funcname = node.type.declname if not funcname in self.functions: - self.functions[funcname] = Function(node) + is_static = "static" in linked_node.parent.node.storage + self.functions[funcname] = Function(node, is_static=is_static, + uniq_provider=self.uniqLbl) if node.args: argstype = type(node.args).__name__ assert argstype == "ParamList", "Expected function arguments, found '{}' instead".format(argstype) |