зеркало из https://github.com/mozilla/pluotsorbet.git
Misc cleanup.
This commit is contained in:
Родитель
d0e9904afb
Коммит
1a562a8943
7
jvm.ts
7
jvm.ts
|
@ -36,8 +36,6 @@ module J2ME {
|
|||
var mainArgs = isolate.klass.classInfo.getField("I._mainArgs.[Ljava/lang/String;").get(isolate);
|
||||
var runtime = new J2ME.Runtime(this);
|
||||
var ctx = new Context(runtime);
|
||||
var oldCtx = $.ctx;
|
||||
ctx.setCurrent();
|
||||
|
||||
isolate.runtime = runtime;
|
||||
runtime.isolate = isolate;
|
||||
|
@ -58,7 +56,9 @@ module J2ME {
|
|||
|
||||
ctx.frames.push(new Frame(CLASSES.getMethod(CLASSES.java_lang_Thread, "I.<init>.(Ljava/lang/String;)V"),
|
||||
[ runtime.mainThread, util.newString("main") ], 0));
|
||||
var oldCtx = $.ctx;
|
||||
ctx.execute();
|
||||
oldCtx.setCurrent();
|
||||
|
||||
var args = J2ME.newStringArray(mainArgs.length);
|
||||
for (var n = 0; n < mainArgs.length; ++n) {
|
||||
|
@ -66,8 +66,7 @@ module J2ME {
|
|||
}
|
||||
|
||||
ctx.frames.push(new Frame(entryPoint, [ args ], 0));
|
||||
ctx.start();
|
||||
oldCtx.setCurrent();
|
||||
ctx.resume();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -514,8 +514,9 @@ Native.create("java/lang/Thread.start0.()V", function(ctx) {
|
|||
this.pid = util.id();
|
||||
var run = CLASSES.getMethod(this.klass.classInfo, "I.run.()V");
|
||||
// Create a context for the thread and start it.
|
||||
var ctx = new Context(ctx.runtime);
|
||||
ctx.thread = this;
|
||||
var newCtx = new Context(ctx.runtime);
|
||||
newCtx.thread = this;
|
||||
|
||||
|
||||
var syntheticMethod = new MethodInfo({
|
||||
name: "ThreadStart0Synthetic",
|
||||
|
@ -547,8 +548,8 @@ Native.create("java/lang/Thread.start0.()V", function(ctx) {
|
|||
])
|
||||
});
|
||||
|
||||
ctx.frames.push(new Frame(syntheticMethod, [ this ], 0));
|
||||
ctx.resume();
|
||||
newCtx.frames.push(new Frame(syntheticMethod, [ this ], 0));
|
||||
newCtx.resume();
|
||||
});
|
||||
|
||||
Native.create("java/lang/Thread.internalExit.()V", function() {
|
||||
|
|
11
override.js
11
override.js
|
@ -128,23 +128,24 @@ function createAlternateImpl(object, key, fn, usesPromise) {
|
|||
var postExec = usesPromise ? executePromise : doReturn;
|
||||
|
||||
object[key] = function() {
|
||||
var ctx = $.ctx;
|
||||
try {
|
||||
var args = Array.prototype.slice.apply(arguments);
|
||||
args.push($.ctx);
|
||||
args.push(ctx);
|
||||
var ret = fn.apply(this, args);
|
||||
return postExec(ret, doReturn, $.ctx, key);
|
||||
return postExec(ret, doReturn, ctx, key);
|
||||
} catch(e) {
|
||||
if (e === VM.Pause || e === VM.Yield) {
|
||||
throwHelper(e);
|
||||
} else if (e.name === "TypeError") {
|
||||
// JavaScript's TypeError is analogous to a NullPointerException.
|
||||
console.log(e.stack);
|
||||
$.ctx.raiseExceptionAndYield("java/lang/NullPointerException", e);
|
||||
ctx.raiseExceptionAndYield("java/lang/NullPointerException", e);
|
||||
} else if (e.javaClassName) {
|
||||
$.ctx.raiseExceptionAndYield(e.javaClassName, e.message);
|
||||
ctx.raiseExceptionAndYield(e.javaClassName, e.message);
|
||||
} else {
|
||||
console.error(e, e.stack);
|
||||
$.ctx.raiseExceptionAndYield("java/lang/RuntimeException", e);
|
||||
ctx.raiseExceptionAndYield("java/lang/RuntimeException", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче