From: Dag Sverre Seljebotn Date: Fri, 1 Aug 2008 22:20:57 +0000 (+0200) Subject: Whoops, missing file in pxd-compilation commits X-Git-Tag: 0.9.8.1~49^2~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c370f9420486cda5297b0d315d64839c4bd6d293;p=cython.git Whoops, missing file in pxd-compilation commits --- diff --git a/Cython/Compiler/CodeGeneration.py b/Cython/Compiler/CodeGeneration.py new file mode 100644 index 00000000..9d9d555d --- /dev/null +++ b/Cython/Compiler/CodeGeneration.py @@ -0,0 +1,30 @@ +from Cython.Compiler.Visitor import VisitorTransform, temp_name_handle, CythonTransform +from Cython.Compiler.ModuleNode import ModuleNode +from Cython.Compiler.Nodes import * +from Cython.Compiler.ExprNodes import * + +class ExtractPxdCode(CythonTransform): + """ + Finds nodes in a pxd file that should generate code, and + returns them in a StatListNode. + + The result is a tuple (StatListNode, ModuleScope), i.e. + everything that is needed from the pxd after it is processed. + + A purer approach would be to seperately compile the pxd code, + but the result would have to be slightly more sophisticated + than pure strings (functions + wanted interned strings + + wanted utility code + wanted cached objects) so for now this + approach is taken. + """ + + def __call__(self, root): + self.funcs = [] + self.visitchildren(root) + return (StatListNode(root.pos, stats=self.funcs), root.scope) + + def visit_FuncDefNode(self, node): + self.funcs.append(node) + # Do not visit children, nested funcdefnodes will + # also be moved by this action... + return node