| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'dart:collection' show LinkedHashMap; | 7 import 'dart:collection' show LinkedHashMap; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| 11 import '../tree/tree.dart'; | 11 import '../tree/tree.dart'; |
| 12 import '../util/util.dart'; | 12 import '../util/util.dart'; |
| 13 import '../resolution/resolution.dart'; | 13 import '../resolution/resolution.dart'; |
| 14 | 14 |
| 15 import '../dart2jslib.dart' show invariant, | 15 import '../dart2jslib.dart' show invariant, |
| 16 InterfaceType, | 16 InterfaceType, |
| 17 DartType, | 17 DartType, |
| 18 TypeVariableType, | 18 TypeVariableType, |
| 19 TypedefType, | 19 TypedefType, |
| 20 DualKind, |
| 20 MessageKind, | 21 MessageKind, |
| 21 DiagnosticListener, | 22 DiagnosticListener, |
| 22 Script, | 23 Script, |
| 23 FunctionType, | 24 FunctionType, |
| 24 SourceString, | 25 SourceString, |
| 25 Selector, | 26 Selector, |
| 26 Constant, | 27 Constant, |
| 27 Compiler; | 28 Compiler; |
| 28 | 29 |
| 29 import '../dart_types.dart'; | 30 import '../dart_types.dart'; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 * An ambiguous element represents multiple elements accessible by the same name
. | 356 * An ambiguous element represents multiple elements accessible by the same name
. |
| 356 * | 357 * |
| 357 * Ambiguous elements are created during handling of import/export scopes. If an | 358 * Ambiguous elements are created during handling of import/export scopes. If an |
| 358 * ambiguous element is encountered during resolution a warning/error should be | 359 * ambiguous element is encountered during resolution a warning/error should be |
| 359 * reported. | 360 * reported. |
| 360 */ | 361 */ |
| 361 class AmbiguousElementX extends ElementX implements AmbiguousElement { | 362 class AmbiguousElementX extends ElementX implements AmbiguousElement { |
| 362 /** | 363 /** |
| 363 * The message to report on resolving this element. | 364 * The message to report on resolving this element. |
| 364 */ | 365 */ |
| 365 final MessageKind messageKind; | 366 final DualKind messageKind; |
| 366 | 367 |
| 367 /** | 368 /** |
| 368 * The message arguments to report on resolving this element. | 369 * The message arguments to report on resolving this element. |
| 369 */ | 370 */ |
| 370 final Map messageArguments; | 371 final Map messageArguments; |
| 371 | 372 |
| 372 /** | 373 /** |
| 373 * The first element that this ambiguous element might refer to. | 374 * The first element that this ambiguous element might refer to. |
| 374 */ | 375 */ |
| 375 final Element existingElement; | 376 final Element existingElement; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 return contents[name]; | 429 return contents[name]; |
| 429 } | 430 } |
| 430 | 431 |
| 431 void add(Element element, DiagnosticListener listener) { | 432 void add(Element element, DiagnosticListener listener) { |
| 432 SourceString name = element.name; | 433 SourceString name = element.name; |
| 433 if (element.isAccessor()) { | 434 if (element.isAccessor()) { |
| 434 addAccessor(element, contents[name], listener); | 435 addAccessor(element, contents[name], listener); |
| 435 } else { | 436 } else { |
| 436 Element existing = contents.putIfAbsent(name, () => element); | 437 Element existing = contents.putIfAbsent(name, () => element); |
| 437 if (!identical(existing, element)) { | 438 if (!identical(existing, element)) { |
| 438 listener.reportErrorCode(element, | 439 listener.reportError( |
| 439 MessageKind.DUPLICATE_DEFINITION, {'name': name}); | 440 element, MessageKind.DUPLICATE_DEFINITION, {'name': name}); |
| 440 listener.reportMessage( | 441 listener.reportMessage( |
| 441 listener.spanFromSpannable(existing), | 442 listener.spanFromSpannable(existing), |
| 442 MessageKind.EXISTING_DEFINITION.error({'name': name}), | 443 MessageKind.EXISTING_DEFINITION.error({'name': name}), |
| 443 api.Diagnostic.INFO); | 444 api.Diagnostic.INFO); |
| 444 } | 445 } |
| 445 } | 446 } |
| 446 } | 447 } |
| 447 | 448 |
| 448 /** | 449 /** |
| 449 * Adds a definition for an [accessor] (getter or setter) to a scope. | 450 * Adds a definition for an [accessor] (getter or setter) to a scope. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 void setPartOf(PartOf tag, DiagnosticListener listener) { | 533 void setPartOf(PartOf tag, DiagnosticListener listener) { |
| 533 LibraryElementX library = enclosingElement; | 534 LibraryElementX library = enclosingElement; |
| 534 if (library.entryCompilationUnit == this) { | 535 if (library.entryCompilationUnit == this) { |
| 535 listener.reportMessage( | 536 listener.reportMessage( |
| 536 listener.spanFromSpannable(tag), | 537 listener.spanFromSpannable(tag), |
| 537 MessageKind.ILLEGAL_DIRECTIVE.error(), | 538 MessageKind.ILLEGAL_DIRECTIVE.error(), |
| 538 api.Diagnostic.WARNING); | 539 api.Diagnostic.WARNING); |
| 539 return; | 540 return; |
| 540 } | 541 } |
| 541 if (!localMembers.isEmpty) { | 542 if (!localMembers.isEmpty) { |
| 542 listener.reportErrorCode(tag, MessageKind.BEFORE_TOP_LEVEL); | 543 listener.reportError(tag, MessageKind.BEFORE_TOP_LEVEL); |
| 543 return; | 544 return; |
| 544 } | 545 } |
| 545 if (partTag != null) { | 546 if (partTag != null) { |
| 546 listener.reportMessage( | 547 listener.reportMessage( |
| 547 listener.spanFromSpannable(tag), | 548 listener.spanFromSpannable(tag), |
| 548 MessageKind.DUPLICATED_PART_OF.error(), | 549 MessageKind.DUPLICATED_PART_OF.error(), |
| 549 api.Diagnostic.WARNING); | 550 api.Diagnostic.WARNING); |
| 550 return; | 551 return; |
| 551 } | 552 } |
| 552 partTag = tag; | 553 partTag = tag; |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 super(constructor.name, | 1371 super(constructor.name, |
| 1371 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, | 1372 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, |
| 1372 Modifiers.EMPTY, | 1373 Modifiers.EMPTY, |
| 1373 constructor.enclosingElement) { | 1374 constructor.enclosingElement) { |
| 1374 functionSignature = constructor.functionSignature; | 1375 functionSignature = constructor.functionSignature; |
| 1375 } | 1376 } |
| 1376 | 1377 |
| 1377 bool isInstanceMember() => true; | 1378 bool isInstanceMember() => true; |
| 1378 | 1379 |
| 1379 FunctionType computeType(Compiler compiler) { | 1380 FunctionType computeType(Compiler compiler) { |
| 1380 compiler.reportFatalError('Internal error: $this.computeType', this); | 1381 compiler.internalErrorOnElement(this, '$this.computeType.'); |
| 1381 } | 1382 } |
| 1382 | 1383 |
| 1383 Node parseNode(DiagnosticListener listener) { | 1384 Node parseNode(DiagnosticListener listener) { |
| 1384 if (cachedNode != null) return cachedNode; | 1385 if (cachedNode != null) return cachedNode; |
| 1385 cachedNode = constructor.parseNode(listener); | 1386 cachedNode = constructor.parseNode(listener); |
| 1386 assert(cachedNode != null); | 1387 assert(cachedNode != null); |
| 1387 return cachedNode; | 1388 return cachedNode; |
| 1388 } | 1389 } |
| 1389 | 1390 |
| 1390 Token position() => constructor.position(); | 1391 Token position() => constructor.position(); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 | 2181 |
| 2181 MetadataAnnotation ensureResolved(Compiler compiler) { | 2182 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2182 if (resolutionState == STATE_NOT_STARTED) { | 2183 if (resolutionState == STATE_NOT_STARTED) { |
| 2183 compiler.resolver.resolveMetadataAnnotation(this); | 2184 compiler.resolver.resolveMetadataAnnotation(this); |
| 2184 } | 2185 } |
| 2185 return this; | 2186 return this; |
| 2186 } | 2187 } |
| 2187 | 2188 |
| 2188 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2189 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2189 } | 2190 } |
| OLD | NEW |