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

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

Issue 2859703003: fix #29544, mixins to a class with named constructors (Closed)
Patch Set: fix to use safeGetOwnProperty 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 22 matching lines...) Expand all
33 if (_trapRuntimeErrors) JS('', 'debugger'); 33 if (_trapRuntimeErrors) JS('', 'debugger');
34 JS('', 'throw Error(#)', message); 34 JS('', 'throw Error(#)', message);
35 } 35 }
36 36
37 getOwnNamesAndSymbols(obj) { 37 getOwnNamesAndSymbols(obj) {
38 var names = getOwnPropertyNames(obj); 38 var names = getOwnPropertyNames(obj);
39 var symbols = getOwnPropertySymbols(obj); 39 var symbols = getOwnPropertySymbols(obj);
40 return JS('', '#.concat(#)', names, symbols); 40 return JS('', '#.concat(#)', names, symbols);
41 } 41 }
42 42
43 safeGetOwnProperty(obj, String name) { 43 safeGetOwnProperty(obj, name) {
44 var desc = getOwnPropertyDescriptor(obj, name); 44 var desc = getOwnPropertyDescriptor(obj, name);
45 if (desc != null) return JS('', '#.value', desc); 45 if (desc != null) return JS('', '#.value', desc);
46 } 46 }
47 47
48 /// Defines a lazy property. 48 /// Defines a lazy property.
49 /// After initial get or set, it will replace itself with a value property. 49 /// After initial get or set, it will replace itself with a value property.
50 // TODO(jmesserly): reusing descriptor objects has been shown to improve 50 // TODO(jmesserly): reusing descriptor objects has been shown to improve
51 // performance in other projects (e.g. webcomponents.js ShadowDOM polyfill). 51 // performance in other projects (e.g. webcomponents.js ShadowDOM polyfill).
52 defineLazyProperty(to, name, desc) => JS( 52 defineLazyProperty(to, name, desc) => JS(
53 '', 53 '',
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/rtti.dart ('k') | tests/language_strong/mixin_named_constructor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698