зеркало из https://github.com/mozilla/pluotsorbet.git
pass ClassInfo instead of class name to getMethod
This commit is contained in:
Родитель
0e899fbc7e
Коммит
fd1d46cb7f
|
@ -89,7 +89,7 @@ Classes.prototype.getClass = function(caller, className) {
|
|||
return this.getArrayClass(caller, className);
|
||||
if (!!(classInfo = this.loadClassFile(className + ".class"))) {
|
||||
classInfo.staticFields = {};
|
||||
var clinit = this.getMethod(caller, className, "<clinit>", "()V", true);
|
||||
var clinit = this.getMethod(caller, classInfo, "<clinit>", "()V", true);
|
||||
if (clinit)
|
||||
caller.invoke(clinit);
|
||||
classInfo.constructor = function () {
|
||||
|
@ -128,10 +128,8 @@ Classes.prototype.setStaticField = function(caller, className, fieldName, value)
|
|||
this.getClass(caller, className).staticFields[fieldName] = value;
|
||||
}
|
||||
|
||||
Classes.prototype.getMethod = function(caller, className, methodName, signature, staticFlag) {
|
||||
console.log(className, methodName, signature);
|
||||
// Only force initialization when accessing a static method.
|
||||
var classInfo = this.getClass(caller, className);
|
||||
Classes.prototype.getMethod = function(caller, classInfo, methodName, signature, staticFlag) {
|
||||
console.log(classInfo.className, methodName, signature);
|
||||
var methods = classInfo.methods;
|
||||
for (var i=0; i<methods.length; i++) {
|
||||
if (ACCESS_FLAGS.isStatic(methods[i].access_flags) === !!staticFlag) {
|
||||
|
|
6
frame.js
6
frame.js
|
@ -98,7 +98,7 @@ Frame.prototype.throw = function(ex) {
|
|||
|
||||
Frame.prototype.raiseException = function(className, message) {
|
||||
var ex = CLASSES.newObject(this, className);
|
||||
var ctor = CLASSES.getMethod(this, className, "<init>", "(Ljava/lang/String;)V", false);
|
||||
var ctor = CLASSES.getMethod(this, ex.class, "<init>", "(Ljava/lang/String;)V", false);
|
||||
this.stack.push(ex);
|
||||
this.stack.push(message);
|
||||
this.invoke(ctor);
|
||||
|
@ -983,11 +983,13 @@ Frame.prototype.invokestatic = Frame.prototype.invokevirtual = Frame.prototype.i
|
|||
}
|
||||
|
||||
var cp = this.cp;
|
||||
|
||||
var className = cp[cp[cp[idx].class_index].name_index].bytes;
|
||||
var methodName = cp[cp[cp[idx].name_and_type_index].name_index].bytes;
|
||||
var signature = cp[cp[cp[idx].name_and_type_index].signature_index].bytes;
|
||||
|
||||
var method = CLASSES.getMethod(this, className, methodName, signature, op === OPCODES.invokestatic);
|
||||
var classInfo = CLASSES.getClass(this, className);
|
||||
var method = CLASSES.getMethod(this, classInfo, methodName, signature, op === OPCODES.invokestatic);
|
||||
|
||||
this.invoke(method);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче