| 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 class TypeCheckerTask extends CompilerTask { | 5 class TypeCheckerTask extends CompilerTask { |
| 6 TypeCheckerTask(Compiler compiler) : super(compiler); | 6 TypeCheckerTask(Compiler compiler) : super(compiler); |
| 7 String get name() => "Type checker"; | 7 String get name() => "Type checker"; |
| 8 | 8 |
| 9 static final bool LOG_FAILURES = false; | 9 static final bool LOG_FAILURES = false; |
| 10 | 10 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 Type visitFunctionDeclaration(FunctionDeclaration node) { | 388 Type visitFunctionDeclaration(FunctionDeclaration node) { |
| 389 analyze(node.function); | 389 analyze(node.function); |
| 390 return StatementType.NOT_RETURNING; | 390 return StatementType.NOT_RETURNING; |
| 391 } | 391 } |
| 392 | 392 |
| 393 Type visitFunctionExpression(FunctionExpression node) { | 393 Type visitFunctionExpression(FunctionExpression node) { |
| 394 Type type; | 394 Type type; |
| 395 Type returnType; | 395 Type returnType; |
| 396 Type previousType; | 396 Type previousType; |
| 397 final FunctionElement element = elements[node]; | 397 final FunctionElement element = elements[node]; |
| 398 if (Element.isInvalid(element)) return types.dynamicType; |
| 398 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR || | 399 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR || |
| 399 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { | 400 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
| 400 type = types.dynamicType; | 401 type = types.dynamicType; |
| 401 returnType = types.voidType; | 402 returnType = types.voidType; |
| 402 } else { | 403 } else { |
| 403 FunctionType functionType = computeType(element); | 404 FunctionType functionType = computeType(element); |
| 404 returnType = functionType.returnType; | 405 returnType = functionType.returnType; |
| 405 type = functionType; | 406 type = functionType; |
| 406 } | 407 } |
| 407 Type previous = expectedReturnType; | 408 Type previous = expectedReturnType; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 } | 701 } |
| 701 return StatementType.RETURNING; | 702 return StatementType.RETURNING; |
| 702 } | 703 } |
| 703 | 704 |
| 704 Type visitThrow(Throw node) { | 705 Type visitThrow(Throw node) { |
| 705 if (node.expression !== null) analyze(node.expression); | 706 if (node.expression !== null) analyze(node.expression); |
| 706 return StatementType.RETURNING; | 707 return StatementType.RETURNING; |
| 707 } | 708 } |
| 708 | 709 |
| 709 Type computeType(Element element) { | 710 Type computeType(Element element) { |
| 710 if (element === null) return types.dynamicType; | 711 if (Element.isInvalid(element)) return types.dynamicType; |
| 711 Type result = element.computeType(compiler); | 712 Type result = element.computeType(compiler); |
| 712 return (result !== null) ? result : types.dynamicType; | 713 return (result !== null) ? result : types.dynamicType; |
| 713 } | 714 } |
| 714 | 715 |
| 715 Type visitTypeAnnotation(TypeAnnotation node) { | 716 Type visitTypeAnnotation(TypeAnnotation node) { |
| 716 return elements.getType(node); | 717 return elements.getType(node); |
| 717 } | 718 } |
| 718 | 719 |
| 719 visitTypeVariable(TypeVariable node) { | 720 visitTypeVariable(TypeVariable node) { |
| 720 return types.dynamicType; | 721 return types.dynamicType; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 } | 842 } |
| 842 | 843 |
| 843 visitCatchBlock(CatchBlock node) { | 844 visitCatchBlock(CatchBlock node) { |
| 844 return unhandledStatement(); | 845 return unhandledStatement(); |
| 845 } | 846 } |
| 846 | 847 |
| 847 visitTypedef(Typedef node) { | 848 visitTypedef(Typedef node) { |
| 848 return unhandledStatement(); | 849 return unhandledStatement(); |
| 849 } | 850 } |
| 850 } | 851 } |
| OLD | NEW |