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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_const_expr.dart

Issue 1966783003: First steps toward AST-based type inference involving closures. (Closed) Base URL: git@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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/summary/summarize_const_expr.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
index 59576a673d00085a992cdafecb077c5fd11ca8ab..f8f6aab2d4eb94ca2047d9a195cdd7141fc19022 100644
--- a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
@@ -143,6 +143,18 @@ abstract class AbstractConstExprSerializer {
EntityRefBuilder serializeIdentifier(Identifier identifier);
/**
+ * Return a pair of ints showing how the given [functionExpression] is nested
+ * within the constant currently being serialized. The first int indicates
+ * how many levels of function nesting must be popped in order to reach the
+ * parent of the [functionExpression]. The second int is the index of the
+ * [functionExpression] within its parent element.
+ *
+ * If the constant being summarized is in a context where local function
+ * references are not allowed, return `null`.
+ */
+ List<int> serializeFunctionExpression(FunctionExpression functionExpression);
+
+ /**
* Return [EntityRefBuilder] that corresponds to the given [expr], which
* must be a sequence of identifiers.
*/
@@ -303,8 +315,14 @@ abstract class AbstractConstExprSerializer {
_serializeCascadeExpression(expr);
} else if (expr is FunctionExpression) {
isValidConst = false;
- // TODO(scheglov) implement
- operations.add(UnlinkedConstOperation.pushNull);
+ List<int> indices = serializeFunctionExpression(expr);
+ if (indices != null) {
+ ints.addAll(serializeFunctionExpression(expr));
+ operations.add(UnlinkedConstOperation.pushLocalFunctionReference);
+ } else {
+ // Invalid expression; just push null.
+ operations.add(UnlinkedConstOperation.pushNull);
+ }
} else if (expr is FunctionExpressionInvocation) {
isValidConst = false;
// TODO(scheglov) implement

Powered by Google App Engine
This is Rietveld 408576698