Author: Alexander Hesse <[email protected]>
Branch: split-rpython
Changeset: r59975:f7bae0b0a270
Date: 2013-01-11 21:38 +0100
http://bitbucket.org/pypy/pypy/changeset/f7bae0b0a270/
Log: Moved pypy.interpreter.argument.Signature to
rpython.rtyper.signature
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -14,7 +14,8 @@
import py
from pypy.interpreter.eval import Code
-from pypy.interpreter.argument import Arguments, Signature
+from pypy.interpreter.argument import Arguments
+from rpython.rtyper.signature import Signature
from pypy.interpreter.baseobjspace import (W_Root, ObjSpace, Wrappable,
SpaceCache, DescrMismatch)
from pypy.interpreter.error import OperationError
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -7,7 +7,7 @@
import dis, imp, struct, types, new, sys
from pypy.interpreter import eval
-from pypy.interpreter.argument import Signature
+from rpython.rtyper.signature import Signature
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter.astcompiler.consts import (
diff --git a/pypy/module/oracle/interp_pool.py
b/pypy/module/oracle/interp_pool.py
--- a/pypy/module/oracle/interp_pool.py
+++ b/pypy/module/oracle/interp_pool.py
@@ -1,10 +1,11 @@
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.argument import Arguments, Signature
+from pypy.interpreter.argument import Arguments
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
from pypy.interpreter.error import OperationError
from rpython.rtyper.lltypesystem import rffi, lltype
+from rpython.rtyper.signature import Signature
from pypy.module.oracle import roci, config
from pypy.module.oracle import interp_error, interp_environ
diff --git a/pypy/objspace/std/bytearrayobject.py
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -19,13 +19,13 @@
from pypy.objspace.std.unicodeobject import W_UnicodeObject
from pypy.objspace.std import slicetype
from pypy.interpreter import gateway
-from pypy.interpreter.argument import Signature
from pypy.interpreter.buffer import RWBuffer
from pypy.objspace.std.bytearraytype import (
makebytearraydata_w, getbytevalue,
new_bytearray
)
from rpython.tool.sourcetools import func_with_new_name
+from rpython.rtyper.signature import Signature
class W_BytearrayObject(W_Object):
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -4,13 +4,13 @@
from pypy.objspace.std.settype import set_typedef as settypedef
from pypy.objspace.std.frozensettype import frozenset_typedef as
frozensettypedef
from pypy.interpreter import gateway
-from pypy.interpreter.argument import Signature
from pypy.interpreter.error import OperationError, operationerrfmt
from rpython.rlib.objectmodel import r_dict, we_are_translated, specialize,\
newlist_hint
from rpython.rlib.debug import mark_dict_non_null
from rpython.tool.sourcetools import func_with_new_name
+from rpython.rtyper.signature import Signature
from rpython.rlib import rerased
from rpython.rlib import jit
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -12,7 +12,7 @@
resizelist_hint)
from rpython.rlib.listsort import make_timsort_class
from rpython.rlib import rerased, jit, debug
-from pypy.interpreter.argument import Signature
+from rpython.rtyper.signature import Signature
from rpython.tool.sourcetools import func_with_new_name
UNROLL_CUTOFF = 5
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -4,11 +4,11 @@
from rpython.rlib.rarithmetic import intmask, r_uint
from pypy.interpreter.error import OperationError
from pypy.interpreter import gateway
-from pypy.interpreter.argument import Signature
from pypy.objspace.std.settype import set_typedef as settypedef
from pypy.objspace.std.frozensettype import frozenset_typedef as
frozensettypedef
from rpython.rlib import rerased
from rpython.rlib.objectmodel import instantiate
+from rpython.rtyper.signature import Signature
from pypy.interpreter.generator import GeneratorIterator
from pypy.objspace.std.listobject import W_ListObject
from pypy.objspace.std.intobject import W_IntObject
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -1,5 +1,5 @@
from rpython.annotator import model as annmodel, description
-from pypy.interpreter.argument import Signature
+from rpython.rtyper.signature import Signature
from rpython.flowspace.model import (Variable, Constant, Block, Link,
checkgraph, FunctionGraph, SpaceOperation)
from rpython.rlib.objectmodel import ComputedIntSymbolic
diff --git a/rpython/rtyper/signature.py b/rpython/rtyper/signature.py
new file mode 100644
--- /dev/null
+++ b/rpython/rtyper/signature.py
@@ -0,0 +1,72 @@
+from rpython.rlib import jit
+
+class Signature(object):
+ _immutable_ = True
+ _immutable_fields_ = ["argnames[*]"]
+ __slots__ = ("argnames", "varargname", "kwargname")
+
+ def __init__(self, argnames, varargname=None, kwargname=None):
+ self.argnames = argnames
+ self.varargname = varargname
+ self.kwargname = kwargname
+
+ @jit.elidable
+ def find_argname(self, name):
+ try:
+ return self.argnames.index(name)
+ except ValueError:
+ return -1
+
+ def num_argnames(self):
+ return len(self.argnames)
+
+ def has_vararg(self):
+ return self.varargname is not None
+
+ def has_kwarg(self):
+ return self.kwargname is not None
+
+ def scope_length(self):
+ scopelen = len(self.argnames)
+ scopelen += self.has_vararg()
+ scopelen += self.has_kwarg()
+ return scopelen
+
+ def getallvarnames(self):
+ argnames = self.argnames
+ if self.varargname is not None:
+ argnames = argnames + [self.varargname]
+ if self.kwargname is not None:
+ argnames = argnames + [self.kwargname]
+ return argnames
+
+ def __repr__(self):
+ return "Signature(%r, %r, %r)" % (
+ self.argnames, self.varargname, self.kwargname)
+
+ def __eq__(self, other):
+ if not isinstance(other, Signature):
+ return NotImplemented
+ return (self.argnames == other.argnames and
+ self.varargname == other.varargname and
+ self.kwargname == other.kwargname)
+
+ def __ne__(self, other):
+ if not isinstance(other, Signature):
+ return NotImplemented
+ return not self == other
+
+
+ # make it look tuply for its use in the annotator
+
+ def __len__(self):
+ return 3
+
+ def __getitem__(self, i):
+ if i == 0:
+ return self.argnames
+ if i == 1:
+ return self.varargname
+ if i == 2:
+ return self.kwargname
+ raise IndexError
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit