6edbfd93ab
Enums are now split between pre and post canonicalization members. A
separate operation during link-time is emitted for every const
enum field. These are required during link time since enhanced enums can have non-trivial type hierarchies.
Example for snippet:
```
enum E {
e1(1), ...
const E(this.i);
final int i;
}
```
Used to emit enum fields as:
```
dart.defineLazy(CT, {
get C1() {
return C[1] = dart.const(Object.setPrototypeOf({
[_Enum__name]: "e1",
[_Enum_index]: 0
i: 1
}, E.prototype));
},
}
```
Now emits them as:
```
// Declaration-time
dart.defineLazy(CT, {
get C1() {
return C[1] = dart.const(Object.setPrototypeOf({
[_Enum__name]: "e1",
}, E.prototype));
},
}
// Link-time
dart.extendEnum(dart.const(Object.setPrototypeOf({
[_Enum__name]: "e1"
}, E.prototype)), {
i: 1,
get index() {
return E.values.indexOf(this);
}
});
```
Change-Id: Id5ce2ec117e59d8daa28df7fe6051e4a7e1a5bc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404723
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>