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 tree_ir_builder; | 5 library tree_ir_builder; |
6 | 6 |
7 import '../dart2jslib.dart' as dart2js; | 7 import '../dart2jslib.dart' as dart2js; |
8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; | 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 373 |
374 Statement visitThrow(cps_ir.Throw node) { | 374 Statement visitThrow(cps_ir.Throw node) { |
375 Expression value = getVariableUse(node.value); | 375 Expression value = getVariableUse(node.value); |
376 return new Throw(value); | 376 return new Throw(value); |
377 } | 377 } |
378 | 378 |
379 Statement visitRethrow(cps_ir.Rethrow node) { | 379 Statement visitRethrow(cps_ir.Rethrow node) { |
380 return new Rethrow(); | 380 return new Rethrow(); |
381 } | 381 } |
382 | 382 |
| 383 Statement visitUnreachable(cps_ir.Unreachable node) { |
| 384 return new Unreachable(); |
| 385 } |
| 386 |
383 Expression visitNonTailThrow(cps_ir.NonTailThrow node) { | 387 Expression visitNonTailThrow(cps_ir.NonTailThrow node) { |
384 unexpectedNode(node); | 388 unexpectedNode(node); |
385 } | 389 } |
386 | 390 |
387 Statement continueWithExpression(cps_ir.Reference continuation, | 391 Statement continueWithExpression(cps_ir.Reference continuation, |
388 Expression expression) { | 392 Expression expression) { |
389 cps_ir.Continuation cont = continuation.definition; | 393 cps_ir.Continuation cont = continuation.definition; |
390 if (cont == returnContinuation) { | 394 if (cont == returnContinuation) { |
391 return new Return(expression); | 395 return new Return(expression); |
392 } else { | 396 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
408 Expression visitGetMutableVariable(cps_ir.GetMutableVariable node) { | 412 Expression visitGetMutableVariable(cps_ir.GetMutableVariable node) { |
409 return getMutableVariableUse(node.variable); | 413 return getMutableVariableUse(node.variable); |
410 } | 414 } |
411 | 415 |
412 Statement visitSetMutableVariable(cps_ir.SetMutableVariable node) { | 416 Statement visitSetMutableVariable(cps_ir.SetMutableVariable node) { |
413 Variable variable = getMutableVariable(node.variable.definition); | 417 Variable variable = getMutableVariable(node.variable.definition); |
414 Expression value = getVariableUse(node.value); | 418 Expression value = getVariableUse(node.value); |
415 return Assign.makeStatement(variable, value, visit(node.body)); | 419 return Assign.makeStatement(variable, value, visit(node.body)); |
416 } | 420 } |
417 | 421 |
418 Statement visitTypeOperator(cps_ir.TypeOperator node) { | 422 Statement visitTypeCast(cps_ir.TypeCast node) { |
419 Expression value = getVariableUse(node.value); | 423 Expression value = getVariableUse(node.value); |
420 List<Expression> typeArgs = translateArguments(node.typeArguments); | 424 List<Expression> typeArgs = translateArguments(node.typeArguments); |
421 Expression concat = | 425 Expression expression = |
422 new TypeOperator(value, node.type, typeArgs, | 426 new TypeOperator(value, node.type, typeArgs, isTypeTest: false); |
423 isTypeTest: node.isTypeTest); | 427 return continueWithExpression(node.continuation, expression); |
424 return continueWithExpression(node.continuation, concat); | 428 } |
| 429 |
| 430 Expression visitTypeTest(cps_ir.TypeTest node) { |
| 431 Expression value = getVariableUse(node.value); |
| 432 List<Expression> typeArgs = translateArguments(node.typeArguments); |
| 433 return new TypeOperator(value, node.type, typeArgs, isTypeTest: true); |
425 } | 434 } |
426 | 435 |
427 Statement visitInvokeConstructor(cps_ir.InvokeConstructor node) { | 436 Statement visitInvokeConstructor(cps_ir.InvokeConstructor node) { |
428 List<Expression> arguments = translateArguments(node.arguments); | 437 List<Expression> arguments = translateArguments(node.arguments); |
429 Expression invoke = new InvokeConstructor( | 438 Expression invoke = new InvokeConstructor( |
430 node.type, | 439 node.type, |
431 node.target, | 440 node.target, |
432 node.selector, | 441 node.selector, |
433 arguments); | 442 arguments); |
434 return continueWithExpression(node.continuation, invoke); | 443 return continueWithExpression(node.continuation, invoke); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 581 |
573 Statement visitSetStatic(cps_ir.SetStatic node) { | 582 Statement visitSetStatic(cps_ir.SetStatic node) { |
574 SetStatic setStatic = new SetStatic( | 583 SetStatic setStatic = new SetStatic( |
575 node.element, | 584 node.element, |
576 getVariableUse(node.value), | 585 getVariableUse(node.value), |
577 node.sourceInformation); | 586 node.sourceInformation); |
578 return new ExpressionStatement(setStatic, visit(node.body)); | 587 return new ExpressionStatement(setStatic, visit(node.body)); |
579 } | 588 } |
580 } | 589 } |
581 | 590 |
OLD | NEW |