Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart

Issue 2488543002: fix #27775, enum declaration where "name" is a property (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
index 87ed08b8be5d1f2e588da66be9c372c3a37a7f5b..1c778719df1ab84ff1059e6b4a0bdfb62c059c85 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -540,3 +540,16 @@ defineNamedConstructorCallable(clazz, name, ctor) => JS(
// like `caller` and `arguments`.
$defineProperty($clazz, $name, { value: ctor, configurable: true });
})()''');
+
+defineEnumValues(enumClass, names) => JS(
+ '',
+ '''(() => {
+ let values = [];
+ for (var i = 0; i < $names.length; i++) {
+ let value = $const_(new $enumClass(i));
+ values.push(value);
+ Object.defineProperty($enumClass, $names[i],
+ { value: value, configurable: true });
+ }
+ $enumClass.values = $constList(values, $enumClass);
+})()''');

Powered by Google App Engine
This is Rietveld 408576698