[pypy-commit] pypy ootype-rerased: Implementation of oo{, un}box_int for CLI.

ademan noreply at buildbot.pypy.org
Fri Jul 22 23:29:20 CEST 2011


Author: Daniel Roberts <Ademan555 at gmail.com>
Branch: ootype-rerased
Changeset: r45889:96a48cd97218
Date: 2011-07-22 14:29 -0700
http://bitbucket.org/pypy/pypy/changeset/96a48cd97218/

Log:	Implementation of oo{,un}box_int for CLI.

diff --git a/pypy/translator/cli/metavm.py b/pypy/translator/cli/metavm.py
--- a/pypy/translator/cli/metavm.py
+++ b/pypy/translator/cli/metavm.py
@@ -1,6 +1,6 @@
 from pypy.translator.cli import oopspec
 from pypy.rpython.ootypesystem import ootype
-from pypy.rpython.lltypesystem import rffi
+from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.translator.oosupport.metavm import Generator, InstructionList, MicroInstruction,\
      PushAllArgs, StoreResult, GetField, SetField, DownCast
 from pypy.translator.oosupport.metavm import _Call as _OOCall
@@ -173,6 +173,17 @@
         generator.load(v_obj)
         generator.ilasm.opcode('unbox.any', boxtype)
 
+class _UnboxType(MicroInstruction):
+    def __init__(self, TO):
+        self.TO = TO
+        super(_UnboxType, self).__init__()
+
+    def render(self, generator, op):
+        v_obj, = op.args
+        boxtype = generator.cts.lltype_to_cts(self.TO)
+        generator.load(v_obj)
+        generator.ilasm.opcode('unbox.any', boxtype)
+
 class _NewArray(MicroInstruction):
     def render(self, generator, op):
         v_type, v_length = op.args
@@ -312,6 +323,7 @@
 #CastWeakAdrToPtr = _CastWeakAdrToPtr()
 Box = _Box()
 Unbox = _Unbox()
+UnboxInt = _UnboxType(lltype.Signed)
 NewArray = _NewArray()
 GetArrayElem = _GetArrayElem()
 SetArrayElem = _SetArrayElem()
diff --git a/pypy/translator/cli/opcodes.py b/pypy/translator/cli/opcodes.py
--- a/pypy/translator/cli/opcodes.py
+++ b/pypy/translator/cli/opcodes.py
@@ -2,7 +2,7 @@
      IndirectCall, GetField, SetField, DownCast, NewCustomDict,\
      MapException, Box, Unbox, NewArray, GetArrayElem, SetArrayElem,\
      TypeOf, CastPrimitive, EventHandler, GetStaticField, SetStaticField, \
-     DebugPrint
+     DebugPrint, UnboxInt
 from pypy.translator.oosupport.metavm import PushArg, PushAllArgs, StoreResult, InstructionList,\
     New, RuntimeNew, CastTo, PushPrimitive, OOString, OOUnicode, OONewArray
 from pypy.translator.cli.cts import WEAKREF
@@ -48,6 +48,8 @@
     'cast_from_object':         [DownCast],
     'clibox':                   [Box],
     'cliunbox':                 [Unbox],
+    'oobox_int':                [Box],
+    'oounbox_int':              [UnboxInt],
     'cli_newarray':             [NewArray],
     'cli_getelem':              [GetArrayElem],
     'cli_setelem':              [SetArrayElem],


More information about the pypy-commit mailing list