[pypy-commit] pypy exctrans: Replace FuncCode.funcgens list with single .funcgen, since there is never more than one
rlamy
pypy.commits at gmail.com
Fri Dec 18 12:33:51 EST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exctrans
Changeset: r81381:70a2702ce64e
Date: 2015-12-18 16:33 +0100
http://bitbucket.org/pypy/pypy/changeset/70a2702ce64e/
Log: Replace FuncCode.funcgens list with single .funcgen, since there is
never more than one
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
@@ -815,39 +815,38 @@
return self.name
def make_funcgens(self):
- self.funcgens = select_function_code_generators(self.obj, self.db, self.name)
- if self.funcgens:
- argnames = self.funcgens[0].argnames() #Assume identical for all funcgens
+ self.funcgen = select_function_code_generators(self.obj, self.db, self.name)
+ if self.funcgen:
+ argnames = self.funcgen.argnames()
self.implementationtypename = self.db.gettype(self.T, argnames=argnames)
- self._funccodegen_owner = self.funcgens[0]
- else:
- self._funccodegen_owner = None
+
+ self._funccodegen_owner = self.funcgen
def basename(self):
return self.obj._name
def enum_dependencies(self):
- if not self.funcgens:
+ if self.funcgen is None:
return []
- return self.funcgens[0].allconstantvalues() #Assume identical for all funcgens
+ return self.funcgen.allconstantvalues()
def forward_declaration(self):
callable = getattr(self.obj, '_callable', None)
is_exported = getattr(callable, 'exported_symbol', False)
- for funcgen in self.funcgens:
+ if self.funcgen:
yield '%s;' % (
forward_cdecl(self.implementationtypename,
- funcgen.name(self.name), self.db.standalone,
+ self.funcgen.name(self.name), self.db.standalone,
is_exported=is_exported))
def implementation(self):
- for funcgen in self.funcgens:
- for s in self.funcgen_implementation(funcgen):
+ if self.funcgen:
+ for s in self.funcgen_implementation(self.funcgen):
yield s
def graphs_to_patch(self):
- for funcgen in self.funcgens:
- for i in funcgen.graphs_to_patch():
+ if self.funcgen:
+ for i in self.funcgen.graphs_to_patch():
yield i
def funcgen_implementation(self, funcgen):
@@ -899,12 +898,11 @@
def sandbox_stub(fnobj, db):
# unexpected external function for --sandbox translation: replace it
- # with a "Not Implemented" stub. To support these functions, port them
- # to the new style registry (e.g. rpython.module.ll_os.RegisterOs).
+ # with a "Not Implemented" stub.
from rpython.translator.sandbox import rsandbox
graph = rsandbox.get_external_function_sandbox_graph(fnobj, db,
force_stub=True)
- return [FunctionCodeGenerator(graph, db)]
+ return FunctionCodeGenerator(graph, db)
def sandbox_transform(fnobj, db):
# for --sandbox: replace a function like os_open_llimpl() with
@@ -912,7 +910,7 @@
# perform the operation.
from rpython.translator.sandbox import rsandbox
graph = rsandbox.get_external_function_sandbox_graph(fnobj, db)
- return [FunctionCodeGenerator(graph, db)]
+ return FunctionCodeGenerator(graph, db)
def select_function_code_generators(fnobj, db, functionname):
sandbox = db.need_sandboxing(fnobj)
@@ -921,16 +919,16 @@
# apply the sandbox transformation
return sandbox_transform(fnobj, db)
exception_policy = getattr(fnobj, 'exception_policy', None)
- return [FunctionCodeGenerator(fnobj.graph, db, exception_policy,
- functionname)]
+ return FunctionCodeGenerator(
+ fnobj.graph, db, exception_policy, functionname)
elif getattr(fnobj, 'external', None) is not None:
if sandbox:
return sandbox_stub(fnobj, db)
else:
assert fnobj.external == 'C'
- return []
+ return None
elif hasattr(fnobj._callable, "c_name"):
- return [] # this case should only be used for entrypoints
+ return None # this case should only be used for entrypoints
else:
raise ValueError("don't know how to generate code for %r" % (fnobj,))
More information about the pypy-commit
mailing list