| OLD | NEW |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 1 library dart_printer_test; | 5 library dart_printer_test; |
| 2 | 6 |
| 3 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 4 import '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_pri
nter.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_pri
nter.dart'; |
| 5 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; | 9 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; |
| 6 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'; | 11 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart' show
DartString; | 12 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart' show
DartString; |
| 9 import 'dart:mirrors'; | 13 import 'dart:mirrors'; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart' as tr
ee; | 14 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart' as tr
ee; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 print(errorCode); | 82 print(errorCode); |
| 79 } | 83 } |
| 80 | 84 |
| 81 withCurrentElement(element, f()) { | 85 withCurrentElement(element, f()) { |
| 82 f(); | 86 f(); |
| 83 } | 87 } |
| 84 } | 88 } |
| 85 | 89 |
| 86 class AstBuilder extends Listener { | 90 class AstBuilder extends Listener { |
| 87 final List stack = []; | 91 final List stack = []; |
| 88 final StringValidator stringValidator | 92 final StringValidator stringValidator |
| 89 = new StringValidator(new PrintDiagnosticListener()); | 93 = new StringValidator(new PrintDiagnosticListener()); |
| 90 | 94 |
| 91 String asName(e) { | 95 String asName(e) { |
| 92 if (e is Identifier) | 96 if (e is Identifier) |
| 93 return e.name; | 97 return e.name; |
| 94 else if (e == null) | 98 else if (e == null) |
| 95 return null; | 99 return null; |
| 96 else | 100 else |
| 97 throw 'Expression is not a name: ${e.runtimeType}'; | 101 throw 'Expression is not a name: ${e.runtimeType}'; |
| 98 } | 102 } |
| 99 | 103 |
| 100 TypeAnnotation asType(x) { | 104 TypeAnnotation asType(x) { |
| 101 if (x is TypeAnnotation) | 105 if (x is TypeAnnotation) |
| 102 return x; | 106 return x; |
| 103 if (x is Identifier) | 107 if (x is Identifier) |
| 104 return new TypeAnnotation(x.name); | 108 return new TypeAnnotation(x.name); |
| 105 if (x == null) | 109 if (x == null) |
| 106 return null; | 110 return null; |
| 107 else | 111 else |
| 108 throw "Not a type: ${x.runtimeType}"; | 112 throw "Not a type: ${x.runtimeType}"; |
| 109 } | 113 } |
| 110 | 114 |
| 111 Parameter asParameter(x) { | 115 Parameter asParameter(x) { |
| 112 if (x is Parameter) | 116 if (x is Parameter) |
| 113 return x; | 117 return x; |
| 114 if (x is Identifier) | 118 if (x is Identifier) |
| 115 return new Parameter(x.name); | 119 return new Parameter(x.name); |
| 116 else | 120 else |
| 117 throw "Not a parameter: ${x.runtimeType}"; | 121 throw "Not a parameter: ${x.runtimeType}"; |
| 118 } | 122 } |
| 119 | 123 |
| 120 void push(node) { | 124 void push(node) { |
| 121 stack.add(node); | 125 stack.add(node); |
| 122 } | 126 } |
| 123 dynamic peek() { | 127 dynamic peek() { |
| 124 return stack.last; | 128 return stack.last; |
| 125 } | 129 } |
| 126 dynamic pop([coerce(x) = null]) { | 130 dynamic pop([coerce(x) = null]) { |
| 127 var x = stack.removeLast(); | 131 var x = stack.removeLast(); |
| 128 if (coerce != null) | 132 if (coerce != null) |
| 129 return coerce(x); | 133 return coerce(x); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 stack.removeRange(stack.length-count, stack.length); | 147 stack.removeRange(stack.length-count, stack.length); |
| 144 return result; | 148 return result; |
| 145 } | 149 } |
| 146 popTypeAnnotation() { | 150 popTypeAnnotation() { |
| 147 List<TypeAnnotation> args = pop(); | 151 List<TypeAnnotation> args = pop(); |
| 148 if (args == null) | 152 if (args == null) |
| 149 return null; | 153 return null; |
| 150 String name = pop(asName); | 154 String name = pop(asName); |
| 151 return new TypeAnnotation(name, args); | 155 return new TypeAnnotation(name, args); |
| 152 } | 156 } |
| 153 | 157 |
| 154 // EXPRESSIONS | 158 // EXPRESSIONS |
| 155 endCascade() { | 159 endCascade() { |
| 156 throw "Cascade not supported yet"; | 160 throw "Cascade not supported yet"; |
| 157 } | 161 } |
| 158 endIdentifierList(int count) { | 162 endIdentifierList(int count) { |
| 159 push(popList(count, <Identifier>[])); | 163 push(popList(count, <Identifier>[])); |
| 160 } | 164 } |
| 161 endTypeList(int count) { | 165 endTypeList(int count) { |
| 162 push(popList(count, <TypeAnnotation>[], asType)); | 166 push(popList(count, <TypeAnnotation>[], asType)); |
| 163 } | 167 } |
| 164 beginLiteralString(Token token) { | 168 beginLiteralString(Token token) { |
| 165 String source = token.value; | 169 String source = token.value; |
| 166 tree.StringQuoting quoting = StringValidator.quotingFromString(source); | 170 tree.StringQuoting quoting = StringValidator.quotingFromString(source); |
| 167 push(quoting); | 171 push(quoting); |
| 168 push(token); // collect token at the end | 172 push(token); // collect token at the end |
| 169 } | 173 } |
| 170 handleStringPart(Token token) { | 174 handleStringPart(Token token) { |
| 171 push(token); // collect token at the end | 175 push(token); // collect token at the end |
| 172 } | 176 } |
| 173 endLiteralString(int interpCount) { | 177 endLiteralString(int interpCount) { |
| 174 List parts = popList(2 * interpCount + 1, []); | 178 List parts = popList(2 * interpCount + 1, []); |
| 175 tree.StringQuoting quoting = pop(); | 179 tree.StringQuoting quoting = pop(); |
| 176 List<Expression> members = <Expression>[]; | 180 List<Expression> members = <Expression>[]; |
| 177 for (var i=0; i<parts.length; i++) { | 181 for (var i=0; i<parts.length; i++) { |
| 178 var part = parts[i]; | 182 var part = parts[i]; |
| 179 if (part is Expression) { | 183 if (part is Expression) { |
| 180 members.add(part); | 184 members.add(part); |
| 181 } else { | 185 } else { |
| 182 assert(part is Token); | 186 assert(part is Token); |
| 183 DartString str = stringValidator.validateInterpolationPart( | 187 DartString str = stringValidator.validateInterpolationPart( |
| 184 part as Token, | 188 part as Token, |
| 185 quoting, | 189 quoting, |
| 186 isFirst: i == 0, | 190 isFirst: i == 0, |
| 187 isLast: i == parts.length - 1); | 191 isLast: i == parts.length - 1); |
| 188 members.add(new Literal(new StringConstant(str))); | 192 members.add(new Literal(new StringConstant(str))); |
| 189 } | 193 } |
| 190 } | 194 } |
| 191 push(new StringConcat(members)); | 195 push(new StringConcat(members)); |
| 192 } | 196 } |
| 193 handleStringJuxtaposition(int litCount) { | 197 handleStringJuxtaposition(int litCount) { |
| 194 push(new StringConcat(popList(litCount, <Expression>[]))); | 198 push(new StringConcat(popList(litCount, <Expression>[]))); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 handleNewExpression(t) { | 337 handleNewExpression(t) { |
| 334 List<Argument> args = pop(); | 338 List<Argument> args = pop(); |
| 335 String constructorName = pop(asName); | 339 String constructorName = pop(asName); |
| 336 TypeAnnotation type = popTypeAnnotation(); | 340 TypeAnnotation type = popTypeAnnotation(); |
| 337 push(new CallNew(type, args, constructorName: constructorName)); | 341 push(new CallNew(type, args, constructorName: constructorName)); |
| 338 } | 342 } |
| 339 handleConstExpression(t) { | 343 handleConstExpression(t) { |
| 340 List<Argument> args = pop(); | 344 List<Argument> args = pop(); |
| 341 String constructorName = pop(asName); | 345 String constructorName = pop(asName); |
| 342 TypeAnnotation type = popTypeAnnotation(); | 346 TypeAnnotation type = popTypeAnnotation(); |
| 343 push(new CallNew(type, args, constructorName: constructorName, | 347 push(new CallNew(type, args, constructorName: constructorName, |
| 344 isConst:true)); | 348 isConst:true)); |
| 345 } | 349 } |
| 346 handleParenthesizedExpression(t) { | 350 handleParenthesizedExpression(t) { |
| 347 // do nothing, just leave expression on top of stack | 351 // do nothing, just leave expression on top of stack |
| 348 } | 352 } |
| 349 handleSuperExpression(t) { | 353 handleSuperExpression(t) { |
| 350 push(new SuperReceiver()); | 354 push(new SuperReceiver()); |
| 351 } | 355 } |
| 352 handleThisExpression(t) { | 356 handleThisExpression(t) { |
| 353 push(new This()); | 357 push(new This()); |
| 354 } | 358 } |
| 355 handleUnaryPostfixAssignmentExpression(Token t) { | 359 handleUnaryPostfixAssignmentExpression(Token t) { |
| 356 push(new Increment.postfix(pop(), t.value)); | 360 push(new Increment.postfix(pop(), t.value)); |
| 357 } | 361 } |
| 358 handleUnaryPrefixAssignmentExpression(Token t) { | 362 handleUnaryPrefixAssignmentExpression(Token t) { |
| 359 push(new Increment.prefix(pop(), t.value)); | 363 push(new Increment.prefix(pop(), t.value)); |
| 360 } | 364 } |
| 361 handleUnaryPrefixExpression(Token t) { | 365 handleUnaryPrefixExpression(Token t) { |
| 362 push(new UnaryOperator(t.value, pop())); | 366 push(new UnaryOperator(t.value, pop())); |
| 363 } | 367 } |
| 364 | 368 |
| 365 handleFunctionTypedFormalParameter(tok) { | 369 handleFunctionTypedFormalParameter(tok) { |
| 366 // handled in endFormalParameter | 370 // handled in endFormalParameter |
| 367 } | 371 } |
| 368 endFormalParameter(thisKeyword) { | 372 endFormalParameter(thisKeyword) { |
| 369 Expression defaultValue = null; | 373 Expression defaultValue = null; |
| 370 var x = pop(); | 374 var x = pop(); |
| 371 if (x is DefaultValue) { | 375 if (x is DefaultValue) { |
| 372 defaultValue = x.expression; | 376 defaultValue = x.expression; |
| 373 x = pop(); | 377 x = pop(); |
| 374 } | 378 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 push(new Parameters([])); | 415 push(new Parameters([])); |
| 412 } | 416 } |
| 413 endUnamedFunction(t) { | 417 endUnamedFunction(t) { |
| 414 Statement body = pop(); | 418 Statement body = pop(); |
| 415 Parameters parameters = pop(); | 419 Parameters parameters = pop(); |
| 416 push(new FunctionExpression(parameters, body)); | 420 push(new FunctionExpression(parameters, body)); |
| 417 } | 421 } |
| 418 handleNoType(Token token) { | 422 handleNoType(Token token) { |
| 419 push(null); | 423 push(null); |
| 420 } | 424 } |
| 421 | 425 |
| 422 endReturnStatement(bool hasExpression, begin, end) { | 426 endReturnStatement(bool hasExpression, begin, end) { |
| 423 // This is also called for functions whose body is "=> expression" | 427 // This is also called for functions whose body is "=> expression" |
| 424 if (hasExpression) { | 428 if (hasExpression) { |
| 425 push(new Return(pop())); | 429 push(new Return(pop())); |
| 426 } else { | 430 } else { |
| 427 push(new Return()); | 431 push(new Return()); |
| 428 } | 432 } |
| 429 } | 433 } |
| 430 | 434 |
| 431 endExpressionStatement(Token token) { | 435 endExpressionStatement(Token token) { |
| 432 push(new ExpressionStatement(pop())); | 436 push(new ExpressionStatement(pop())); |
| 433 } | 437 } |
| 434 | 438 |
| 435 endDoWhileStatement(Token doKeyword, Token whileKeyword, Token end) { | 439 endDoWhileStatement(Token doKeyword, Token whileKeyword, Token end) { |
| 436 Expression condition = pop(); | 440 Expression condition = pop(); |
| 437 Statement body = pop(); | 441 Statement body = pop(); |
| 438 push(new DoWhile(body, condition)); | 442 push(new DoWhile(body, condition)); |
| 439 } | 443 } |
| 440 | 444 |
| 441 endWhileStatement(Token whileKeyword, Token end) { | 445 endWhileStatement(Token whileKeyword, Token end) { |
| 442 Statement body = pop(); | 446 Statement body = pop(); |
| 443 Expression condition = pop(); | 447 Expression condition = pop(); |
| 444 push(new While(condition, body)); | 448 push(new While(condition, body)); |
| 445 } | 449 } |
| 446 | 450 |
| 447 endBlock(int count, Token begin, Token end) { | 451 endBlock(int count, Token begin, Token end) { |
| 448 push(new Block(popList(count, <Statement>[]))); | 452 push(new Block(popList(count, <Statement>[]))); |
| 449 } | 453 } |
| 450 | 454 |
| 451 endRethrowStatement(Token throwToken, Token endToken) { | 455 endRethrowStatement(Token throwToken, Token endToken) { |
| 452 push(new Rethrow()); | 456 push(new Rethrow()); |
| 453 } | 457 } |
| 454 | 458 |
| 455 endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { | 459 endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { |
| 456 Statement finallyBlock = null; | 460 Statement finallyBlock = null; |
| 457 if (finallyKeyword != null) { | 461 if (finallyKeyword != null) { |
| 458 finallyBlock = pop(); | 462 finallyBlock = pop(); |
| 459 } | 463 } |
| 460 List<CatchBlock> catchBlocks = popList(catchCount, <CatchBlock>[]); | 464 List<CatchBlock> catchBlocks = popList(catchCount, <CatchBlock>[]); |
| 461 Statement tryBlock = pop(); | 465 Statement tryBlock = pop(); |
| 462 push(new Try(tryBlock, catchBlocks, finallyBlock)); | 466 push(new Try(tryBlock, catchBlocks, finallyBlock)); |
| 463 } | 467 } |
| 464 | 468 |
| 465 void handleCatchBlock(Token onKeyword, Token catchKeyword) { | 469 void handleCatchBlock(Token onKeyword, Token catchKeyword) { |
| 466 Statement block = pop(); | 470 Statement block = pop(); |
| 467 String exceptionVar = null; | 471 String exceptionVar = null; |
| 468 String stackVar = null; | 472 String stackVar = null; |
| 469 if (catchKeyword != null) { | 473 if (catchKeyword != null) { |
| 470 Parameters params = pop(); | 474 Parameters params = pop(); |
| 471 exceptionVar = params.requiredParameters[0].name; | 475 exceptionVar = params.requiredParameters[0].name; |
| 472 if (params.requiredParameters.length > 1) { | 476 if (params.requiredParameters.length > 1) { |
| 473 stackVar = params.requiredParameters[1].name; | 477 stackVar = params.requiredParameters[1].name; |
| 474 } | 478 } |
| 475 } | 479 } |
| 476 TypeAnnotation type = onKeyword == null ? null : pop(); | 480 TypeAnnotation type = onKeyword == null ? null : pop(); |
| 477 push(new CatchBlock(block, | 481 push(new CatchBlock(block, |
| 478 onType: type, | 482 onType: type, |
| 479 exceptionVar: exceptionVar, | 483 exceptionVar: exceptionVar, |
| 480 stackVar: stackVar | 484 stackVar: stackVar |
| 481 )); | 485 )); |
| 482 } | 486 } |
| 483 | 487 |
| 484 endSwitchStatement(Token switchKeyword, Token end) { | 488 endSwitchStatement(Token switchKeyword, Token end) { |
| 485 List<SwitchCase> cases = pop(); | 489 List<SwitchCase> cases = pop(); |
| 486 Expression expression = pop(); | 490 Expression expression = pop(); |
| 487 push(new Switch(expression, cases)); | 491 push(new Switch(expression, cases)); |
| 488 } | 492 } |
| 489 | 493 |
| 490 endSwitchBlock(int caseCount, Token begin, Token end) { | 494 endSwitchBlock(int caseCount, Token begin, Token end) { |
| 491 push(popList(caseCount, <SwitchCase>[])); | 495 push(popList(caseCount, <SwitchCase>[])); |
| 492 } | 496 } |
| 493 | 497 |
| 494 handleSwitchCase(int labelCount, int caseCount, Token defaultKeyword, | 498 handleSwitchCase(int labelCount, int caseCount, Token defaultKeyword, |
| 495 int statementCount, Token first, Token end) { | 499 int statementCount, Token first, Token end) { |
| 496 List<Statement> statements = popList(statementCount, <Statement>[]); | 500 List<Statement> statements = popList(statementCount, <Statement>[]); |
| 497 List<Expression> cases = popList(caseCount, <Expression>[]); | 501 List<Expression> cases = popList(caseCount, <Expression>[]); |
| 498 if (defaultKeyword != null) { | 502 if (defaultKeyword != null) { |
| 499 cases = null; | 503 cases = null; |
| 500 } | 504 } |
| 501 push(new SwitchCase(cases, statements)); | 505 push(new SwitchCase(cases, statements)); |
| 502 } | 506 } |
| 503 | 507 |
| 504 handleCaseMatch(Token caseKeyword, Token colon) { | 508 handleCaseMatch(Token caseKeyword, Token colon) { |
| 505 // do nothing, leave case expression on stack | 509 // do nothing, leave case expression on stack |
| 506 } | 510 } |
| 507 | 511 |
| 508 handleBreakStatement(bool hasTarget, Token breakKeyword, Token end) { | 512 handleBreakStatement(bool hasTarget, Token breakKeyword, Token end) { |
| 509 String target = hasTarget ? pop(asName) : null; | 513 String target = hasTarget ? pop(asName) : null; |
| 510 push(new Break(target)); | 514 push(new Break(target)); |
| 511 } | 515 } |
| 512 | 516 |
| 513 handleContinueStatement(bool hasTarget, Token continueKeyword, Token end) { | 517 handleContinueStatement(bool hasTarget, Token continueKeyword, Token end) { |
| 514 String target = hasTarget ? pop(asName) : null; | 518 String target = hasTarget ? pop(asName) : null; |
| 515 push(new Continue(target)); | 519 push(new Continue(target)); |
| 516 } | 520 } |
| 517 | 521 |
| 518 handleEmptyStatement(Token token) { | 522 handleEmptyStatement(Token token) { |
| 519 push(new EmptyStatement()); | 523 push(new EmptyStatement()); |
| 520 } | 524 } |
| 521 | 525 |
| 522 | 526 |
| 523 VariableDeclaration asVariableDeclaration(x) { | 527 VariableDeclaration asVariableDeclaration(x) { |
| 524 if (x is VariableDeclaration) | 528 if (x is VariableDeclaration) |
| 525 return x; | 529 return x; |
| 526 if (x is Identifier) | 530 if (x is Identifier) |
| 527 return new VariableDeclaration(x.name); | 531 return new VariableDeclaration(x.name); |
| 528 throw "Not a variable definition: ${x.runtimeType}"; | 532 throw "Not a variable definition: ${x.runtimeType}"; |
| 529 } | 533 } |
| 530 | 534 |
| 531 endVariablesDeclaration(int count, Token end) { | 535 endVariablesDeclaration(int count, Token end) { |
| 532 List<VariableDeclaration> variables = | 536 List<VariableDeclaration> variables = |
| 533 popList(count, <VariableDeclaration>[], asVariableDeclaration); | 537 popList(count, <VariableDeclaration>[], asVariableDeclaration); |
| 534 TypeAnnotation type = popTypeAnnotation(); | 538 TypeAnnotation type = popTypeAnnotation(); |
| 535 push(new VariableDeclarations(variables, | 539 push(new VariableDeclarations(variables, |
| 536 type: type, | 540 type: type, |
| 537 isFinal: false, // TODO(asgerf): Parse modifiers. | 541 isFinal: false, // TODO(asgerf): Parse modifiers. |
| 538 isConst: false | 542 isConst: false |
| 539 )); | 543 )); |
| 540 } | 544 } |
| 541 | 545 |
| 542 endInitializer(Token assign) { | 546 endInitializer(Token assign) { |
| 543 Expression init = pop(); | 547 Expression init = pop(); |
| 544 String name = pop(asName); | 548 String name = pop(asName); |
| 545 push(new VariableDeclaration(name, init)); | 549 push(new VariableDeclaration(name, init)); |
| 546 } | 550 } |
| 547 | 551 |
| 548 endIfStatement(Token ifToken, Token elseToken) { | 552 endIfStatement(Token ifToken, Token elseToken) { |
| 549 Statement elsePart = (elseToken == null) ? null : pop(); | 553 Statement elsePart = (elseToken == null) ? null : pop(); |
| 550 Statement thenPart = pop(); | 554 Statement thenPart = pop(); |
| 551 Expression condition = pop(); | 555 Expression condition = pop(); |
| 552 push(new If(condition, thenPart, elsePart)); | 556 push(new If(condition, thenPart, elsePart)); |
| 553 } | 557 } |
| 554 | 558 |
| 555 endForStatement(int updateCount, Token begin, Token end) { | 559 endForStatement(int updateCount, Token begin, Token end) { |
| 556 Statement body = pop(); | 560 Statement body = pop(); |
| 557 List<Expression> updates = popList(updateCount, <Expression>[]); | 561 List<Expression> updates = popList(updateCount, <Expression>[]); |
| 558 ExpressionStatement condition = pop(); // parsed as expression statement | 562 ExpressionStatement condition = pop(); // parsed as expression statement |
| 559 Expression exp = condition == null ? null : condition.expression; | 563 Expression exp = condition == null ? null : condition.expression; |
| 560 Node initializer = pop(); | 564 Node initializer = pop(); |
| 561 push(new For(initializer, exp, updates, body)); | 565 push(new For(initializer, exp, updates, body)); |
| 562 } | 566 } |
| 563 | 567 |
| 564 handleNoExpression(Token token) { | 568 handleNoExpression(Token token) { |
| 565 push(null); | 569 push(null); |
| 566 } | 570 } |
| 567 | 571 |
| 568 endForIn(Token begin, Token inKeyword, Token end) { | 572 endForIn(Token begin, Token inKeyword, Token end) { |
| 569 Statement body = pop(); | 573 Statement body = pop(); |
| 570 Expression exp = pop(); | 574 Expression exp = pop(); |
| 571 Node declaredIdentifier = pop(); | 575 Node declaredIdentifier = pop(); |
| 572 push(new ForIn(declaredIdentifier, exp, body)); | 576 push(new ForIn(declaredIdentifier, exp, body)); |
| 573 } | 577 } |
| 574 | 578 |
| 575 handleAssertStatement(Token assertKeyword, Token semicolonToken) { | 579 handleAssertStatement(Token assertKeyword, Token semicolonToken) { |
| 576 Expression exp = pop(); | 580 Expression exp = pop(); |
| 577 Expression call = new CallFunction(new Identifier("assert"), [exp]); | 581 Expression call = new CallFunction(new Identifier("assert"), [exp]); |
| 578 push(new ExpressionStatement(call)); | 582 push(new ExpressionStatement(call)); |
| 579 } | 583 } |
| 580 | 584 |
| 581 endLabeledStatement(int labelCount) { | 585 endLabeledStatement(int labelCount) { |
| 582 Statement statement = pop(); | 586 Statement statement = pop(); |
| 583 for (int i=0; i<labelCount; i++) { | 587 for (int i=0; i<labelCount; i++) { |
| 584 String label = pop(asName); | 588 String label = pop(asName); |
| 585 statement = new LabeledStatement(label, statement); | 589 statement = new LabeledStatement(label, statement); |
| 586 } | 590 } |
| 587 push(statement); | 591 push(statement); |
| 588 } | 592 } |
| 589 | 593 |
| 590 // TODO(kmillikin,asgerf): this code is currently untested. | 594 // TODO(kmillikin,asgerf): this code is currently untested. |
| 591 endFunctionDeclaration(Token end) { | 595 endFunctionDeclaration(Token end) { |
| 592 Statement body = pop(); | 596 Statement body = pop(); |
| 593 Parameters parameters = pop(); | 597 Parameters parameters = pop(); |
| 594 String name = pop(asName); | 598 String name = pop(asName); |
| 595 TypeAnnotation returnType = popTypeAnnotation(); | 599 TypeAnnotation returnType = popTypeAnnotation(); |
| 596 push(new FunctionDeclaration(name, parameters, returnType)); | 600 push(new FunctionDeclaration(name, parameters, returnType)); |
| 597 } | 601 } |
| 598 | 602 |
| 599 endFunctionBody(int count, Token begin, Token end) { | 603 endFunctionBody(int count, Token begin, Token end) { |
| 600 push(new Block(popList(count, <Statement>[]))); | 604 push(new Block(popList(count, <Statement>[]))); |
| 601 } | 605 } |
| 602 } | 606 } |
| 603 | 607 |
| 604 class DefaultValue { | 608 class DefaultValue { |
| 605 final Expression expression; | 609 final Expression expression; |
| 606 DefaultValue(this.expression); | 610 DefaultValue(this.expression); |
| 607 } | 611 } |
| 608 | 612 |
| 609 /// Compares ASTs for structural equality. | 613 /// Compares ASTs for structural equality. |
| 610 void checkDeepEqual(x, y) { | 614 void checkDeepEqual(x, y) { |
| 611 if (x is List && y is List) { | 615 if (x is List && y is List) { |
| 612 if (x.length != y.length) | 616 if (x.length != y.length) |
| 613 return; | 617 return; |
| 614 for (var i=0; i<x.length; i++) { | 618 for (var i=0; i<x.length; i++) { |
| 615 checkDeepEqual(x[i], y[i]); | 619 checkDeepEqual(x[i], y[i]); |
| 616 } | 620 } |
| 617 } | 621 } |
| 618 else if (x is Node && y is Node) { | 622 else if (x is Node && y is Node) { |
| 619 if (x.runtimeType != y.runtimeType) | 623 if (x.runtimeType != y.runtimeType) |
| 620 throw new Error(); | 624 throw new Error(); |
| 621 InstanceMirror xm = reflect(x); | 625 InstanceMirror xm = reflect(x); |
| 622 InstanceMirror ym = reflect(y); | 626 InstanceMirror ym = reflect(y); |
| 623 for (Symbol name in xm.type.instanceMembers.keys) { | 627 for (Symbol name in xm.type.instanceMembers.keys) { |
| 624 if (reflectClass(Object).declarations.containsKey(name)) { | 628 if (reflectClass(Object).declarations.containsKey(name)) { |
| 625 continue; // do not check things from Object, such as hashCode | 629 continue; // do not check things from Object, such as hashCode |
| 626 } | 630 } |
| 627 MethodMirror mm = xm.type.instanceMembers[name]; | 631 MethodMirror mm = xm.type.instanceMembers[name]; |
| 628 if (mm.isGetter) { | 632 if (mm.isGetter) { |
| 629 var xv = xm.getField(name).reflectee; | 633 var xv = xm.getField(name).reflectee; |
| 630 var yv = ym.getField(name).reflectee; | 634 var yv = ym.getField(name).reflectee; |
| 631 checkDeepEqual(xv,yv); | 635 checkDeepEqual(xv,yv); |
| 632 } | 636 } |
| 633 } | 637 } |
| 634 } | 638 } |
| 635 else if (x is PrimitiveConstant && y is PrimitiveConstant) { | 639 else if (x is PrimitiveConstant && y is PrimitiveConstant) { |
| 636 checkDeepEqual(x.value, y.value); | 640 checkDeepEqual(x.value, y.value); |
| 637 } | 641 } |
| 638 else if (x is DartString && y is DartString) { | 642 else if (x is DartString && y is DartString) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 SourceFile file = new StringSourceFile('', code); | 727 SourceFile file = new StringSourceFile('', code); |
| 724 Scanner scan = new Scanner(file); | 728 Scanner scan = new Scanner(file); |
| 725 Token tok = scan.tokenize(); | 729 Token tok = scan.tokenize(); |
| 726 while (tok.next != tok) { | 730 while (tok.next != tok) { |
| 727 print(tok.toString()); | 731 print(tok.toString()); |
| 728 tok = tok.next; | 732 tok = tok.next; |
| 729 } | 733 } |
| 730 } | 734 } |
| 731 | 735 |
| 732 void main() { | 736 void main() { |
| 733 // To check if these tests are effective, one should manually alter | 737 // To check if these tests are effective, one should manually alter |
| 734 // something in [Unparser] and see if a test fails. | 738 // something in [Unparser] and see if a test fails. |
| 735 | 739 |
| 736 checkExpression(" a + b + c"); | 740 checkExpression(" a + b + c"); |
| 737 checkExpression("(a + b) + c"); | 741 checkExpression("(a + b) + c"); |
| 738 checkExpression(" a + (b + c)"); | 742 checkExpression(" a + (b + c)"); |
| 739 | 743 |
| 740 checkExpression(" a + b - c"); | 744 checkExpression(" a + b - c"); |
| 741 checkExpression("(a + b) - c"); | 745 checkExpression("(a + b) - c"); |
| 742 checkExpression(" a + (b - c)"); | 746 checkExpression(" a + (b - c)"); |
| 743 | 747 |
| 744 checkExpression(" a - b + c"); | 748 checkExpression(" a - b + c"); |
| 745 checkExpression("(a - b) + c"); | 749 checkExpression("(a - b) + c"); |
| 746 checkExpression(" a - (b + c)"); | 750 checkExpression(" a - (b + c)"); |
| 747 | 751 |
| 748 checkExpression(" a * b + c"); | 752 checkExpression(" a * b + c"); |
| 749 checkExpression("(a * b) + c"); | 753 checkExpression("(a * b) + c"); |
| 750 checkExpression(" a * (b + c)"); | 754 checkExpression(" a * (b + c)"); |
| 751 | 755 |
| 752 checkExpression(" a + b * c"); | 756 checkExpression(" a + b * c"); |
| 753 checkExpression("(a + b) * c"); | 757 checkExpression("(a + b) * c"); |
| 754 checkExpression(" a + (b * c)"); | 758 checkExpression(" a + (b * c)"); |
| 755 | 759 |
| 756 checkExpression(" a * b * c"); | 760 checkExpression(" a * b * c"); |
| 757 checkExpression("(a * b) * c"); | 761 checkExpression("(a * b) * c"); |
| 758 checkExpression(" a * (b * c)"); | 762 checkExpression(" a * (b * c)"); |
| 759 | 763 |
| 760 checkExpression("a is T"); | 764 checkExpression("a is T"); |
| 761 checkExpression("a is! T"); | 765 checkExpression("a is! T"); |
| 762 checkExpression("!(a is T)"); | 766 checkExpression("!(a is T)"); |
| 763 | 767 |
| 764 checkExpression("a is T.x"); | 768 checkExpression("a is T.x"); |
| 765 checkExpression("a is! T.x"); | 769 checkExpression("a is! T.x"); |
| 766 checkExpression("!(a is T.x)"); | 770 checkExpression("!(a is T.x)"); |
| 767 checkExpression("!(a is T).x"); | 771 checkExpression("!(a is T).x"); |
| 768 | 772 |
| 769 checkExpression("a as T.x"); | 773 checkExpression("a as T.x"); |
| 770 checkExpression("(a as T).x"); | 774 checkExpression("(a as T).x"); |
| 771 | 775 |
| 772 checkExpression("a == b"); | 776 checkExpression("a == b"); |
| 773 checkExpression("a != b"); | 777 checkExpression("a != b"); |
| 774 checkExpression("!(a == b)", "a != b"); | 778 checkExpression("!(a == b)", "a != b"); |
| 775 | 779 |
| 776 checkExpression("a && b ? c : d"); | 780 checkExpression("a && b ? c : d"); |
| 777 checkExpression("(a && b) ? c : d"); | 781 checkExpression("(a && b) ? c : d"); |
| 778 checkExpression("a && (b ? c : d)"); | 782 checkExpression("a && (b ? c : d)"); |
| 779 | 783 |
| 780 checkExpression("a || b ? c : d"); | 784 checkExpression("a || b ? c : d"); |
| 781 checkExpression("(a || b) ? c : d"); | 785 checkExpression("(a || b) ? c : d"); |
| 782 checkExpression("a || (b ? c : d)"); | 786 checkExpression("a || (b ? c : d)"); |
| 783 | 787 |
| 784 checkExpression(" a ? b : c && d"); | 788 checkExpression(" a ? b : c && d"); |
| 785 checkExpression(" a ? b : (c && d)"); | 789 checkExpression(" a ? b : (c && d)"); |
| 786 checkExpression("(a ? b : c) && d"); | 790 checkExpression("(a ? b : c) && d"); |
| 787 | 791 |
| 788 checkExpression(" a ? b : c = d"); | 792 checkExpression(" a ? b : c = d"); |
| 789 checkExpression(" a ? b : (c = d)"); | 793 checkExpression(" a ? b : (c = d)"); |
| 790 | 794 |
| 791 checkExpression("(a == b) == c"); | 795 checkExpression("(a == b) == c"); |
| 792 checkExpression("a == (b == c)"); | 796 checkExpression("a == (b == c)"); |
| 793 | 797 |
| 794 checkExpression(" a < b == c"); | 798 checkExpression(" a < b == c"); |
| 795 checkExpression("(a < b) == c"); | 799 checkExpression("(a < b) == c"); |
| 796 checkExpression(" a < (b == c)"); | 800 checkExpression(" a < (b == c)"); |
| 797 | 801 |
| 798 checkExpression(" a == b < c"); | 802 checkExpression(" a == b < c"); |
| 799 checkExpression("(a == b) < c"); | 803 checkExpression("(a == b) < c"); |
| 800 checkExpression(" a == (b < c)"); | 804 checkExpression(" a == (b < c)"); |
| 801 | 805 |
| 802 checkExpression("x.f()"); | 806 checkExpression("x.f()"); |
| 803 checkExpression("(x.f)()"); | 807 checkExpression("(x.f)()"); |
| 804 | 808 |
| 805 checkExpression("x.f()()"); | 809 checkExpression("x.f()()"); |
| 806 checkExpression("(x.f)()()"); | 810 checkExpression("(x.f)()()"); |
| 807 | 811 |
| 808 checkExpression("x.f().g()"); | 812 checkExpression("x.f().g()"); |
| 809 checkExpression("(x.f)().g()"); | 813 checkExpression("(x.f)().g()"); |
| 810 | 814 |
| 811 checkExpression("x.f()"); | 815 checkExpression("x.f()"); |
| 812 checkExpression("x.f(1 + 2)"); | 816 checkExpression("x.f(1 + 2)"); |
| 813 checkExpression("x.f(1 + 2, 3 + 4)"); | 817 checkExpression("x.f(1 + 2, 3 + 4)"); |
| 814 checkExpression("x.f(1 + 2, foo:3 + 4)"); | 818 checkExpression("x.f(1 + 2, foo:3 + 4)"); |
| 815 checkExpression("x.f(1 + 2, foo:3 + 4, bar: 5)"); | 819 checkExpression("x.f(1 + 2, foo:3 + 4, bar: 5)"); |
| 816 checkExpression("x.f(foo:3 + 4)"); | 820 checkExpression("x.f(foo:3 + 4)"); |
| 817 checkExpression("x.f(foo:3 + 4, bar: 5)"); | 821 checkExpression("x.f(foo:3 + 4, bar: 5)"); |
| 818 | 822 |
| 819 checkExpression("x.f.g.h"); | 823 checkExpression("x.f.g.h"); |
| 820 checkExpression("(x.f).g.h"); | 824 checkExpression("(x.f).g.h"); |
| 821 checkExpression("(x.f.g).h"); | 825 checkExpression("(x.f.g).h"); |
| 822 | 826 |
| 823 checkExpression(" a = b + c"); | 827 checkExpression(" a = b + c"); |
| 824 checkExpression(" a = (b + c)"); | 828 checkExpression(" a = (b + c)"); |
| 825 checkExpression("(a = b) + c"); | 829 checkExpression("(a = b) + c"); |
| 826 | 830 |
| 827 checkExpression("a + (b = c)"); | 831 checkExpression("a + (b = c)"); |
| 828 | 832 |
| 829 checkExpression("dx * dx + dy * dy < r * r", | 833 checkExpression("dx * dx + dy * dy < r * r", |
| 830 "((dx * dx) + (dy * dy)) < (r * r)"); | 834 "((dx * dx) + (dy * dy)) < (r * r)"); |
| 831 checkExpression("mid = left + right << 1", | 835 checkExpression("mid = left + right << 1", |
| 832 "mid = ((left + right) << 1)"); | 836 "mid = ((left + right) << 1)"); |
| 833 checkExpression("a + b % c * -d ^ e - f ~/ x & ++y / z++ | w > a ? b : c"); | 837 checkExpression("a + b % c * -d ^ e - f ~/ x & ++y / z++ | w > a ? b : c"); |
| 834 checkExpression("a + b % c * -d ^ (e - f) ~/ x & ++y / z++ | w > a ? b : c"); | 838 checkExpression("a + b % c * -d ^ (e - f) ~/ x & ++y / z++ | w > a ? b : c"); |
| 835 | 839 |
| 836 checkExpression("'foo'"); | 840 checkExpression("'foo'"); |
| 837 checkExpression("'foo' 'bar'", "'foobar'"); | 841 checkExpression("'foo' 'bar'", "'foobar'"); |
| 838 | 842 |
| 839 checkExpression("{}.length"); | 843 checkExpression("{}.length"); |
| 840 checkExpression("{x: 1+2}.length"); | 844 checkExpression("{x: 1+2}.length"); |
| 841 checkExpression("<String,int>{}.length"); | 845 checkExpression("<String,int>{}.length"); |
| 842 checkExpression("<String,int>{x: 1+2}.length"); | 846 checkExpression("<String,int>{x: 1+2}.length"); |
| 843 | 847 |
| 844 checkExpression("[].length"); | 848 checkExpression("[].length"); |
| 845 checkExpression("[1+2].length"); | 849 checkExpression("[1+2].length"); |
| 846 checkExpression("<num>[].length"); | 850 checkExpression("<num>[].length"); |
| 847 checkExpression("<num>[1+2].length"); | 851 checkExpression("<num>[1+2].length"); |
| 848 | 852 |
| 849 checkExpression("x + -y"); | 853 checkExpression("x + -y"); |
| 850 checkExpression("x + --y"); | 854 checkExpression("x + --y"); |
| 851 checkExpression("x++ + y"); | 855 checkExpression("x++ + y"); |
| 852 checkExpression("x + ++y"); | 856 checkExpression("x + ++y"); |
| 853 checkExpression("x-- - y"); | 857 checkExpression("x-- - y"); |
| 854 checkExpression("x-- - -y"); | 858 checkExpression("x-- - -y"); |
| 855 checkExpression("x - --y"); | 859 checkExpression("x - --y"); |
| 856 | 860 |
| 857 checkExpression("x && !y"); | 861 checkExpression("x && !y"); |
| 858 checkExpression("!x && y"); | 862 checkExpression("!x && y"); |
| 859 checkExpression("!(x && y)"); | 863 checkExpression("!(x && y)"); |
| 860 | 864 |
| 861 checkExpression(" super + 1 * 2"); | 865 checkExpression(" super + 1 * 2"); |
| 862 checkExpression("(super + 1) * 2"); | 866 checkExpression("(super + 1) * 2"); |
| 863 checkExpression(" super + (1 * 2)"); | 867 checkExpression(" super + (1 * 2)"); |
| 864 checkExpression("x + -super"); | 868 checkExpression("x + -super"); |
| 865 checkExpression("x-- - -super"); | 869 checkExpression("x-- - -super"); |
| 866 checkExpression("x - -super"); | 870 checkExpression("x - -super"); |
| 867 checkExpression("x && !super"); | 871 checkExpression("x && !super"); |
| 868 | 872 |
| 869 checkExpression("super.f(1, 2) + 3"); | 873 checkExpression("super.f(1, 2) + 3"); |
| 870 checkExpression("super.f + 3"); | 874 checkExpression("super.f + 3"); |
| 871 | 875 |
| 872 checkExpression(r"'foo\nbar'"); | 876 checkExpression(r"'foo\nbar'"); |
| 873 checkExpression(r"'foo\r\nbar'"); | 877 checkExpression(r"'foo\r\nbar'"); |
| 874 checkExpression(r"'foo\rbar'"); | 878 checkExpression(r"'foo\rbar'"); |
| 875 checkExpression(r"'foo\'bar'"); | 879 checkExpression(r"'foo\'bar'"); |
| 876 checkExpression(r"""'foo"bar'"""); | 880 checkExpression(r"""'foo"bar'"""); |
| 877 checkExpression(r"r'foo\nbar'"); | 881 checkExpression(r"r'foo\nbar'"); |
| 878 checkExpression("''"); | 882 checkExpression("''"); |
| 879 checkExpression("r''"); | 883 checkExpression("r''"); |
| 880 | 884 |
| 881 var sq = "'"; | 885 var sq = "'"; |
| 882 var dq = '"'; | 886 var dq = '"'; |
| 883 checkExpression("'$dq$dq' \"$sq$sq\""); | 887 checkExpression("'$dq$dq' \"$sq$sq\""); |
| 884 checkExpression("'$dq$dq$dq$dq' \"$sq$sq$sq$sq\""); | 888 checkExpression("'$dq$dq$dq$dq' \"$sq$sq$sq$sq\""); |
| 885 checkExpression(r"'\$\$\$\$\$\$\$\$\$'"); | 889 checkExpression(r"'\$\$\$\$\$\$\$\$\$'"); |
| 886 checkExpression("'$dq$dq$dq' '\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n' \"$sq$sq$sq\""); | 890 checkExpression("'$dq$dq$dq' '\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n' \"$sq$sq$sq\""); |
| 887 checkExpression("'$dq$dq$dq' '\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r' \"$sq$sq$sq\""); | 891 checkExpression("'$dq$dq$dq' '\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r' \"$sq$sq$sq\""); |
| 888 checkExpression("'$dq$dq$dq' '\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n' \"$sq$sq$sq\""); | 892 checkExpression("'$dq$dq$dq' '\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n' \"$sq$sq$sq\""); |
| 889 | 893 |
| 890 checkExpression(r"'$foo'"); | 894 checkExpression(r"'$foo'"); |
| 891 checkExpression(r"'${foo}x'"); | 895 checkExpression(r"'${foo}x'"); |
| 892 checkExpression(r"'${foo}x\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'"); | 896 checkExpression(r"'${foo}x\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'"); |
| 893 checkExpression(r"'abc' '${foo}' r'\\\\\\\'"); | 897 checkExpression(r"'abc' '${foo}' r'\\\\\\\'"); |
| 894 | 898 |
| 895 checkExpression(r"'${$x}'"); | 899 checkExpression(r"'${$x}'"); |
| 896 checkExpression(r"'${$x}y'"); | 900 checkExpression(r"'${$x}y'"); |
| 897 checkExpression("null + null"); | 901 checkExpression("null + null"); |
| 898 | 902 |
| 899 checkExpression("throw x"); | 903 checkExpression("throw x"); |
| 900 checkStatement("throw x;"); | 904 checkStatement("throw x;"); |
| 901 | 905 |
| 902 checkStatement("var x, y, z;"); | 906 checkStatement("var x, y, z;"); |
| 903 checkStatement("final x, y, z;"); | 907 checkStatement("final x, y, z;"); |
| 904 checkStatement("dynamic x, y, z;"); | 908 checkStatement("dynamic x, y, z;"); |
| 905 checkStatement("String x, y, z;"); | 909 checkStatement("String x, y, z;"); |
| 906 checkStatement("List<int> x, y, z;"); | 910 checkStatement("List<int> x, y, z;"); |
| 907 checkStatement("final dynamic x, y, z;"); | 911 checkStatement("final dynamic x, y, z;"); |
| 908 checkStatement("final String x, y, z;"); | 912 checkStatement("final String x, y, z;"); |
| 909 checkStatement("final List<int> x, y, z;"); | 913 checkStatement("final List<int> x, y, z;"); |
| 910 | 914 |
| 911 checkStatement("var x = y, z;"); | 915 checkStatement("var x = y, z;"); |
| 912 checkStatement("var x, y = z;"); | 916 checkStatement("var x, y = z;"); |
| 913 checkStatement("var x = y = z;"); | 917 checkStatement("var x = y = z;"); |
| 914 | 918 |
| 915 // Note: We sometimes have to pass an expected string to account for | 919 // Note: We sometimes have to pass an expected string to account for |
| 916 // block flattening which does not preserve structural AST equality | 920 // block flattening which does not preserve structural AST equality |
| 917 checkStatement("if (x) if (y) foo(); else bar(); "); | 921 checkStatement("if (x) if (y) foo(); else bar(); "); |
| 918 checkStatement("if (x) { if (y) foo(); } else bar(); "); | 922 checkStatement("if (x) { if (y) foo(); } else bar(); "); |
| 919 checkStatement("if (x) { if (y) foo(); else bar(); }", | 923 checkStatement("if (x) { if (y) foo(); else bar(); }", |
| 920 "if (x) if (y) foo(); else bar(); "); | 924 "if (x) if (y) foo(); else bar(); "); |
| 921 | 925 |
| 922 checkStatement("if (x) while (y) if (z) foo(); else bar(); "); | 926 checkStatement("if (x) while (y) if (z) foo(); else bar(); "); |
| 923 checkStatement("if (x) while (y) { if (z) foo(); } else bar(); "); | 927 checkStatement("if (x) while (y) { if (z) foo(); } else bar(); "); |
| 924 checkStatement("if (x) while (y) { if (z) foo(); else bar(); }", | 928 checkStatement("if (x) while (y) { if (z) foo(); else bar(); }", |
| 925 "if (x) while (y) if (z) foo(); else bar(); "); | 929 "if (x) while (y) if (z) foo(); else bar(); "); |
| 926 | 930 |
| 927 checkStatement("{var x = 1; {var x = 2;} return x;}"); | 931 checkStatement("{var x = 1; {var x = 2;} return x;}"); |
| 928 checkStatement("{var x = 1; {x = 2;} return x;}", | 932 checkStatement("{var x = 1; {x = 2;} return x;}", |
| 929 "{var x = 1; x = 2; return x;}"); | 933 "{var x = 1; x = 2; return x;}"); |
| 930 | 934 |
| 931 checkStatement("if (x) {var x = 1;}"); | 935 checkStatement("if (x) {var x = 1;}"); |
| 932 | 936 |
| 933 checkStatement("({'foo': 1}).bar();"); | 937 checkStatement("({'foo': 1}).bar();"); |
| 934 checkStatement("({'foo': 1}).length;"); | 938 checkStatement("({'foo': 1}).length;"); |
| 935 checkStatement("({'foo': 1}).length + 1;"); | 939 checkStatement("({'foo': 1}).length + 1;"); |
| 936 checkStatement("({'foo': 1})['foo'].toString();"); | 940 checkStatement("({'foo': 1})['foo'].toString();"); |
| 937 checkStatement("({'foo': 1})['foo'] = 3;"); | 941 checkStatement("({'foo': 1})['foo'] = 3;"); |
| 938 checkStatement("({'foo': 1}['foo']());"); | 942 checkStatement("({'foo': 1}['foo']());"); |
| 939 checkStatement("({'foo': 1}['foo'])();"); | 943 checkStatement("({'foo': 1}['foo'])();"); |
| 940 checkStatement("({'foo': 1})['foo'].x++;"); | 944 checkStatement("({'foo': 1})['foo'].x++;"); |
| 941 checkStatement("({'foo': 1}) is Map;"); | 945 checkStatement("({'foo': 1}) is Map;"); |
| 942 checkStatement("({'foo': 1}) as Map;"); | 946 checkStatement("({'foo': 1}) as Map;"); |
| 943 checkStatement("({'foo': 1}) is util.Map;"); | 947 checkStatement("({'foo': 1}) is util.Map;"); |
| 944 checkStatement("({'foo': 1}) + 1;"); | 948 checkStatement("({'foo': 1}) + 1;"); |
| 945 | 949 |
| 946 checkStatement("[1].bar();"); | 950 checkStatement("[1].bar();"); |
| 947 checkStatement("1.bar();"); | 951 checkStatement("1.bar();"); |
| 948 checkStatement("'foo'.bar();"); | 952 checkStatement("'foo'.bar();"); |
| 949 | 953 |
| 950 checkStatement("do while(x); while (y);"); | 954 checkStatement("do while(x); while (y);"); |
| 951 checkStatement("{do; while(x); while (y);}"); | 955 checkStatement("{do; while(x); while (y);}"); |
| 952 | 956 |
| 953 checkStatement('switch(x) { case 1: case 2: return y; }'); | 957 checkStatement('switch(x) { case 1: case 2: return y; }'); |
| 954 checkStatement('switch(x) { default: return y; }'); | 958 checkStatement('switch(x) { default: return y; }'); |
| 955 checkStatement('switch(x) { case 1: x=y; default: return y; }'); | 959 checkStatement('switch(x) { case 1: x=y; default: return y; }'); |
| 956 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); | 960 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); |
| 957 | 961 |
| 958 } | 962 } |
| 959 | 963 |
| OLD | NEW |