зеркало из https://github.com/mozilla/pluotsorbet.git
move newMultiArray over to context
This commit is contained in:
Родитель
c17f2bda62
Коммит
4dbfc348c8
10
classes.js
10
classes.js
|
@ -214,13 +214,3 @@ Classes.prototype.newArray = function(typeName, size) {
|
|||
return new (this.getClass(typeName).constructor)(size);
|
||||
}
|
||||
|
||||
Classes.prototype.newMultiArray = function(typeName, lengths) {
|
||||
var length = lengths[0];
|
||||
var array = this.newArray(typeName, length);
|
||||
if (lengths.length > 1) {
|
||||
lengths = lengths.slice(1);
|
||||
for (var i=0; i<length; i++)
|
||||
array[i] = this.newMultiArray(typeName.substr(1), lengths);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
|
11
context.js
11
context.js
|
@ -238,3 +238,14 @@ Context.prototype.notify = function(obj, notifyAll) {
|
|||
ctx.wakeup(obj);
|
||||
});
|
||||
}
|
||||
|
||||
Context.prototype.newMultiArray = function(typeName, lengths) {
|
||||
var length = lengths[0];
|
||||
var array = CLASSES.newArray(typeName, length);
|
||||
if (lengths.length > 1) {
|
||||
lengths = lengths.slice(1);
|
||||
for (var i=0; i<length; i++)
|
||||
array[i] = this.newMultiArray(typeName.substr(1), lengths);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
|
2
vm.js
2
vm.js
|
@ -837,7 +837,7 @@ VM.execute = function(ctx) {
|
|||
var lengths = new Array(dimensions);
|
||||
for (var i=0; i<dimensions; i++)
|
||||
lengths[i] = stack.pop();
|
||||
stack.push(CLASSES.newMultiArray(classInfo.className, lengths.reverse()));
|
||||
stack.push(ctx.newMultiArray(classInfo.className, lengths.reverse()));
|
||||
break;
|
||||
case 0xbe: // arraylength
|
||||
var obj = stack.pop();
|
||||
|
|
Загрузка…
Ссылка в новой задаче