[fasta] Create a 'constant helper' class which will throw on illegal 'constant' expressions
[fasta] Create a 'constant helper' class which will throw on illegal 'constant' expressions

Currently kernel fails a number of test because too much is allowed to be constant.

Examples includes

const x = "hello " * 4; // yielding "hello hello hello hello "
const y = "hello".leng; // crashing the VM

The idea behing the helper class is, that fasta can generate those as for instance
var c = new _ConstantHelper();
const x = c.times("hello ", 4, () => thow yadayada);

where - upon evaluating it in for instance the VMs constant evaluator - the helper will see that "hello " is neiher an integer nor null, and thus execute the given onError function.

This is only one step towards that; it will still have to be hooked up in fasta,
and constant evaluators (e.g. in the VM, I suppose there's also one in dart2js etc)
might need to be updated to be able to execute it.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2982843002 .

dartino/dart-sdk,dart-lang/sdk,dartino/dart-sdk,dart-lang/sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dartino/dart-sdk,dartino/dart-sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-archive/dart-sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-archive/dart-sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-lang/sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-archive/dart-sdk,dart-archive/dart-sdk,dart-lang/sdk