| ... | @@ -390,7 +390,6 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -390,7 +390,6 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 390 | | 390 | |
| 391 | var if_level: u8 = 0; | 391 | var if_level: u8 = 0; |
| 392 | var if_kind: [64]u8 = .{0} ** 64; | 392 | var if_kind: [64]u8 = .{0} ** 64; |
| 393 | const native_endian = @import("builtin").cpu.arch.endian(); | | |
| 394 | const until_else = 0; | 393 | const until_else = 0; |
| 395 | const until_endif = 1; | 394 | const until_endif = 1; |
| 396 | const until_endif_seen_else = 2; | 395 | const until_endif_seen_else = 2; |
| ... | @@ -431,24 +430,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -431,24 +430,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 431 | if_level = sum; | 430 | if_level = sum; |
| 432 | | 431 | |
| 433 | if (try pp.expr(&tokenizer)) { | 432 | if (try pp.expr(&tokenizer)) { |
| 434 | std.mem.writePackedInt( | 433 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 435 | u2, | | |
| 436 | &if_kind, | | |
| 437 | if_level * 2, | | |
| 438 | until_endif, | | |
| 439 | native_endian, | | |
| 440 | ); | | |
| 441 | if (pp.verbose) { | 434 | if (pp.verbose) { |
| 442 | pp.verboseLog(directive, "entering then branch of #if", .{}); | 435 | pp.verboseLog(directive, "entering then branch of #if", .{}); |
| 443 | } | 436 | } |
| 444 | } else { | 437 | } else { |
| 445 | std.mem.writePackedInt( | 438 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 446 | u2, | | |
| 447 | &if_kind, | | |
| 448 | if_level * 2, | | |
| 449 | until_else, | | |
| 450 | native_endian, | | |
| 451 | ); | | |
| 452 | try pp.skip(&tokenizer, .until_else); | 439 | try pp.skip(&tokenizer, .until_else); |
| 453 | if (pp.verbose) { | 440 | if (pp.verbose) { |
| 454 | pp.verboseLog(directive, "entering else branch of #if", .{}); | 441 | pp.verboseLog(directive, "entering else branch of #if", .{}); |
| ... | @@ -464,24 +451,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -464,24 +451,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 464 | const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; | 451 | const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; |
| 465 | try pp.expectNl(&tokenizer); | 452 | try pp.expectNl(&tokenizer); |
| 466 | if (pp.defines.get(macro_name) != null) { | 453 | if (pp.defines.get(macro_name) != null) { |
| 467 | std.mem.writePackedInt( | 454 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 468 | u2, | | |
| 469 | &if_kind, | | |
| 470 | if_level * 2, | | |
| 471 | until_endif, | | |
| 472 | native_endian, | | |
| 473 | ); | | |
| 474 | if (pp.verbose) { | 455 | if (pp.verbose) { |
| 475 | pp.verboseLog(directive, "entering then branch of #ifdef", .{}); | 456 | pp.verboseLog(directive, "entering then branch of #ifdef", .{}); |
| 476 | } | 457 | } |
| 477 | } else { | 458 | } else { |
| 478 | std.mem.writePackedInt( | 459 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 479 | u2, | | |
| 480 | &if_kind, | | |
| 481 | if_level * 2, | | |
| 482 | until_else, | | |
| 483 | native_endian, | | |
| 484 | ); | | |
| 485 | try pp.skip(&tokenizer, .until_else); | 460 | try pp.skip(&tokenizer, .until_else); |
| 486 | if (pp.verbose) { | 461 | if (pp.verbose) { |
| 487 | pp.verboseLog(directive, "entering else branch of #ifdef", .{}); | 462 | pp.verboseLog(directive, "entering else branch of #ifdef", .{}); |
| ... | @@ -497,21 +472,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -497,21 +472,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 497 | const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; | 472 | const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; |
| 498 | try pp.expectNl(&tokenizer); | 473 | try pp.expectNl(&tokenizer); |
| 499 | if (pp.defines.get(macro_name) == null) { | 474 | if (pp.defines.get(macro_name) == null) { |
| 500 | std.mem.writePackedInt( | 475 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 501 | u2, | | |
| 502 | &if_kind, | | |
| 503 | if_level * 2, | | |
| 504 | until_endif, | | |
| 505 | native_endian, | | |
| 506 | ); | | |
| 507 | } else { | 476 | } else { |
| 508 | std.mem.writePackedInt( | 477 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 509 | u2, | | |
| 510 | &if_kind, | | |
| 511 | if_level * 2, | | |
| 512 | until_else, | | |
| 513 | native_endian, | | |
| 514 | ); | | |
| 515 | try pp.skip(&tokenizer, .until_else); | 478 | try pp.skip(&tokenizer, .until_else); |
| 516 | } | 479 | } |
| 517 | }, | 480 | }, |
| ... | @@ -519,25 +482,13 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -519,25 +482,13 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 519 | if (if_level == 0) { | 482 | if (if_level == 0) { |
| 520 | try pp.err(directive, .elif_without_if); | 483 | try pp.err(directive, .elif_without_if); |
| 521 | if_level += 1; | 484 | if_level += 1; |
| 522 | std.mem.writePackedInt( | 485 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 523 | u2, | | |
| 524 | &if_kind, | | |
| 525 | if_level * 2, | | |
| 526 | until_else, | | |
| 527 | native_endian, | | |
| 528 | ); | | |
| 529 | } else if (if_level == 1) { | 486 | } else if (if_level == 1) { |
| 530 | guard_name = null; | 487 | guard_name = null; |
| 531 | } | 488 | } |
| 532 | switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) { | 489 | switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) { |
| 533 | until_else => if (try pp.expr(&tokenizer)) { | 490 | until_else => if (try pp.expr(&tokenizer)) { |
| 534 | std.mem.writePackedInt( | 491 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 535 | u2, | | |
| 536 | &if_kind, | | |
| 537 | if_level * 2, | | |
| 538 | until_endif, | | |
| 539 | native_endian, | | |
| 540 | ); | | |
| 541 | if (pp.verbose) { | 492 | if (pp.verbose) { |
| 542 | pp.verboseLog(directive, "entering then branch of #elif", .{}); | 493 | pp.verboseLog(directive, "entering then branch of #elif", .{}); |
| 543 | } | 494 | } |
| ... | @@ -559,27 +510,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -559,27 +510,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 559 | if (if_level == 0) { | 510 | if (if_level == 0) { |
| 560 | try pp.err(directive, .elifdef_without_if); | 511 | try pp.err(directive, .elifdef_without_if); |
| 561 | if_level += 1; | 512 | if_level += 1; |
| 562 | std.mem.writePackedInt( | 513 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 563 | u2, | | |
| 564 | &if_kind, | | |
| 565 | if_level * 2, | | |
| 566 | until_else, | | |
| 567 | native_endian, | | |
| 568 | ); | | |
| 569 | } else if (if_level == 1) { | 514 | } else if (if_level == 1) { |
| 570 | guard_name = null; | 515 | guard_name = null; |
| 571 | } | 516 | } |
| 572 | switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) { | 517 | switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) { |
| 573 | until_else => { | 518 | until_else => { |
| 574 | const macro_name = try pp.expectMacroName(&tokenizer); | 519 | const macro_name = try pp.expectMacroName(&tokenizer); |
| 575 | if (macro_name == null) { | 520 | if (macro_name == null) { |
| 576 | std.mem.writePackedInt( | 521 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 577 | u2, | | |
| 578 | &if_kind, | | |
| 579 | if_level * 2, | | |
| 580 | until_else, | | |
| 581 | native_endian, | | |
| 582 | ); | | |
| 583 | try pp.skip(&tokenizer, .until_else); | 522 | try pp.skip(&tokenizer, .until_else); |
| 584 | if (pp.verbose) { | 523 | if (pp.verbose) { |
| 585 | pp.verboseLog(directive, "entering else branch of #elifdef", .{}); | 524 | pp.verboseLog(directive, "entering else branch of #elifdef", .{}); |
| ... | @@ -587,24 +526,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -587,24 +526,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 587 | } else { | 526 | } else { |
| 588 | try pp.expectNl(&tokenizer); | 527 | try pp.expectNl(&tokenizer); |
| 589 | if (pp.defines.get(macro_name.?) != null) { | 528 | if (pp.defines.get(macro_name.?) != null) { |
| 590 | std.mem.writePackedInt( | 529 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 591 | u2, | | |
| 592 | &if_kind, | | |
| 593 | if_level * 2, | | |
| 594 | until_endif, | | |
| 595 | native_endian, | | |
| 596 | ); | | |
| 597 | if (pp.verbose) { | 530 | if (pp.verbose) { |
| 598 | pp.verboseLog(directive, "entering then branch of #elifdef", .{}); | 531 | pp.verboseLog(directive, "entering then branch of #elifdef", .{}); |
| 599 | } | 532 | } |
| 600 | } else { | 533 | } else { |
| 601 | std.mem.writePackedInt( | 534 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 602 | u2, | | |
| 603 | &if_kind, | | |
| 604 | if_level * 2, | | |
| 605 | until_else, | | |
| 606 | native_endian, | | |
| 607 | ); | | |
| 608 | try pp.skip(&tokenizer, .until_else); | 535 | try pp.skip(&tokenizer, .until_else); |
| 609 | if (pp.verbose) { | 536 | if (pp.verbose) { |
| 610 | pp.verboseLog(directive, "entering else branch of #elifdef", .{}); | 537 | pp.verboseLog(directive, "entering else branch of #elifdef", .{}); |
| ... | @@ -624,27 +551,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -624,27 +551,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 624 | if (if_level == 0) { | 551 | if (if_level == 0) { |
| 625 | try pp.err(directive, .elifdef_without_if); | 552 | try pp.err(directive, .elifdef_without_if); |
| 626 | if_level += 1; | 553 | if_level += 1; |
| 627 | std.mem.writePackedInt( | 554 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 628 | u2, | | |
| 629 | &if_kind, | | |
| 630 | if_level * 2, | | |
| 631 | until_else, | | |
| 632 | native_endian, | | |
| 633 | ); | | |
| 634 | } else if (if_level == 1) { | 555 | } else if (if_level == 1) { |
| 635 | guard_name = null; | 556 | guard_name = null; |
| 636 | } | 557 | } |
| 637 | switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) { | 558 | switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) { |
| 638 | until_else => { | 559 | until_else => { |
| 639 | const macro_name = try pp.expectMacroName(&tokenizer); | 560 | const macro_name = try pp.expectMacroName(&tokenizer); |
| 640 | if (macro_name == null) { | 561 | if (macro_name == null) { |
| 641 | std.mem.writePackedInt( | 562 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 642 | u2, | | |
| 643 | &if_kind, | | |
| 644 | if_level * 2, | | |
| 645 | until_else, | | |
| 646 | native_endian, | | |
| 647 | ); | | |
| 648 | try pp.skip(&tokenizer, .until_else); | 563 | try pp.skip(&tokenizer, .until_else); |
| 649 | if (pp.verbose) { | 564 | if (pp.verbose) { |
| 650 | pp.verboseLog(directive, "entering else branch of #elifndef", .{}); | 565 | pp.verboseLog(directive, "entering else branch of #elifndef", .{}); |
| ... | @@ -652,24 +567,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -652,24 +567,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 652 | } else { | 567 | } else { |
| 653 | try pp.expectNl(&tokenizer); | 568 | try pp.expectNl(&tokenizer); |
| 654 | if (pp.defines.get(macro_name.?) == null) { | 569 | if (pp.defines.get(macro_name.?) == null) { |
| 655 | std.mem.writePackedInt( | 570 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif); |
| 656 | u2, | | |
| 657 | &if_kind, | | |
| 658 | if_level * 2, | | |
| 659 | until_endif, | | |
| 660 | native_endian, | | |
| 661 | ); | | |
| 662 | if (pp.verbose) { | 571 | if (pp.verbose) { |
| 663 | pp.verboseLog(directive, "entering then branch of #elifndef", .{}); | 572 | pp.verboseLog(directive, "entering then branch of #elifndef", .{}); |
| 664 | } | 573 | } |
| 665 | } else { | 574 | } else { |
| 666 | std.mem.writePackedInt( | 575 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else); |
| 667 | u2, | | |
| 668 | &if_kind, | | |
| 669 | if_level * 2, | | |
| 670 | until_else, | | |
| 671 | native_endian, | | |
| 672 | ); | | |
| 673 | try pp.skip(&tokenizer, .until_else); | 576 | try pp.skip(&tokenizer, .until_else); |
| 674 | if (pp.verbose) { | 577 | if (pp.verbose) { |
| 675 | pp.verboseLog(directive, "entering else branch of #elifndef", .{}); | 578 | pp.verboseLog(directive, "entering else branch of #elifndef", .{}); |
| ... | @@ -693,15 +596,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans | ... | @@ -693,15 +596,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans |
| 693 | } else if (if_level == 1) { | 596 | } else if (if_level == 1) { |
| 694 | guard_name = null; | 597 | guard_name = null; |
| 695 | } | 598 | } |
| 696 | switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) { | 599 | switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) { |
| 697 | until_else => { | 600 | until_else => { |
| 698 | std.mem.writePackedInt( | 601 | std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif_seen_else); |
| 699 | u2, | | |
| 700 | &if_kind, | | |
| 701 | if_level * 2, | | |
| 702 | until_endif_seen_else, | | |
| 703 | native_endian, | | |
| 704 | ); | | |
| 705 | if (pp.verbose) { | 602 | if (pp.verbose) { |
| 706 | pp.verboseLog(directive, "#else branch here", .{}); | 603 | pp.verboseLog(directive, "#else branch here", .{}); |
| 707 | } | 604 | } |