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 dart2js.typechecker; | 5 library dart2js.typechecker; |
6 | 6 |
7 import 'common/names.dart' show Identifiers; | 7 import 'common/names.dart' show Identifiers; |
8 import 'common/resolution.dart' show Resolution; | 8 import 'common/resolution.dart' show Resolution; |
9 import 'common/tasks.dart' show CompilerTask; | 9 import 'common/tasks.dart' show CompilerTask; |
10 import 'common.dart'; | 10 import 'common.dart'; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 String get name => "Type checker"; | 53 String get name => "Type checker"; |
54 DiagnosticReporter get reporter => compiler.reporter; | 54 DiagnosticReporter get reporter => compiler.reporter; |
55 | 55 |
56 void check(AstElement element) { | 56 void check(AstElement element) { |
57 if (element.isClass) return; | 57 if (element.isClass) return; |
58 if (element.isTypedef) return; | 58 if (element.isTypedef) return; |
59 ResolvedAst resolvedAst = element.resolvedAst; | 59 ResolvedAst resolvedAst = element.resolvedAst; |
60 reporter.withCurrentElement(element.implementation, () { | 60 reporter.withCurrentElement(element.implementation, () { |
61 measure(() { | 61 measure(() { |
62 TypeCheckerVisitor visitor = new TypeCheckerVisitor( | 62 TypeCheckerVisitor visitor = new TypeCheckerVisitor( |
63 compiler, resolvedAst.elements, compiler.types); | 63 compiler, resolvedAst.elements, compiler.resolution.types); |
64 if (element.isField) { | 64 if (element.isField) { |
65 visitor.analyzingInitializer = true; | 65 visitor.analyzingInitializer = true; |
66 ResolutionDartType type = | 66 ResolutionDartType type = |
67 visitor.analyzeVariableTypeAnnotation(resolvedAst.node); | 67 visitor.analyzeVariableTypeAnnotation(resolvedAst.node); |
68 visitor.analyzeVariableInitializer(element, type, resolvedAst.body); | 68 visitor.analyzeVariableInitializer(element, type, resolvedAst.body); |
69 } else { | 69 } else { |
70 resolvedAst.node.accept(visitor); | 70 resolvedAst.node.accept(visitor); |
71 } | 71 } |
72 }); | 72 }); |
73 }); | 73 }); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool isCallable(Compiler compiler) { | 105 bool isCallable(Compiler compiler) { |
106 if (element != null && element.isAbstractField) { | 106 if (element != null && element.isAbstractField) { |
107 AbstractFieldElement abstractFieldElement = element; | 107 AbstractFieldElement abstractFieldElement = element; |
108 if (abstractFieldElement.getter == null) { | 108 if (abstractFieldElement.getter == null) { |
109 // Setters cannot be invoked as function invocations. | 109 // Setters cannot be invoked as function invocations. |
110 return false; | 110 return false; |
111 } | 111 } |
112 } | 112 } |
113 ResolutionInterfaceType functionType = | 113 ResolutionInterfaceType functionType = |
114 compiler.resolution.commonElements.functionType; | 114 compiler.resolution.commonElements.functionType; |
115 return compiler.types | 115 return compiler.resolution.types |
116 .isAssignable(computeType(compiler.resolution), functionType); | 116 .isAssignable(computeType(compiler.resolution), functionType); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 /// An access of a instance member. | 120 /// An access of a instance member. |
121 class MemberAccess extends ElementAccess { | 121 class MemberAccess extends ElementAccess { |
122 final MemberSignature member; | 122 final MemberSignature member; |
123 | 123 |
124 MemberAccess(MemberSignature this.member); | 124 MemberAccess(MemberSignature this.member); |
125 | 125 |
(...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 | 2055 |
2056 visitTypedef(Typedef node) { | 2056 visitTypedef(Typedef node) { |
2057 // Do not typecheck [Typedef] nodes. | 2057 // Do not typecheck [Typedef] nodes. |
2058 } | 2058 } |
2059 | 2059 |
2060 visitNode(Node node) { | 2060 visitNode(Node node) { |
2061 reporter.internalError(node, | 2061 reporter.internalError(node, |
2062 'Unexpected node ${node.getObjectDescription()} in the type checker.'); | 2062 'Unexpected node ${node.getObjectDescription()} in the type checker.'); |
2063 } | 2063 } |
2064 } | 2064 } |
OLD | NEW |