From: Dag Sverre Seljebotn Date: Tue, 22 Jul 2008 14:57:46 +0000 (+0200) Subject: Support retrieving "delayed" temps before or after allocate_temps phase (dead code... X-Git-Tag: 0.9.8.1~49^2~79 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8fd5165ec75e4f9d6685ef2f21f4afed54378c13;p=cython.git Support retrieving "delayed" temps before or after allocate_temps phase (dead code for now) --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 4f02ef1e..5a193055 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -810,6 +810,7 @@ class NameNode(AtomicExprNode): is_name = 1 skip_assignment_decref = False + entry = None def create_analysed_rvalue(pos, env, entry): node = NameNode(pos) @@ -845,7 +846,9 @@ class NameNode(AtomicExprNode): def analyse_as_module(self, env): # Try to interpret this as a reference to a cimported module. # Returns the module scope, or None. - entry = env.lookup(self.name) + entry = self.entry + if not entry: + entry = env.lookup(self.name) if entry and entry.as_module: return entry.as_module return None @@ -853,14 +856,17 @@ class NameNode(AtomicExprNode): def analyse_as_extension_type(self, env): # Try to interpret this as a reference to an extension type. # Returns the extension type, or None. - entry = env.lookup(self.name) + entry = self.entry + if not entry: + entry = env.lookup(self.name) if entry and entry.is_type and entry.type.is_extension_type: return entry.type else: return None def analyse_target_declaration(self, env): - self.entry = env.lookup_here(self.name) + if not self.entry: + self.entry = env.lookup_here(self.name) if not self.entry: self.entry = env.declare_var(self.name, py_object_type, self.pos) env.control_flow.set_state(self.pos, (self.name, 'initalized'), True) @@ -870,10 +876,9 @@ class NameNode(AtomicExprNode): if self.entry.is_pyglobal and self.entry.is_member: env.use_utility_code(type_cache_invalidation_code) - def analyse_types(self, env, entry=None): - if entry is None: - entry = env.lookup(self.name) - self.entry = entry + def analyse_types(self, env): + if self.entry is None: + self.entry = env.lookup(self.name) if not self.entry: self.entry = env.declare_builtin(self.name, self.pos) if not self.entry: diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index ea2ed78d..6bd15d29 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -360,6 +360,7 @@ def create_default_pipeline(context, options, result): from ParseTreeTransforms import AnalyseDeclarationsTransform, AnalyseExpressionsTransform from ParseTreeTransforms import CreateClosureClasses, MarkClosureVisitor, DecoratorTransform from Optimize import FlattenInListTransform, SwitchTransform, OptimizeRefcounting + from CodeGeneration import AnchorTemps from Buffer import BufferTransform from ModuleNode import check_c_classes @@ -376,6 +377,7 @@ def create_default_pipeline(context, options, result): BufferTransform(context), SwitchTransform(), OptimizeRefcounting(context), +# AnchorTemps(context), # CreateClosureClasses(context), create_generate_code(context, options, result) ] diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 6ad8ce4a..302d6689 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -73,6 +73,7 @@ class Node(object): is_name = 0 is_literal = 0 + temps = None # All descandants should set child_attrs to a list of the attributes # containing nodes considered "children" in the tree. Each such attribute diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 05d38cc7..48c0fada 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -141,6 +141,15 @@ class Entry: def redeclared(self, pos): error(pos, "'%s' does not match previous declaration" % self.name) error(self.pos, "Previous declaration is here") + +def new_temp(type, description=""): + # Returns a temporary entry which is "floating" and not finally resolved + # before the AnchorTemps transform is run. cname will not be available on + # the temp before this transform is run. See the mentioned transform for + # more docs. + e = Entry(name="$" + description, type=type, cname="") + e.is_variable = True + return e class Scope: # name string Unqualified name