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

Side by Side Diff: frog/tests/leg/src/TypeCheckerTest.dart

Issue 10091037: Clean up handling of types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove debug code. Created 8 years, 8 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #import("../../../../lib/compiler/implementation/leg.dart"); 5 #import("../../../../lib/compiler/implementation/leg.dart");
6 #import("../../../../lib/compiler/implementation/elements/elements.dart"); 6 #import("../../../../lib/compiler/implementation/elements/elements.dart");
7 #import("../../../../lib/compiler/implementation/tree/tree.dart"); 7 #import("../../../../lib/compiler/implementation/tree/tree.dart");
8 #import('../../../../lib/compiler/implementation/scanner/scannerlib.dart'); 8 #import('../../../../lib/compiler/implementation/scanner/scannerlib.dart');
9 #import("../../../../lib/compiler/implementation/util/util.dart"); 9 #import("../../../../lib/compiler/implementation/util/util.dart");
10 #import("mock_compiler.dart"); 10 #import("mock_compiler.dart");
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 String returnWithType(String type, expression) { 388 String returnWithType(String type, expression) {
389 return "$type foo() { return $expression; }"; 389 return "$type foo() { return $expression; }";
390 } 390 }
391 391
392 Node parseExpression(String text) => 392 Node parseExpression(String text) =>
393 parseBodyCode(text, (parser, token) => parser.parseExpression(token)); 393 parseBodyCode(text, (parser, token) => parser.parseExpression(token));
394 394
395 void setup() { 395 void setup() {
396 compiler = new MockCompiler(); 396 compiler = new MockCompiler();
397 types = compiler.types; 397 types = compiler.types;
398 intType = lookupType(Types.INT, compiler, types); 398 intType = compiler.intClass.computeType(compiler);
399 doubleType = lookupType(Types.DOUBLE, compiler, types); 399 doubleType = compiler.doubleClass.computeType(compiler);
400 boolType = lookupType(Types.BOOL, compiler, types); 400 boolType = compiler.boolClass.computeType(compiler);
401 stringType = lookupType(Types.STRING, compiler, types); 401 stringType = compiler.stringClass.computeType(compiler);
402 objectType = lookupType(Types.OBJECT, compiler, types); 402 objectType = compiler.objectClass.computeType(compiler);
403 } 403 }
404 404
405 Type analyzeType(String text) { 405 Type analyzeType(String text) {
406 var node = parseExpression(text); 406 var node = parseExpression(text);
407 TypeCheckerVisitor visitor = 407 TypeCheckerVisitor visitor =
408 new TypeCheckerVisitor(compiler, new TreeElementMapping(), types); 408 new TypeCheckerVisitor(compiler, new TreeElementMapping(), types);
409 return visitor.analyze(node); 409 return visitor.analyze(node);
410 } 410 }
411 411
412 analyzeTopLevel(String text, [expectedWarnings]) { 412 analyzeTopLevel(String text, [expectedWarnings]) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 parser.parseStatement(tokens); 457 parser.parseStatement(tokens);
458 Node node = listener.popNode(); 458 Node node = listener.popNode();
459 TreeElements elements = compiler.resolveNodeStatement(node, classElement); 459 TreeElements elements = compiler.resolveNodeStatement(node, classElement);
460 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, 460 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
461 types); 461 types);
462 compiler.clearWarnings(); 462 compiler.clearWarnings();
463 checker.currentClass = classElement; 463 checker.currentClass = classElement;
464 checker.analyze(node); 464 checker.analyze(node);
465 compareWarningKinds(text, expectedWarnings, compiler.warnings); 465 compareWarningKinds(text, expectedWarnings, compiler.warnings);
466 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698