| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_printer_test; | 5 library dart_printer_test; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'package:compiler/implementation/constants/values.dart'; | 8 import 'package:compiler/implementation/constants/values.dart'; |
| 9 import 'package:compiler/implementation/dart_backend/backend_ast_nodes.dart'; | 9 import 'package:compiler/implementation/dart_backend/backend_ast_nodes.dart'; |
| 10 import 'package:compiler/implementation/scanner/scannerlib.dart'; | 10 import 'package:compiler/implementation/scanner/scannerlib.dart'; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } else { | 410 } else { |
| 411 // No optional parameters. | 411 // No optional parameters. |
| 412 List<Parameter> required = popList(count-1, <Parameter>[], asParameter); | 412 List<Parameter> required = popList(count-1, <Parameter>[], asParameter); |
| 413 required.add(last); | 413 required.add(last); |
| 414 push(new Parameters(required)); | 414 push(new Parameters(required)); |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 handleNoFormalParameters(tok) { | 417 handleNoFormalParameters(tok) { |
| 418 push(new Parameters([])); | 418 push(new Parameters([])); |
| 419 } | 419 } |
| 420 endUnamedFunction(t) { | 420 |
| 421 endUnnamedFunction(t) { |
| 421 Statement body = pop(); | 422 Statement body = pop(); |
| 422 Parameters parameters = pop(); | 423 Parameters parameters = pop(); |
| 423 push(new FunctionExpression(parameters, body)); | 424 push(new FunctionExpression(parameters, body)); |
| 424 } | 425 } |
| 426 |
| 425 handleNoType(Token token) { | 427 handleNoType(Token token) { |
| 426 push(null); | 428 push(null); |
| 427 } | 429 } |
| 428 | 430 |
| 429 endReturnStatement(bool hasExpression, begin, end) { | 431 endReturnStatement(bool hasExpression, begin, end) { |
| 430 // This is also called for functions whose body is "=> expression" | 432 // This is also called for functions whose body is "=> expression" |
| 431 if (hasExpression) { | 433 if (hasExpression) { |
| 432 push(new Return(pop())); | 434 push(new Return(pop())); |
| 433 } else { | 435 } else { |
| 434 push(new Return()); | 436 push(new Return()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 ExpressionStatement condition = pop(); // parsed as expression statement | 567 ExpressionStatement condition = pop(); // parsed as expression statement |
| 566 Expression exp = condition == null ? null : condition.expression; | 568 Expression exp = condition == null ? null : condition.expression; |
| 567 Node initializer = pop(); | 569 Node initializer = pop(); |
| 568 push(new For(initializer, exp, updates, body)); | 570 push(new For(initializer, exp, updates, body)); |
| 569 } | 571 } |
| 570 | 572 |
| 571 handleNoExpression(Token token) { | 573 handleNoExpression(Token token) { |
| 572 push(null); | 574 push(null); |
| 573 } | 575 } |
| 574 | 576 |
| 575 endForIn(Token begin, Token inKeyword, Token end) { | 577 endForIn(Token await, Token begin, Token inKeyword, Token end) { |
| 576 Statement body = pop(); | 578 Statement body = pop(); |
| 577 Expression exp = pop(); | 579 Expression exp = pop(); |
| 578 Node declaredIdentifier = pop(); | 580 Node declaredIdentifier = pop(); |
| 579 push(new ForIn(declaredIdentifier, exp, body)); | 581 push(new ForIn(declaredIdentifier, exp, body)); |
| 580 } | 582 } |
| 581 | 583 |
| 582 handleAssertStatement(Token assertKeyword, Token semicolonToken) { | 584 handleAssertStatement(Token assertKeyword, Token semicolonToken) { |
| 583 Expression exp = pop(); | 585 Expression exp = pop(); |
| 584 Expression call = new CallFunction(new Identifier("assert"), [exp]); | 586 Expression call = new CallFunction(new Identifier("assert"), [exp]); |
| 585 push(new ExpressionStatement(call)); | 587 push(new ExpressionStatement(call)); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 checkStatement("do while(x); while (y);"); | 968 checkStatement("do while(x); while (y);"); |
| 967 checkStatement("{do; while(x); while (y);}"); | 969 checkStatement("{do; while(x); while (y);}"); |
| 968 | 970 |
| 969 checkStatement('switch(x) { case 1: case 2: return y; }'); | 971 checkStatement('switch(x) { case 1: case 2: return y; }'); |
| 970 checkStatement('switch(x) { default: return y; }'); | 972 checkStatement('switch(x) { default: return y; }'); |
| 971 checkStatement('switch(x) { case 1: x=y; default: return y; }'); | 973 checkStatement('switch(x) { case 1: x=y; default: return y; }'); |
| 972 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); | 974 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); |
| 973 | 975 |
| 974 } | 976 } |
| 975 | 977 |
| OLD | NEW |