Commit f70aceac authored by Vitja Makarov's avatar Vitja Makarov

Remove analyse_control_flow() phase

parent 68dfde1d
...@@ -173,19 +173,15 @@ class Node(object): ...@@ -173,19 +173,15 @@ class Node(object):
# #
# There are 4 phases of parse tree processing, applied in order to # There are 3 phases of parse tree processing, applied in order to
# all the statements in a given scope-block: # all the statements in a given scope-block:
# #
# (0) analyse_control_flow # (0) analyse_declarations
# Create the control flow tree into which state can be asserted and
# queried.
#
# (1) analyse_declarations
# Make symbol table entries for all declarations at the current # Make symbol table entries for all declarations at the current
# level, both explicit (def, cdef, etc.) and implicit (assignment # level, both explicit (def, cdef, etc.) and implicit (assignment
# to an otherwise undeclared name). # to an otherwise undeclared name).
# #
# (2) analyse_expressions # (1) analyse_expressions
# Determine the result types of expressions and fill in the # Determine the result types of expressions and fill in the
# 'type' attribute of each ExprNode. Insert coercion nodes into the # 'type' attribute of each ExprNode. Insert coercion nodes into the
# tree where needed to convert to and from Python objects. # tree where needed to convert to and from Python objects.
...@@ -193,15 +189,12 @@ class Node(object): ...@@ -193,15 +189,12 @@ class Node(object):
# in the 'result_code' attribute of each ExprNode with a C code # in the 'result_code' attribute of each ExprNode with a C code
# fragment. # fragment.
# #
# (3) generate_code # (2) generate_code
# Emit C code for all declarations, statements and expressions. # Emit C code for all declarations, statements and expressions.
# Recursively applies the 3 processing phases to the bodies of # Recursively applies the 3 processing phases to the bodies of
# functions. # functions.
# #
def analyse_control_flow(self, env):
pass
def analyse_declarations(self, env): def analyse_declarations(self, env):
pass pass
...@@ -277,12 +270,6 @@ class CompilerDirectivesNode(Node): ...@@ -277,12 +270,6 @@ class CompilerDirectivesNode(Node):
# body Node # body Node
child_attrs = ["body"] child_attrs = ["body"]
def analyse_control_flow(self, env):
old = env.directives
env.directives = self.directives
self.body.analyse_control_flow(env)
env.directives = old
def analyse_declarations(self, env): def analyse_declarations(self, env):
old = env.directives old = env.directives
env.directives = self.directives env.directives = self.directives
...@@ -338,10 +325,6 @@ class StatListNode(Node): ...@@ -338,10 +325,6 @@ class StatListNode(Node):
return node # No node-specific analysis necesarry return node # No node-specific analysis necesarry
create_analysed = staticmethod(create_analysed) create_analysed = staticmethod(create_analysed)
def analyse_control_flow(self, env):
for stat in self.stats:
stat.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
#print "StatListNode.analyse_declarations" ### #print "StatListNode.analyse_declarations" ###
for stat in self.stats: for stat in self.stats:
...@@ -4341,12 +4324,6 @@ class IfStatNode(StatNode): ...@@ -4341,12 +4324,6 @@ class IfStatNode(StatNode):
child_attrs = ["if_clauses", "else_clause"] child_attrs = ["if_clauses", "else_clause"]
def analyse_control_flow(self, env):
for if_clause in self.if_clauses:
if_clause.analyse_control_flow(env)
if self.else_clause:
self.else_clause.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
for if_clause in self.if_clauses: for if_clause in self.if_clauses:
if_clause.analyse_declarations(env) if_clause.analyse_declarations(env)
...@@ -4391,9 +4368,6 @@ class IfClauseNode(Node): ...@@ -4391,9 +4368,6 @@ class IfClauseNode(Node):
child_attrs = ["condition", "body"] child_attrs = ["condition", "body"]
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
...@@ -4489,11 +4463,7 @@ class SwitchStatNode(StatNode): ...@@ -4489,11 +4463,7 @@ class SwitchStatNode(StatNode):
self.else_clause.annotate(code) self.else_clause.annotate(code)
class LoopNode(object): class LoopNode(object):
pass
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
if self.else_clause:
self.else_clause.analyse_control_flow(env)
class WhileStatNode(LoopNode, StatNode): class WhileStatNode(LoopNode, StatNode):
...@@ -5032,16 +5002,6 @@ class TryExceptStatNode(StatNode): ...@@ -5032,16 +5002,6 @@ class TryExceptStatNode(StatNode):
child_attrs = ["body", "except_clauses", "else_clause"] child_attrs = ["body", "except_clauses", "else_clause"]
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
for except_clause in self.except_clauses:
except_clause.analyse_control_flow(env)
# the else cause it executed only when the try clause finishes
if self.else_clause:
self.else_clause.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
for except_clause in self.except_clauses: for except_clause in self.except_clauses:
...@@ -5362,10 +5322,6 @@ class TryFinallyStatNode(StatNode): ...@@ -5362,10 +5322,6 @@ class TryFinallyStatNode(StatNode):
return node return node
create_analysed = staticmethod(create_analysed) create_analysed = staticmethod(create_analysed)
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
self.finally_clause.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
self.finally_clause.analyse_declarations(env) self.finally_clause.analyse_declarations(env)
......
...@@ -1354,7 +1354,6 @@ if VALUE is not None: ...@@ -1354,7 +1354,6 @@ if VALUE is not None:
def visit_FuncDefNode(self, node): def visit_FuncDefNode(self, node):
self.seen_vars_stack.append(cython.set()) self.seen_vars_stack.append(cython.set())
lenv = node.local_scope lenv = node.local_scope
node.body.analyse_control_flow(lenv) # this will be totally refactored
node.declare_arguments(lenv) node.declare_arguments(lenv)
for var, type_node in node.directive_locals.items(): for var, type_node in node.directive_locals.items():
if not lenv.lookup_here(var): # don't redeclare args if not lenv.lookup_here(var): # don't redeclare args
......
...@@ -100,9 +100,6 @@ class TempsBlockNode(Node): ...@@ -100,9 +100,6 @@ class TempsBlockNode(Node):
code.put_decref_clear(handle.temp, handle.type) code.put_decref_clear(handle.temp, handle.type)
code.funcstate.release_temp(handle.temp) code.funcstate.release_temp(handle.temp)
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
...@@ -290,9 +287,6 @@ class LetNode(Nodes.StatNode, LetNodeMixin): ...@@ -290,9 +287,6 @@ class LetNode(Nodes.StatNode, LetNodeMixin):
self.pos = body.pos self.pos = body.pos
self.body = body self.body = body
def analyse_control_flow(self, env):
self.body.analyse_control_flow(env)
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.temp_expression.analyse_declarations(env) self.temp_expression.analyse_declarations(env)
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment