[pypy-svn] r48161 - pypy/dist/pypy/lang/smalltalk
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Oct 29 16:47:22 CET 2007
Author: cfbolz
Date: Mon Oct 29 16:47:21 2007
New Revision: 48161
Modified:
pypy/dist/pypy/lang/smalltalk/primitives.py
pypy/dist/pypy/lang/smalltalk/utility.py
Log:
move unwrap_float, kill unused w_subscript
Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py Mon Oct 29 16:47:21 2007
@@ -9,24 +9,6 @@
PrimitiveNotYetWrittenError
from pypy.rlib import rarithmetic
-def unwrap_float(w_v):
- if isinstance(w_v, model.W_Float): return w_v.value
- elif isinstance(w_v, model.W_SmallInteger): return float(w_v.value)
- raise PrimitiveFailedError()
-
-def w_subscript(w_obj, idx):
- """
- Rather cryptically named function which retrieves an indexed field
- from the object, wrapping as necessary depending on the format of
- the object so that the result can be returned.
- """
- if isinstance(w_obj, model.W_PointersObject):
- return w_obj.fetch(idx)
- elif isinstance(w_obj, model.W_WordsObject):
- return utility.wrap_int(w_obj.getword(idx))
- elif isinstance(w_obj, model.W_BytesObject):
- return utility.wrap_int(w_obj.getchar(idx))
- raise PrimitiveFailedError()
def assert_bounds(n0, minimum, maximum):
if not minimum <= n0 < maximum:
@@ -105,7 +87,7 @@
elif spec is index1_0:
args += (utility.unwrap_int(w_arg)-1, )
elif spec is float:
- args += (unwrap_float(w_arg), )
+ args += (utility.unwrap_float(w_arg), )
elif spec is object:
args += (w_arg, )
elif spec is str:
Modified: pypy/dist/pypy/lang/smalltalk/utility.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/utility.py (original)
+++ pypy/dist/pypy/lang/smalltalk/utility.py Mon Oct 29 16:47:21 2007
@@ -23,6 +23,12 @@
assert isinstance(w_ord, model.W_SmallInteger)
return chr(w_ord.value)
+def unwrap_float(w_v):
+ from pypy.lang.smalltalk import model
+ if isinstance(w_v, model.W_Float): return w_v.value
+ elif isinstance(w_v, model.W_SmallInteger): return float(w_v.value)
+ raise PrimitiveFailedError()
+
# ____________________________________________________________
# wrapping utilities
More information about the Pypy-commit
mailing list