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

Side by Side Diff: pkg/kernel/lib/binary/ast_to_binary.dart

Issue 2985293002: Add optional FunctionType.positionalParameterNames and use them to resynthesize function-type forma… (Closed)
Patch Set: Created 3 years, 4 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 library kernel.ast_to_binary; 4 library kernel.ast_to_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import 'tag.dart'; 8 import 'tag.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 writeNodeList(node.typeArguments); 1108 writeNodeList(node.typeArguments);
1109 } 1109 }
1110 } 1110 }
1111 1111
1112 visitFunctionType(FunctionType node) { 1112 visitFunctionType(FunctionType node) {
1113 if (node.requiredParameterCount == node.positionalParameters.length && 1113 if (node.requiredParameterCount == node.positionalParameters.length &&
1114 node.typeParameters.isEmpty && 1114 node.typeParameters.isEmpty &&
1115 node.namedParameters.isEmpty) { 1115 node.namedParameters.isEmpty) {
1116 writeByte(Tag.SimpleFunctionType); 1116 writeByte(Tag.SimpleFunctionType);
1117 writeNodeList(node.positionalParameters); 1117 writeNodeList(node.positionalParameters);
1118 writeStringReferenceList(node.positionalParameterNames);
1118 writeNode(node.returnType); 1119 writeNode(node.returnType);
1119 } else { 1120 } else {
1120 writeByte(Tag.FunctionType); 1121 writeByte(Tag.FunctionType);
1121 _typeParameterIndexer.enter(node.typeParameters); 1122 _typeParameterIndexer.enter(node.typeParameters);
1122 writeNodeList(node.typeParameters); 1123 writeNodeList(node.typeParameters);
1123 writeUInt30(node.requiredParameterCount); 1124 writeUInt30(node.requiredParameterCount);
1124 writeUInt30( 1125 writeUInt30(
1125 node.positionalParameters.length + node.namedParameters.length); 1126 node.positionalParameters.length + node.namedParameters.length);
1126 writeNodeList(node.positionalParameters); 1127 writeNodeList(node.positionalParameters);
1127 writeNodeList(node.namedParameters); 1128 writeNodeList(node.namedParameters);
1129 writeStringReferenceList(node.positionalParameterNames);
1128 writeNode(node.returnType); 1130 writeNode(node.returnType);
1129 _typeParameterIndexer.exit(node.typeParameters); 1131 _typeParameterIndexer.exit(node.typeParameters);
1130 } 1132 }
1131 } 1133 }
1132 1134
1133 visitNamedType(NamedType node) { 1135 visitNamedType(NamedType node) {
1134 writeStringReference(node.name); 1136 writeStringReference(node.name);
1135 writeNode(node.type); 1137 writeNode(node.type);
1136 } 1138 }
1137 1139
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 putOptional(node.documentationComment); 1380 putOptional(node.documentationComment);
1379 super.visitConstructor(node); 1381 super.visitConstructor(node);
1380 } 1382 }
1381 1383
1382 @override 1384 @override
1383 visitField(Field node) { 1385 visitField(Field node) {
1384 putOptional(node.documentationComment); 1386 putOptional(node.documentationComment);
1385 super.visitField(node); 1387 super.visitField(node);
1386 } 1388 }
1387 1389
1390 @override
1391 visitFunctionType(FunctionType node) {
1392 node.positionalParameterNames.forEach(put);
1393 super.visitFunctionType(node);
1394 }
1395
1388 visitNamedExpression(NamedExpression node) { 1396 visitNamedExpression(NamedExpression node) {
1389 put(node.name); 1397 put(node.name);
1390 node.visitChildren(this); 1398 node.visitChildren(this);
1391 } 1399 }
1392 1400
1393 @override 1401 @override
1394 visitProcedure(Procedure node) { 1402 visitProcedure(Procedure node) {
1395 putOptional(node.documentationComment); 1403 putOptional(node.documentationComment);
1396 super.visitProcedure(node); 1404 super.visitProcedure(node);
1397 } 1405 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 _sink.add(_buffer.sublist(0, length)); 1544 _sink.add(_buffer.sublist(0, length));
1537 _buffer = new Uint8List(SIZE); 1545 _buffer = new Uint8List(SIZE);
1538 flushedLength += length; 1546 flushedLength += length;
1539 length = 0; 1547 length = 0;
1540 } 1548 }
1541 1549
1542 void flushAndDestroy() { 1550 void flushAndDestroy() {
1543 _sink.add(_buffer.sublist(0, length)); 1551 _sink.add(_buffer.sublist(0, length));
1544 } 1552 }
1545 } 1553 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698