зеркало из https://github.com/mozilla/pluotsorbet.git
more fixes
This commit is contained in:
Родитель
7972db1598
Коммит
44e5a5a331
39
classes.js
39
classes.js
|
@ -68,14 +68,13 @@ Classes.prototype.getEntryPoint = function(className, methodName) {
|
|||
if (ACCESS_FLAGS.isPublic(ca.getAccessFlags())) {
|
||||
var methods = ca.getMethods();
|
||||
var cp = ca.getConstantPool();
|
||||
for(var i=0; i<methods.length; i++) {
|
||||
if
|
||||
(
|
||||
ACCESS_FLAGS.isPublic(methods[i].access_flags) &&
|
||||
ACCESS_FLAGS.isStatic(methods[i].access_flags) &&
|
||||
cp[methods[i].name_index].bytes === methodName
|
||||
)
|
||||
{ return new Frame(ca, methods[i]); }
|
||||
for (var i=0; i<methods.length; i++) {
|
||||
if (ACCESS_FLAGS.isPublic(methods[i].access_flags) &&
|
||||
ACCESS_FLAGS.isStatic(methods[i].access_flags) &&
|
||||
!ACCESS_FLAGS.isNative(methods[i].access_flags) &&
|
||||
cp[methods[i].name_index].bytes === methodName) {
|
||||
return new Frame(ca, methods[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,18 +119,18 @@ Classes.prototype.setStaticField = function(className, fieldName, value) {
|
|||
Classes.prototype.getMethod = function(className, methodName, signature, staticFlag) {
|
||||
// Only force initialization when accessing a static method.
|
||||
var ca = this.getClass(className, staticFlag);
|
||||
if (ca instanceof ClassArea) {
|
||||
var methods = ca.getMethods();
|
||||
var cp = ca.getConstantPool();
|
||||
for(var i=0; i<methods.length; i++) {
|
||||
if (ACCESS_FLAGS.isStatic(methods[i].access_flags) === !!staticFlag)
|
||||
if (cp[methods[i].name_index].bytes === methodName)
|
||||
if (signature.toString() === cp[methods[i].signature_index].bytes)
|
||||
return new Frame(ca, methods[i]);
|
||||
}
|
||||
} else {
|
||||
if (methodName in ca) {
|
||||
return ca[methodName];
|
||||
var methods = ca.getMethods();
|
||||
var cp = ca.getConstantPool();
|
||||
for (var i=0; i<methods.length; i++) {
|
||||
if (ACCESS_FLAGS.isStatic(methods[i].access_flags) === !!staticFlag) {
|
||||
if (cp[methods[i].name_index].bytes === methodName) {
|
||||
if (signature.toString() === cp[methods[i].signature_index].bytes) {
|
||||
if (ACCESS_FLAGS.isNative(methods[i].access_flags)) {
|
||||
return NATIVE.getMethod(className, methodName, signature.toString());
|
||||
}
|
||||
return new Frame(ca, methods[i], className, methodName, signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
42
frame.js
42
frame.js
|
@ -16,7 +16,6 @@ var Frame = function(classArea, method) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return new Frame(classArea, method);
|
||||
}
|
||||
|
@ -1443,15 +1442,31 @@ Frame.prototype.putstatic = function(done) {
|
|||
return done();
|
||||
}
|
||||
|
||||
Frame.prototype._invoke = function(method, signature, args, done) {
|
||||
if (method instanceof Frame) {
|
||||
method.setPid(this._pid);
|
||||
method.run(args, function(res) {
|
||||
if (signature.OUT.length != 0) {
|
||||
this._stack.push(res);
|
||||
}
|
||||
return done();
|
||||
});
|
||||
} else {
|
||||
var res = method.apply(null, args);
|
||||
if (signature.OUT.length != 0) {
|
||||
this._stack.push(res);
|
||||
}
|
||||
return done();
|
||||
}
|
||||
}
|
||||
|
||||
Frame.prototype.invokestatic = function(done) {
|
||||
var self = this;
|
||||
|
||||
var idx = this._read16();
|
||||
|
||||
var className = this._cp[this._cp[this._cp[idx].class_index].name_index].bytes;
|
||||
var methodName = this._cp[this._cp[this._cp[idx].name_and_type_index].name_index].bytes;
|
||||
var signature = Signature.parse(this._cp[this._cp[this._cp[idx].name_and_type_index].signature_index].bytes);
|
||||
|
||||
|
||||
var args = [];
|
||||
for (var i=0; i<signature.IN.length; i++) {
|
||||
if (!signature.IN[i].isArray && ["long", "double"].indexOf(signature.IN[i].type) !== -1) {
|
||||
|
@ -1462,23 +1477,7 @@ Frame.prototype.invokestatic = function(done) {
|
|||
}
|
||||
}
|
||||
|
||||
var method = CLASSES.getStaticMethod(className, methodName, signature);
|
||||
|
||||
if (method instanceof Frame) {
|
||||
method.setPid(self._pid);
|
||||
method.run(args, function(res) {
|
||||
if (signature.OUT.length != 0) {
|
||||
self._stack.push(res);
|
||||
}
|
||||
return done();
|
||||
});
|
||||
} else {
|
||||
var res = method.apply(null, args);
|
||||
if (signature.OUT.length != 0) {
|
||||
self._stack.push(res);
|
||||
}
|
||||
return done();
|
||||
}
|
||||
this._invoke(CLASSES.getStaticMethod(className, methodName, signature), signature, args, done);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1698,7 +1697,6 @@ Frame.prototype.checkcast = function(done) {
|
|||
return done();
|
||||
}
|
||||
|
||||
|
||||
Frame.prototype.athrow = function(done) {
|
||||
this._throw(this._stack.pop());
|
||||
return done();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<script type="text/javascript" src="signature.js"></script>
|
||||
<script type="text/javascript" src="opcodes.js"></script>
|
||||
<script type="text/javascript" src="classes.js"></script>
|
||||
<script type="text/javascript" src="native.js"></script>
|
||||
<script type="text/javascript" src="frame.js"></script>
|
||||
<script type="text/javascript" src="scheduler.js"></script>
|
||||
<script type="text/javascript" src="thread.js"></script>
|
||||
|
|
|
@ -4,6 +4,6 @@ CLDC1_1_1_SRC=$(shell find cldc1.1.1 -name *.java) $(shell find vm -name *.java)
|
|||
cldc1_1_1.jar: $(CLDC1_1_1_SRC)
|
||||
rm -rf build
|
||||
mkdir build
|
||||
javac -d ./build $^
|
||||
javac -source 1.3 -d ./build $^
|
||||
cd build && jar cvf ../cldc1.1.1.jar *
|
||||
rm -rf build
|
||||
|
|
3
jvm.js
3
jvm.js
|
@ -3,7 +3,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var LOG, CLASSES, THREADS, SCHEDULER;
|
||||
var LOG, CLASSES, THREADS, SCHEDULER, NATIVE;
|
||||
|
||||
var JVM = function() {
|
||||
if (this instanceof JVM) {
|
||||
|
@ -11,6 +11,7 @@ var JVM = function() {
|
|||
CLASSES = new Classes();
|
||||
THREADS = new Threads();
|
||||
SCHEDULER = new Scheduler();
|
||||
NATIVE = new Native();
|
||||
|
||||
THREADS.add(new Thread("main"));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче