mirror of
https://github.com/irmen/prog8.git
synced 2024-11-25 19:31:36 +00:00
slightly optimized the most called function
This commit is contained in:
parent
daca1cce37
commit
191978c8fb
@ -2,9 +2,6 @@
|
||||
|
||||
|
||||
class CodeGenerator:
|
||||
BREAKPOINT_COMMENT_SIGNATURE = "~~~BREAKPOINT~~~"
|
||||
BREAKPOINT_COMMENT_DETECTOR = r".(?P<address>\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:
|
||||
|
@ -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
|
||||
|
12
run_profile.py
Normal file
12
run_profile.py
Normal file
@ -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")
|
Loading…
Reference in New Issue
Block a user