[pypy-svn] r36597 - pypy/dist/pypy/annotation
fijal at codespeak.net
fijal at codespeak.net
Fri Jan 12 18:04:27 CET 2007
Author: fijal
Date: Fri Jan 12 18:04:19 2007
New Revision: 36597
Added:
pypy/dist/pypy/annotation/signature.py
Modified:
pypy/dist/pypy/annotation/policy.py
Log:
(fijal, pedronis, arigo) Move signature to a different file to decrease the confusion
Modified: pypy/dist/pypy/annotation/policy.py
==============================================================================
--- pypy/dist/pypy/annotation/policy.py (original)
+++ pypy/dist/pypy/annotation/policy.py Fri Jan 12 18:04:19 2007
@@ -6,6 +6,7 @@
# or we create a cycle.
from pypy.annotation import model as annmodel
from pypy.annotation.bookkeeper import getbookkeeper
+from pypy.annotation.signature import Sig
import types
@@ -92,42 +93,3 @@
bk = getbookkeeper()
return bk.immutablevalue(None)
-# ____________________________________________________________
-
-class Sig(object):
-
- def __init__(self, *argtypes):
- self.argtypes = argtypes
-
- def __call__(self, funcdesc, inputcells):
- from pypy.rpython.lltypesystem import lltype
- args_s = []
- for i, argtype in enumerate(self.argtypes):
- if isinstance(argtype, (types.FunctionType, types.MethodType)):
- argtype = argtype(*inputcells)
- if isinstance(argtype, annmodel.SomeObject):
- args_s.append(argtype)
- elif isinstance(argtype, lltype.LowLevelType):
- if argtype is lltype.Void:
- # XXX the mapping between Void and annotation
- # is not quite well defined
- s_input = inputcells[i]
- assert isinstance(s_input, annmodel.SomePBC)
- assert s_input.is_constant()
- args_s.append(s_input)
- else:
- args_s.append(annmodel.lltype_to_annotation(argtype))
- else:
- args_s.append(funcdesc.bookkeeper.valueoftype(argtype))
- if len(inputcells) != len(args_s):
- raise Exception("%r: expected %d args, got %d" % (funcdesc,
- len(args_s),
- len(inputcells)))
- for i, (s_arg, s_input) in enumerate(zip(args_s, inputcells)):
- if not s_arg.contains(s_input):
- raise Exception("%r argument %d:\n"
- "expected %s,\n"
- " got %s" % (funcdesc, i+1,
- s_arg,
- s_input))
- inputcells[:] = args_s
Added: pypy/dist/pypy/annotation/signature.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/annotation/signature.py Fri Jan 12 18:04:19 2007
@@ -0,0 +1,41 @@
+
+import types
+from pypy.annotation import model as annmodel
+
+class Sig(object):
+
+ def __init__(self, *argtypes):
+ self.argtypes = argtypes
+
+ def __call__(self, funcdesc, inputcells):
+ from pypy.rpython.lltypesystem import lltype
+ args_s = []
+ for i, argtype in enumerate(self.argtypes):
+ if isinstance(argtype, (types.FunctionType, types.MethodType)):
+ argtype = argtype(*inputcells)
+ if isinstance(argtype, annmodel.SomeObject):
+ args_s.append(argtype)
+ elif isinstance(argtype, lltype.LowLevelType):
+ if argtype is lltype.Void:
+ # XXX the mapping between Void and annotation
+ # is not quite well defined
+ s_input = inputcells[i]
+ assert isinstance(s_input, annmodel.SomePBC)
+ assert s_input.is_constant()
+ args_s.append(s_input)
+ else:
+ args_s.append(annmodel.lltype_to_annotation(argtype))
+ else:
+ args_s.append(funcdesc.bookkeeper.valueoftype(argtype))
+ if len(inputcells) != len(args_s):
+ raise Exception("%r: expected %d args, got %d" % (funcdesc,
+ len(args_s),
+ len(inputcells)))
+ for i, (s_arg, s_input) in enumerate(zip(args_s, inputcells)):
+ if not s_arg.contains(s_input):
+ raise Exception("%r argument %d:\n"
+ "expected %s,\n"
+ " got %s" % (funcdesc, i+1,
+ s_arg,
+ s_input))
+ inputcells[:] = args_s
More information about the Pypy-commit
mailing list