зеркало из https://github.com/mozilla/pluotsorbet.git
move newArray to context
This commit is contained in:
Родитель
4dbfc348c8
Коммит
67c5746f6d
|
@ -210,7 +210,3 @@ Classes.prototype.newPrimitiveArray = function(type, size) {
|
|||
return new constructor(size);
|
||||
}
|
||||
|
||||
Classes.prototype.newArray = function(typeName, size) {
|
||||
return new (this.getClass(typeName).constructor)(size);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,9 +239,13 @@ Context.prototype.notify = function(obj, notifyAll) {
|
|||
});
|
||||
}
|
||||
|
||||
Context.prototype.newArray = function(typeName, size) {
|
||||
return new (CLASSES.getClass(typeName).constructor)(size);
|
||||
}
|
||||
|
||||
Context.prototype.newMultiArray = function(typeName, lengths) {
|
||||
var length = lengths[0];
|
||||
var array = CLASSES.newArray(typeName, length);
|
||||
var array = this.newArray(typeName, length);
|
||||
if (lengths.length > 1) {
|
||||
lengths = lengths.slice(1);
|
||||
for (var i=0; i<length; i++)
|
||||
|
|
2
jvm.js
2
jvm.js
|
@ -46,7 +46,7 @@ JVM.prototype.run = function(className, args) {
|
|||
ctx.pushFrame(CLASSES.getMethod(CLASSES.java_lang_Thread, "<init>", "(Ljava/lang/String;)V"), 2);
|
||||
ctx.execute(caller);
|
||||
|
||||
var arr = CLASSES.newArray("[Ljava/lang/String;", args.length);
|
||||
var arr = ctx.newArray("[Ljava/lang/String;", args.length);
|
||||
for (var n = 0; n < args.length; ++n)
|
||||
arr[n] = CLASSES.newString(args[n]);
|
||||
caller.stack.push(arr);
|
||||
|
|
|
@ -301,15 +301,15 @@ Native["java/lang/Throwable.obtainBackTrace.()Ljava/lang/Object;"] = (function(c
|
|||
var result = null;
|
||||
if (obj.stackTrace) {
|
||||
var depth = obj.stackTrace.length;
|
||||
var classNames = CLASSES.newArray("[Ljava/lang/Object;", depth);
|
||||
var methodNames = CLASSES.newArray("[Ljava/lang/Object;", depth);
|
||||
var classNames = ctx.newArray("[Ljava/lang/Object;", depth);
|
||||
var methodNames = ctx.newArray("[Ljava/lang/Object;", depth);
|
||||
var offsets = CLASSES.newPrimitiveArray("I", depth);
|
||||
obj.stackTrace.forEach(function(e, n) {
|
||||
classNames[n] = CLASSES.newString(e.className);
|
||||
methodNames[n] = CLASSES.newString(e.methodName);
|
||||
offsets[n] = e.offset;
|
||||
});
|
||||
result = CLASSES.newArray("[Ljava/lang/Object;", 3);
|
||||
result = ctx.newArray("[Ljava/lang/Object;", 3);
|
||||
result[0] = classNames;
|
||||
result[1] = methodNames;
|
||||
result[2] = offsets;
|
||||
|
|
2
vm.js
2
vm.js
|
@ -826,7 +826,7 @@ VM.execute = function(ctx) {
|
|||
if (className[0] !== "[")
|
||||
className = "L" + className + ";";
|
||||
className = "[" + className;
|
||||
stack.push(CLASSES.newArray(className, size));
|
||||
stack.push(ctx.newArray(className, size));
|
||||
break;
|
||||
case 0xc5: // multianewarray
|
||||
var idx = frame.read16();
|
||||
|
|
Загрузка…
Ссылка в новой задаче