From d1d79cda477a243b874c20d775f2baf565eeb0cd Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Sat, 7 Jun 2008 12:32:52 +0200 Subject: [PATCH] Initialize unassigned node child attributes to None, clean up ExprNode --- Cython/Compiler/ExprNodes.py | 13 ++++--------- Cython/Compiler/Nodes.py | 6 +++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 2a95b4f2..67873530 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -168,16 +168,9 @@ class ExprNode(Node): saved_subexpr_nodes = None is_temp = 0 - def get_child_attrs(self): return self.subexprs - child_attrs = property(fget=get_child_attrs) - def get_child_attrs(self): - """Automatically provide the contents of subexprs as children, unless child_attr - has been declared. See Nodes.Node.get_child_accessors.""" - if self.child_attrs is not None: - return self.child_attrs - elif self.subexprs is not None: - return self.subexprs + return self.subexprs + child_attrs = property(fget=get_child_attrs) def not_implemented(self, method_name): print_call_chain(method_name, "not implemented") ### @@ -3289,6 +3282,8 @@ class CondExprNode(ExprNode): # false_val ExprNode temp_bool = None + true_val = None + false_val = None subexprs = ['test', 'true_val', 'false_val'] diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 39755885..c521a9d1 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2217,6 +2217,7 @@ class CascadedAssignmentNode(AssignmentNode): # coerced_rhs_list [ExprNode] RHS coerced to type of each LHS child_attrs = ["lhs_list", "rhs", "coerced_rhs_list"] + coerced_rhs_list = None def analyse_declarations(self, env): for lhs in self.lhs_list: @@ -2353,6 +2354,7 @@ class InPlaceAssignmentNode(AssignmentNode): # (it must be a NameNode, AttributeNode, or IndexNode). child_attrs = ["lhs", "rhs", "dup"] + dup = None def analyse_declarations(self, env): self.lhs.analyse_target_declaration(env) @@ -2987,6 +2989,7 @@ class ForInStatNode(LoopNode, StatNode): # item NextNode used internally child_attrs = ["target", "iterator", "body", "else_clause", "item"] + item = None def analyse_declarations(self, env): self.target.analyse_target_declaration(env) @@ -3103,7 +3106,7 @@ class ForFromStatNode(LoopNode, StatNode): # is_py_target bool # loopvar_name string # py_loopvar_node PyTempNode or None - child_attrs = ["target", "bound1", "bound2", "step", "body", "else_clause", "py_loopvar_node"] + child_attrs = ["target", "bound1", "bound2", "step", "body", "else_clause"] def analyse_declarations(self, env): self.target.analyse_target_declaration(env) @@ -3317,6 +3320,7 @@ class ExceptClauseNode(Node): # exc_vars (string * 3) local exception variables child_attrs = ["pattern", "target", "body", "exc_value"] + exc_value = None def analyse_declarations(self, env): if self.target: -- 2.26.2