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 library dart2js.serialization.resolved_ast; | 5 library dart2js.serialization.resolved_ast; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart'; | 8 import '../common/resolution.dart'; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 FunctionExpression functionExpression = root.asFunctionExpression(); | 139 FunctionExpression functionExpression = root.asFunctionExpression(); |
140 if (functionExpression.getOrSet != null) { | 140 if (functionExpression.getOrSet != null) { |
141 // Getters/setters need the get/set token to be parsed. | 141 // Getters/setters need the get/set token to be parsed. |
142 objectEncoder.setInt( | 142 objectEncoder.setInt( |
143 Key.GET_OR_SET, functionExpression.getOrSet.charOffset); | 143 Key.GET_OR_SET, functionExpression.getOrSet.charOffset); |
144 } | 144 } |
145 } | 145 } |
146 } | 146 } |
147 objectEncoder.setEnum(Key.SUB_KIND, kind); | 147 objectEncoder.setEnum(Key.SUB_KIND, kind); |
148 root.accept(indexComputer); | 148 root.accept(indexComputer); |
| 149 objectEncoder.setBool(Key.CONTAINS_TRY, elements.containsTryStatement); |
149 if (resolvedAst.body != null) { | 150 if (resolvedAst.body != null) { |
150 int index = nodeIndices[resolvedAst.body]; | 151 int index = nodeIndices[resolvedAst.body]; |
151 assert(invariant(element, index != null, | 152 assert(invariant(element, index != null, |
152 message: | 153 message: "No index for body of $element: " |
153 "No index for body of $element: ${resolvedAst.body} ($nodeIndices)
.")); | 154 "${resolvedAst.body} ($nodeIndices).")); |
154 objectEncoder.setInt(Key.BODY, index); | 155 objectEncoder.setInt(Key.BODY, index); |
155 } | 156 } |
156 root.accept(this); | 157 root.accept(this); |
157 if (jumpTargetMap.isNotEmpty) { | 158 if (jumpTargetMap.isNotEmpty) { |
158 ListEncoder list = objectEncoder.createList(Key.JUMP_TARGETS); | 159 ListEncoder list = objectEncoder.createList(Key.JUMP_TARGETS); |
159 for (JumpTarget jumpTarget in jumpTargetMap.keys) { | 160 for (JumpTarget jumpTarget in jumpTargetMap.keys) { |
160 serializeJumpTarget(jumpTarget, list.createObject()); | 161 serializeJumpTarget(jumpTarget, list.createObject()); |
161 } | 162 } |
162 } | 163 } |
163 if (labelDefinitionMap.isNotEmpty) { | 164 if (labelDefinitionMap.isNotEmpty) { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 522 } |
522 } | 523 } |
523 | 524 |
524 AstKind kind = objectDecoder.getEnum(Key.SUB_KIND, AstKind.values); | 525 AstKind kind = objectDecoder.getEnum(Key.SUB_KIND, AstKind.values); |
525 Node root = computeNode(kind); | 526 Node root = computeNode(kind); |
526 TreeElementMapping elements = new TreeElementMapping(element); | 527 TreeElementMapping elements = new TreeElementMapping(element); |
527 AstIndexComputer indexComputer = new AstIndexComputer(); | 528 AstIndexComputer indexComputer = new AstIndexComputer(); |
528 Map<Node, int> nodeIndices = indexComputer.nodeIndices; | 529 Map<Node, int> nodeIndices = indexComputer.nodeIndices; |
529 List<Node> nodeList = indexComputer.nodeList; | 530 List<Node> nodeList = indexComputer.nodeList; |
530 root.accept(indexComputer); | 531 root.accept(indexComputer); |
| 532 elements.containsTryStatement = objectDecoder.getBool(Key.CONTAINS_TRY); |
| 533 |
531 Node body; | 534 Node body; |
532 int bodyNodeIndex = objectDecoder.getInt(Key.BODY, isOptional: true); | 535 int bodyNodeIndex = objectDecoder.getInt(Key.BODY, isOptional: true); |
533 if (bodyNodeIndex != null) { | 536 if (bodyNodeIndex != null) { |
534 assert(invariant(element, bodyNodeIndex < nodeList.length, | 537 assert(invariant(element, bodyNodeIndex < nodeList.length, |
535 message: "Body node index ${bodyNodeIndex} out of range. " | 538 message: "Body node index ${bodyNodeIndex} out of range. " |
536 "Node count: ${nodeList.length}")); | 539 "Node count: ${nodeList.length}")); |
537 body = nodeList[bodyNodeIndex]; | 540 body = nodeList[bodyNodeIndex]; |
538 } | 541 } |
539 | 542 |
540 List<JumpTarget> jumpTargets = <JumpTarget>[]; | 543 List<JumpTarget> jumpTargets = <JumpTarget>[]; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 } | 685 } |
683 assert(invariant(element, !resolvedAstMap.containsKey(element), | 686 assert(invariant(element, !resolvedAstMap.containsKey(element), |
684 message: "ResolvedAst has already been computed for $element.")); | 687 message: "ResolvedAst has already been computed for $element.")); |
685 resolvedAstMap[element] = | 688 resolvedAstMap[element] = |
686 new ParsedResolvedAst(element, root, body, elements, uri); | 689 new ParsedResolvedAst(element, root, body, elements, uri); |
687 } | 690 } |
688 } | 691 } |
689 | 692 |
690 const Key PARAMETER_NODE = const Key('parameter.node'); | 693 const Key PARAMETER_NODE = const Key('parameter.node'); |
691 const Key PARAMETER_INITIALIZER = const Key('parameter.initializer'); | 694 const Key PARAMETER_INITIALIZER = const Key('parameter.initializer'); |
OLD | NEW |