Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart

Issue 1932183003: Handle deserialized compilation of closures (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 } 104 }
105 105
106 /// Serialize [ResolvedAst] that is defined in terms of an AST together with 106 /// Serialize [ResolvedAst] that is defined in terms of an AST together with
107 /// [TreeElements]. 107 /// [TreeElements].
108 void serializeParsed() { 108 void serializeParsed() {
109 objectEncoder.setUri( 109 objectEncoder.setUri(
110 Key.URI, 110 Key.URI,
111 elements.analyzedElement.compilationUnit.script.resourceUri, 111 elements.analyzedElement.compilationUnit.script.resourceUri,
112 elements.analyzedElement.compilationUnit.script.resourceUri); 112 elements.analyzedElement.compilationUnit.script.resourceUri);
113 if (resolvedAst.body != null) {
114 objectEncoder.setInt(Key.BODY, nodeIndices[resolvedAst.body]);
115 }
116 AstKind kind; 113 AstKind kind;
117 if (element.enclosingClass is EnumClassElement) { 114 if (element.enclosingClass is EnumClassElement) {
118 if (element.name == 'index') { 115 if (element.name == 'index') {
119 kind = AstKind.ENUM_INDEX_FIELD; 116 kind = AstKind.ENUM_INDEX_FIELD;
120 } else if (element.name == 'values') { 117 } else if (element.name == 'values') {
121 kind = AstKind.ENUM_VALUES_FIELD; 118 kind = AstKind.ENUM_VALUES_FIELD;
122 } else if (element.name == 'toString') { 119 } else if (element.name == 'toString') {
123 kind = AstKind.ENUM_TO_STRING; 120 kind = AstKind.ENUM_TO_STRING;
124 } else if (element.isConstructor) { 121 } else if (element.isConstructor) {
125 kind = AstKind.ENUM_CONSTRUCTOR; 122 kind = AstKind.ENUM_CONSTRUCTOR;
(...skipping 15 matching lines...) Expand all
141 FunctionExpression functionExpression = root.asFunctionExpression(); 138 FunctionExpression functionExpression = root.asFunctionExpression();
142 if (functionExpression.getOrSet != null) { 139 if (functionExpression.getOrSet != null) {
143 // Getters/setters need the get/set token to be parsed. 140 // Getters/setters need the get/set token to be parsed.
144 objectEncoder.setInt( 141 objectEncoder.setInt(
145 Key.GET_OR_SET, functionExpression.getOrSet.charOffset); 142 Key.GET_OR_SET, functionExpression.getOrSet.charOffset);
146 } 143 }
147 } 144 }
148 } 145 }
149 objectEncoder.setEnum(Key.SUB_KIND, kind); 146 objectEncoder.setEnum(Key.SUB_KIND, kind);
150 root.accept(indexComputer); 147 root.accept(indexComputer);
148 if (resolvedAst.body != null) {
149 int index = nodeIndices[resolvedAst.body];
150 assert(invariant(element, index != null,
151 message: "No index for body of $element: ${resolvedAst.body} ($nodeInd ices)."));
Siggi Cherem (dart-lang) 2016/04/30 00:08:11 nit: 80
Johnni Winther 2016/04/30 09:23:55 Done.
152 objectEncoder.setInt(Key.BODY, index);
153 }
151 root.accept(this); 154 root.accept(this);
152 if (jumpTargetMap.isNotEmpty) { 155 if (jumpTargetMap.isNotEmpty) {
153 ListEncoder list = objectEncoder.createList(Key.JUMP_TARGETS); 156 ListEncoder list = objectEncoder.createList(Key.JUMP_TARGETS);
154 for (JumpTarget jumpTarget in jumpTargetMap.keys) { 157 for (JumpTarget jumpTarget in jumpTargetMap.keys) {
155 serializeJumpTarget(jumpTarget, list.createObject()); 158 serializeJumpTarget(jumpTarget, list.createObject());
156 } 159 }
157 } 160 }
158 if (labelDefinitionMap.isNotEmpty) { 161 if (labelDefinitionMap.isNotEmpty) {
159 ListEncoder list = objectEncoder.createList(Key.LABEL_DEFINITIONS); 162 ListEncoder list = objectEncoder.createList(Key.LABEL_DEFINITIONS);
160 for (LabelDefinition labelDefinition in labelDefinitionMap.keys) { 163 for (LabelDefinition labelDefinition in labelDefinitionMap.keys) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 }); 485 });
483 } 486 }
484 } 487 }
485 488
486 AstKind kind = objectDecoder.getEnum(Key.SUB_KIND, AstKind.values); 489 AstKind kind = objectDecoder.getEnum(Key.SUB_KIND, AstKind.values);
487 Node root = computeNode(kind); 490 Node root = computeNode(kind);
488 TreeElementMapping elements = new TreeElementMapping(element); 491 TreeElementMapping elements = new TreeElementMapping(element);
489 AstIndexComputer indexComputer = new AstIndexComputer(); 492 AstIndexComputer indexComputer = new AstIndexComputer();
490 Map<Node, int> nodeIndices = indexComputer.nodeIndices; 493 Map<Node, int> nodeIndices = indexComputer.nodeIndices;
491 List<Node> nodeList = indexComputer.nodeList; 494 List<Node> nodeList = indexComputer.nodeList;
495 root.accept(indexComputer);
492 Node body; 496 Node body;
493 int bodyNodeIndex = objectDecoder.getInt(Key.BODY, isOptional: true); 497 int bodyNodeIndex = objectDecoder.getInt(Key.BODY, isOptional: true);
494 if (bodyNodeIndex != null) { 498 if (bodyNodeIndex != null) {
499 assert(invariant(element, bodyNodeIndex < nodeList.length,
500 message: "Body node index ${bodyNodeIndex} out of range. "
501 "Node count: ${nodeList.length}"));
495 body = nodeList[bodyNodeIndex]; 502 body = nodeList[bodyNodeIndex];
496 } 503 }
497 root.accept(indexComputer);
498 504
499 List<JumpTarget> jumpTargets = <JumpTarget>[]; 505 List<JumpTarget> jumpTargets = <JumpTarget>[];
500 Map<JumpTarget, List<int>> jumpTargetLabels = <JumpTarget, List<int>>{}; 506 Map<JumpTarget, List<int>> jumpTargetLabels = <JumpTarget, List<int>>{};
501 List<LabelDefinition> labelDefinitions = <LabelDefinition>[]; 507 List<LabelDefinition> labelDefinitions = <LabelDefinition>[];
502 508
503 ListDecoder jumpTargetsDecoder = 509 ListDecoder jumpTargetsDecoder =
504 objectDecoder.getList(Key.JUMP_TARGETS, isOptional: true); 510 objectDecoder.getList(Key.JUMP_TARGETS, isOptional: true);
505 if (jumpTargetsDecoder != null) { 511 if (jumpTargetsDecoder != null) {
506 for (int i = 0; i < jumpTargetsDecoder.length; i++) { 512 for (int i = 0; i < jumpTargetsDecoder.length; i++) {
507 ObjectDecoder decoder = jumpTargetsDecoder.getObject(i); 513 ObjectDecoder decoder = jumpTargetsDecoder.getObject(i);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); 620 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder);
615 if (nativeData != null) { 621 if (nativeData != null) {
616 elements.registerNativeData(node, nativeData); 622 elements.registerNativeData(node, nativeData);
617 } 623 }
618 } 624 }
619 } 625 }
620 } 626 }
621 return new ParsedResolvedAst(element, root, body, elements); 627 return new ParsedResolvedAst(element, root, body, elements);
622 } 628 }
623 } 629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698