зеркало из https://github.com/mozilla/pluotsorbet.git
Merge commit '1741920316ee5d5bb29bf1d91b2860447664c5d5' into jitopt3
This commit is contained in:
Коммит
99d11b80fc
|
@ -942,20 +942,14 @@ module J2ME {
|
|||
case Bytecodes.NEWARRAY:
|
||||
type = frame.read8();
|
||||
size = stack.pop();
|
||||
if (size < 0) {
|
||||
throw $.newNegativeArraySizeException();
|
||||
}
|
||||
stack.push(util.newPrimitiveArray("????ZCFDBSIJ"[type], size));
|
||||
stack.push(newArray(PrimitiveClassInfo["????ZCFDBSIJ"[type]].klass, size));
|
||||
break;
|
||||
case Bytecodes.ANEWARRAY:
|
||||
index = frame.read16();
|
||||
classInfo = resolveClass(index, mi.classInfo, false);
|
||||
classInitCheck(classInfo, frame.pc - 3);
|
||||
size = stack.pop();
|
||||
if (size < 0) {
|
||||
throw $.newNegativeArraySizeException();
|
||||
}
|
||||
stack.push(util.newArray(classInfo, size));
|
||||
stack.push(newArray(classInfo.klass, size));
|
||||
break;
|
||||
case Bytecodes.MULTIANEWARRAY:
|
||||
index = frame.read16();
|
||||
|
@ -1031,7 +1025,7 @@ module J2ME {
|
|||
if (U) {
|
||||
return;
|
||||
}
|
||||
stack.push(util.newObject(classInfo));
|
||||
stack.push(newObject(classInfo.klass));
|
||||
break;
|
||||
case Bytecodes.CHECKCAST:
|
||||
index = frame.read16();
|
||||
|
|
2
jvm.ts
2
jvm.ts
|
@ -53,7 +53,7 @@ module J2ME {
|
|||
if (!entryPoint)
|
||||
throw new Error("Could not find main method in class " + mainClass);
|
||||
|
||||
ctx.thread = runtime.mainThread = util.newObject(CLASSES.java_lang_Thread);
|
||||
ctx.thread = runtime.mainThread = <java.lang.Thread>newObject(CLASSES.java_lang_Thread.klass);
|
||||
ctx.thread.pid = util.id();
|
||||
ctx.thread.alive = true;
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ Native["com/nokia/mid/s40/codec/DataEncoder.putEnd.(ILjava/lang/String;)V"] = fu
|
|||
Native["com/nokia/mid/s40/codec/DataEncoder.getData.()[B"] = function() {
|
||||
var data = this.encoder.getData();
|
||||
|
||||
var array = util.newPrimitiveArray("B", data.length);
|
||||
var array = J2ME.newByteArray(data.length);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
array[i] = data.charCodeAt(i);
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ function(jPath, filterArray, includeHidden) {
|
|||
|
||||
files.forEach(function(file, i) {
|
||||
var bytesFile = encoder.encode(file);
|
||||
var fileArray = util.newPrimitiveArray("B", bytesFile.byteLength);
|
||||
var fileArray = J2ME.newByteArray(bytesFile.byteLength);
|
||||
fileArray.set(bytesFile);
|
||||
filesArray[i] = fileArray;
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ var currentlyFocusedTextEditor;
|
|||
}
|
||||
|
||||
Native["com/sun/midp/lcdui/DisplayDeviceContainer.getDisplayDevicesIds0.()[I"] = function() {
|
||||
var ids = util.newPrimitiveArray("I", 1);
|
||||
var ids = J2ME.newIntArray( 1);
|
||||
ids[0] = 1;
|
||||
return ids;
|
||||
};
|
||||
|
|
|
@ -656,7 +656,7 @@ PlayerContainer.prototype.isVolumeControlSupported = function() {
|
|||
|
||||
PlayerContainer.prototype.writeBuffer = function(buffer) {
|
||||
if (this.contentSize === 0) {
|
||||
this.data = util.newPrimitiveArray("B", this.getBufferSize());
|
||||
this.data = J2ME.newByteArray(this.getBufferSize());
|
||||
}
|
||||
|
||||
this.data.set(buffer, this.contentSize);
|
||||
|
|
|
@ -14,7 +14,7 @@ Native["com/sun/midp/jarutil/JarReader.readJarEntry0.(Ljava/lang/String;Ljava/la
|
|||
throw $.newIOException();
|
||||
var length = bytes.byteLength;
|
||||
var data = new Uint8Array(bytes);
|
||||
var array = util.newPrimitiveArray("B", length);
|
||||
var array = J2ME.newByteArray(length);
|
||||
for (var n = 0; n < length; ++n)
|
||||
array[n] = data[n];
|
||||
return array;
|
||||
|
@ -450,7 +450,7 @@ Native["com/sun/midp/util/ResourceHandler.loadRomizedResource0.(Ljava/lang/Strin
|
|||
return null;
|
||||
}
|
||||
var len = data.byteLength;
|
||||
var bytes = util.newPrimitiveArray("B", len);
|
||||
var bytes = J2ME.newByteArray(len);
|
||||
var src = new Uint8Array(data);
|
||||
for (var n = 0; n < bytes.byteLength; ++n)
|
||||
bytes[n] = src[n];
|
||||
|
@ -1045,7 +1045,7 @@ Native["javax/microedition/lcdui/Display.drawTrustedIcon0.(IZ)V"] = function(dis
|
|||
};
|
||||
|
||||
Native["com/sun/midp/events/EventQueue.sendShutdownEvent.()V"] = function() {
|
||||
var obj = util.newObject(CLASSES.getClass("com/sun/midp/events/NativeEvent"));
|
||||
var obj = J2ME.newObject(CLASSES.getClass("com/sun/midp/events/NativeEvent").klass);
|
||||
obj.klass.classInfo.getField("I.type.I").set(obj, MIDP.EVENT_QUEUE_SHUTDOWN);
|
||||
MIDP.sendEvent(obj, $.ctx.runtime.isolate.id);
|
||||
};
|
||||
|
|
|
@ -132,12 +132,12 @@ function(port, msid, handle, smsPacket) {
|
|||
var text = sms.text;
|
||||
var addr = sms.addr;
|
||||
|
||||
var message = util.newPrimitiveArray("B", text.length);
|
||||
var message = J2ME.newByteArray(text.length);
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
message[i] = text.charCodeAt(i);
|
||||
}
|
||||
|
||||
var address = util.newPrimitiveArray("B", addr.length);
|
||||
var address = J2ME.newByteArray(addr.length);
|
||||
for (var i = 0; i < addr.length; i++) {
|
||||
address[i] = addr.charCodeAt(i);
|
||||
}
|
||||
|
|
|
@ -474,7 +474,7 @@ Native["java/lang/Throwable.obtainBackTrace.()Ljava/lang/Object;"] = function()
|
|||
var depth = this.stackTrace.length;
|
||||
var classNames = J2ME.newObjectArray(depth);
|
||||
var methodNames = J2ME.newObjectArray(depth);
|
||||
var offsets = util.newPrimitiveArray("I", depth);
|
||||
var offsets = J2ME.newIntArray(depth);
|
||||
this.stackTrace.forEach(function(e, n) {
|
||||
classNames[n] = J2ME.newString(e.className);
|
||||
methodNames[n] = J2ME.newString(e.methodName);
|
||||
|
@ -627,7 +627,7 @@ Native["com/sun/cldc/io/ResourceInputStream.open.(Ljava/lang/String;)Ljava/lang/
|
|||
var data = CLASSES.loadFile(fileName);
|
||||
var obj = null;
|
||||
if (data) {
|
||||
obj = util.newObject(CLASSES.java_lang_Object);
|
||||
obj = J2ME.newObject(CLASSES.java_lang_Object.klass);
|
||||
obj.data = new Uint8Array(data);
|
||||
obj.pos = 0;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ Native["com/sun/cldc/io/ResourceInputStream.open.(Ljava/lang/String;)Ljava/lang/
|
|||
};
|
||||
|
||||
Native["com/sun/cldc/io/ResourceInputStream.clone.(Ljava/lang/Object;)Ljava/lang/Object;"] = function(source) {
|
||||
var obj = util.newObject(CLASSES.java_lang_Object);
|
||||
var obj = J2ME.newObject(CLASSES.java_lang_Object.klass);
|
||||
obj.data = new Uint8Array(source.data);
|
||||
obj.pos = source.pos;
|
||||
return obj;
|
||||
|
@ -838,7 +838,7 @@ Native["java/io/DataOutputStream.UTFToBytes.(Ljava/lang/String;)[B"] = function(
|
|||
}
|
||||
|
||||
var count = 0;
|
||||
var bytearr = util.newPrimitiveArray("B", utflen + 2);
|
||||
var bytearr = J2ME.newByteArray(utflen + 2);
|
||||
bytearr[count++] = (utflen >>> 8) & 0xFF;
|
||||
bytearr[count++] = (utflen >>> 0) & 0xFF;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
|
|
|
@ -1614,6 +1614,10 @@ module J2ME {
|
|||
return newArray(Klasses.byte, size);
|
||||
}
|
||||
|
||||
export function newIntArray(size: number): number[] {
|
||||
return newArray(Klasses.int, size);
|
||||
}
|
||||
|
||||
export function getArrayKlass(elementKlass: Klass): Klass {
|
||||
// Have we already created one? We need to maintain pointer identity.
|
||||
if (elementKlass.arrayKlass) {
|
||||
|
|
|
@ -142,7 +142,7 @@ Native["org/mozilla/io/TestNokiaPhoneStatusServer.sendFakeOfflineEvent.()V"] = f
|
|||
|
||||
Native["javax/microedition/media/TestAudioRecorder.convert3gpToAmr.([B)[B"] = function(data) {
|
||||
var converted = Media.convert3gpToAmr(new Uint8Array(data));
|
||||
var result = util.newPrimitiveArray("B", converted.length);
|
||||
var result = J2ME.newByteArray(converted.length);
|
||||
result.set(converted);
|
||||
return result;
|
||||
};
|
||||
|
|
27
util.js
27
util.js
|
@ -107,21 +107,9 @@ var util = (function () {
|
|||
return J2ME.fromJavaString(jStr);
|
||||
}
|
||||
|
||||
// Remove and switch to newArray
|
||||
function newPrimitiveArray(type, size) {
|
||||
var constructor = J2ME.getArrayConstructor(type);
|
||||
return new constructor(size);
|
||||
}
|
||||
|
||||
|
||||
// Remove
|
||||
function newArray(classInfo, size) {
|
||||
return J2ME.newArray(classInfo.klass, size);
|
||||
}
|
||||
|
||||
function newMultiArray(classInfo, lengths) {
|
||||
var length = lengths[0];
|
||||
var array = newArray(classInfo.elementClass, length);
|
||||
var array = J2ME.newArray(classInfo.elementClass.klass, length);
|
||||
if (lengths.length > 1) {
|
||||
lengths = lengths.slice(1);
|
||||
for (var i=0; i<length; i++)
|
||||
|
@ -130,15 +118,6 @@ var util = (function () {
|
|||
return array;
|
||||
}
|
||||
|
||||
// Remove
|
||||
function newObject(classInfo) {
|
||||
return J2ME.newObject(classInfo.klass);
|
||||
}
|
||||
|
||||
function newString(s) {
|
||||
return J2ME.newString(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayBufferView of the underlying code points
|
||||
* represented by the given Java string.
|
||||
|
@ -221,11 +200,7 @@ var util = (function () {
|
|||
double2long: double2long,
|
||||
fromJavaChars: fromJavaChars,
|
||||
fromJavaString: fromJavaString,
|
||||
newPrimitiveArray: newPrimitiveArray,
|
||||
newArray: newArray,
|
||||
newMultiArray: newMultiArray,
|
||||
newObject: newObject,
|
||||
newString: newString,
|
||||
stringToCharArray: stringToCharArray,
|
||||
id: id,
|
||||
tag: tag,
|
||||
|
|
Загрузка…
Ссылка в новой задаче