Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart |
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart |
index ad2566869c8b477a08d1271375d77508b8d14ad8..4075646b8e11fc05a496381658b5d14c63ab11f9 100644 |
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart |
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart |
@@ -16,6 +16,18 @@ defineValue(obj, name, value) { |
return value; |
} |
+void defineGetter(obj, name, getter) { |
+ defineProperty(obj, name, JS('', '{get: #}', getter)); |
+} |
+ |
+void defineMemoizedGetter(obj, name, compute) { |
+ defineProperty( |
+ obj, |
+ name, |
+ JS('', '{get: () => #, configurable: true}', |
+ defineValue(obj, name, JS('', '#()', compute)))); |
+} |
+ |
getOwnPropertyDescriptor(obj, name) => |
JS('', 'Object.getOwnPropertyDescriptor(#, #)', obj, name); |
@@ -40,7 +52,7 @@ void throwInternalError(String message) { |
JS('', 'throw Error(#)', message); |
} |
-getOwnNamesAndSymbols(obj) { |
+Iterable getOwnNamesAndSymbols(obj) { |
var names = getOwnPropertyNames(obj); |
var symbols = getOwnPropertySymbols(obj); |
return JS('', '#.concat(#)', names, symbols); |
@@ -83,27 +95,13 @@ defineLazyProperty(to, name, desc) => JS( |
return $defineProperty($to, $name, $desc); |
})()'''); |
-void defineLazy(to, from) => JS( |
- '', |
- '''(() => { |
- for (let name of $getOwnNamesAndSymbols($from)) { |
- $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name)); |
+copyTheseProperties(to, from, names) { |
+ for (var i = 0; i < JS('int', '#.length', names); ++i) { |
+ copyProperty(to, from, JS('', '#[#]', names, i)); |
} |
-})()'''); |
- |
-defineMemoizedGetter(obj, name, getter) { |
- return defineLazyProperty(obj, name, JS('', '{get: #}', getter)); |
+ return to; |
} |
-copyTheseProperties(to, from, names) => JS( |
- '', |
- '''(() => { |
- for (let i = 0; i < $names.length; ++i) { |
- $copyProperty($to, $from, $names[i]); |
- } |
- return $to; |
-})()'''); |
- |
copyProperty(to, from, name) { |
var desc = getOwnPropertyDescriptor(from, name); |
if (JS('bool', '# == Symbol.iterator', name)) { |