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

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

Issue 2750013002: [kernel] Debugging of switch statement (Closed)
Patch Set: Take #2: Update switch case to include list of positions Created 3 years, 9 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 writeByte(0); 214 writeByte(0);
215 } else { 215 } else {
216 writeUInt30(name.index + 1); 216 writeUInt30(name.index + 1);
217 } 217 }
218 } 218 }
219 219
220 void writeLibraryReference(Library node) { 220 void writeLibraryReference(Library node) {
221 writeCanonicalNameReference(node.canonicalName); 221 writeCanonicalNameReference(node.canonicalName);
222 } 222 }
223 223
224 writeOffset(TreeNode node, int offset) { 224 writeOffset(int offset) {
225 // TODO(jensj): Delta-encoding. 225 // TODO(jensj): Delta-encoding.
226 // File offset ranges from -1 and up, 226 // File offset ranges from -1 and up,
227 // but is here saved as unsigned (thus the +1) 227 // but is here saved as unsigned (thus the +1)
228 writeUInt30(offset + 1); 228 writeUInt30(offset + 1);
229 } 229 }
230 230
231 void writeClassReference(Class class_, {bool allowNull: false}) { 231 void writeClassReference(Class class_, {bool allowNull: false}) {
232 if (class_ == null && !allowNull) { 232 if (class_ == null && !allowNull) {
233 throw 'Expected a class reference to be valid but was `null`.'; 233 throw 'Expected a class reference to be valid but was `null`.';
234 } 234 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return abstactFlag | levelFlags; 298 return abstactFlag | levelFlags;
299 } 299 }
300 300
301 visitClass(Class node) { 301 visitClass(Class node) {
302 int flags = _encodeClassFlags(node.isAbstract, node.level); 302 int flags = _encodeClassFlags(node.isAbstract, node.level);
303 if (node.canonicalName == null) { 303 if (node.canonicalName == null) {
304 throw 'Missing canonical name for $node'; 304 throw 'Missing canonical name for $node';
305 } 305 }
306 writeByte(Tag.Class); 306 writeByte(Tag.Class);
307 writeCanonicalNameReference(getCanonicalNameOfClass(node)); 307 writeCanonicalNameReference(getCanonicalNameOfClass(node));
308 writeOffset(node, node.fileOffset); 308 writeOffset(node.fileOffset);
309 writeByte(flags); 309 writeByte(flags);
310 writeStringReference(node.name ?? ''); 310 writeStringReference(node.name ?? '');
311 writeUriReference(node.fileUri ?? ''); 311 writeUriReference(node.fileUri ?? '');
312 writeAnnotationList(node.annotations); 312 writeAnnotationList(node.annotations);
313 _typeParameterIndexer.enter(node.typeParameters); 313 _typeParameterIndexer.enter(node.typeParameters);
314 writeNodeList(node.typeParameters); 314 writeNodeList(node.typeParameters);
315 writeOptionalNode(node.supertype); 315 writeOptionalNode(node.supertype);
316 writeOptionalNode(node.mixedInType); 316 writeOptionalNode(node.mixedInType);
317 writeNodeList(node.implementedTypes); 317 writeNodeList(node.implementedTypes);
318 writeNodeList(node.fields); 318 writeNodeList(node.fields);
319 writeNodeList(node.constructors); 319 writeNodeList(node.constructors);
320 writeNodeList(node.procedures); 320 writeNodeList(node.procedures);
321 _typeParameterIndexer.exit(node.typeParameters); 321 _typeParameterIndexer.exit(node.typeParameters);
322 } 322 }
323 323
324 static final Name _emptyName = new Name(''); 324 static final Name _emptyName = new Name('');
325 325
326 visitConstructor(Constructor node) { 326 visitConstructor(Constructor node) {
327 if (node.canonicalName == null) { 327 if (node.canonicalName == null) {
328 throw 'Missing canonical name for $node'; 328 throw 'Missing canonical name for $node';
329 } 329 }
330 _variableIndexer = new VariableIndexer(); 330 _variableIndexer = new VariableIndexer();
331 writeByte(Tag.Constructor); 331 writeByte(Tag.Constructor);
332 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 332 writeCanonicalNameReference(getCanonicalNameOfMember(node));
333 writeOffset(node, node.fileOffset); 333 writeOffset(node.fileOffset);
334 writeOffset(node, node.fileEndOffset); 334 writeOffset(node.fileEndOffset);
335 writeByte(node.flags); 335 writeByte(node.flags);
336 writeName(node.name ?? _emptyName); 336 writeName(node.name ?? _emptyName);
337 writeAnnotationList(node.annotations); 337 writeAnnotationList(node.annotations);
338 assert(node.function.typeParameters.isEmpty); 338 assert(node.function.typeParameters.isEmpty);
339 writeNode(node.function); 339 writeNode(node.function);
340 // Parameters are in scope in the initializers. 340 // Parameters are in scope in the initializers.
341 _variableIndexer.restoreScope(node.function.positionalParameters.length + 341 _variableIndexer.restoreScope(node.function.positionalParameters.length +
342 node.function.namedParameters.length); 342 node.function.namedParameters.length);
343 writeNodeList(node.initializers); 343 writeNodeList(node.initializers);
344 _variableIndexer = null; 344 _variableIndexer = null;
345 } 345 }
346 346
347 visitProcedure(Procedure node) { 347 visitProcedure(Procedure node) {
348 if (node.canonicalName == null) { 348 if (node.canonicalName == null) {
349 throw 'Missing canonical name for $node'; 349 throw 'Missing canonical name for $node';
350 } 350 }
351 _variableIndexer = new VariableIndexer(); 351 _variableIndexer = new VariableIndexer();
352 writeByte(Tag.Procedure); 352 writeByte(Tag.Procedure);
353 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 353 writeCanonicalNameReference(getCanonicalNameOfMember(node));
354 writeOffset(node, node.fileOffset); 354 writeOffset(node.fileOffset);
355 writeOffset(node, node.fileEndOffset); 355 writeOffset(node.fileEndOffset);
356 writeByte(node.kind.index); 356 writeByte(node.kind.index);
357 writeByte(node.flags); 357 writeByte(node.flags);
358 writeName(node.name ?? ''); 358 writeName(node.name ?? '');
359 writeUriReference(node.fileUri ?? ''); 359 writeUriReference(node.fileUri ?? '');
360 writeAnnotationList(node.annotations); 360 writeAnnotationList(node.annotations);
361 writeOptionalNode(node.function); 361 writeOptionalNode(node.function);
362 _variableIndexer = null; 362 _variableIndexer = null;
363 } 363 }
364 364
365 visitField(Field node) { 365 visitField(Field node) {
366 if (node.canonicalName == null) { 366 if (node.canonicalName == null) {
367 throw 'Missing canonical name for $node'; 367 throw 'Missing canonical name for $node';
368 } 368 }
369 _variableIndexer = new VariableIndexer(); 369 _variableIndexer = new VariableIndexer();
370 writeByte(Tag.Field); 370 writeByte(Tag.Field);
371 writeCanonicalNameReference(getCanonicalNameOfMember(node)); 371 writeCanonicalNameReference(getCanonicalNameOfMember(node));
372 writeOffset(node, node.fileOffset); 372 writeOffset(node.fileOffset);
373 writeOffset(node, node.fileEndOffset); 373 writeOffset(node.fileEndOffset);
374 writeByte(node.flags); 374 writeByte(node.flags);
375 writeName(node.name); 375 writeName(node.name);
376 writeUriReference(node.fileUri ?? ''); 376 writeUriReference(node.fileUri ?? '');
377 writeAnnotationList(node.annotations); 377 writeAnnotationList(node.annotations);
378 writeNode(node.type); 378 writeNode(node.type);
379 writeOptionalInferredValue(node.inferredValue); 379 writeOptionalInferredValue(node.inferredValue);
380 writeOptionalNode(node.initializer); 380 writeOptionalNode(node.initializer);
381 _variableIndexer = null; 381 _variableIndexer = null;
382 } 382 }
383 383
(...skipping 26 matching lines...) Expand all
410 410
411 visitFunctionNode(FunctionNode node) { 411 visitFunctionNode(FunctionNode node) {
412 assert(_variableIndexer != null); 412 assert(_variableIndexer != null);
413 _variableIndexer.pushScope(); 413 _variableIndexer.pushScope();
414 var oldLabels = _labelIndexer; 414 var oldLabels = _labelIndexer;
415 _labelIndexer = new LabelIndexer(); 415 _labelIndexer = new LabelIndexer();
416 var oldCases = _switchCaseIndexer; 416 var oldCases = _switchCaseIndexer;
417 _switchCaseIndexer = new SwitchCaseIndexer(); 417 _switchCaseIndexer = new SwitchCaseIndexer();
418 // Note: FunctionNode has no tag. 418 // Note: FunctionNode has no tag.
419 _typeParameterIndexer.enter(node.typeParameters); 419 _typeParameterIndexer.enter(node.typeParameters);
420 writeOffset(node, node.fileOffset); 420 writeOffset(node.fileOffset);
421 writeOffset(node, node.fileEndOffset); 421 writeOffset(node.fileEndOffset);
422 writeByte(node.asyncMarker.index); 422 writeByte(node.asyncMarker.index);
423 writeByte(node.dartAsyncMarker.index); 423 writeByte(node.dartAsyncMarker.index);
424 writeNodeList(node.typeParameters); 424 writeNodeList(node.typeParameters);
425 writeUInt30(node.requiredParameterCount); 425 writeUInt30(node.requiredParameterCount);
426 writeVariableDeclarationList(node.positionalParameters); 426 writeVariableDeclarationList(node.positionalParameters);
427 writeVariableDeclarationList(node.namedParameters); 427 writeVariableDeclarationList(node.namedParameters);
428 writeNode(node.returnType); 428 writeNode(node.returnType);
429 writeOptionalInferredValue(node.inferredReturnValue); 429 writeOptionalInferredValue(node.inferredReturnValue);
430 writeOptionalNode(node.body); 430 writeOptionalNode(node.body);
431 _labelIndexer = oldLabels; 431 _labelIndexer = oldLabels;
432 _switchCaseIndexer = oldCases; 432 _switchCaseIndexer = oldCases;
433 _typeParameterIndexer.exit(node.typeParameters); 433 _typeParameterIndexer.exit(node.typeParameters);
434 _variableIndexer.popScope(); 434 _variableIndexer.popScope();
435 } 435 }
436 436
437 visitInvalidExpression(InvalidExpression node) { 437 visitInvalidExpression(InvalidExpression node) {
438 writeByte(Tag.InvalidExpression); 438 writeByte(Tag.InvalidExpression);
439 } 439 }
440 440
441 visitVariableGet(VariableGet node) { 441 visitVariableGet(VariableGet node) {
442 assert(_variableIndexer != null); 442 assert(_variableIndexer != null);
443 int index = _variableIndexer[node.variable]; 443 int index = _variableIndexer[node.variable];
444 assert(index != null); 444 assert(index != null);
445 if (index & Tag.SpecializedPayloadMask == index && 445 if (index & Tag.SpecializedPayloadMask == index &&
446 node.promotedType == null) { 446 node.promotedType == null) {
447 writeByte(Tag.SpecializedVariableGet + index); 447 writeByte(Tag.SpecializedVariableGet + index);
448 writeOffset(node, node.fileOffset); 448 writeOffset(node.fileOffset);
449 } else { 449 } else {
450 writeByte(Tag.VariableGet); 450 writeByte(Tag.VariableGet);
451 writeOffset(node, node.fileOffset); 451 writeOffset(node.fileOffset);
452 writeUInt30(_variableIndexer[node.variable]); 452 writeUInt30(_variableIndexer[node.variable]);
453 writeOptionalNode(node.promotedType); 453 writeOptionalNode(node.promotedType);
454 } 454 }
455 } 455 }
456 456
457 visitVariableSet(VariableSet node) { 457 visitVariableSet(VariableSet node) {
458 assert(_variableIndexer != null); 458 assert(_variableIndexer != null);
459 int index = _variableIndexer[node.variable]; 459 int index = _variableIndexer[node.variable];
460 if (index & Tag.SpecializedPayloadMask == index) { 460 if (index & Tag.SpecializedPayloadMask == index) {
461 writeByte(Tag.SpecializedVariableSet + index); 461 writeByte(Tag.SpecializedVariableSet + index);
462 writeOffset(node, node.fileOffset); 462 writeOffset(node.fileOffset);
463 writeNode(node.value); 463 writeNode(node.value);
464 } else { 464 } else {
465 writeByte(Tag.VariableSet); 465 writeByte(Tag.VariableSet);
466 writeOffset(node, node.fileOffset); 466 writeOffset(node.fileOffset);
467 writeUInt30(_variableIndexer[node.variable]); 467 writeUInt30(_variableIndexer[node.variable]);
468 writeNode(node.value); 468 writeNode(node.value);
469 } 469 }
470 } 470 }
471 471
472 visitPropertyGet(PropertyGet node) { 472 visitPropertyGet(PropertyGet node) {
473 writeByte(Tag.PropertyGet); 473 writeByte(Tag.PropertyGet);
474 writeOffset(node, node.fileOffset); 474 writeOffset(node.fileOffset);
475 writeNode(node.receiver); 475 writeNode(node.receiver);
476 writeName(node.name); 476 writeName(node.name);
477 writeReference(node.interfaceTargetReference); 477 writeReference(node.interfaceTargetReference);
478 } 478 }
479 479
480 visitPropertySet(PropertySet node) { 480 visitPropertySet(PropertySet node) {
481 writeByte(Tag.PropertySet); 481 writeByte(Tag.PropertySet);
482 writeOffset(node, node.fileOffset); 482 writeOffset(node.fileOffset);
483 writeNode(node.receiver); 483 writeNode(node.receiver);
484 writeName(node.name); 484 writeName(node.name);
485 writeNode(node.value); 485 writeNode(node.value);
486 writeReference(node.interfaceTargetReference); 486 writeReference(node.interfaceTargetReference);
487 } 487 }
488 488
489 visitSuperPropertyGet(SuperPropertyGet node) { 489 visitSuperPropertyGet(SuperPropertyGet node) {
490 writeByte(Tag.SuperPropertyGet); 490 writeByte(Tag.SuperPropertyGet);
491 writeName(node.name); 491 writeName(node.name);
492 writeReference(node.interfaceTargetReference); 492 writeReference(node.interfaceTargetReference);
(...skipping 14 matching lines...) Expand all
507 507
508 visitDirectPropertySet(DirectPropertySet node) { 508 visitDirectPropertySet(DirectPropertySet node) {
509 writeByte(Tag.DirectPropertySet); 509 writeByte(Tag.DirectPropertySet);
510 writeNode(node.receiver); 510 writeNode(node.receiver);
511 writeReference(node.targetReference); 511 writeReference(node.targetReference);
512 writeNode(node.value); 512 writeNode(node.value);
513 } 513 }
514 514
515 visitStaticGet(StaticGet node) { 515 visitStaticGet(StaticGet node) {
516 writeByte(Tag.StaticGet); 516 writeByte(Tag.StaticGet);
517 writeOffset(node, node.fileOffset); 517 writeOffset(node.fileOffset);
518 writeReference(node.targetReference); 518 writeReference(node.targetReference);
519 } 519 }
520 520
521 visitStaticSet(StaticSet node) { 521 visitStaticSet(StaticSet node) {
522 writeByte(Tag.StaticSet); 522 writeByte(Tag.StaticSet);
523 writeOffset(node, node.fileOffset); 523 writeOffset(node.fileOffset);
524 writeReference(node.targetReference); 524 writeReference(node.targetReference);
525 writeNode(node.value); 525 writeNode(node.value);
526 } 526 }
527 527
528 visitMethodInvocation(MethodInvocation node) { 528 visitMethodInvocation(MethodInvocation node) {
529 writeByte(Tag.MethodInvocation); 529 writeByte(Tag.MethodInvocation);
530 writeOffset(node, node.fileOffset); 530 writeOffset(node.fileOffset);
531 writeNode(node.receiver); 531 writeNode(node.receiver);
532 writeName(node.name); 532 writeName(node.name);
533 writeNode(node.arguments); 533 writeNode(node.arguments);
534 writeReference(node.interfaceTargetReference); 534 writeReference(node.interfaceTargetReference);
535 } 535 }
536 536
537 visitSuperMethodInvocation(SuperMethodInvocation node) { 537 visitSuperMethodInvocation(SuperMethodInvocation node) {
538 writeByte(Tag.SuperMethodInvocation); 538 writeByte(Tag.SuperMethodInvocation);
539 writeOffset(node, node.fileOffset); 539 writeOffset(node.fileOffset);
540 writeName(node.name); 540 writeName(node.name);
541 writeNode(node.arguments); 541 writeNode(node.arguments);
542 writeReference(node.interfaceTargetReference); 542 writeReference(node.interfaceTargetReference);
543 } 543 }
544 544
545 visitDirectMethodInvocation(DirectMethodInvocation node) { 545 visitDirectMethodInvocation(DirectMethodInvocation node) {
546 writeByte(Tag.DirectMethodInvocation); 546 writeByte(Tag.DirectMethodInvocation);
547 writeNode(node.receiver); 547 writeNode(node.receiver);
548 writeReference(node.targetReference); 548 writeReference(node.targetReference);
549 writeNode(node.arguments); 549 writeNode(node.arguments);
550 } 550 }
551 551
552 visitStaticInvocation(StaticInvocation node) { 552 visitStaticInvocation(StaticInvocation node) {
553 writeByte(node.isConst ? Tag.ConstStaticInvocation : Tag.StaticInvocation); 553 writeByte(node.isConst ? Tag.ConstStaticInvocation : Tag.StaticInvocation);
554 writeOffset(node, node.fileOffset); 554 writeOffset(node.fileOffset);
555 writeReference(node.targetReference); 555 writeReference(node.targetReference);
556 writeNode(node.arguments); 556 writeNode(node.arguments);
557 } 557 }
558 558
559 visitConstructorInvocation(ConstructorInvocation node) { 559 visitConstructorInvocation(ConstructorInvocation node) {
560 writeByte(node.isConst 560 writeByte(node.isConst
561 ? Tag.ConstConstructorInvocation 561 ? Tag.ConstConstructorInvocation
562 : Tag.ConstructorInvocation); 562 : Tag.ConstructorInvocation);
563 writeOffset(node, node.fileOffset); 563 writeOffset(node.fileOffset);
564 writeReference(node.targetReference); 564 writeReference(node.targetReference);
565 writeNode(node.arguments); 565 writeNode(node.arguments);
566 } 566 }
567 567
568 visitArguments(Arguments node) { 568 visitArguments(Arguments node) {
569 writeNodeList(node.types); 569 writeNodeList(node.types);
570 writeNodeList(node.positional); 570 writeNodeList(node.positional);
571 writeNodeList(node.named); 571 writeNodeList(node.named);
572 } 572 }
573 573
(...skipping 27 matching lines...) Expand all
601 visitConditionalExpression(ConditionalExpression node) { 601 visitConditionalExpression(ConditionalExpression node) {
602 writeByte(Tag.ConditionalExpression); 602 writeByte(Tag.ConditionalExpression);
603 writeNode(node.condition); 603 writeNode(node.condition);
604 writeNode(node.then); 604 writeNode(node.then);
605 writeNode(node.otherwise); 605 writeNode(node.otherwise);
606 writeOptionalNode(node.staticType); 606 writeOptionalNode(node.staticType);
607 } 607 }
608 608
609 visitStringConcatenation(StringConcatenation node) { 609 visitStringConcatenation(StringConcatenation node) {
610 writeByte(Tag.StringConcatenation); 610 writeByte(Tag.StringConcatenation);
611 writeOffset(node, node.fileOffset); 611 writeOffset(node.fileOffset);
612 writeNodeList(node.expressions); 612 writeNodeList(node.expressions);
613 } 613 }
614 614
615 visitIsExpression(IsExpression node) { 615 visitIsExpression(IsExpression node) {
616 writeByte(Tag.IsExpression); 616 writeByte(Tag.IsExpression);
617 writeOffset(node, node.fileOffset); 617 writeOffset(node.fileOffset);
618 writeNode(node.operand); 618 writeNode(node.operand);
619 writeNode(node.type); 619 writeNode(node.type);
620 } 620 }
621 621
622 visitAsExpression(AsExpression node) { 622 visitAsExpression(AsExpression node) {
623 writeByte(Tag.AsExpression); 623 writeByte(Tag.AsExpression);
624 writeOffset(node, node.fileOffset); 624 writeOffset(node.fileOffset);
625 writeNode(node.operand); 625 writeNode(node.operand);
626 writeNode(node.type); 626 writeNode(node.type);
627 } 627 }
628 628
629 visitStringLiteral(StringLiteral node) { 629 visitStringLiteral(StringLiteral node) {
630 writeByte(Tag.StringLiteral); 630 writeByte(Tag.StringLiteral);
631 writeStringReference(node.value); 631 writeStringReference(node.value);
632 } 632 }
633 633
634 visitIntLiteral(IntLiteral node) { 634 visitIntLiteral(IntLiteral node) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 writeByte(Tag.TypeLiteral); 675 writeByte(Tag.TypeLiteral);
676 writeNode(node.type); 676 writeNode(node.type);
677 } 677 }
678 678
679 visitThisExpression(ThisExpression node) { 679 visitThisExpression(ThisExpression node) {
680 writeByte(Tag.ThisExpression); 680 writeByte(Tag.ThisExpression);
681 } 681 }
682 682
683 visitRethrow(Rethrow node) { 683 visitRethrow(Rethrow node) {
684 writeByte(Tag.Rethrow); 684 writeByte(Tag.Rethrow);
685 writeOffset(node, node.fileOffset); 685 writeOffset(node.fileOffset);
686 } 686 }
687 687
688 visitThrow(Throw node) { 688 visitThrow(Throw node) {
689 writeByte(Tag.Throw); 689 writeByte(Tag.Throw);
690 writeOffset(node, node.fileOffset); 690 writeOffset(node.fileOffset);
691 writeNode(node.expression); 691 writeNode(node.expression);
692 } 692 }
693 693
694 visitListLiteral(ListLiteral node) { 694 visitListLiteral(ListLiteral node) {
695 writeByte(node.isConst ? Tag.ConstListLiteral : Tag.ListLiteral); 695 writeByte(node.isConst ? Tag.ConstListLiteral : Tag.ListLiteral);
696 writeOffset(node, node.fileOffset); 696 writeOffset(node.fileOffset);
697 writeNode(node.typeArgument); 697 writeNode(node.typeArgument);
698 writeNodeList(node.expressions); 698 writeNodeList(node.expressions);
699 } 699 }
700 700
701 visitMapLiteral(MapLiteral node) { 701 visitMapLiteral(MapLiteral node) {
702 writeByte(node.isConst ? Tag.ConstMapLiteral : Tag.MapLiteral); 702 writeByte(node.isConst ? Tag.ConstMapLiteral : Tag.MapLiteral);
703 writeOffset(node, node.fileOffset); 703 writeOffset(node.fileOffset);
704 writeNode(node.keyType); 704 writeNode(node.keyType);
705 writeNode(node.valueType); 705 writeNode(node.valueType);
706 writeNodeList(node.entries); 706 writeNodeList(node.entries);
707 } 707 }
708 708
709 visitMapEntry(MapEntry node) { 709 visitMapEntry(MapEntry node) {
710 // Note: there is no tag on MapEntry 710 // Note: there is no tag on MapEntry
711 writeNode(node.key); 711 writeNode(node.key);
712 writeNode(node.value); 712 writeNode(node.value);
713 } 713 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 775
776 visitLabeledStatement(LabeledStatement node) { 776 visitLabeledStatement(LabeledStatement node) {
777 _labelIndexer.enter(node); 777 _labelIndexer.enter(node);
778 writeByte(Tag.LabeledStatement); 778 writeByte(Tag.LabeledStatement);
779 writeNode(node.body); 779 writeNode(node.body);
780 _labelIndexer.exit(); 780 _labelIndexer.exit();
781 } 781 }
782 782
783 visitBreakStatement(BreakStatement node) { 783 visitBreakStatement(BreakStatement node) {
784 writeByte(Tag.BreakStatement); 784 writeByte(Tag.BreakStatement);
785 writeOffset(node, node.fileOffset); 785 writeOffset(node.fileOffset);
786 writeUInt30(_labelIndexer[node.target]); 786 writeUInt30(_labelIndexer[node.target]);
787 } 787 }
788 788
789 visitWhileStatement(WhileStatement node) { 789 visitWhileStatement(WhileStatement node) {
790 writeByte(Tag.WhileStatement); 790 writeByte(Tag.WhileStatement);
791 writeNode(node.condition); 791 writeNode(node.condition);
792 writeNode(node.body); 792 writeNode(node.body);
793 } 793 }
794 794
795 visitDoStatement(DoStatement node) { 795 visitDoStatement(DoStatement node) {
(...skipping 25 matching lines...) Expand all
821 _switchCaseIndexer.enter(node); 821 _switchCaseIndexer.enter(node);
822 writeByte(Tag.SwitchStatement); 822 writeByte(Tag.SwitchStatement);
823 writeNode(node.expression); 823 writeNode(node.expression);
824 writeNodeList(node.cases); 824 writeNodeList(node.cases);
825 _switchCaseIndexer.exit(node); 825 _switchCaseIndexer.exit(node);
826 } 826 }
827 827
828 visitSwitchCase(SwitchCase node) { 828 visitSwitchCase(SwitchCase node) {
829 // Note: there is no tag on SwitchCase. 829 // Note: there is no tag on SwitchCase.
830 writeNodeList(node.expressions); 830 writeNodeList(node.expressions);
831 writeList(node.expressionsOffsets, writeOffset);
831 writeByte(node.isDefault ? 1 : 0); 832 writeByte(node.isDefault ? 1 : 0);
832 writeNode(node.body); 833 writeNode(node.body);
833 } 834 }
834 835
835 visitContinueSwitchStatement(ContinueSwitchStatement node) { 836 visitContinueSwitchStatement(ContinueSwitchStatement node) {
836 writeByte(Tag.ContinueSwitchStatement); 837 writeByte(Tag.ContinueSwitchStatement);
837 writeUInt30(_switchCaseIndexer[node.target]); 838 writeUInt30(_switchCaseIndexer[node.target]);
838 } 839 }
839 840
840 visitIfStatement(IfStatement node) { 841 visitIfStatement(IfStatement node) {
841 writeByte(Tag.IfStatement); 842 writeByte(Tag.IfStatement);
842 writeNode(node.condition); 843 writeNode(node.condition);
843 writeNode(node.then); 844 writeNode(node.then);
844 writeStatementOrEmpty(node.otherwise); 845 writeStatementOrEmpty(node.otherwise);
845 } 846 }
846 847
847 visitReturnStatement(ReturnStatement node) { 848 visitReturnStatement(ReturnStatement node) {
848 writeByte(Tag.ReturnStatement); 849 writeByte(Tag.ReturnStatement);
849 writeOffset(node, node.fileOffset); 850 writeOffset(node.fileOffset);
850 writeOptionalNode(node.expression); 851 writeOptionalNode(node.expression);
851 } 852 }
852 853
853 visitTryCatch(TryCatch node) { 854 visitTryCatch(TryCatch node) {
854 writeByte(Tag.TryCatch); 855 writeByte(Tag.TryCatch);
855 writeNode(node.body); 856 writeNode(node.body);
856 writeNodeList(node.catches); 857 writeNodeList(node.catches);
857 } 858 }
858 859
859 visitCatch(Catch node) { 860 visitCatch(Catch node) {
860 // Note: there is no tag on Catch. 861 // Note: there is no tag on Catch.
861 _variableIndexer.pushScope(); 862 _variableIndexer.pushScope();
862 writeNode(node.guard); 863 writeNode(node.guard);
863 writeOptionalVariableDeclaration(node.exception); 864 writeOptionalVariableDeclaration(node.exception);
864 writeOptionalVariableDeclaration(node.stackTrace); 865 writeOptionalVariableDeclaration(node.stackTrace);
865 writeNode(node.body); 866 writeNode(node.body);
866 _variableIndexer.popScope(); 867 _variableIndexer.popScope();
867 } 868 }
868 869
869 visitTryFinally(TryFinally node) { 870 visitTryFinally(TryFinally node) {
870 writeByte(Tag.TryFinally); 871 writeByte(Tag.TryFinally);
871 writeNode(node.body); 872 writeNode(node.body);
872 writeNode(node.finalizer); 873 writeNode(node.finalizer);
873 } 874 }
874 875
875 visitYieldStatement(YieldStatement node) { 876 visitYieldStatement(YieldStatement node) {
876 writeByte(Tag.YieldStatement); 877 writeByte(Tag.YieldStatement);
877 writeOffset(node, node.fileOffset); 878 writeOffset(node.fileOffset);
878 writeByte(node.flags); 879 writeByte(node.flags);
879 writeNode(node.expression); 880 writeNode(node.expression);
880 } 881 }
881 882
882 visitVariableDeclaration(VariableDeclaration node) { 883 visitVariableDeclaration(VariableDeclaration node) {
883 writeByte(Tag.VariableDeclaration); 884 writeByte(Tag.VariableDeclaration);
884 writeVariableDeclaration(node); 885 writeVariableDeclaration(node);
885 } 886 }
886 887
887 void writeVariableDeclaration(VariableDeclaration node) { 888 void writeVariableDeclaration(VariableDeclaration node) {
888 writeOffset(node, node.fileOffset); 889 writeOffset(node.fileOffset);
889 writeOffset(node, node.fileEqualsOffset); 890 writeOffset(node.fileEqualsOffset);
890 writeByte(node.flags); 891 writeByte(node.flags);
891 writeStringReference(node.name ?? ''); 892 writeStringReference(node.name ?? '');
892 writeNode(node.type); 893 writeNode(node.type);
893 writeOptionalInferredValue(node.inferredValue); 894 writeOptionalInferredValue(node.inferredValue);
894 writeOptionalNode(node.initializer); 895 writeOptionalNode(node.initializer);
895 // Declare the variable after its initializer. It is not in scope in its 896 // Declare the variable after its initializer. It is not in scope in its
896 // own initializer. 897 // own initializer.
897 _variableIndexer.declare(node); 898 _variableIndexer.declare(node);
898 } 899 }
899 900
900 void writeVariableDeclarationList(List<VariableDeclaration> nodes) { 901 void writeVariableDeclarationList(List<VariableDeclaration> nodes) {
901 writeList(nodes, writeVariableDeclaration); 902 writeList(nodes, writeVariableDeclaration);
902 } 903 }
903 904
904 void writeOptionalVariableDeclaration(VariableDeclaration node) { 905 void writeOptionalVariableDeclaration(VariableDeclaration node) {
905 if (node == null) { 906 if (node == null) {
906 writeByte(Tag.Nothing); 907 writeByte(Tag.Nothing);
907 } else { 908 } else {
908 writeByte(Tag.Something); 909 writeByte(Tag.Something);
909 writeVariableDeclaration(node); 910 writeVariableDeclaration(node);
910 } 911 }
911 } 912 }
912 913
913 visitFunctionDeclaration(FunctionDeclaration node) { 914 visitFunctionDeclaration(FunctionDeclaration node) {
914 writeByte(Tag.FunctionDeclaration); 915 writeByte(Tag.FunctionDeclaration);
915 writeOffset(node, node.fileOffset); 916 writeOffset(node.fileOffset);
916 writeVariableDeclaration(node.variable); 917 writeVariableDeclaration(node.variable);
917 writeNode(node.function); 918 writeNode(node.function);
918 } 919 }
919 920
920 visitBottomType(BottomType node) { 921 visitBottomType(BottomType node) {
921 writeByte(Tag.BottomType); 922 writeByte(Tag.BottomType);
922 } 923 }
923 924
924 visitInvalidType(InvalidType node) { 925 visitInvalidType(InvalidType node) {
925 writeByte(Tag.InvalidType); 926 writeByte(Tag.InvalidType);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 void flush() { 1281 void flush() {
1281 _sink.add(_buffer.sublist(0, length)); 1282 _sink.add(_buffer.sublist(0, length));
1282 _buffer = new Uint8List(SIZE); 1283 _buffer = new Uint8List(SIZE);
1283 length = 0; 1284 length = 0;
1284 } 1285 }
1285 1286
1286 void flushAndDestroy() { 1287 void flushAndDestroy() {
1287 _sink.add(_buffer.sublist(0, length)); 1288 _sink.add(_buffer.sublist(0, length));
1288 } 1289 }
1289 } 1290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698