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

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

Issue 2934623003: fix #29753, use ES5 constructors for ddc (Closed)
Patch Set: rebase Created 3 years, 6 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) =>
11 JS('', 'Object.defineProperty(#, #, #)', obj, name, desc); 11 JS('', 'Object.defineProperty(#, #, #)', obj, name, desc);
12 12
13 defineValue(obj, name, value) {
14 defineProperty(obj, name,
15 JS('', '{ value: #, configurable: true, writable: true }', value));
16 return value;
17 }
18
13 getOwnPropertyDescriptor(obj, name) => 19 getOwnPropertyDescriptor(obj, name) =>
14 JS('', 'Object.getOwnPropertyDescriptor(#, #)', obj, name); 20 JS('', 'Object.getOwnPropertyDescriptor(#, #)', obj, name);
15 21
16 Iterable getOwnPropertyNames(obj) => 22 Iterable getOwnPropertyNames(obj) =>
17 JS('', 'Object.getOwnPropertyNames(#)', obj); 23 JS('', 'Object.getOwnPropertyNames(#)', obj);
18 24
19 Iterable getOwnPropertySymbols(obj) => 25 Iterable getOwnPropertySymbols(obj) =>
20 JS('', 'Object.getOwnPropertySymbols(#)', obj); 26 JS('', 'Object.getOwnPropertySymbols(#)', obj);
21 27
22 final hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty'); 28 final hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty');
23 29
24 /// This error indicates a strong mode specific failure, other than a type 30 /// This error indicates a strong mode specific failure, other than a type
25 /// assertion failure (TypeError) or CastError. 31 /// assertion failure (TypeError) or CastError.
26 void throwStrongModeError(String message) { 32 void throwStrongModeError(String message) {
27 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger'); 33 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
28 JS('', 'throw new #(#);', StrongModeErrorImplementation, message); 34 throw new StrongModeErrorImplementation(message);
29 } 35 }
30 36
31 /// This error indicates a bug in the runtime or the compiler. 37 /// This error indicates a bug in the runtime or the compiler.
32 void throwInternalError(String message) { 38 void throwInternalError(String message) {
33 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger'); 39 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
34 JS('', 'throw Error(#)', message); 40 JS('', 'throw Error(#)', message);
35 } 41 }
36 42
37 getOwnNamesAndSymbols(obj) { 43 getOwnNamesAndSymbols(obj) {
38 var names = getOwnPropertyNames(obj); 44 var names = getOwnPropertyNames(obj);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 123 }
118 124
119 @JSExportName('export') 125 @JSExportName('export')
120 exportProperty(to, from, name) => copyProperty(to, from, name); 126 exportProperty(to, from, name) => copyProperty(to, from, name);
121 127
122 /// Copy properties from source to destination object. 128 /// Copy properties from source to destination object.
123 /// This operation is commonly called `mixin` in JS. 129 /// This operation is commonly called `mixin` in JS.
124 copyProperties(to, from) { 130 copyProperties(to, from) {
125 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); 131 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from));
126 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698