Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 9 import '../common/names.dart'; | 9 import '../common/names.dart'; |
| 10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 buildField(target); | 101 buildField(target); |
| 102 } else if (target is ir.Constructor) { | 102 } else if (target is ir.Constructor) { |
| 103 buildConstructor(target); | 103 buildConstructor(target); |
| 104 } | 104 } |
| 105 assert(graph.isValid()); | 105 assert(graph.isValid()); |
| 106 return graph; | 106 return graph; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void buildField(ir.Field field) { | 109 void buildField(ir.Field field) { |
| 110 openFunction(); | 110 openFunction(); |
| 111 field.initializer.accept(this); | 111 if (field.initializer != null) { |
| 112 field.initializer.accept(this); | |
| 113 } else { | |
| 114 stack.add(graph.addConstantNull(compiler)); | |
| 115 } | |
| 112 HInstruction value = pop(); | 116 HInstruction value = pop(); |
| 113 closeAndGotoExit(new HReturn(value, null)); | 117 closeAndGotoExit(new HReturn(value, null)); |
| 114 closeFunction(); | 118 closeFunction(); |
| 115 } | 119 } |
| 116 | 120 |
| 117 @override | 121 @override |
| 118 HInstruction popBoolified() { | 122 HInstruction popBoolified() { |
| 119 HInstruction value = pop(); | 123 HInstruction value = pop(); |
| 120 // TODO(het): add boolean conversion type check | 124 // TODO(het): add boolean conversion type check |
| 121 HInstruction result = new HBoolify(value, backend.boolType); | 125 HInstruction result = new HBoolify(value, backend.boolType); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 @override | 417 @override |
| 414 void visitIfStatement(ir.IfStatement ifStatement) { | 418 void visitIfStatement(ir.IfStatement ifStatement) { |
| 415 SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); | 419 SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); |
| 416 brancher.handleIf( | 420 brancher.handleIf( |
| 417 () => ifStatement.condition.accept(this), | 421 () => ifStatement.condition.accept(this), |
| 418 () => ifStatement.then.accept(this), | 422 () => ifStatement.then.accept(this), |
| 419 () => ifStatement.otherwise?.accept(this)); | 423 () => ifStatement.otherwise?.accept(this)); |
| 420 } | 424 } |
| 421 | 425 |
| 422 @override | 426 @override |
| 427 void visitAssertStatement(ir.AssertStatement assertStatement) { | |
| 428 if (!compiler.options.enableUserAssertions) return; | |
| 429 if (assertStatement.message == null) { | |
| 430 assertStatement.condition.accept(this); | |
| 431 // TODO(het): should these be desugared in a kernel transformation? | |
|
Siggi Cherem (dart-lang)
2016/09/29 15:36:52
maybe - but I think it's possible that we could us
Harry Terkelsen
2016/09/29 21:16:21
Removed TODO after our team meeting discussing thi
| |
| 432 _pushStaticInvocation(astAdapter.assertHelper, <HInstruction>[pop()], | |
| 433 astAdapter.assertHelperReturnType); | |
| 434 pop(); | |
| 435 return; | |
| 436 } | |
| 437 | |
| 438 // if (assertTest(condition)) assertThrow(message); | |
| 439 void buildCondition() { | |
| 440 assertStatement.condition.accept(this); | |
| 441 _pushStaticInvocation(astAdapter.assertTest, <HInstruction>[pop()], | |
| 442 astAdapter.assertTestReturnType); | |
| 443 } | |
| 444 | |
| 445 void fail() { | |
| 446 assertStatement.message.accept(this); | |
| 447 _pushStaticInvocation(astAdapter.assertThrow, <HInstruction>[pop()], | |
| 448 astAdapter.assertThrowReturnType); | |
| 449 pop(); | |
| 450 } | |
| 451 | |
| 452 SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); | |
| 453 brancher.handleIf(buildCondition, fail, null); | |
|
Siggi Cherem (dart-lang)
2016/09/29 15:36:52
suggestion for later: it seems we always do:
Ss
Harry Terkelsen
2016/09/29 21:16:21
Good idea. I moved these to graph_builder
| |
| 454 } | |
| 455 | |
| 456 @override | |
| 423 void visitConditionalExpression(ir.ConditionalExpression conditional) { | 457 void visitConditionalExpression(ir.ConditionalExpression conditional) { |
| 424 SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); | 458 SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); |
| 425 brancher.handleConditional( | 459 brancher.handleConditional( |
| 426 () => conditional.condition.accept(this), | 460 () => conditional.condition.accept(this), |
| 427 () => conditional.then.accept(this), | 461 () => conditional.then.accept(this), |
| 428 () => conditional.otherwise.accept(this)); | 462 () => conditional.otherwise.accept(this)); |
| 429 } | 463 } |
| 430 | 464 |
| 431 @override | 465 @override |
| 432 void visitLogicalExpression(ir.LogicalExpression logicalExpression) { | 466 void visitLogicalExpression(ir.LogicalExpression logicalExpression) { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 push(new HNot(popBoolified(), backend.boolType)); | 820 push(new HNot(popBoolified(), backend.boolType)); |
| 787 } | 821 } |
| 788 | 822 |
| 789 @override | 823 @override |
| 790 void visitStringConcatenation(ir.StringConcatenation stringConcat) { | 824 void visitStringConcatenation(ir.StringConcatenation stringConcat) { |
| 791 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); | 825 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); |
| 792 stringConcat.accept(stringBuilder); | 826 stringConcat.accept(stringBuilder); |
| 793 stack.add(stringBuilder.result); | 827 stack.add(stringBuilder.result); |
| 794 } | 828 } |
| 795 } | 829 } |
| OLD | NEW |