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

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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 class _LocalMirrorSystemImpl extends MirrorSystem { 77 class _LocalMirrorSystemImpl extends MirrorSystem {
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
87 // ClassMirror protocol, so they should not inherit from the ClassMirror
88 // implementation.
89
90 TypeMirror _dynamicType = null; 86 TypeMirror _dynamicType = null;
91 87
92 TypeMirror get dynamicType { 88 TypeMirror get dynamicType {
93 if (_dynamicType == null) { 89 if (_dynamicType == null) {
94 _dynamicType = 90 _dynamicType = new _SpecialTypeMirrorImpl(_s('dynamic'));
95 new _LocalClassMirrorImpl(
96 null, null, 'dynamic', false, null, null, [], null,
97 const {}, const {}, const {});
98 } 91 }
99 return _dynamicType; 92 return _dynamicType;
100 } 93 }
101 94
102 TypeMirror _voidType = null; 95 TypeMirror _voidType = null;
103 96
104 TypeMirror get voidType { 97 TypeMirror get voidType {
105 if (_voidType == null) { 98 if (_voidType == null) {
106 _voidType = 99 _voidType = new _SpecialTypeMirrorImpl(_s('void'));
107 new _LocalClassMirrorImpl(
108 null, null, 'void', false, null, null, [], null,
109 const {}, const {}, const {});
110 } 100 }
111 return _voidType; 101 return _voidType;
112 } 102 }
113 103
114 final Map<String, FunctionTypeMirror> _functionTypes; 104 final Map<String, FunctionTypeMirror> _functionTypes;
115 FunctionTypeMirror _lookupFunctionTypeMirror( 105 FunctionTypeMirror _lookupFunctionTypeMirror(
116 TypeMirror returnType, 106 TypeMirror returnType,
117 List<ParameterMirror> parameters) { 107 List<ParameterMirror> parameters) {
118 var sigString = _makeSignatureString(returnType, parameters); 108 var sigString = _makeSignatureString(returnType, parameters);
119 var mirror = _functionTypes[sigString]; 109 var mirror = _functionTypes[sigString];
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 throw new UnimplementedError( 1006 throw new UnimplementedError(
1017 'ParameterMirror.defaultValue is not implemented'); 1007 'ParameterMirror.defaultValue is not implemented');
1018 } 1008 }
1019 1009
1020 bool get hasDefaultValue { 1010 bool get hasDefaultValue {
1021 throw new UnimplementedError( 1011 throw new UnimplementedError(
1022 'ParameterMirror.hasDefaultValue is not implemented'); 1012 'ParameterMirror.hasDefaultValue is not implemented');
1023 } 1013 }
1024 } 1014 }
1025 1015
1016 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
1017 implements TypeMirror, DeclarationMirror {
1018 _SpecialTypeMirrorImpl(this.simpleName);
1019
1020 final bool isPrivate = false;
1021 final bool isTopLevel = true;
1022
1023 // Fixed length 0, therefore immutable.
1024 final List<InstanceMirror> metadata = new List(0);
1025
1026 final DeclarationMirror owner = null;
1027 final Symbol simpleName;
1028
1029 SourceLocation get location {
1030 throw new UnimplementedError(
1031 'TypeMirror.location is not implemented');
1032 }
1033
1034 Symbol get qualifiedName {
1035 return simpleName;
1036 }
1037
1038 String toString() => "TypeMirror on '${_n(simpleName)}'";
1039 }
1040
1026 class _Mirrors { 1041 class _Mirrors {
1027 // Does a port refer to our local isolate? 1042 // Does a port refer to our local isolate?
1028 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; 1043 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort';
1029 1044
1030 static MirrorSystem _currentMirrorSystem = null; 1045 static MirrorSystem _currentMirrorSystem = null;
1031 1046
1032 // Creates a new local MirrorSystem. 1047 // Creates a new local MirrorSystem.
1033 static MirrorSystem makeLocalMirrorSystem() 1048 static MirrorSystem makeLocalMirrorSystem()
1034 native 'Mirrors_makeLocalMirrorSystem'; 1049 native 'Mirrors_makeLocalMirrorSystem';
1035 1050
(...skipping 30 matching lines...) Expand all
1066 } 1081 }
1067 1082
1068 // Creates a new local ClassMirror. 1083 // Creates a new local ClassMirror.
1069 static ClassMirror makeLocalClassMirror(Type key) 1084 static ClassMirror makeLocalClassMirror(Type key)
1070 native "Mirrors_makeLocalClassMirror"; 1085 native "Mirrors_makeLocalClassMirror";
1071 1086
1072 static ClassMirror reflectClass(Type key) { 1087 static ClassMirror reflectClass(Type key) {
1073 return makeLocalClassMirror(key); 1088 return makeLocalClassMirror(key);
1074 } 1089 }
1075 } 1090 }
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