prepack icon indicating copy to clipboard operation
prepack copied to clipboard

Evaluating and serializing arrays with abstract elements/properties

Open trueadm opened this issue 7 years ago • 2 comments

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?

trueadm avatar Jan 17 '18 00:01 trueadm

This is still a non trivial work item. When do you need it to be done?

hermanventer avatar Jan 17 '18 00:01 hermanventer

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 };
})();

sebmarkbage avatar Jan 17 '18 02:01 sebmarkbage