diff --git a/il65/oldstuff/codegen.py b/il65/oldstuff/codegen.py index 7267a4e2f..7404e42c3 100644 --- a/il65/oldstuff/codegen.py +++ b/il65/oldstuff/codegen.py @@ -2,9 +2,6 @@ class CodeGenerator: - BREAKPOINT_COMMENT_SIGNATURE = "~~~BREAKPOINT~~~" - BREAKPOINT_COMMENT_DETECTOR = r".(?P
\w+)\s+ea\s+nop\s+;\s+{:s}.*".format(BREAKPOINT_COMMENT_SIGNATURE) - def generate_call(self, stmt: CallStmt) -> None: self.p("\t\t\t\t\t; " + stmt.lineref) if stmt.condition: diff --git a/il65/plyparse.py b/il65/plyparse.py index 3786d7c05..e5a100e02 100644 --- a/il65/plyparse.py +++ b/il65/plyparse.py @@ -87,17 +87,18 @@ class AstNode: raise LookupError("no scope found in node ancestry", self) def all_nodes(self, *nodetypes: type) -> Generator['AstNode', None, None]: - nodetypes = nodetypes or (AstNode, ) - if self.nodes is None: - # this is the case when a node has been pruned away + if not self.nodes: + # this is the case when a node has been pruned away (nodes=None) or we don't have any child nodes return child_nodes = list(self.nodes) + if nodetypes: + for node in child_nodes: + if isinstance(node, nodetypes): + yield node + else: + yield from child_nodes for node in child_nodes: - if isinstance(node, nodetypes): - yield node - for node in child_nodes: - if isinstance(node, AstNode): - yield from node.all_nodes(*nodetypes) + yield from node.all_nodes(*nodetypes) def remove_node(self, node: 'AstNode') -> None: assert node.parent is self diff --git a/run_profile.py b/run_profile.py new file mode 100644 index 000000000..b09de680a --- /dev/null +++ b/run_profile.py @@ -0,0 +1,12 @@ +import cProfile +from il65.compile import PlyParser +from il65.optimize import optimize + + +def parse(): + parser = PlyParser(enable_floats=True) + parsed_module = parser.parse_file("testsource/large.ill") + optimize(parsed_module) + + +cProfile.run("parse()", filename="profile.dat")