| OLD | NEW |
| 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 'dart:uri'; | 7 import 'dart:uri'; |
| 8 | 8 |
| 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 import '../../compiler.dart' as api_e; | 10 import '../../compiler.dart' as api_e; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 * Accessing any field or calling any method defined on [ErroneousElement] | 372 * Accessing any field or calling any method defined on [ErroneousElement] |
| 373 * except [isErroneous] will currently throw an exception. (This might | 373 * except [isErroneous] will currently throw an exception. (This might |
| 374 * change when we actually want more information on the erroneous element, | 374 * change when we actually want more information on the erroneous element, |
| 375 * e.g., the name of the element we were trying to resolve.) | 375 * e.g., the name of the element we were trying to resolve.) |
| 376 * | 376 * |
| 377 * Code that cannot not handle an [ErroneousElement] should use | 377 * Code that cannot not handle an [ErroneousElement] should use |
| 378 * [: Element.isInvalid(element) :] | 378 * [: Element.isInvalid(element) :] |
| 379 * to check for unresolvable elements instead of | 379 * to check for unresolvable elements instead of |
| 380 * [: element == null :]. | 380 * [: element == null :]. |
| 381 */ | 381 */ |
| 382 class ErroneousElement extends Element { | 382 class ErroneousElement extends Element implements FunctionElement { |
| 383 final MessageKind messageKind; | 383 final MessageKind messageKind; |
| 384 final List messageArguments; | 384 final List messageArguments; |
| 385 final SourceString targetName; | |
| 386 | 385 |
| 387 ErroneousElement(this.messageKind, this.messageArguments, | 386 ErroneousElement(this.messageKind, this.messageArguments, |
| 388 this.targetName, Element enclosing) | 387 SourceString name, Element enclosing) |
| 389 : super(const SourceString('erroneous element'), | 388 : super(name, ElementKind.ERROR, enclosing); |
| 390 ElementKind.ERROR, enclosing); | |
| 391 | 389 |
| 392 isErroneous() => true; | 390 isErroneous() => true; |
| 393 | 391 |
| 394 unsupported() { | 392 unsupported() { |
| 395 throw 'unsupported operation on erroneous element'; | 393 throw 'unsupported operation on erroneous element'; |
| 396 } | 394 } |
| 397 | 395 |
| 398 SourceString get name => unsupported(); | |
| 399 Link<MetadataAnnotation> get metadata => unsupported(); | 396 Link<MetadataAnnotation> get metadata => unsupported(); |
| 400 | |
| 401 getLibrary() => enclosingElement.getLibrary(); | |
| 402 | |
| 403 String toString() { | |
| 404 String n = targetName.slowToString(); | |
| 405 return '<$n: ${messageKind.message(messageArguments)}>'; | |
| 406 } | |
| 407 } | |
| 408 | |
| 409 class ErroneousFunctionElement extends ErroneousElement | |
| 410 implements FunctionElement { | |
| 411 ErroneousFunctionElement(MessageKind messageKind, List messageArguments, | |
| 412 SourceString targetName, Element enclosing) | |
| 413 : super(messageKind, messageArguments, targetName, enclosing); | |
| 414 | |
| 415 get type => unsupported(); | 397 get type => unsupported(); |
| 416 get cachedNode => unsupported(); | 398 get cachedNode => unsupported(); |
| 417 get functionSignature => unsupported(); | 399 get functionSignature => unsupported(); |
| 418 get patch => unsupported(); | 400 get patch => unsupported(); |
| 419 get origin => unsupported(); | 401 get origin => unsupported(); |
| 420 get defaultImplementation => unsupported(); | 402 get defaultImplementation => unsupported(); |
| 421 bool get isPatched => unsupported(); | 403 bool get isPatched => unsupported(); |
| 422 bool get isPatch => unsupported(); | 404 bool get isPatch => unsupported(); |
| 423 setPatch(patch) => unsupported(); | 405 setPatch(patch) => unsupported(); |
| 424 computeSignature(compiler) => unsupported(); | 406 computeSignature(compiler) => unsupported(); |
| 425 requiredParameterCount(compiler) => unsupported(); | 407 requiredParameterCount(compiler) => unsupported(); |
| 426 optionalParameterCount(compiler) => unsupported(); | 408 optionalParameterCount(compiler) => unsupported(); |
| 427 parameterCount(copmiler) => unsupported(); | 409 parameterCount(copmiler) => unsupported(); |
| 428 | 410 |
| 429 get redirectionTarget => this; | 411 get redirectionTarget => this; |
| 412 |
| 413 getLibrary() => enclosingElement.getLibrary(); |
| 414 |
| 415 String toString() { |
| 416 String n = name.slowToString(); |
| 417 return '<$n: ${messageKind.message(messageArguments)}>'; |
| 418 } |
| 430 } | 419 } |
| 431 | 420 |
| 432 /** | 421 /** |
| 433 * An ambiguous element represent multiple elements accessible by the same name. | 422 * An ambiguous element represent multiple elements accessible by the same name. |
| 434 * | 423 * |
| 435 * Ambiguous elements are created during handling of import/export scopes. If an | 424 * Ambiguous elements are created during handling of import/export scopes. If an |
| 436 * ambiguous element is encountered during resolution a warning/error should be | 425 * ambiguous element is encountered during resolution a warning/error should be |
| 437 * reported. | 426 * reported. |
| 438 */ | 427 */ |
| 439 class AmbiguousElement extends Element { | 428 class AmbiguousElement extends Element { |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 | 2009 |
| 2021 MetadataAnnotation ensureResolved(Compiler compiler) { | 2010 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2022 if (resolutionState == STATE_NOT_STARTED) { | 2011 if (resolutionState == STATE_NOT_STARTED) { |
| 2023 compiler.resolver.resolveMetadataAnnotation(this); | 2012 compiler.resolver.resolveMetadataAnnotation(this); |
| 2024 } | 2013 } |
| 2025 return this; | 2014 return this; |
| 2026 } | 2015 } |
| 2027 | 2016 |
| 2028 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2017 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2029 } | 2018 } |
| OLD | NEW |