OLD | NEW |
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 | 4 |
5 var dart, _js_helper; | 5 var dart, _js_helper, _js_primitives; |
6 (function (dart) { | 6 (function (dart) { |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 let defineProperty = Object.defineProperty; | 9 let defineProperty = Object.defineProperty; |
10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
11 let getOwnPropertyNames = Object.getOwnPropertyNames; | 11 let getOwnPropertyNames = Object.getOwnPropertyNames; |
12 let getOwnPropertySymbols = Object.getOwnPropertySymbols; | 12 let getOwnPropertySymbols = Object.getOwnPropertySymbols; |
13 | 13 |
14 function getOwnNamesAndSymbols(obj) { | 14 function getOwnNamesAndSymbols(obj) { |
15 return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); | 15 return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 753 |
754 /** | 754 /** |
755 * Given a class and an initializer method name, creates a constructor | 755 * Given a class and an initializer method name, creates a constructor |
756 * function with the same name. For example `new SomeClass.name(args)`. | 756 * function with the same name. For example `new SomeClass.name(args)`. |
757 */ | 757 */ |
758 function defineNamedConstructor(clazz, name) { | 758 function defineNamedConstructor(clazz, name) { |
759 let proto = clazz.prototype; | 759 let proto = clazz.prototype; |
760 let initMethod = proto[name]; | 760 let initMethod = proto[name]; |
761 let ctor = function() { return initMethod.apply(this, arguments); } | 761 let ctor = function() { return initMethod.apply(this, arguments); } |
762 ctor.prototype = proto; | 762 ctor.prototype = proto; |
763 clazz[name] = ctor; | 763 // Use defineProperty so we don't hit a property defined on Function, |
| 764 // like `caller` and `arguments`. |
| 765 defineProperty(clazz, name, { value: ctor, configurable: true }); |
764 } | 766 } |
765 dart.defineNamedConstructor = defineNamedConstructor; | 767 dart.defineNamedConstructor = defineNamedConstructor; |
766 | 768 |
767 function stackTrace(exception) { | 769 function stackTrace(exception) { |
768 throw new core.UnimplementedError(); | 770 throw new core.UnimplementedError(); |
769 } | 771 } |
770 dart.stackTrace = stackTrace; | 772 dart.stackTrace = stackTrace; |
771 | 773 |
772 /** The Symbol for storing type arguments on a specialized generic type. */ | 774 /** The Symbol for storing type arguments on a specialized generic type. */ |
773 dart.typeArguments = Symbol('typeArguments'); | 775 dart.typeArguments = Symbol('typeArguments'); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 dart.void = { toString() { return 'void'; } }; | 932 dart.void = { toString() { return 'void'; } }; |
931 dart.bottom = { toString() { return 'bottom'; } }; | 933 dart.bottom = { toString() { return 'bottom'; } }; |
932 | 934 |
933 dart.global = window || global; | 935 dart.global = window || global; |
934 dart.JsSymbol = Symbol; | 936 dart.JsSymbol = Symbol; |
935 | 937 |
936 // TODO(jmesserly): hack to bootstrap the SDK | 938 // TODO(jmesserly): hack to bootstrap the SDK |
937 _js_helper = _js_helper || {}; | 939 _js_helper = _js_helper || {}; |
938 _js_helper.checkNum = notNull; | 940 _js_helper.checkNum = notNull; |
939 | 941 |
| 942 _js_primitives = _js_primitives || {}; |
| 943 _js_primitives.printString = (s) => console.log(s); |
| 944 |
940 })(dart || (dart = {})); | 945 })(dart || (dart = {})); |
OLD | NEW |