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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 /// For each class, stores the possible class subtype tests that could succeed. | 7 /// For each class, stores the possible class subtype tests that could succeed. |
8 abstract class TypeChecks { | 8 abstract class TypeChecks { |
9 /// Get the set of checks required for class [element]. | 9 /// Get the set of checks required for class [element]. |
10 Iterable<TypeCheck> operator[](ClassElement element); | 10 Iterable<TypeCheck> operator[](ClassElement element); |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 } | 596 } |
597 | 597 |
598 static int getTypeVariableIndex(TypeVariableElement variable) { | 598 static int getTypeVariableIndex(TypeVariableElement variable) { |
599 ClassElement classElement = variable.getEnclosingClass(); | 599 ClassElement classElement = variable.getEnclosingClass(); |
600 Link<DartType> variables = classElement.typeVariables; | 600 Link<DartType> variables = classElement.typeVariables; |
601 for (int index = 0; !variables.isEmpty; | 601 for (int index = 0; !variables.isEmpty; |
602 index++, variables = variables.tail) { | 602 index++, variables = variables.tail) { |
603 if (variables.head.element == variable) return index; | 603 if (variables.head.element == variable) return index; |
604 } | 604 } |
605 } | 605 } |
| 606 |
| 607 /// Return all classes that are referenced in the type of the function, i.e., |
| 608 /// in the return type or the argument types. |
| 609 Set<ClassElement> getReferencedClasses(FunctionType type) { |
| 610 FunctionArgumentCollector collector = |
| 611 new FunctionArgumentCollector(backend); |
| 612 collector.collect(type); |
| 613 return collector.classes; |
| 614 } |
606 } | 615 } |
607 | 616 |
608 class TypeRepresentationGenerator extends DartTypeVisitor { | 617 class TypeRepresentationGenerator extends DartTypeVisitor { |
609 final Compiler compiler; | 618 final Compiler compiler; |
610 OnVariableCallback onVariable; | 619 OnVariableCallback onVariable; |
611 | 620 |
612 JavaScriptBackend get backend => compiler.backend; | 621 JavaScriptBackend get backend => compiler.backend; |
613 Namer get namer => backend.namer; | 622 Namer get namer => backend.namer; |
614 | 623 |
615 TypeRepresentationGenerator(Compiler this.compiler); | 624 TypeRepresentationGenerator(Compiler this.compiler); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 * substition for this check. | 885 * substition for this check. |
877 */ | 886 */ |
878 class TypeCheck { | 887 class TypeCheck { |
879 final ClassElement cls; | 888 final ClassElement cls; |
880 final Substitution substitution; | 889 final Substitution substitution; |
881 final int hashCode = (nextHash++) & 0x3fffffff; | 890 final int hashCode = (nextHash++) & 0x3fffffff; |
882 static int nextHash = 49; | 891 static int nextHash = 49; |
883 | 892 |
884 TypeCheck(this.cls, this.substitution); | 893 TypeCheck(this.cls, this.substitution); |
885 } | 894 } |
OLD | NEW |