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

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

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor Created 3 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 unified diff | Download patch
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | pkg/kernel/lib/binary/tag.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_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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 bool insideExternalLibrary = false; 244 bool insideExternalLibrary = false;
245 245
246 visitLibrary(Library node) { 246 visitLibrary(Library node) {
247 insideExternalLibrary = node.isExternal; 247 insideExternalLibrary = node.isExternal;
248 writeByte(insideExternalLibrary ? 1 : 0); 248 writeByte(insideExternalLibrary ? 1 : 0);
249 writeCanonicalNameReference(getCanonicalNameOfLibrary(node)); 249 writeCanonicalNameReference(getCanonicalNameOfLibrary(node));
250 writeStringReference(node.name ?? ''); 250 writeStringReference(node.name ?? '');
251 // TODO(jensj): We save (almost) the same URI twice. 251 // TODO(jensj): We save (almost) the same URI twice.
252 writeUriReference(node.fileUri ?? ''); 252 writeUriReference(node.fileUri ?? '');
253 writeDeferredImports(node); 253 writeDeferredImports(node);
254 writeNodeList(node.typedefs);
254 writeNodeList(node.classes); 255 writeNodeList(node.classes);
255 writeNodeList(node.fields); 256 writeNodeList(node.fields);
256 writeNodeList(node.procedures); 257 writeNodeList(node.procedures);
257 } 258 }
258 259
259 void writeDeferredImports(Library library) { 260 void writeDeferredImports(Library library) {
260 _deferredImportIndexer = library.deferredImports.isEmpty 261 _deferredImportIndexer = library.deferredImports.isEmpty
261 ? const <DeferredImport, int>{} 262 ? const <DeferredImport, int>{}
262 : <DeferredImport, int>{}; 263 : <DeferredImport, int>{};
263 writeUInt30(library.deferredImports.length); 264 writeUInt30(library.deferredImports.length);
264 for (int i = 0; i < library.deferredImports.length; ++i) { 265 for (int i = 0; i < library.deferredImports.length; ++i) {
265 var importNode = library.deferredImports[i]; 266 var importNode = library.deferredImports[i];
266 _deferredImportIndexer[importNode] = i; 267 _deferredImportIndexer[importNode] = i;
267 writeDeferredImport(importNode); 268 writeDeferredImport(importNode);
268 } 269 }
269 } 270 }
270 271
271 void writeDeferredImport(DeferredImport node) { 272 void writeDeferredImport(DeferredImport node) {
272 writeLibraryReference(node.importedLibrary); 273 writeLibraryReference(node.importedLibrary);
273 writeStringReference(node.name); 274 writeStringReference(node.name);
274 } 275 }
275 276
277 void visitTypedef(Typedef node) {
278 writeCanonicalNameReference(getCanonicalNameOfTypedef(node));
279 writeOffset(node.fileOffset);
280 writeStringReference(node.name);
281 writeUriReference(node.fileUri ?? '');
282 writeNodeList(node.typeParameters);
283 writeNode(node.type);
284 }
285
276 void writeAnnotation(Expression annotation) { 286 void writeAnnotation(Expression annotation) {
277 _variableIndexer ??= new VariableIndexer(); 287 _variableIndexer ??= new VariableIndexer();
278 writeNode(annotation); 288 writeNode(annotation);
279 } 289 }
280 290
281 void writeAnnotationList(List<Expression> annotations) { 291 void writeAnnotationList(List<Expression> annotations) {
282 writeList(annotations, writeAnnotation); 292 writeList(annotations, writeAnnotation);
283 } 293 }
284 294
285 int _encodeClassFlags(bool isAbstract, ClassLevel level) { 295 int _encodeClassFlags(bool isAbstract, ClassLevel level) {
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 1012
1003 visitTypeParameterType(TypeParameterType node) { 1013 visitTypeParameterType(TypeParameterType node) {
1004 writeByte(Tag.TypeParameterType); 1014 writeByte(Tag.TypeParameterType);
1005 writeUInt30(_typeParameterIndexer[node.parameter]); 1015 writeUInt30(_typeParameterIndexer[node.parameter]);
1006 } 1016 }
1007 1017
1008 visitVectorType(VectorType node) { 1018 visitVectorType(VectorType node) {
1009 writeByte(Tag.VectorType); 1019 writeByte(Tag.VectorType);
1010 } 1020 }
1011 1021
1022 visitTypedefType(TypedefType node) {
1023 writeByte(Tag.TypedefType);
1024 writeReference(node.typedefReference);
1025 writeNodeList(node.typeArguments);
1026 }
1027
1012 visitTypeParameter(TypeParameter node) { 1028 visitTypeParameter(TypeParameter node) {
1013 writeStringReference(node.name ?? ''); 1029 writeStringReference(node.name ?? '');
1014 writeNode(node.bound); 1030 writeNode(node.bound);
1015 } 1031 }
1016 1032
1017 defaultNode(Node node) { 1033 defaultNode(Node node) {
1018 throw 'Unsupported node: $node'; 1034 throw 'Unsupported node: $node';
1019 } 1035 }
1020 } 1036 }
1021 1037
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 void flush() { 1349 void flush() {
1334 _sink.add(_buffer.sublist(0, length)); 1350 _sink.add(_buffer.sublist(0, length));
1335 _buffer = new Uint8List(SIZE); 1351 _buffer = new Uint8List(SIZE);
1336 length = 0; 1352 length = 0;
1337 } 1353 }
1338 1354
1339 void flushAndDestroy() { 1355 void flushAndDestroy() {
1340 _sink.add(_buffer.sublist(0, length)); 1356 _sink.add(_buffer.sublist(0, length));
1341 } 1357 }
1342 } 1358 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/binary/ast_from_binary.dart ('k') | pkg/kernel/lib/binary/tag.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698