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

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 10697003: Various token issues fixed in the compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged Created 8 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
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 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 Element getOutermostEnclosingMemberOrTopLevel() { 198 Element getOutermostEnclosingMemberOrTopLevel() {
199 for (Element e = this; e !== null; e = e.enclosingElement) { 199 for (Element e = this; e !== null; e = e.enclosingElement) {
200 if (e.isMember() || e.isTopLevel()) { 200 if (e.isMember() || e.isTopLevel()) {
201 return e; 201 return e;
202 } 202 }
203 } 203 }
204 return null; 204 return null;
205 } 205 }
206 206
207 toString() { 207 toString() {
208 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an
209 // invariant for all element types.
208 if (!isTopLevel()) { 210 if (!isTopLevel()) {
209 String holderName = enclosingElement.name.slowToString(); 211 String holderName = enclosingElement.name.slowToString();
210 return '$kind($holderName#${name.slowToString()})'; 212 return '$kind($holderName#${name.slowToString()})';
211 } else { 213 } else {
212 return '$kind(${name.slowToString()})'; 214 return '$kind(${name.slowToString()})';
213 } 215 }
214 } 216 }
215 217
216 bool _isNative = false; 218 bool _isNative = false;
217 void setNative() { _isNative = true; } 219 void setNative() { _isNative = true; }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 elements.forEach((SourceString _, Element e) { 354 elements.forEach((SourceString _, Element e) {
353 if (this === e.getLibrary() 355 if (this === e.getLibrary()
354 && e.kind !== ElementKind.PREFIX 356 && e.kind !== ElementKind.PREFIX
355 && e.kind !== ElementKind.FOREIGN) { 357 && e.kind !== ElementKind.FOREIGN) {
356 if (!e.name.isPrivate()) f(e); 358 if (!e.name.isPrivate()) f(e);
357 } 359 }
358 }); 360 });
359 } 361 }
360 362
361 bool hasLibraryName() => libraryTag !== null; 363 bool hasLibraryName() => libraryTag !== null;
364
365 String getLibraryOrScriptName() {
ahe 2012/06/27 10:48:27 What is this method for?
366 if (libraryTag !== null) {
367 return libraryTag.argument.dartString.slowToString();
368 } else {
369 // Use the file name as script name.
370 var path = script.uri.path;
371 return path.substring(path.lastIndexOf('/')+1);
Lasse Reichstein Nielsen 2012/06/27 09:22:16 Spaces around '+'. What is the script name used fo
372 }
373 }
362 } 374 }
363 375
364 class PrefixElement extends Element { 376 class PrefixElement extends Element {
365 Map<SourceString, Element> imported; 377 Map<SourceString, Element> imported;
366 Token firstPosition; 378 Token firstPosition;
367 379
368 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) 380 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition)
369 : imported = new Map<SourceString, Element>(), 381 : imported = new Map<SourceString, Element>(),
370 super(prefix, ElementKind.PREFIX, enclosing); 382 super(prefix, ElementKind.PREFIX, enclosing);
371 383
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 final Node node; 1076 final Node node;
1065 Type bound; 1077 Type bound;
1066 Type type; 1078 Type type;
1067 TypeVariableElement(name, Element enclosing, this.node, this.type, 1079 TypeVariableElement(name, Element enclosing, this.node, this.type,
1068 [this.bound]) 1080 [this.bound])
1069 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1081 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1070 Type computeType(compiler) => type; 1082 Type computeType(compiler) => type;
1071 Node parseNode(compiler) => node; 1083 Node parseNode(compiler) => node;
1072 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1084 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1073 } 1085 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698