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

Unified Diff: pkg/compiler/lib/src/parser/node_listener.dart

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Fix comments. Created 4 years 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/parser/node_listener.dart
diff --git a/pkg/compiler/lib/src/parser/node_listener.dart b/pkg/compiler/lib/src/parser/node_listener.dart
index 4dc325cef5becfcb281cae7f5dc8aaa55653dc84..92aba071f35f88ec5319edbb7150ba6684fc0d8a 100644
--- a/pkg/compiler/lib/src/parser/node_listener.dart
+++ b/pkg/compiler/lib/src/parser/node_listener.dart
@@ -120,10 +120,31 @@ class NodeListener extends ElementListener {
NodeList typeParameters = popNode();
Identifier name = popNode();
TypeAnnotation returnType = popNode();
- pushNode(new Typedef(
+ bool isNewSyntax = false;
+ pushNode(new Typedef(isNewSyntax,
returnType, name, typeParameters, formals, typedefKeyword, endToken));
}
+ void endNewFunctionTypeAlias(Token typedefKeyword, Token endToken) {
+ NewFunctionType type = popNode();
+ NodeList typeParameters = popNode();
+ Identifier name = popNode();
+ // TODO(floitsch): keep using the `FunctionType' node.
+ // TODO(floitsch): keep track of generic function arguments. At the
+ // moment they are replaced by the typedef arguments.
+ bool isNewSyntax = true;
+ pushNode(new Typedef(isNewSyntax,
+ type.returnType, name, typeParameters, type.formals,
+ typedefKeyword, endToken));
+ }
+
+ void endFunctionType(Token beginToken, Token endToken) {
+ NodeList formals = popNode();
+ NodeList typeParameters = popNode();
+ TypeAnnotation returnType = popNode();
+ pushNode(new NewFunctionType(returnType, typeParameters, formals));
+ }
+
void endNamedMixinApplication(
Token classKeyword, Token implementsKeyword, Token endToken) {
NodeList interfaces = (implementsKeyword != null) ? popNode() : null;

Powered by Google App Engine
This is Rietveld 408576698