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

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

Issue 2990783002: Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize t… (Closed)
Patch Set: Test for named parameters. 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
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_from_binary; 4 library kernel.ast_from_binary;
5 5
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import '../ast.dart'; 9 import '../ast.dart';
10 import '../transformations/flags.dart'; 10 import '../transformations/flags.dart';
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 var reference = canonicalName.getReference(); 431 var reference = canonicalName.getReference();
432 Typedef node = reference.node; 432 Typedef node = reference.node;
433 bool shouldWriteData = node == null || _isReadingLibraryImplementation; 433 bool shouldWriteData = node == null || _isReadingLibraryImplementation;
434 if (node == null) { 434 if (node == null) {
435 node = new Typedef(null, null, reference: reference); 435 node = new Typedef(null, null, reference: reference);
436 } 436 }
437 int fileOffset = readOffset(); 437 int fileOffset = readOffset();
438 String name = readStringReference(); 438 String name = readStringReference();
439 String fileUri = readUriReference(); 439 String fileUri = readUriReference();
440 readAndPushTypeParameterList(node.typeParameters, node); 440 readAndPushTypeParameterList(node.typeParameters, node);
441
442 int requiredParameterCount = readUInt();
443 var positionalParameters = readVariableDeclarationList();
444 var namedParameters = readVariableDeclarationList();
445 node.setParameters(
446 requiredParameterCount, positionalParameters, namedParameters);
447
441 var type = readDartType(); 448 var type = readDartType();
442 typeParameterStack.length = 0; 449 typeParameterStack.length = 0;
443 if (shouldWriteData) { 450 if (shouldWriteData) {
444 node.fileOffset = fileOffset; 451 node.fileOffset = fileOffset;
445 node.name = name; 452 node.name = name;
446 node.fileUri = fileUri; 453 node.fileUri = fileUri;
447 node.type = type; 454 node.type = type;
448 } 455 }
449 return node; 456 return node;
450 } 457 }
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 1221
1215 List<NamedExpression> readNamedExpressionList() { 1222 List<NamedExpression> readNamedExpressionList() {
1216 return new List<NamedExpression>.generate( 1223 return new List<NamedExpression>.generate(
1217 readUInt(), (i) => readNamedExpression()); 1224 readUInt(), (i) => readNamedExpression());
1218 } 1225 }
1219 1226
1220 NamedExpression readNamedExpression() { 1227 NamedExpression readNamedExpression() {
1221 return new NamedExpression(readStringReference(), readExpression()); 1228 return new NamedExpression(readStringReference(), readExpression());
1222 } 1229 }
1223 1230
1231 List<VariableDeclaration> readVariableDeclarationList() {
1232 return new List<VariableDeclaration>.generate(
1233 readUInt(), (i) => readVariableDeclaration());
1234 }
1235
1224 List<VariableDeclaration> readAndPushVariableDeclarationList() { 1236 List<VariableDeclaration> readAndPushVariableDeclarationList() {
1225 return new List<VariableDeclaration>.generate( 1237 return new List<VariableDeclaration>.generate(
1226 readUInt(), (i) => readAndPushVariableDeclaration()); 1238 readUInt(), (i) => readAndPushVariableDeclaration());
1227 } 1239 }
1228 1240
1229 VariableDeclaration readAndPushVariableDeclarationOption() { 1241 VariableDeclaration readAndPushVariableDeclarationOption() {
1230 return readAndCheckOptionTag() ? readAndPushVariableDeclaration() : null; 1242 return readAndCheckOptionTag() ? readAndPushVariableDeclaration() : null;
1231 } 1243 }
1232 1244
1233 VariableDeclaration readAndPushVariableDeclaration() { 1245 VariableDeclaration readAndPushVariableDeclaration() {
(...skipping 14 matching lines...) Expand all
1248 ..fileOffset = offset 1260 ..fileOffset = offset
1249 ..fileEqualsOffset = fileEqualsOffset; 1261 ..fileEqualsOffset = fileEqualsOffset;
1250 } 1262 }
1251 1263
1252 int readOffset() { 1264 int readOffset() {
1253 // Offset is saved as unsigned, 1265 // Offset is saved as unsigned,
1254 // but actually ranges from -1 and up (thus the -1) 1266 // but actually ranges from -1 and up (thus the -1)
1255 return readUInt() - 1; 1267 return readUInt() - 1;
1256 } 1268 }
1257 } 1269 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698