зеркало из https://github.com/mozilla/pluotsorbet.git
add ClassTest.java and hashCode()
This commit is contained in:
Родитель
bde88bd000
Коммит
2a08d3b8ea
15
native.js
15
native.js
|
@ -9,6 +9,8 @@ Native.invoke = function(ctx, methodInfo) {
|
||||||
if (!methodInfo.native) {
|
if (!methodInfo.native) {
|
||||||
var key = methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature;
|
var key = methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature;
|
||||||
methodInfo.native = Native[key];
|
methodInfo.native = Native[key];
|
||||||
|
if (!methodInfo.native)
|
||||||
|
console.log(key);
|
||||||
}
|
}
|
||||||
methodInfo.native.call(null, ctx, ctx.current().stack);
|
methodInfo.native.call(null, ctx, ctx.current().stack);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +96,19 @@ Native["java/lang/Object.getClass.()Ljava/lang/Class;"] = function(ctx, stack) {
|
||||||
stack.push(stack.pop().class.getClassObject());
|
stack.push(stack.pop().class.getClassObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Native["java/lang/Object.hashCode.()I"] = (function() {
|
||||||
|
var gen = 0;
|
||||||
|
return function(ctx, stack) {
|
||||||
|
var obj = stack.pop();
|
||||||
|
var hashCode = obj.hashCode;
|
||||||
|
if (hashCode) {
|
||||||
|
hashCode = obj.hashCode = gen;
|
||||||
|
gen = (gen+1) & 0x7fffffff;
|
||||||
|
}
|
||||||
|
stack.push(hashCode);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
Native["java/lang/Class.invoke_clinit.()V"] = function(ctx, stack) {
|
Native["java/lang/Class.invoke_clinit.()V"] = function(ctx, stack) {
|
||||||
var classInfo = stack.pop().vmClass;
|
var classInfo = stack.pop().vmClass;
|
||||||
var clinit = CLASSES.getMethod(classInfo, "<clinit>", "()V", true);
|
var clinit = CLASSES.getMethod(classInfo, "<clinit>", "()V", true);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче