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

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

Issue 2847893002: fix #27258, don't allow dynamic set of a final field (Closed)
Patch Set: format Created 3 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 })()'''); 78 })()''');
79 79
80 void defineLazy(to, from) => JS( 80 void defineLazy(to, from) => JS(
81 '', 81 '',
82 '''(() => { 82 '''(() => {
83 for (let name of $getOwnNamesAndSymbols($from)) { 83 for (let name of $getOwnNamesAndSymbols($from)) {
84 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name)); 84 $defineLazyProperty($to, name, $getOwnPropertyDescriptor($from, name));
85 } 85 }
86 })()'''); 86 })()''');
87 87
88 defineMemoizedGetter(obj, String name, getter) { 88 defineMemoizedGetter(obj, name, getter) {
89 return defineLazyProperty(obj, name, JS('', '{get: #}', getter)); 89 return defineLazyProperty(obj, name, JS('', '{get: #}', getter));
90 } 90 }
91 91
92 copyTheseProperties(to, from, names) => JS( 92 copyTheseProperties(to, from, names) => JS(
93 '', 93 '',
94 '''(() => { 94 '''(() => {
95 for (let i = 0; i < $names.length; ++i) { 95 for (let i = 0; i < $names.length; ++i) {
96 $copyProperty($to, $from, $names[i]); 96 $copyProperty($to, $from, $names[i]);
97 } 97 }
98 return $to; 98 return $to;
(...skipping 18 matching lines...) Expand all
117 } 117 }
118 118
119 @JSExportName('export') 119 @JSExportName('export')
120 exportProperty(to, from, name) => copyProperty(to, from, name); 120 exportProperty(to, from, name) => copyProperty(to, from, name);
121 121
122 /// Copy properties from source to destination object. 122 /// Copy properties from source to destination object.
123 /// This operation is commonly called `mixin` in JS. 123 /// This operation is commonly called `mixin` in JS.
124 copyProperties(to, from) { 124 copyProperties(to, from) {
125 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); 125 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from));
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698