| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (!arguments.isEmpty()) { | 414 if (!arguments.isEmpty()) { |
| 415 reportTypeWarning(arguments.head, MessageKind.ADDITIONAL_ARGUMENT); | 415 reportTypeWarning(arguments.head, MessageKind.ADDITIONAL_ARGUMENT); |
| 416 } else if (!parameterTypes.isEmpty()) { | 416 } else if (!parameterTypes.isEmpty()) { |
| 417 reportTypeWarning(send, MessageKind.MISSING_ARGUMENT, | 417 reportTypeWarning(send, MessageKind.MISSING_ARGUMENT, |
| 418 [parameterTypes.head]); | 418 [parameterTypes.head]); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 Type visitSend(Send node) { | 423 Type visitSend(Send node) { |
| 424 Element element = elements[node]; | 424 if (Elements.isClosureSend(node, elements)) { |
| 425 | |
| 426 if (Elements.isClosureSend(node, element)) { | |
| 427 // TODO(karlklose): Finish implementation. | 425 // TODO(karlklose): Finish implementation. |
| 428 return types.dynamicType; | 426 return types.dynamicType; |
| 429 } | 427 } |
| 430 | 428 |
| 431 Identifier selector = node.selector.asIdentifier(); | 429 Identifier selector = node.selector.asIdentifier(); |
| 432 String name = selector.source.stringValue; | 430 String name = selector.source.stringValue; |
| 433 | 431 |
| 434 if (node.isOperator && name === 'is') { | 432 if (node.isOperator && name === 'is') { |
| 435 analyze(node.receiver); | 433 analyze(node.receiver); |
| 436 return boolType; | 434 return boolType; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 459 } | 457 } |
| 460 return boolType; | 458 return boolType; |
| 461 } | 459 } |
| 462 fail(selector, 'unexpected operator ${name}'); | 460 fail(selector, 'unexpected operator ${name}'); |
| 463 | 461 |
| 464 } else if (node.isPropertyAccess) { | 462 } else if (node.isPropertyAccess) { |
| 465 if (node.receiver !== null) { | 463 if (node.receiver !== null) { |
| 466 // TODO(karlklose): we cannot handle fields. | 464 // TODO(karlklose): we cannot handle fields. |
| 467 return unhandledExpression(); | 465 return unhandledExpression(); |
| 468 } | 466 } |
| 467 Element element = elements[node]; |
| 469 if (element === null) return types.dynamicType; | 468 if (element === null) return types.dynamicType; |
| 470 return computeType(element); | 469 return computeType(element); |
| 471 | 470 |
| 472 } else if (node.isFunctionObjectInvocation) { | 471 } else if (node.isFunctionObjectInvocation) { |
| 473 fail(node.receiver, 'function object invocation unimplemented'); | 472 fail(node.receiver, 'function object invocation unimplemented'); |
| 474 | 473 |
| 475 } else { | 474 } else { |
| 476 FunctionType computeFunType() { | 475 FunctionType computeFunType() { |
| 477 if (node.receiver !== null) { | 476 if (node.receiver !== null) { |
| 478 Type receiverType = analyze(node.receiver); | 477 Type receiverType = analyze(node.receiver); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 496 if (receiverKind !== ElementKind.CLASS) { | 495 if (receiverKind !== ElementKind.CLASS) { |
| 497 fail(node.receiver, 'unexpected receiver kind: ${receiverKind}'); | 496 fail(node.receiver, 'unexpected receiver kind: ${receiverKind}'); |
| 498 } | 497 } |
| 499 ClassElement classElement = receiverType.element; | 498 ClassElement classElement = receiverType.element; |
| 500 // TODO(karlklose): substitute type arguments. | 499 // TODO(karlklose): substitute type arguments. |
| 501 Type memberType = | 500 Type memberType = |
| 502 lookupMethodType(selector, classElement, selector.source); | 501 lookupMethodType(selector, classElement, selector.source); |
| 503 if (memberType.element === compiler.dynamicClass) return null; | 502 if (memberType.element === compiler.dynamicClass) return null; |
| 504 return memberType; | 503 return memberType; |
| 505 } else { | 504 } else { |
| 505 Element element = elements[node]; |
| 506 if (element === null) { | 506 if (element === null) { |
| 507 fail(node, 'unresolved ${node.selector}'); | 507 fail(node, 'unresolved ${node.selector}'); |
| 508 } else if (element.kind === ElementKind.FUNCTION) { | 508 } else if (element.kind === ElementKind.FUNCTION) { |
| 509 return computeType(element); | 509 return computeType(element); |
| 510 } else if (element.kind === ElementKind.FOREIGN) { | 510 } else if (element.kind === ElementKind.FOREIGN) { |
| 511 return null; | 511 return null; |
| 512 } else if (element.kind === ElementKind.VARIABLE | 512 } else if (element.kind === ElementKind.VARIABLE |
| 513 || element.kind === ElementKind.FIELD) { | 513 || element.kind === ElementKind.FIELD) { |
| 514 // TODO(karlklose): handle object invocations. | 514 // TODO(karlklose): handle object invocations. |
| 515 return null; | 515 return null; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 } | 774 } |
| 775 | 775 |
| 776 visitCatchBlock(CatchBlock node) { | 776 visitCatchBlock(CatchBlock node) { |
| 777 return unhandledStatement(); | 777 return unhandledStatement(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 visitTypedef(Typedef node) { | 780 visitTypedef(Typedef node) { |
| 781 return unhandledStatement(); | 781 return unhandledStatement(); |
| 782 } | 782 } |
| 783 } | 783 } |
| OLD | NEW |