Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: exctrans
Changeset: r81771:54678c7d1ee3
Date: 2016-01-13 18:57 +0000
http://bitbucket.org/pypy/pypy/changeset/54678c7d1ee3/

Log:    Create factory function for creating FuncNodes

diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -813,16 +813,13 @@
     # there not so many node of this kind, slots should not
     # be necessary
 
-    def __init__(self, db, T, obj, forcename=None):
+    def __init__(self, db, T, obj, ptrname):
         Node.__init__(self, db)
         self.globalcontainer = True
         self.T = T
         self.obj = obj
-        if forcename:
-            self.name = forcename
-        else:
-            self.name = _select_name(db, obj)
-        self.funcgen = select_function_code_generators(obj, db, self.name)
+        self.name = ptrname
+        self.funcgen = select_function_code_generators(obj, db, ptrname)
         if self.funcgen:
             argnames = self.funcgen.argnames()
             self.implementationtypename = db.gettype(T, argnames=argnames)
@@ -905,6 +902,13 @@
         del bodyiter
         funcgen.implementation_end()
 
+def new_funcnode(db, T, obj, forcename=None):
+    if forcename:
+        name = forcename
+    else:
+        name = _select_name(db, obj)
+    return FuncNode(db, T, obj, name)
+
 def sandbox_stub(fnobj, db):
     # unexpected external function for --sandbox translation: replace it
     # with a "Not Implemented" stub.
@@ -1070,7 +1074,7 @@
     Array:        ArrayNode,
     GcArray:      ArrayNode,
     FixedSizeArray: FixedSizeArrayNode,
-    FuncType:     FuncNode,
+    FuncType:     new_funcnode,
     OpaqueType:   opaquenode_factory,
     llmemory._WeakRefType: weakrefnode_factory,
     llgroup.GroupType: GroupNode,
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to