| 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 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
| 10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 CompilationUnitOverrideElement(CompilationUnitElement compilationUnit, | 393 CompilationUnitOverrideElement(CompilationUnitElement compilationUnit, |
| 394 Element enclosing) | 394 Element enclosing) |
| 395 : this.compilationUnit = compilationUnit, | 395 : this.compilationUnit = compilationUnit, |
| 396 super(compilationUnit.name, | 396 super(compilationUnit.name, |
| 397 ElementKind.COMPILATION_UNIT_OVERRIDE, | 397 ElementKind.COMPILATION_UNIT_OVERRIDE, |
| 398 enclosing); | 398 enclosing); |
| 399 } | 399 } |
| 400 | 400 |
| 401 class LibraryElement extends ScopeContainerElement { | 401 class LibraryElement extends ScopeContainerElement { |
| 402 final Uri uri; |
| 402 CompilationUnitElement entryCompilationUnit; | 403 CompilationUnitElement entryCompilationUnit; |
| 403 Link<CompilationUnitElement> compilationUnits = | 404 Link<CompilationUnitElement> compilationUnits = |
| 404 const EmptyLink<CompilationUnitElement>(); | 405 const EmptyLink<CompilationUnitElement>(); |
| 405 | |
| 406 Link<ScriptTag> tags = const EmptyLink<ScriptTag>(); | 406 Link<ScriptTag> tags = const EmptyLink<ScriptTag>(); |
| 407 ScriptTag libraryTag; | 407 ScriptTag libraryTag; |
| 408 bool canUseNative = false; | 408 bool canUseNative = false; |
| 409 LibraryElement patch = null; | 409 LibraryElement patch = null; |
| 410 | 410 |
| 411 LibraryElement(Script script) | 411 LibraryElement(Script script, [Uri uri]) |
| 412 : super(new SourceString(script.name), ElementKind.LIBRARY, null) { | 412 : this.uri = ((uri === null) ? script.uri : uri), |
| 413 super(new SourceString(script.name), ElementKind.LIBRARY, null) { |
| 413 entryCompilationUnit = new CompilationUnitElement(script, this); | 414 entryCompilationUnit = new CompilationUnitElement(script, this); |
| 414 } | 415 } |
| 415 | 416 |
| 416 Uri get uri() => entryCompilationUnit.script.uri; | |
| 417 | 417 |
| 418 bool get isPatched() => patch !== null; | 418 bool get isPatched() => patch !== null; |
| 419 | 419 |
| 420 void addCompilationUnit(CompilationUnitElement element) { | 420 void addCompilationUnit(CompilationUnitElement element) { |
| 421 compilationUnits = compilationUnits.prepend(element); | 421 compilationUnits = compilationUnits.prepend(element); |
| 422 } | 422 } |
| 423 | 423 |
| 424 void addTag(ScriptTag tag, DiagnosticListener listener) { | 424 void addTag(ScriptTag tag, DiagnosticListener listener) { |
| 425 tags = tags.prepend(tag); | 425 tags = tags.prepend(tag); |
| 426 } | 426 } |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 assert(state <= STATE_DONE); | 1020 assert(state <= STATE_DONE); |
| 1021 _resolutionState = state; | 1021 _resolutionState = state; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 // backendMembers are members that have been added by the backend to simplify | 1024 // backendMembers are members that have been added by the backend to simplify |
| 1025 // compilation. They don't have any user-side counter-part. | 1025 // compilation. They don't have any user-side counter-part. |
| 1026 Link<Element> backendMembers = const EmptyLink<Element>(); | 1026 Link<Element> backendMembers = const EmptyLink<Element>(); |
| 1027 | 1027 |
| 1028 Link<Type> allSupertypes; | 1028 Link<Type> allSupertypes; |
| 1029 | 1029 |
| 1030 // Lazily applied patch of class members. |
| 1031 ClassElement patch = null; |
| 1032 |
| 1030 ClassElement(SourceString name, Element enclosing, this.id) | 1033 ClassElement(SourceString name, Element enclosing, this.id) |
| 1031 : super(name, ElementKind.CLASS, enclosing); | 1034 : super(name, ElementKind.CLASS, enclosing); |
| 1032 | 1035 |
| 1033 InterfaceType computeType(compiler) { | 1036 InterfaceType computeType(compiler) { |
| 1034 if (type == null) { | 1037 if (type == null) { |
| 1035 ClassNode node = parseNode(compiler); | 1038 ClassNode node = parseNode(compiler); |
| 1036 Link<Type> parameters = | 1039 Link<Type> parameters = |
| 1037 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 1040 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
| 1038 type = new InterfaceType(this, parameters); | 1041 type = new InterfaceType(this, parameters); |
| 1039 } | 1042 } |
| 1040 return type; | 1043 return type; |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1046 bool get isPatched() => patch != null; |
| 1047 |
| 1043 Link<Type> get typeVariables() => type.arguments; | 1048 Link<Type> get typeVariables() => type.arguments; |
| 1044 | 1049 |
| 1045 ClassElement ensureResolved(Compiler compiler) { | 1050 ClassElement ensureResolved(Compiler compiler) { |
| 1046 if (resolutionState == STATE_NOT_STARTED) { | 1051 if (resolutionState == STATE_NOT_STARTED) { |
| 1047 compiler.resolver.resolveClass(this); | 1052 compiler.resolver.resolveClass(this); |
| 1048 } | 1053 } |
| 1049 return this; | 1054 return this; |
| 1050 } | 1055 } |
| 1051 | 1056 |
| 1052 /** | 1057 /** |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 Node parseNode(compiler) => cachedNode; | 1456 Node parseNode(compiler) => cachedNode; |
| 1452 | 1457 |
| 1453 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1458 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1454 | 1459 |
| 1455 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1460 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1456 TypeVariableElement result = | 1461 TypeVariableElement result = |
| 1457 new TypeVariableElement(name, enclosing, node, type, bound); | 1462 new TypeVariableElement(name, enclosing, node, type, bound); |
| 1458 return result; | 1463 return result; |
| 1459 } | 1464 } |
| 1460 } | 1465 } |
| OLD | NEW |