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

Side by Side Diff: tool/input_sdk/private/ddc_runtime/utils.dart

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « tool/input_sdk/private/ddc_runtime/runtime.dart ('k') | tool/node_test.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 part of dart._runtime; 4 part of dart._runtime;
5 5
6 /// This library defines a set of general javascript utilities for us 6 /// This library defines a set of general javascript utilities for us
7 /// by the Dart runtime. 7 /// by the Dart runtime.
8 // TODO(ochafik): Rewrite some of these in Dart when possible. 8 // TODO(ochafik): Rewrite some of these in Dart when possible.
9 9
10 final defineProperty = JS('', 'Object.defineProperty'); 10 final defineProperty = JS('', 'Object.defineProperty');
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void defineLazy(to, from) => JS('', '''(() => { 76 void defineLazy(to, from) => JS('', '''(() => {
77 for (let name of $getOwnNamesAndSymbols($from)) { 77 for (let name of $getOwnNamesAndSymbols($from)) {
78 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name)); 78 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name));
79 } 79 }
80 })()'''); 80 })()''');
81 81
82 defineMemoizedGetter(obj, String name, getter) => JS('', '''(() => { 82 defineMemoizedGetter(obj, String name, getter) => JS('', '''(() => {
83 return $defineLazyProperty($obj, $name, {get: $getter}); 83 return $defineLazyProperty($obj, $name, {get: $getter});
84 })()'''); 84 })()''');
85 85
86
87 // TODO(jmesserly): don't stomp on native Symbol.iterator.
88 // We need to find a better solution for this.
89 // See: https://github.com/dart-lang/dev_compiler/issues/487
86 copyTheseProperties(to, from, names) => JS('', '''(() => { 90 copyTheseProperties(to, from, names) => JS('', '''(() => {
87 for (let name of $names) { 91 for (let name of $names) {
88 var desc = $getOwnPropertyDescriptor($from, name); 92 let desc = $getOwnPropertyDescriptor($from, name);
89 if (desc != void 0) { 93 if (desc != void 0) {
94 if (name == Symbol.iterator) {
95 // On native types, Symbol.iterator may already be present.
96 let existing = $getOwnPropertyDescriptor($to, name);
97 if (existing != null) {
98 if (existing.writable) $to[Symbol.iterator] = desc.value;
99 continue;
100 }
101 }
90 $defineProperty($to, name, desc); 102 $defineProperty($to, name, desc);
91 } else { 103 } else {
92 $defineLazyProperty($to, name, () => $from[name]); 104 $defineLazyProperty($to, name, () => $from[name]);
93 } 105 }
94 } 106 }
95 return $to; 107 return $to;
96 })()'''); 108 })()''');
97 109
98 /// Copy properties from source to destination object. 110 /// Copy properties from source to destination object.
99 /// This operation is commonly called `mixin` in JS. 111 /// This operation is commonly called `mixin` in JS.
100 copyProperties(to, from) => JS('', '''(() => { 112 copyProperties(to, from) => JS('', '''(() => {
101 return $copyTheseProperties($to, $from, $getOwnNamesAndSymbols($from)); 113 return $copyTheseProperties($to, $from, $getOwnNamesAndSymbols($from));
102 })()'''); 114 })()''');
103
104 /// Exports from one Dart module to another.
105 @JSExportName('export')
106 export_(to, from, show, hide) => JS('', '''(() => {
107 if ($show == void 0 || $show.length == 0) {
108 $show = $getOwnNamesAndSymbols($from);
109 }
110 if ($hide != void 0) {
111 var hideMap = new Set($hide);
112 $show = $show.filter((k) => !hideMap.has(k));
113 }
114 return $copyTheseProperties($to, $from, $show);
115 })()''');
OLDNEW
« no previous file with comments | « tool/input_sdk/private/ddc_runtime/runtime.dart ('k') | tool/node_test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698