зеркало из https://github.com/mozilla/pluotsorbet.git
Merge branch 'master' of https://github.com/andreasgal/j2me.js into seal_Frame
This commit is contained in:
Коммит
e1390b706c
|
@ -40,8 +40,10 @@ Context.prototype.pushClassInitFrame = function(classInfo) {
|
|||
return;
|
||||
classInfo.thread = this.thread;
|
||||
var syntheticMethod = {
|
||||
syntheticKey: "ClassInitSynthetic:" + classInfo.className,
|
||||
name: "ClassInitSynthetic",
|
||||
signature: "()V",
|
||||
classInfo: {
|
||||
className: classInfo.className,
|
||||
vmc: {},
|
||||
vfc: {},
|
||||
constant_pool: [
|
||||
|
@ -80,8 +82,10 @@ Context.prototype.raiseException = function(className, message) {
|
|||
message = "";
|
||||
message = "" + message;
|
||||
var syntheticMethod = {
|
||||
syntheticKey: "RaiseExceptionSynthetic",
|
||||
name: "RaiseExceptionSynthetic",
|
||||
signature: "()V",
|
||||
classInfo: {
|
||||
className: className,
|
||||
vmc: {},
|
||||
vfc: {},
|
||||
constant_pool: [
|
||||
|
|
|
@ -11,8 +11,7 @@ var Instrument = {
|
|||
profile: null,
|
||||
|
||||
getKey: function(methodInfo) {
|
||||
return "name" in methodInfo ? methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature
|
||||
: methodInfo.syntheticKey;
|
||||
return methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature;
|
||||
},
|
||||
|
||||
callEnterHooks: function(methodInfo, caller, callee) {
|
||||
|
|
38
midp/midp.js
38
midp/midp.js
|
@ -863,28 +863,44 @@ Native["com/sun/midp/events/NativeEventMonitor.readNativeEvent.(Lcom/sun/midp/ev
|
|||
stack.push(1);
|
||||
}
|
||||
|
||||
MIDP.localizedStrings = new Map();
|
||||
|
||||
Native["com/sun/midp/l10n/LocalizedStringsBase.getContent.(I)Ljava/lang/String;"] = function(ctx, stack) {
|
||||
var id = stack.pop();
|
||||
|
||||
var classInfo = CLASSES.getClass("com/sun/midp/i18n/ResourceConstants");
|
||||
var key;
|
||||
classInfo.fields.forEach(function(field) {
|
||||
if (classInfo.constant_pool[field.constantValue].integer === id)
|
||||
key = field.name;
|
||||
});
|
||||
var data = CLASSES.loadFile("assets/0/en-US.xml");
|
||||
if (!data || !key)
|
||||
|
||||
if (!key) {
|
||||
ctx.raiseExceptionAndYield("java/io/IOException");
|
||||
var text = util.decodeUtf8(data);
|
||||
var xml = new window.DOMParser().parseFromString(text, "text/xml");
|
||||
var entries = xml.getElementsByTagName("localized_string");
|
||||
for (var n = 0; n < entries.length; ++n) {
|
||||
var entry = entries[n];
|
||||
if (entry.attributes.Key.value === key) {
|
||||
stack.push(ctx.newString(entry.attributes.Value.value));
|
||||
return;
|
||||
}
|
||||
|
||||
if (MIDP.localizedStrings.size === 0) {
|
||||
var data = CLASSES.loadFileFromJar("java/classes.jar", "assets/0/en-US.xml");
|
||||
if (!data)
|
||||
ctx.raiseExceptionAndYield("java/io/IOException");
|
||||
|
||||
var text = util.decodeUtf8(data);
|
||||
var xml = new window.DOMParser().parseFromString(text, "text/xml");
|
||||
var entries = xml.getElementsByTagName("localized_string");
|
||||
|
||||
for (var n = 0; n < entries.length; ++n) {
|
||||
var attrs = entries[n].attributes;
|
||||
MIDP.localizedStrings.set(attrs.Key.value, attrs.Value.value);
|
||||
}
|
||||
}
|
||||
ctx.raiseExceptionAndYield("java/lang/IllegalStateException");
|
||||
|
||||
var value = MIDP.localizedStrings.get(key);
|
||||
|
||||
if (!value) {
|
||||
ctx.raiseExceptionAndYield("java/lang/IllegalStateException");
|
||||
}
|
||||
|
||||
stack.push(ctx.newString(value));
|
||||
}
|
||||
|
||||
Native["javax/microedition/lcdui/Display.drawTrustedIcon0.(IZ)V"] = function(ctx, stack) {
|
||||
|
|
|
@ -282,8 +282,10 @@ Native["java/lang/Class.newInstance.()Ljava/lang/Object;"] = function(ctx, stack
|
|||
var classObject = stack.pop();
|
||||
var className = classObject.vmClass.className;
|
||||
var syntheticMethod = {
|
||||
syntheticKey: "ClassNewInstanceSynthetic:" + className,
|
||||
name: "ClassNewInstanceSynthetic",
|
||||
signature: "()Ljava/lang/Object;",
|
||||
classInfo: {
|
||||
className: className,
|
||||
vmc: {},
|
||||
vfc: {},
|
||||
constant_pool: [
|
||||
|
@ -503,8 +505,10 @@ Native["java/lang/Thread.start0.()V"] = function(ctx, stack) {
|
|||
ctx.thread = thread;
|
||||
|
||||
var syntheticMethod = {
|
||||
syntheticKey: "ThreadStart0Synthetic:" + thread.class.className + "." + run.name + "." + run.signature,
|
||||
name: "ThreadStart0Synthetic",
|
||||
signature: "()V",
|
||||
classInfo: {
|
||||
className: thread.class.className,
|
||||
vmc: {},
|
||||
vfc: {},
|
||||
constant_pool: [
|
||||
|
|
18
override.js
18
override.js
|
@ -67,6 +67,24 @@ Override["java/io/ByteArrayOutputStream.write.([BII)V"] = function(ctx, stack) {
|
|||
_this.class.getField("I.count.I").set(_this, newcount);
|
||||
}
|
||||
|
||||
Override["java/io/ByteArrayOutputStream.write.(I)V"] = function(ctx, stack) {
|
||||
var value = stack.pop(), _this = stack.pop();
|
||||
|
||||
var count = _this.class.getField("I.count.I").get(_this);
|
||||
var buf = _this.class.getField("I.buf.[B").get(_this);
|
||||
|
||||
var newcount = count + 1;
|
||||
if (newcount > buf.length) {
|
||||
var newbuf = ctx.newPrimitiveArray("B", Math.max(buf.length << 1, newcount));
|
||||
newbuf.set(buf);
|
||||
buf = newbuf;
|
||||
_this.class.getField("I.buf.[B").set(_this, buf);
|
||||
}
|
||||
|
||||
buf[count] = value;
|
||||
_this.class.getField("I.count.I").set(_this, newcount);
|
||||
}
|
||||
|
||||
Override["java/io/ByteArrayInputStream.<init>.([B)V"] = function(ctx, stack) {
|
||||
var buf = stack.pop(), _this = stack.pop();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче