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

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

Issue 1969093002: Miscellaneous runtime fixes. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
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 defineProperty(obj, name, desc) => 10 defineProperty(obj, name, desc) =>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 for (let name of $getOwnNamesAndSymbols($from)) { 86 for (let name of $getOwnNamesAndSymbols($from)) {
87 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name)); 87 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name));
88 } 88 }
89 })()'''); 89 })()''');
90 90
91 defineMemoizedGetter(obj, String name, getter) { 91 defineMemoizedGetter(obj, String name, getter) {
92 return defineLazyProperty(obj, name, JS('', '{get: #}', getter)); 92 return defineLazyProperty(obj, name, JS('', '{get: #}', getter));
93 } 93 }
94 94
95 copyTheseProperties(to, from, names) => JS('', '''(() => { 95 copyTheseProperties(to, from, names) => JS('', '''(() => {
96 for (let name of $names) { 96 for (var i = 0; i < $names.length; ++i) {
Jennifer Messerly 2016/05/11 19:56:26 nit: use `let`
Leaf 2016/05/12 17:00:44 Done.
97 $copyProperty($to, $from, name); 97 $copyProperty($to, $from, $names[i]);
98 } 98 }
99 return $to; 99 return $to;
100 })()'''); 100 })()''');
101 101
102 copyProperty(to, from, name) { 102 copyProperty(to, from, name) {
103 var desc = getOwnPropertyDescriptor(from, name); 103 var desc = getOwnPropertyDescriptor(from, name);
104 if (JS('bool', '# == Symbol.iterator', name)) { 104 if (JS('bool', '# == Symbol.iterator', name)) {
105 // On native types, Symbol.iterator may already be present. 105 // On native types, Symbol.iterator may already be present.
106 // TODO(jmesserly): investigate if we still need this. 106 // TODO(jmesserly): investigate if we still need this.
107 // If so, we need to find a better solution. 107 // If so, we need to find a better solution.
(...skipping 10 matching lines...) Expand all
118 } 118 }
119 119
120 @JSExportName('export') 120 @JSExportName('export')
121 exportProperty(to, from, name) => copyProperty(to, from, name); 121 exportProperty(to, from, name) => copyProperty(to, from, name);
122 122
123 /// Copy properties from source to destination object. 123 /// Copy properties from source to destination object.
124 /// This operation is commonly called `mixin` in JS. 124 /// This operation is commonly called `mixin` in JS.
125 copyProperties(to, from) { 125 copyProperties(to, from) {
126 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); 126 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from));
127 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698