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

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

Issue 2962263002: fix #30030, fix #27327 - fix tearoffs and various Object member bugs (Closed)
Patch Set: fix Created 3 years, 5 months 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/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)) {

Powered by Google App Engine
This is Rietveld 408576698