prepack
prepack copied to clipboard
Evaluating and serializing arrays with abstract elements/properties
This is a follow-up from some of the internal discussion we've had regarding the handling of abstract loops within Prepack.
Given the example:
(function () {
var array = __abstract("array", "array");
var result = [];
for (var i = 0; i < array.length; i++) {
result.push(array[i]);
}
window.result = result;
})();
I'm not entirely sure how this should be dealt with, but maybe it's something that @sebmarkbage, @NTillmann and @hermanventer have thought about.
I'd expect that the evaluated value of result
in this case would be that of an abstract value with a kind
set to forLoop
, maybe with a loop args for the starting index value, incrementer value, end index value and the body of the loop?
This is still a non trivial work item. When do you need it to be done?
I'd expect us to be able to work around it for at least another 2 months or so.
I think we probably need to iterate on the design a bit too.
E.g. what does it means for an example like this:
var array = __abstract("array", "array");
var count = 0;
var result = [];
var result2 = [];
for (var i = 0; i < array.length; i++) {
count++;
result.push({foo: array[i]});
result2.push({bar: array[i]});
}
window.result = { result, result2, count };
})();