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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_mirrors.dart

Issue 767643002: dart2js: Make usage of names more consistent between compiler and runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix long lines. Created 6 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart._js_mirrors; 5 library dart._js_mirrors;
6 6
7 import 'shared/runtime_data.dart' as encoding; 7 import 'shared/runtime_data.dart' as encoding;
8 import 'shared/embedded_names.dart' show 8 import 'shared/embedded_names.dart' show
9 ALL_CLASSES, 9 ALL_CLASSES,
10 LAZIES, 10 LAZIES,
11 LIBRARIES, 11 LIBRARIES,
12 STATICS, 12 STATICS,
13 TYPE_INFORMATION; 13 TYPE_INFORMATION;
14 14
15 import 'dart:collection' show 15 import 'dart:collection' show
16 UnmodifiableListView, 16 UnmodifiableListView,
17 UnmodifiableMapView; 17 UnmodifiableMapView;
18 18
19 import 'dart:mirrors'; 19 import 'dart:mirrors';
20 20
21 import 'dart:_foreign_helper' show 21 import 'dart:_foreign_helper' show
22 JS, 22 JS,
23 JS_CURRENT_ISOLATE, 23 JS_CURRENT_ISOLATE,
24 JS_CURRENT_ISOLATE_CONTEXT, 24 JS_CURRENT_ISOLATE_CONTEXT,
25 JS_EMBEDDED_GLOBAL, 25 JS_EMBEDDED_GLOBAL,
26 JS_GET_NAME; 26 JS_GET_NAME,
27 JS_TYPEDEF_TAG,
karlklose 2014/11/28 10:19:00 I think we should use JS_GET_NAME instead of havin
floitsch 2014/11/28 10:40:16 Added TODOs in the builder.
28 JS_FUNCTION_TYPE_TAG,
29 JS_FUNCTION_TYPE_RETURN_TYPE_TAG,
30 JS_FUNCTION_TYPE_VOID_RETURN_TAG,
31 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG,
32 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG,
33 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG;
34
27 35
28 import 'dart:_internal' as _symbol_dev; 36 import 'dart:_internal' as _symbol_dev;
29 37
30 import 'dart:_js_helper' show 38 import 'dart:_js_helper' show
31 BoundClosure, 39 BoundClosure,
32 CachedInvocation, 40 CachedInvocation,
33 Closure, 41 Closure,
34 JSInvocationMirror, 42 JSInvocationMirror,
35 JsCache, 43 JsCache,
36 Null, 44 Null,
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 class JsFunctionTypeMirror extends BrokenClassMirror 2603 class JsFunctionTypeMirror extends BrokenClassMirror
2596 implements FunctionTypeMirror { 2604 implements FunctionTypeMirror {
2597 final _typeData; 2605 final _typeData;
2598 String _cachedToString; 2606 String _cachedToString;
2599 TypeMirror _cachedReturnType; 2607 TypeMirror _cachedReturnType;
2600 UnmodifiableListView<ParameterMirror> _cachedParameters; 2608 UnmodifiableListView<ParameterMirror> _cachedParameters;
2601 DeclarationMirror owner; 2609 DeclarationMirror owner;
2602 2610
2603 JsFunctionTypeMirror(this._typeData, this.owner); 2611 JsFunctionTypeMirror(this._typeData, this.owner);
2604 2612
2605 bool get _hasReturnType => JS('bool', '"ret" in #', _typeData); 2613 bool get _hasReturnType {
2606 get _returnType => JS('', '#.ret', _typeData); 2614 return JS('bool', '# in #', JS_FUNCTION_TYPE_RETURN_TYPE_TAG(), _typeData);
2615 }
2616 get _returnType {
2617 return JS('', '#[#]', _typeData, JS_FUNCTION_TYPE_RETURN_TYPE_TAG());
2618 }
2607 2619
2608 bool get _isVoid => JS('bool', '!!#.void', _typeData); 2620 bool get _isVoid {
2621 return JS('bool', '!!#[#]', _typeData, JS_FUNCTION_TYPE_VOID_RETURN_TAG());
2622 }
2609 2623
2610 bool get _hasArguments => JS('bool', '"args" in #', _typeData); 2624 bool get _hasArguments {
2611 List get _arguments => JS('JSExtendableArray', '#.args', _typeData); 2625 return JS('bool', '# in #',
2626 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG(), _typeData);
2627 }
2628 List get _arguments {
2629 return JS('JSExtendableArray', '#[#]',
2630 _typeData, JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG());
2631 }
2612 2632
2613 bool get _hasOptionalArguments => JS('bool', '"opt" in #', _typeData); 2633 bool get _hasOptionalArguments {
2614 List get _optionalArguments => JS('JSExtendableArray', '#.opt', _typeData); 2634 return JS('bool', '# in #',
2635 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG(), _typeData);
2636 }
2637 List get _optionalArguments {
2638 return JS('JSExtendableArray', '#[#]',
2639 _typeData, JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG());
2640 }
2615 2641
2616 bool get _hasNamedArguments => JS('bool', '"named" in #', _typeData); 2642 bool get _hasNamedArguments {
2617 get _namedArguments => JS('=Object', '#.named', _typeData); 2643 return JS('bool', '# in #',
2644 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG(), _typeData);
2645 }
2646 get _namedArguments {
2647 return JS('=Object', '#[#]',
2648 _typeData, JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG());
2649 }
2650
2618 bool get isOriginalDeclaration => true; 2651 bool get isOriginalDeclaration => true;
2619 2652
2620 bool get isAbstract => false; 2653 bool get isAbstract => false;
2621 2654
2622 TypeMirror get returnType { 2655 TypeMirror get returnType {
2623 if (_cachedReturnType != null) return _cachedReturnType; 2656 if (_cachedReturnType != null) return _cachedReturnType;
2624 if (_isVoid) return _cachedReturnType = JsMirrorSystem._voidType; 2657 if (_isVoid) return _cachedReturnType = JsMirrorSystem._voidType;
2625 if (!_hasReturnType) return _cachedReturnType = JsMirrorSystem._dynamicType; 2658 if (!_hasReturnType) return _cachedReturnType = JsMirrorSystem._dynamicType;
2626 return _cachedReturnType = 2659 return _cachedReturnType =
2627 typeMirrorFromRuntimeTypeRepresentation(owner, _returnType); 2660 typeMirrorFromRuntimeTypeRepresentation(owner, _returnType);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 } 2825 }
2793 return typeArgument._mangledName; 2826 return typeArgument._mangledName;
2794 } 2827 }
2795 representation = 2828 representation =
2796 runtimeTypeToString(type, onTypeVariable: substituteTypeVariable); 2829 runtimeTypeToString(type, onTypeVariable: substituteTypeVariable);
2797 } 2830 }
2798 if (representation != null) { 2831 if (representation != null) {
2799 return reflectClassByMangledName( 2832 return reflectClassByMangledName(
2800 getMangledTypeName(createRuntimeType(representation))); 2833 getMangledTypeName(createRuntimeType(representation)));
2801 } 2834 }
2802 if (type != null && JS('', '#.typedef', type) != null) { 2835 String typedefPropertyName = JS_TYPEDEF_TAG();
2836 String functionTagPropertyName = JS_FUNCTION_TYPE_TAG();
2837 if (type != null && JS('', '#[#]', type, typedefPropertyName) != null) {
2803 return typeMirrorFromRuntimeTypeRepresentation( 2838 return typeMirrorFromRuntimeTypeRepresentation(
2804 owner, JS('', '#.typedef', type)); 2839 owner, JS('', '#[#]', type, typedefPropertyName));
2805 } else if (type != null && JS('', '#.func', type) != null) { 2840 } else if (type != null &&
2841 JS('', '#[#]', type, functionTagPropertyName) != null) {
2806 return new JsFunctionTypeMirror(type, owner); 2842 return new JsFunctionTypeMirror(type, owner);
2807 } 2843 }
2808 return reflectClass(Function); 2844 return reflectClass(Function);
2809 } 2845 }
2810 2846
2811 Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { 2847 Symbol computeQualifiedName(DeclarationMirror owner, Symbol simpleName) {
2812 if (owner == null) return simpleName; 2848 if (owner == null) return simpleName;
2813 String ownerName = n(owner.qualifiedName); 2849 String ownerName = n(owner.qualifiedName);
2814 return s('$ownerName.${n(simpleName)}'); 2850 return s('$ownerName.${n(simpleName)}');
2815 } 2851 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 // have a part (following a '.') that starts with '_'. 3014 // have a part (following a '.') that starts with '_'.
2979 const int UNDERSCORE = 0x5f; 3015 const int UNDERSCORE = 0x5f;
2980 if (name.isEmpty) return true; 3016 if (name.isEmpty) return true;
2981 int index = -1; 3017 int index = -1;
2982 do { 3018 do {
2983 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; 3019 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false;
2984 index = name.indexOf('.', index + 1); 3020 index = name.indexOf('.', index + 1);
2985 } while (index >= 0 && index + 1 < name.length); 3021 } while (index >= 0 && index + 1 < name.length);
2986 return true; 3022 return true;
2987 } 3023 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698