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 '../closure.dart'; | 7 import '../closure.dart'; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
11 import '../common/tasks.dart' show CompilerTask; | 11 import '../common/tasks.dart' show CompilerTask; |
12 import '../compiler.dart'; | 12 import '../compiler.dart'; |
13 import '../constants/values.dart' | 13 import '../constants/values.dart' |
14 show | 14 show |
15 ConstantValue, | 15 ConstantValue, |
16 InterceptorConstantValue, | 16 InterceptorConstantValue, |
17 StringConstantValue, | 17 StringConstantValue, |
18 TypeConstantValue; | 18 TypeConstantValue; |
19 import '../elements/resolution_types.dart'; | 19 import '../elements/resolution_types.dart'; |
20 import '../elements/elements.dart'; | 20 import '../elements/elements.dart'; |
21 import '../io/source_information.dart'; | 21 import '../io/source_information.dart'; |
22 import '../js/js.dart' as js; | 22 import '../js/js.dart' as js; |
23 import '../js_backend/backend.dart' show JavaScriptBackend; | 23 import '../js_backend/backend.dart' show JavaScriptBackend; |
24 import '../kernel/kernel.dart'; | 24 import '../kernel/kernel.dart'; |
25 import '../native/native.dart' as native; | 25 import '../native/native.dart' as native; |
26 import '../resolution/tree_elements.dart'; | 26 import '../resolution/tree_elements.dart'; |
27 import '../tree/dartstring.dart'; | 27 import '../tree/dartstring.dart'; |
28 import '../tree/nodes.dart' show Node, BreakStatement; | 28 import '../tree/nodes.dart' show Node; |
29 import '../types/masks.dart'; | 29 import '../types/masks.dart'; |
30 import '../universe/call_structure.dart' show CallStructure; | 30 import '../universe/call_structure.dart' show CallStructure; |
31 import '../universe/selector.dart'; | 31 import '../universe/selector.dart'; |
32 import '../universe/side_effects.dart' show SideEffects; | 32 import '../universe/side_effects.dart' show SideEffects; |
33 import '../universe/use.dart' show StaticUse; | 33 import '../universe/use.dart' show StaticUse; |
34 import '../world.dart'; | 34 import '../world.dart'; |
35 import 'graph_builder.dart'; | 35 import 'graph_builder.dart'; |
36 import 'jump_handler.dart'; | 36 import 'jump_handler.dart'; |
37 import 'kernel_ast_adapter.dart'; | 37 import 'kernel_ast_adapter.dart'; |
38 import 'kernel_string_builder.dart'; | 38 import 'kernel_string_builder.dart'; |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 @override | 590 @override |
591 void visitReturnStatement(ir.ReturnStatement returnStatement) { | 591 void visitReturnStatement(ir.ReturnStatement returnStatement) { |
592 HInstruction value; | 592 HInstruction value; |
593 if (returnStatement.expression == null) { | 593 if (returnStatement.expression == null) { |
594 value = graph.addConstantNull(closedWorld); | 594 value = graph.addConstantNull(closedWorld); |
595 } else { | 595 } else { |
596 assert(_targetFunction != null && _targetFunction is ir.FunctionNode); | 596 assert(_targetFunction != null && _targetFunction is ir.FunctionNode); |
597 returnStatement.expression.accept(this); | 597 returnStatement.expression.accept(this); |
598 value = pop(); | 598 value = pop(); |
599 if (_targetFunction.asyncMarker == ir.AsyncMarker.Async) { | 599 if (_targetFunction.asyncMarker == ir.AsyncMarker.Async) { |
600 var returnType = astAdapter.getDartType(_targetFunction.returnType); | 600 astAdapter.getDartType(_targetFunction.returnType); |
Siggi Cherem (dart-lang)
2017/01/20 18:12:32
you can delete the entire line here
ahe
2017/01/23 10:58:36
Done.
| |
601 if (compiler.options.enableTypeAssertions && | 601 if (compiler.options.enableTypeAssertions && |
602 !isValidAsyncReturnType(_targetFunction.returnType)) { | 602 !isValidAsyncReturnType(_targetFunction.returnType)) { |
603 generateTypeError( | 603 generateTypeError( |
604 returnStatement, | 604 returnStatement, |
605 "Async function returned a Future," | 605 "Async function returned a Future," |
606 " was declared to return a ${_targetFunction.returnType}."); | 606 " was declared to return a ${_targetFunction.returnType}."); |
607 pop(); | 607 pop(); |
608 return; | 608 return; |
609 } | 609 } |
610 } else { | 610 } else { |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 @override | 1237 @override |
1238 void visitSwitchStatement(ir.SwitchStatement switchStatement) { | 1238 void visitSwitchStatement(ir.SwitchStatement switchStatement) { |
1239 Map<ir.Expression, ConstantValue> constants = | 1239 Map<ir.Expression, ConstantValue> constants = |
1240 _buildSwitchCaseConstants(switchStatement); | 1240 _buildSwitchCaseConstants(switchStatement); |
1241 | 1241 |
1242 // The switch case indices must match those computed in | 1242 // The switch case indices must match those computed in |
1243 // [KernelSwitchCaseJumpHandler]. | 1243 // [KernelSwitchCaseJumpHandler]. |
1244 bool hasContinue = false; | 1244 bool hasContinue = false; |
1245 Map<ir.SwitchCase, int> caseIndex = new Map<ir.SwitchCase, int>(); | 1245 Map<ir.SwitchCase, int> caseIndex = new Map<ir.SwitchCase, int>(); |
1246 int switchIndex = 1; | 1246 int switchIndex = 1; |
1247 bool hasDefault = false; | |
1248 for (ir.SwitchCase switchCase in switchStatement.cases) { | 1247 for (ir.SwitchCase switchCase in switchStatement.cases) { |
1249 if (SwitchContinueAnalysis.containsContinue(switchCase.body)) { | 1248 if (SwitchContinueAnalysis.containsContinue(switchCase.body)) { |
1250 hasContinue = true; | 1249 hasContinue = true; |
1251 } | 1250 } |
1252 if (switchCase.isDefault) { | |
1253 hasDefault = true; | |
1254 } | |
1255 caseIndex[switchCase] = switchIndex; | 1251 caseIndex[switchCase] = switchIndex; |
1256 switchIndex++; | 1252 switchIndex++; |
1257 } | 1253 } |
1258 | 1254 |
1259 JumpHandler jumpHandler = createJumpHandler(switchStatement); | 1255 JumpHandler jumpHandler = createJumpHandler(switchStatement); |
1260 if (!hasContinue) { | 1256 if (!hasContinue) { |
1261 // If the switch statement has no switch cases targeted by continue | 1257 // If the switch statement has no switch cases targeted by continue |
1262 // statements we encode the switch statement directly. | 1258 // statements we encode the switch statement directly. |
1263 _buildSimpleSwitchStatement(switchStatement, jumpHandler, constants); | 1259 _buildSimpleSwitchStatement(switchStatement, jumpHandler, constants); |
1264 } else { | 1260 } else { |
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2879 enterBlock.setBlockFlow( | 2875 enterBlock.setBlockFlow( |
2880 new HTryBlockInformation( | 2876 new HTryBlockInformation( |
2881 kernelBuilder.wrapStatementGraph(bodyGraph), | 2877 kernelBuilder.wrapStatementGraph(bodyGraph), |
2882 exception, | 2878 exception, |
2883 kernelBuilder.wrapStatementGraph(catchGraph), | 2879 kernelBuilder.wrapStatementGraph(catchGraph), |
2884 kernelBuilder.wrapStatementGraph(finallyGraph)), | 2880 kernelBuilder.wrapStatementGraph(finallyGraph)), |
2885 exitBlock); | 2881 exitBlock); |
2886 kernelBuilder.inTryStatement = previouslyInTryStatement; | 2882 kernelBuilder.inTryStatement = previouslyInTryStatement; |
2887 } | 2883 } |
2888 } | 2884 } |
OLD | NEW |