Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / cython / src / Cython / Compiler / CodeGeneration.py
blobf446d9e92340bb4d8c23bfaa0661488b18c88693
1 from Cython.Compiler.Visitor import VisitorTransform
2 from Cython.Compiler.Nodes import StatListNode
4 class ExtractPxdCode(VisitorTransform):
5 """
6 Finds nodes in a pxd file that should generate code, and
7 returns them in a StatListNode.
9 The result is a tuple (StatListNode, ModuleScope), i.e.
10 everything that is needed from the pxd after it is processed.
12 A purer approach would be to seperately compile the pxd code,
13 but the result would have to be slightly more sophisticated
14 than pure strings (functions + wanted interned strings +
15 wanted utility code + wanted cached objects) so for now this
16 approach is taken.
17 """
19 def __call__(self, root):
20 self.funcs = []
21 self.visitchildren(root)
22 return (StatListNode(root.pos, stats=self.funcs), root.scope)
24 def visit_FuncDefNode(self, node):
25 self.funcs.append(node)
26 # Do not visit children, nested funcdefnodes will
27 # also be moved by this action...
28 return node
30 def visit_Node(self, node):
31 self.visitchildren(node)
32 return node