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

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 18343005: Implement dynamicType and voidType as TypeMirrors not ClassMirrors. Issue 11743. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // VM-specific implementation of the dart:mirrors library. 5 // VM-specific implementation of the dart:mirrors library.
6 6
7 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Change parameter back to "this.libraries" when native code is changed. 78 // Change parameter back to "this.libraries" when native code is changed.
79 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate) 79 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate)
80 : this.libraries = _createLibrariesMap(libraries), 80 : this.libraries = _createLibrariesMap(libraries),
81 _functionTypes = new Map<String, FunctionTypeMirror>(); 81 _functionTypes = new Map<String, FunctionTypeMirror>();
82 82
83 final Map<Uri, LibraryMirror> libraries; 83 final Map<Uri, LibraryMirror> libraries;
84 final IsolateMirror isolate; 84 final IsolateMirror isolate;
85 85
86 // TODO(11743): dynamicType and voidType should not respond to the 86 // TODO(11743): dynamicType and voidType should not respond to the
87 // ClassMirror protocol, so they should not inherit from the ClassMirror 87 // ClassMirror protocol, so they should not inherit from the ClassMirror
88 // implementation. 88 // implementation.
siva 2013/07/15 05:47:11 The TODO(11743) can go right?
89 89
90 TypeMirror _dynamicType = null; 90 TypeMirror _dynamicType = null;
91 91
92 TypeMirror get dynamicType { 92 TypeMirror get dynamicType {
93 if (_dynamicType == null) { 93 if (_dynamicType == null) {
94 _dynamicType = 94 _dynamicType = new _SpecialTypeMirrorImpl(_s('dynamic'));
95 new _LocalClassMirrorImpl(
96 null, null, 'dynamic', false, null, null, [], null,
97 const {}, const {}, const {});
98 } 95 }
99 return _dynamicType; 96 return _dynamicType;
100 } 97 }
101 98
102 TypeMirror _voidType = null; 99 TypeMirror _voidType = null;
103 100
104 TypeMirror get voidType { 101 TypeMirror get voidType {
105 if (_voidType == null) { 102 if (_voidType == null) {
106 _voidType = 103 _voidType = new _SpecialTypeMirrorImpl(_s('void'));
107 new _LocalClassMirrorImpl(
108 null, null, 'void', false, null, null, [], null,
109 const {}, const {}, const {});
110 } 104 }
111 return _voidType; 105 return _voidType;
112 } 106 }
113 107
114 final Map<String, FunctionTypeMirror> _functionTypes; 108 final Map<String, FunctionTypeMirror> _functionTypes;
115 FunctionTypeMirror _lookupFunctionTypeMirror( 109 FunctionTypeMirror _lookupFunctionTypeMirror(
116 TypeMirror returnType, 110 TypeMirror returnType,
117 List<ParameterMirror> parameters) { 111 List<ParameterMirror> parameters) {
118 var sigString = _makeSignatureString(returnType, parameters); 112 var sigString = _makeSignatureString(returnType, parameters);
119 var mirror = _functionTypes[sigString]; 113 var mirror = _functionTypes[sigString];
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 throw new UnimplementedError( 1010 throw new UnimplementedError(
1017 'ParameterMirror.defaultValue is not implemented'); 1011 'ParameterMirror.defaultValue is not implemented');
1018 } 1012 }
1019 1013
1020 bool get hasDefaultValue { 1014 bool get hasDefaultValue {
1021 throw new UnimplementedError( 1015 throw new UnimplementedError(
1022 'ParameterMirror.hasDefaultValue is not implemented'); 1016 'ParameterMirror.hasDefaultValue is not implemented');
1023 } 1017 }
1024 } 1018 }
1025 1019
1020 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
1021 implements TypeMirror, DeclarationMirror {
1022 _SpecialTypeMirrorImpl(this.simpleName);
1023
1024 final bool isPrivate = false;
1025 final bool isTopLevel = true;
1026 final List<InstanceMirror> metadata = new List(0); // Fixed length 0, therefo re immutable.
siva 2013/07/15 05:47:11 Does the comment line fit in 80 chars?
1027 final DeclarationMirror owner = null;
1028 final Symbol simpleName;
1029
1030 SourceLocation get location {
1031 throw new UnimplementedError(
1032 'TypeMirror.location is not implemented');
1033 }
1034
1035 Symbol get qualifiedName {
1036 return simpleName;
1037 }
1038
1039 String toString() => "TypeMirror on '${_n(simpleName)}'";
1040 }
1041
1026 class _Mirrors { 1042 class _Mirrors {
1027 // Does a port refer to our local isolate? 1043 // Does a port refer to our local isolate?
1028 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; 1044 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort';
1029 1045
1030 static MirrorSystem _currentMirrorSystem = null; 1046 static MirrorSystem _currentMirrorSystem = null;
1031 1047
1032 // Creates a new local MirrorSystem. 1048 // Creates a new local MirrorSystem.
1033 static MirrorSystem makeLocalMirrorSystem() 1049 static MirrorSystem makeLocalMirrorSystem()
1034 native 'Mirrors_makeLocalMirrorSystem'; 1050 native 'Mirrors_makeLocalMirrorSystem';
1035 1051
(...skipping 30 matching lines...) Expand all
1066 } 1082 }
1067 1083
1068 // Creates a new local ClassMirror. 1084 // Creates a new local ClassMirror.
1069 static ClassMirror makeLocalClassMirror(Type key) 1085 static ClassMirror makeLocalClassMirror(Type key)
1070 native "Mirrors_makeLocalClassMirror"; 1086 native "Mirrors_makeLocalClassMirror";
1071 1087
1072 static ClassMirror reflectClass(Type key) { 1088 static ClassMirror reflectClass(Type key) {
1073 return makeLocalClassMirror(key); 1089 return makeLocalClassMirror(key);
1074 } 1090 }
1075 } 1091 }
OLDNEW
« no previous file with comments | « no previous file | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698