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

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

Issue 211243009: Implement MethodMirror.location in the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add to api and fix type warnings Created 6 years, 9 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 | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 import "dart:collection"; 7 import "dart:collection";
8 8
9 final emptyList = new UnmodifiableListView([]); 9 final emptyList = new UnmodifiableListView([]);
10 final emptyMap = new _UnmodifiableMapView({}); 10 final emptyMap = new _UnmodifiableMapView({});
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 TypeMirror get voidType { 135 TypeMirror get voidType {
136 if (_voidType == null) { 136 if (_voidType == null) {
137 _voidType = new _SpecialTypeMirror('void'); 137 _voidType = new _SpecialTypeMirror('void');
138 } 138 }
139 return _voidType; 139 return _voidType;
140 } 140 }
141 141
142 String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; 142 String toString() => "MirrorSystem for isolate '${isolate.debugName}'";
143 } 143 }
144 144
145 class _SourceLocation implements SourceLocation {
146 _SourceLocation(uriString, this.line, this.column)
147 : this.sourceUri = Uri.parse(uriString);
148
149 // Line and column positions are 1-origin, or 0 if unknown.
150 final int line;
151 final int column;
152
153 final Uri sourceUri;
154
155 String toString() {
156 return column == 0 ? "$sourceUri:$line" : "$sourceUri:$line:$column";
157 }
158 }
159
145 abstract class _LocalMirror implements Mirror {} 160 abstract class _LocalMirror implements Mirror {}
146 161
147 class _LocalIsolateMirror extends _LocalMirror implements IsolateMirror { 162 class _LocalIsolateMirror extends _LocalMirror implements IsolateMirror {
148 final String debugName; 163 final String debugName;
149 final LibraryMirror rootLibrary; 164 final LibraryMirror rootLibrary;
150 165
151 _LocalIsolateMirror(this.debugName, this.rootLibrary); 166 _LocalIsolateMirror(this.debugName, this.rootLibrary);
152 167
153 bool get isCurrent => true; 168 bool get isCurrent => true;
154 169
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 203
189 TypeMirror get returnType => _target.type; 204 TypeMirror get returnType => _target.type;
190 List<ParameterMirror> get parameters { 205 List<ParameterMirror> get parameters {
191 if (isGetter) return emptyList; 206 if (isGetter) return emptyList;
192 return new UnmodifiableListView( 207 return new UnmodifiableListView(
193 [new _SyntheticSetterParameter(this, this._target)]); 208 [new _SyntheticSetterParameter(this, this._target)]);
194 } 209 }
195 210
196 List<InstanceMirror> get metadata => emptyList; 211 List<InstanceMirror> get metadata => emptyList;
197 String get source => null; 212 String get source => null;
198 SourceLocation get location => throw new UnimplementedError(); 213 SourceLocation get location => null;
199 } 214 }
200 215
201 class _SyntheticSetterParameter implements ParameterMirror { 216 class _SyntheticSetterParameter implements ParameterMirror {
202 final DeclarationMirror owner; 217 final DeclarationMirror owner;
203 final VariableMirror _target; 218 final VariableMirror _target;
204 219
205 _SyntheticSetterParameter(this.owner, this._target); 220 _SyntheticSetterParameter(this.owner, this._target);
206 221
207 Symbol get simpleName => _target.simpleName; 222 Symbol get simpleName => _target.simpleName;
208 Symbol get qualifiedName => _computeQualifiedName(owner, simpleName); 223 Symbol get qualifiedName => _computeQualifiedName(owner, simpleName);
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 } 1309 }
1295 return _owner; 1310 return _owner;
1296 } 1311 }
1297 1312
1298 bool get isPrivate => _n(simpleName).startsWith('_') || 1313 bool get isPrivate => _n(simpleName).startsWith('_') ||
1299 _n(constructorName).startsWith('_'); 1314 _n(constructorName).startsWith('_');
1300 1315
1301 bool get isTopLevel => owner is LibraryMirror; 1316 bool get isTopLevel => owner is LibraryMirror;
1302 bool get isSynthetic => false; 1317 bool get isSynthetic => false;
1303 1318
1319 SourceLocation _location;
1304 SourceLocation get location { 1320 SourceLocation get location {
1305 throw new UnimplementedError('MethodMirror.location is not implemented'); 1321 if (_location == null) {
1322 _location = _MethodMirror_location(_reflectee);
1323 }
1324 return _location;
1306 } 1325 }
1307 1326
1308 Type get _instantiator { 1327 Type get _instantiator {
1309 var o = owner; 1328 var o = owner;
1310 while (o is MethodMirror) o = o.owner; 1329 while (o is MethodMirror) o = o.owner;
1311 return o._instantiator; 1330 return o._instantiator;
1312 } 1331 }
1313 1332
1314 TypeMirror _returnType = null; 1333 TypeMirror _returnType = null;
1315 TypeMirror get returnType { 1334 TypeMirror get returnType {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 native "MethodMirror_owner"; 1399 native "MethodMirror_owner";
1381 1400
1382 static dynamic _MethodMirror_return_type(reflectee, instantiator) 1401 static dynamic _MethodMirror_return_type(reflectee, instantiator)
1383 native "MethodMirror_return_type"; 1402 native "MethodMirror_return_type";
1384 1403
1385 List<ParameterMirror> _MethodMirror_parameters(reflectee) 1404 List<ParameterMirror> _MethodMirror_parameters(reflectee)
1386 native "MethodMirror_parameters"; 1405 native "MethodMirror_parameters";
1387 1406
1388 static String _MethodMirror_source(reflectee) 1407 static String _MethodMirror_source(reflectee)
1389 native "MethodMirror_source"; 1408 native "MethodMirror_source";
1409
1410 static SourceLocation _MethodMirror_location(reflectee)
1411 native "MethodMirror_location";
1390 } 1412 }
1391 1413
1392 class _LocalVariableMirror extends _LocalDeclarationMirror 1414 class _LocalVariableMirror extends _LocalDeclarationMirror
1393 implements VariableMirror { 1415 implements VariableMirror {
1394 final DeclarationMirror owner; 1416 final DeclarationMirror owner;
1395 final bool isStatic; 1417 final bool isStatic;
1396 final bool isFinal; 1418 final bool isFinal;
1397 final bool isConst; 1419 final bool isConst;
1398 1420
1399 _LocalVariableMirror(reflectee, 1421 _LocalVariableMirror(reflectee,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 if (typeMirror == null) { 1618 if (typeMirror == null) {
1597 typeMirror = makeLocalTypeMirror(key); 1619 typeMirror = makeLocalTypeMirror(key);
1598 _instanitationCache[key] = typeMirror; 1620 _instanitationCache[key] = typeMirror;
1599 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1621 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1600 _declarationCache[key] = typeMirror; 1622 _declarationCache[key] = typeMirror;
1601 } 1623 }
1602 } 1624 }
1603 return typeMirror; 1625 return typeMirror;
1604 } 1626 }
1605 } 1627 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698