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

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

Issue 2972343002: [kernel] Insert kernel bodies into VM heap (Closed)
Patch Set: Rebased 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 isSyntheticMixinImplementationFlag | 375 isSyntheticMixinImplementationFlag |
376 levelFlags; 376 levelFlags;
377 } 377 }
378 378
379 visitClass(Class node) { 379 visitClass(Class node) {
380 int flags = _encodeClassFlags(node.isAbstract, node.isEnum, 380 int flags = _encodeClassFlags(node.isAbstract, node.isEnum,
381 node.isSyntheticMixinImplementation, node.level); 381 node.isSyntheticMixinImplementation, node.level);
382 if (node.canonicalName == null) { 382 if (node.canonicalName == null) {
383 throw 'Missing canonical name for $node'; 383 throw 'Missing canonical name for $node';
384 } 384 }
385 node.binaryOffset = _sink.flushedLength + _sink.length;
386 writeByte(Tag.Class); 385 writeByte(Tag.Class);
387 writeCanonicalNameReference(getCanonicalNameOfClass(node)); 386 writeCanonicalNameReference(getCanonicalNameOfClass(node));
388 writeOffset(node.fileOffset); 387 writeOffset(node.fileOffset);
389 writeOffset(node.fileEndOffset); 388 writeOffset(node.fileEndOffset);
390 writeByte(flags); 389 writeByte(flags);
391 writeStringReference(node.name ?? ''); 390 writeStringReference(node.name ?? '');
392 writeUriReference(node.fileUri ?? ''); 391 writeUriReference(node.fileUri ?? '');
393 writeStringReference(node.documentationComment ?? ''); 392 writeStringReference(node.documentationComment ?? '');
394 writeAnnotationList(node.annotations); 393 writeAnnotationList(node.annotations);
395 _typeParameterIndexer.enter(node.typeParameters); 394 _typeParameterIndexer.enter(node.typeParameters);
(...skipping 12 matching lines...) Expand all
408 visitConstructor(Constructor node) { 407 visitConstructor(Constructor node) {
409 if (node.canonicalName == null) { 408 if (node.canonicalName == null) {
410 throw 'Missing canonical name for $node'; 409 throw 'Missing canonical name for $node';
411 } 410 }
412 _variableIndexer = new VariableIndexer(); 411 _variableIndexer = new VariableIndexer();
413 writeByte(Tag.Constructor); 412 writeByte(Tag.Constructor);
414 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 413 writeCanonicalNameReference(getCanonicalNameOfMember(node));
415 writeOffset(node.fileOffset); 414 writeOffset(node.fileOffset);
416 writeOffset(node.fileEndOffset); 415 writeOffset(node.fileEndOffset);
417 writeByte(node.flags); 416 writeByte(node.flags);
418 assert(node.parent is Class);
419 Class parent = node.parent;
420 writeUInt30(parent.binaryOffset);
421 writeName(node.name ?? _emptyName); 417 writeName(node.name ?? _emptyName);
422 writeStringReference(node.documentationComment ?? ''); 418 writeStringReference(node.documentationComment ?? '');
423 writeAnnotationList(node.annotations); 419 writeAnnotationList(node.annotations);
424 assert(node.function.typeParameters.isEmpty); 420 assert(node.function.typeParameters.isEmpty);
425 writeNode(node.function); 421 writeNode(node.function);
426 // Parameters are in scope in the initializers. 422 // Parameters are in scope in the initializers.
427 _variableIndexer.restoreScope(node.function.positionalParameters.length + 423 _variableIndexer.restoreScope(node.function.positionalParameters.length +
428 node.function.namedParameters.length); 424 node.function.namedParameters.length);
429 writeNodeList(node.initializers); 425 writeNodeList(node.initializers);
430 _variableIndexer = null; 426 _variableIndexer = null;
431 } 427 }
432 428
433 visitProcedure(Procedure node) { 429 visitProcedure(Procedure node) {
434 if (node.canonicalName == null) { 430 if (node.canonicalName == null) {
435 throw 'Missing canonical name for $node'; 431 throw 'Missing canonical name for $node';
436 } 432 }
437 _variableIndexer = new VariableIndexer(); 433 _variableIndexer = new VariableIndexer();
438 writeByte(Tag.Procedure); 434 writeByte(Tag.Procedure);
439 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 435 writeCanonicalNameReference(getCanonicalNameOfMember(node));
440 writeOffset(node.fileOffset); 436 writeOffset(node.fileOffset);
441 writeOffset(node.fileEndOffset); 437 writeOffset(node.fileEndOffset);
442 writeByte(node.kind.index); 438 writeByte(node.kind.index);
443 writeByte(node.flags); 439 writeByte(node.flags);
444 if (node.parent is Class) {
445 Class parent = node.parent;
446 writeUInt30(parent.binaryOffset);
447 } else {
448 writeUInt30(0); // 0 is a valid offset, but not for a class.
449 }
450 writeName(node.name ?? ''); 440 writeName(node.name ?? '');
451 writeUriReference(node.fileUri ?? ''); 441 writeUriReference(node.fileUri ?? '');
452 writeStringReference(node.documentationComment ?? ''); 442 writeStringReference(node.documentationComment ?? '');
453 writeAnnotationList(node.annotations); 443 writeAnnotationList(node.annotations);
454 writeOptionalNode(node.function); 444 writeOptionalNode(node.function);
455 _variableIndexer = null; 445 _variableIndexer = null;
456 } 446 }
457 447
458 visitField(Field node) { 448 visitField(Field node) {
459 if (node.canonicalName == null) { 449 if (node.canonicalName == null) {
460 throw 'Missing canonical name for $node'; 450 throw 'Missing canonical name for $node';
461 } 451 }
462 _variableIndexer = new VariableIndexer(); 452 _variableIndexer = new VariableIndexer();
463 writeByte(Tag.Field); 453 writeByte(Tag.Field);
464 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 454 writeCanonicalNameReference(getCanonicalNameOfMember(node));
465 writeOffset(node.fileOffset); 455 writeOffset(node.fileOffset);
466 writeOffset(node.fileEndOffset); 456 writeOffset(node.fileEndOffset);
467 writeByte(node.flags); 457 writeByte(node.flags);
468 if (node.parent is Class) {
469 Class parent = node.parent;
470 writeUInt30(parent.binaryOffset);
471 } else {
472 writeUInt30(0); // 0 is a valid offset, but not for a class.
473 }
474 writeName(node.name); 458 writeName(node.name);
475 writeUriReference(node.fileUri ?? ''); 459 writeUriReference(node.fileUri ?? '');
476 writeStringReference(node.documentationComment ?? ''); 460 writeStringReference(node.documentationComment ?? '');
477 writeAnnotationList(node.annotations); 461 writeAnnotationList(node.annotations);
478 writeNode(node.type); 462 writeNode(node.type);
479 writeOptionalNode(node.initializer); 463 writeOptionalNode(node.initializer);
480 _variableIndexer = null; 464 _variableIndexer = null;
481 } 465 }
482 466
483 visitInvalidInitializer(InvalidInitializer node) { 467 visitInvalidInitializer(InvalidInitializer node) {
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 writeByte(Tag.VectorType); 1135 writeByte(Tag.VectorType);
1152 } 1136 }
1153 1137
1154 visitTypedefType(TypedefType node) { 1138 visitTypedefType(TypedefType node) {
1155 writeByte(Tag.TypedefType); 1139 writeByte(Tag.TypedefType);
1156 writeReference(node.typedefReference); 1140 writeReference(node.typedefReference);
1157 writeNodeList(node.typeArguments); 1141 writeNodeList(node.typeArguments);
1158 } 1142 }
1159 1143
1160 visitTypeParameter(TypeParameter node) { 1144 visitTypeParameter(TypeParameter node) {
1161 node.binaryOffset = _sink.flushedLength + _sink.length;
1162 writeStringReference(node.name ?? ''); 1145 writeStringReference(node.name ?? '');
1163 writeNode(node.bound); 1146 writeNode(node.bound);
1164 } 1147 }
1165 1148
1166 defaultNode(Node node) { 1149 defaultNode(Node node) {
1167 throw 'Unsupported node: $node'; 1150 throw 'Unsupported node: $node';
1168 } 1151 }
1169 } 1152 }
1170 1153
1171 typedef bool LibraryFilter(Library _); 1154 typedef bool LibraryFilter(Library _);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 _sink.add(_buffer.sublist(0, length)); 1524 _sink.add(_buffer.sublist(0, length));
1542 _buffer = new Uint8List(SIZE); 1525 _buffer = new Uint8List(SIZE);
1543 flushedLength += length; 1526 flushedLength += length;
1544 length = 0; 1527 length = 0;
1545 } 1528 }
1546 1529
1547 void flushAndDestroy() { 1530 void flushAndDestroy() {
1548 _sink.add(_buffer.sublist(0, length)); 1531 _sink.add(_buffer.sublist(0, length));
1549 } 1532 }
1550 } 1533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698