зеркало из https://github.com/mozilla/pluotsorbet.git
more fixes
This commit is contained in:
Родитель
673c224628
Коммит
9e3bd1c3c8
|
@ -86,12 +86,8 @@ Classes.prototype.initClass = function(className) {
|
|||
var clinit = this.getStaticMethod(className, "<clinit>", "()V");
|
||||
if (!clinit)
|
||||
return;
|
||||
SCHEDULER.sync(function() {
|
||||
LOG.debug("call " + className + ".<clinit> ...");
|
||||
clinit.run([], function() {
|
||||
LOG.debug("call " + className + ".<clinit> ... done");
|
||||
});
|
||||
});
|
||||
LOG.debug("call " + className + ".<clinit> ...");
|
||||
clinit.run(THREADS.current.stack);
|
||||
}
|
||||
|
||||
Classes.prototype.getClass = function(className, initialize) {
|
||||
|
|
20
frame.js
20
frame.js
|
@ -106,24 +106,26 @@ Frame.prototype.run = function(stack) {
|
|||
|
||||
this.ip = 0;
|
||||
|
||||
var result;
|
||||
while (true) {
|
||||
var op = this.read8();
|
||||
console.log(this.ip - 1, op, OPCODES[op], stack.length);
|
||||
console.log(this.ip - 1, OPCODES[op], stack.array.length);
|
||||
switch (op) {
|
||||
case OPCODES.return:
|
||||
break;
|
||||
stack.popLocals(locals);
|
||||
return;
|
||||
|
||||
case OPCODES.ireturn:
|
||||
case OPCODES.freturn:
|
||||
case OPCODES.areturn:
|
||||
result = stack.pop();
|
||||
break;
|
||||
var result = stack.pop();
|
||||
stack.popLocals(locals);
|
||||
return result;
|
||||
|
||||
case OPCODES.lreturn:
|
||||
case OPCODES.dreturn:
|
||||
result = stack.pop2();
|
||||
break;
|
||||
var result = stack.pop2();
|
||||
stack.popLocals(locals);
|
||||
return result;
|
||||
|
||||
default:
|
||||
var opName = OPCODES[op];
|
||||
|
@ -134,9 +136,6 @@ Frame.prototype.run = function(stack) {
|
|||
break;
|
||||
}
|
||||
};
|
||||
|
||||
stack.popLocals(locals);
|
||||
return result;
|
||||
}
|
||||
|
||||
Frame.prototype.nop = function(stack, locals) {
|
||||
|
@ -364,6 +363,7 @@ Frame.prototype.lastore = Frame.prototype.dastore = function(stack, locals) {
|
|||
}
|
||||
|
||||
Frame.prototype.pop = function(stack, locals) {
|
||||
console.trace();
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
|
|
7
jvm.js
7
jvm.js
|
@ -59,10 +59,5 @@ JVM.prototype.run = function() {
|
|||
throw new Error("Entry point method is not found.");
|
||||
}
|
||||
|
||||
console.log(entryPoint);
|
||||
|
||||
var stack = new Stack();
|
||||
stack.push(null); // args
|
||||
var exit = entryPoint.run(stack);
|
||||
console.log("exit(" + exit + ")");
|
||||
THREADS.current.startMain(entryPoint, []);
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
'use strict';
|
||||
|
||||
var Locals = function(stack, base) {
|
||||
this.stack = stack;
|
||||
this.array = stack.array;
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
Locals.prototype.set = function (idx, value) {
|
||||
this.stack[base + idx] = value;
|
||||
this.array[this.base + idx] = value;
|
||||
}
|
||||
|
||||
Locals.prototype.get = function (idx) {
|
||||
return this.stack[base + idx];
|
||||
return this.array[this.base + idx];
|
||||
}
|
||||
|
|
2
stack.js
2
stack.js
|
@ -47,7 +47,7 @@ Stack.prototype.popArgs = function (signature) {
|
|||
}
|
||||
|
||||
Stack.prototype.top = function () {
|
||||
return this.array[this.array.lengt - 1];
|
||||
return this.array[this.array.length - 1];
|
||||
}
|
||||
|
||||
Stack.prototype.reserveLocals = function (argc, max_locals) {
|
||||
|
|
|
@ -7,6 +7,7 @@ var Thread = function(name) {
|
|||
if (this instanceof Thread) {
|
||||
this.name = name || "noname";
|
||||
this.priority = (Thread.MAX_PRIORITY + Thread.MIN_PRIORITY) >> 1;
|
||||
this.stack = new Stack();
|
||||
} else {
|
||||
return new Thread(name);
|
||||
}
|
||||
|
@ -31,3 +32,7 @@ Thread.prototype.getPriority = function() {
|
|||
return this.priority;
|
||||
}
|
||||
|
||||
Thread.prototype.startMain = function(entryPoint, args) {
|
||||
this.stack.push(null); // args
|
||||
entryPoint.run(this.stack);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
var Threads = function() {
|
||||
this.threads = [];
|
||||
this.empty = [];
|
||||
var mainThread = new Thread("main");
|
||||
this.add(mainThread);
|
||||
this.current = mainThread;
|
||||
}
|
||||
|
||||
Threads.prototype.add = function(thread) {
|
||||
|
@ -30,6 +33,3 @@ Threads.prototype.count = function() {
|
|||
Threads.prototype.getThread = function(pid) {
|
||||
return this.threads[pid];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче