Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Side by Side Diff: lib/compiler/implementation/typechecker.dart

Issue 10834270: Implement call operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Simplify nested loop and add TODO.p Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 if (Elements.isClosureSend(node, elements)) { 424 Element element = elements[node];
425
426 if (Elements.isClosureSend(node, element)) {
425 // TODO(karlklose): Finish implementation. 427 // TODO(karlklose): Finish implementation.
426 return types.dynamicType; 428 return types.dynamicType;
427 } 429 }
428 430
429 Identifier selector = node.selector.asIdentifier(); 431 Identifier selector = node.selector.asIdentifier();
430 String name = selector.source.stringValue; 432 String name = selector.source.stringValue;
431 433
432 if (node.isOperator && name === 'is') { 434 if (node.isOperator && name === 'is') {
433 analyze(node.receiver); 435 analyze(node.receiver);
434 return boolType; 436 return boolType;
(...skipping 22 matching lines...) Expand all
457 } 459 }
458 return boolType; 460 return boolType;
459 } 461 }
460 fail(selector, 'unexpected operator ${name}'); 462 fail(selector, 'unexpected operator ${name}');
461 463
462 } else if (node.isPropertyAccess) { 464 } else if (node.isPropertyAccess) {
463 if (node.receiver !== null) { 465 if (node.receiver !== null) {
464 // TODO(karlklose): we cannot handle fields. 466 // TODO(karlklose): we cannot handle fields.
465 return unhandledExpression(); 467 return unhandledExpression();
466 } 468 }
467 Element element = elements[node];
468 if (element === null) return types.dynamicType; 469 if (element === null) return types.dynamicType;
469 return computeType(element); 470 return computeType(element);
470 471
471 } else if (node.isFunctionObjectInvocation) { 472 } else if (node.isFunctionObjectInvocation) {
472 fail(node.receiver, 'function object invocation unimplemented'); 473 fail(node.receiver, 'function object invocation unimplemented');
473 474
474 } else { 475 } else {
475 FunctionType computeFunType() { 476 FunctionType computeFunType() {
476 if (node.receiver !== null) { 477 if (node.receiver !== null) {
477 Type receiverType = analyze(node.receiver); 478 Type receiverType = analyze(node.receiver);
(...skipping 17 matching lines...) Expand all
495 if (receiverKind !== ElementKind.CLASS) { 496 if (receiverKind !== ElementKind.CLASS) {
496 fail(node.receiver, 'unexpected receiver kind: ${receiverKind}'); 497 fail(node.receiver, 'unexpected receiver kind: ${receiverKind}');
497 } 498 }
498 ClassElement classElement = receiverType.element; 499 ClassElement classElement = receiverType.element;
499 // TODO(karlklose): substitute type arguments. 500 // TODO(karlklose): substitute type arguments.
500 Type memberType = 501 Type memberType =
501 lookupMethodType(selector, classElement, selector.source); 502 lookupMethodType(selector, classElement, selector.source);
502 if (memberType.element === compiler.dynamicClass) return null; 503 if (memberType.element === compiler.dynamicClass) return null;
503 return memberType; 504 return memberType;
504 } else { 505 } 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
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 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | tests/compiler/dart2js/closure_codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698