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

Unified Diff: pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart

Issue 1945263003: Serialize ParameterElement.node and ParameterElement.initializer for type inference (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
diff --git a/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart b/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
index 613bd6195968761aa842525475609f732ba2d255..633b65efb326cb549e36a2862f00977465544bac 100644
--- a/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
@@ -22,6 +22,7 @@ import '../tree/tree.dart';
import '../universe/selector.dart';
import '../util/util.dart';
import 'keys.dart';
+import 'modelz.dart';
import 'serialization.dart';
import 'serialization_util.dart';
@@ -165,6 +166,19 @@ class ResolvedAstSerializer extends Visitor {
serializeLabelDefinition(labelDefinition, list.createObject());
}
}
+ if (element is FunctionElement) {
+ FunctionElement function = element;
+ function.functionSignature.forEachParameter((ParameterElement parameter) {
+ ParameterElement parameterImpl = parameter.implementation;
+ // TODO(johnniwinther): Should we support element->node mapping as well?
+ getNodeDataEncoder(parameterImpl.node)
+ .setElement(PARAMETER_NODE, parameter);
+ if (parameter.initializer != null) {
+ getNodeDataEncoder(parameterImpl.initializer)
+ .setElement(PARAMETER_INITIALIZER, parameter);
+ }
+ });
+ }
}
/// Serialize [target] into [encoder].
@@ -203,7 +217,9 @@ class ResolvedAstSerializer extends Visitor {
/// Computes the [ObjectEncoder] for serializing data for [node].
ObjectEncoder getNodeDataEncoder(Node node) {
+ assert(invariant(element, node != null, message: "Node must be non-null."));
int id = nodeIndices[node];
+ assert(invariant(element, id != null, message: "Node without id: $node"));
return nodeData.putIfAbsent(id, () {
ObjectEncoder objectEncoder = nodeDataEncoder.createObject();
objectEncoder.setInt(Key.ID, id);
@@ -650,6 +666,18 @@ class ResolvedAstDeserializer {
resolvedAstMap[function] = new ParsedResolvedAst(function,
functionExpression, functionExpression.body, elements, uri);
}
+ // TODO(johnniwinther): Remove these when inference doesn't need `.node`
+ // and `.initializer` of [ParameterElement]s.
+ ParameterElementZ parameter =
+ objectDecoder.getElement(PARAMETER_NODE, isOptional: true);
+ if (parameter != null) {
+ parameter.node = node;
+ }
+ parameter =
+ objectDecoder.getElement(PARAMETER_INITIALIZER, isOptional: true);
+ if (parameter != null) {
+ parameter.initializer = node;
+ }
}
}
assert(invariant(element, !resolvedAstMap.containsKey(element),
@@ -658,3 +686,6 @@ class ResolvedAstDeserializer {
new ParsedResolvedAst(element, root, body, elements, uri);
}
}
+
+const Key PARAMETER_NODE = const Key('parameter.node');
+const Key PARAMETER_INITIALIZER = const Key('parameter.initializer');
« no previous file with comments | « pkg/compiler/lib/src/serialization/modelz.dart ('k') | tests/compiler/dart2js/serialization/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698