[pypy-svn] r34040 - in pypy/dist/pypy/translator/jvm: . src
xoraxax at codespeak.net
xoraxax at codespeak.net
Wed Nov 1 16:47:17 CET 2006
Author: xoraxax
Date: Wed Nov 1 16:47:16 2006
New Revision: 34040
Modified:
pypy/dist/pypy/translator/jvm/database.py
pypy/dist/pypy/translator/jvm/generator.py
pypy/dist/pypy/translator/jvm/opcodes.py
pypy/dist/pypy/translator/jvm/src/PyPy.java
Log:
Fixed IF_ICMPGE, added oostring operation.
Modified: pypy/dist/pypy/translator/jvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/database.py (original)
+++ pypy/dist/pypy/translator/jvm/database.py Wed Nov 1 16:47:16 2006
@@ -178,6 +178,7 @@
ootype.Float:jvmgen.PYPYDUMPDOUBLE,
ootype.Bool:jvmgen.PYPYDUMPBOOLEAN,
ootype.Class:jvmgen.PYPYDUMPOBJECT,
+ ootype.String:jvmgen.PYPYDUMPSTRING,
}
def generate_dump_method_for_ootype(self, OOTYPE):
Modified: pypy/dist/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/generator.py (original)
+++ pypy/dist/pypy/translator/jvm/generator.py Wed Nov 1 16:47:16 2006
@@ -2,7 +2,8 @@
from pypy.objspace.flow import model as flowmodel
from pypy.translator.oosupport.metavm import Generator
from pypy.translator.jvm.typesystem import \
- JvmType, jObject, jPrintStream, jvm_for_class, jVoid
+ JvmType, jObject, jPrintStream, jvm_for_class, jVoid, jvm_method_desc, \
+ jInt, jByteArray
from pypy.rpython.ootypesystem import ootype
# ___________________________________________________________________________
@@ -739,7 +740,7 @@
# Ignore Void values
if v.concretetype is ootype.Void:
return
-
+
if isinstance(v, flowmodel.Variable):
jty, idx = self._var_data(v)
return self.store_jvm_var(jty, idx)
@@ -795,6 +796,11 @@
def call_primitive(self, graph):
raise NotImplementedError
+ def call_oostring(self, OOTYPE):
+ cts_type = self.db.lltype_to_cts(OOTYPE)
+ mthd = Method('pypy.PyPy', 'oostring', jvm_method_desc([cts_type, jInt], jByteArray))
+ self.emit(mthd)
+
def new(self, TYPE):
jtype = self.db.lltype_to_cts(TYPE)
ctor = Method(jtype.class_name(), "<init>", "()V", opcode=INVOKESPECIAL)
@@ -857,7 +863,7 @@
less_than = lambda self: self._compare_op(IF_ICMPLT)
greater_than = lambda self: self._compare_op(IF_ICMPGT)
less_equals = lambda self: self._compare_op(IF_ICMPLT)
- greater_equals = lambda self: self._compare_op(IF_ICMPGT)
+ greater_equals = lambda self: self._compare_op(IF_ICMPGE)
def _uint_compare_op(self, cmpopcode):
PYPYUINTCMP.invoke(self)
Modified: pypy/dist/pypy/translator/jvm/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/opcodes.py (original)
+++ pypy/dist/pypy/translator/jvm/opcodes.py Wed Nov 1 16:47:16 2006
@@ -7,7 +7,7 @@
from pypy.translator.oosupport.metavm import \
PushArg, PushAllArgs, StoreResult, InstructionList, New, DoNothing, Call,\
- SetField, GetField, CallMethod, DownCast, RuntimeNew
+ SetField, GetField, CallMethod, DownCast, RuntimeNew, OOString
import pypy.translator.jvm.generator as jvmgen
def _check_zer(op):
@@ -28,14 +28,14 @@
'oogetfield': [GetField, StoreResult],
'oosend': [CallMethod, StoreResult],
'ooupcast': DoNothing,
- 'oodowncast': [DownCast,StoreResult],
+ 'oodowncast': [DownCast, StoreResult],
'oois': 'is_null',
'oononnull': 'is_not_null',
#'instanceof': [CastTo, 'ldnull', 'cgt.un'],
#'subclassof': [PushAllArgs, 'call bool [pypylib]pypy.runtime.Utils::SubclassOf(class [mscorlib]System.Type, class[mscorlib]System.Type)'],
#'ooidentityhash': [PushAllArgs, 'callvirt instance int32 object::GetHashCode()'],
#'oohash': [PushAllArgs, 'callvirt instance int32 object::GetHashCode()'],
- #'oostring': [OOString],
+ 'oostring': [OOString, StoreResult],
#'ooparse_int': [PushAllArgs, 'call int32 [pypylib]pypy.runtime.Utils::OOParseInt(string, int32)'],
#'oonewcustomdict': [NewCustomDict],
#
Modified: pypy/dist/pypy/translator/jvm/src/PyPy.java
==============================================================================
--- pypy/dist/pypy/translator/jvm/src/PyPy.java (original)
+++ pypy/dist/pypy/translator/jvm/src/PyPy.java Wed Nov 1 16:47:16 2006
@@ -251,6 +251,50 @@
}
// ----------------------------------------------------------------------
+ // Helpers
+
+ public static byte[] string2bytes(String s) {
+ return s.getBytes();
+ }
+
+ // ----------------------------------------------------------------------
+ // OOString support
+
+ public static byte[] oostring(int n, int base_) {
+ // XXX needs special case for unsigned ints
+ if (base_ == -1)
+ base_ = 10;
+ if (n < 0 && base_ != 10)
+ return string2bytes("-" + Integer.toString(-n, base_));
+ else
+ return string2bytes(Integer.toString(n, base_));
+ }
+
+ public static byte[] oostring(double d, int base_) {
+ return string2bytes(new Double(d).toString());
+ }
+
+ public static byte[] oostring(Object obj, int base_)
+ {
+ return string2bytes(String.format("<%s object>", new Object[] { obj.getClass().getName() }));
+ }
+
+ public static byte[] oostring(char ch, int base_)
+ {
+ return string2bytes(new Character(ch).toString());
+ }
+
+ public static byte[] oostring(byte[] s, int base_)
+ {
+ return s;
+ }
+
+ public static byte[] OOString(boolean b, int base_)
+ {
+ return string2bytes(new Boolean(b).toString());
+ }
+
+ // ----------------------------------------------------------------------
// Self Test
public static int __counter = 0, __failures = 0;
More information about the Pypy-commit
mailing list