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