From a053e3e1ed43b31ad74596ad168c4221b8b909f7 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Tue, 17 Jun 2008 23:00:08 -0700 Subject: [PATCH] More CodeWriter support --- Cython/CodeWriter.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Cython/CodeWriter.py b/Cython/CodeWriter.py index d4161701..aad485c6 100644 --- a/Cython/CodeWriter.py +++ b/Cython/CodeWriter.py @@ -1,5 +1,7 @@ from Cython.Compiler.Visitor import TreeVisitor from Cython.Compiler.Nodes import * +from Cython.Compiler.ExprNodes import * +from Cython.Compiler.Symtab import TempName """ Serializes a Cython code tree to Cython code. This is primarily useful for @@ -196,6 +198,18 @@ class CodeWriter(TreeVisitor): self.comma_seperated_list(node.args) self.put(")") + def visit_GeneralCallNode(self, node): + self.visit(node.function) + self.put(u"(") + posarg = node.positional_args + if isinstance(posarg, AsTupleNode): + self.visit(posarg.arg) + else: + self.comma_seperated_list(posarg) + if node.keyword_args is not None or node.starstar_arg is not None: + raise Exception("Not implemented yet") + self.put(u")") + def visit_ExprStatNode(self, node): self.startline() self.visit(node.expr) @@ -260,6 +274,17 @@ class CodeWriter(TreeVisitor): self.visit(node.body) self.dedent() + def visit_ReraiseStatNode(self, node): + self.line("raise") + def visit_NoneNode(self, node): self.put(u"None") + def visit_ImportNode(self, node): + self.put(u"(import %s)" % node.module_name.value) + + def visit_NotNode(self, node): + self.put(u"(not ") + self.visit(node.operand) + self.put(u")") + -- 2.26.2