authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2024-10-12 17:59:41+02:00
committergravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2024-10-12 17:59:41+02:00
log8a4bcc4ec3dfc8bb8ff43eaece43bacb60a36a91
treeb34431a4552e0253572fc5acec0fe12cb87aa3f8
parentb1eaed6c8d439f5e5cbd69af5186af68f1e65e34

Change (read/write)PackedInt to (read/write)PackedIntNative in aro/Preprocessor


1 files changed, 21 insertions(+), 124 deletions(-)

lib/compiler/aro/aro/Preprocessor.zig+21-124
......@@ -390,7 +390,6 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
390390
391391 var if_level: u8 = 0;
392392 var if_kind: [64]u8 = .{0} ** 64;
393 const native_endian = @import("builtin").cpu.arch.endian();
394393 const until_else = 0;
395394 const until_endif = 1;
396395 const until_endif_seen_else = 2;
......@@ -431,24 +430,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
431430 if_level = sum;
432431
433432 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);
441434 if (pp.verbose) {
442435 pp.verboseLog(directive, "entering then branch of #if", .{});
443436 }
444437 } 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);
452439 try pp.skip(&tokenizer, .until_else);
453440 if (pp.verbose) {
454441 pp.verboseLog(directive, "entering else branch of #if", .{});
......@@ -464,24 +451,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
464451 const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
465452 try pp.expectNl(&tokenizer);
466453 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);
474455 if (pp.verbose) {
475456 pp.verboseLog(directive, "entering then branch of #ifdef", .{});
476457 }
477458 } 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);
485460 try pp.skip(&tokenizer, .until_else);
486461 if (pp.verbose) {
487462 pp.verboseLog(directive, "entering else branch of #ifdef", .{});
......@@ -497,21 +472,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
497472 const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
498473 try pp.expectNl(&tokenizer);
499474 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);
507476 } 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);
515478 try pp.skip(&tokenizer, .until_else);
516479 }
517480 },
......@@ -519,25 +482,13 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
519482 if (if_level == 0) {
520483 try pp.err(directive, .elif_without_if);
521484 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);
529486 } else if (if_level == 1) {
530487 guard_name = null;
531488 }
532 switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
489 switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
533490 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);
541492 if (pp.verbose) {
542493 pp.verboseLog(directive, "entering then branch of #elif", .{});
543494 }
......@@ -559,27 +510,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
559510 if (if_level == 0) {
560511 try pp.err(directive, .elifdef_without_if);
561512 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);
569514 } else if (if_level == 1) {
570515 guard_name = null;
571516 }
572 switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
517 switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
573518 until_else => {
574519 const macro_name = try pp.expectMacroName(&tokenizer);
575520 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);
583522 try pp.skip(&tokenizer, .until_else);
584523 if (pp.verbose) {
585524 pp.verboseLog(directive, "entering else branch of #elifdef", .{});
......@@ -587,24 +526,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
587526 } else {
588527 try pp.expectNl(&tokenizer);
589528 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);
597530 if (pp.verbose) {
598531 pp.verboseLog(directive, "entering then branch of #elifdef", .{});
599532 }
600533 } 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);
608535 try pp.skip(&tokenizer, .until_else);
609536 if (pp.verbose) {
610537 pp.verboseLog(directive, "entering else branch of #elifdef", .{});
......@@ -624,27 +551,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
624551 if (if_level == 0) {
625552 try pp.err(directive, .elifdef_without_if);
626553 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);
634555 } else if (if_level == 1) {
635556 guard_name = null;
636557 }
637 switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
558 switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
638559 until_else => {
639560 const macro_name = try pp.expectMacroName(&tokenizer);
640561 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);
648563 try pp.skip(&tokenizer, .until_else);
649564 if (pp.verbose) {
650565 pp.verboseLog(directive, "entering else branch of #elifndef", .{});
......@@ -652,24 +567,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
652567 } else {
653568 try pp.expectNl(&tokenizer);
654569 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);
662571 if (pp.verbose) {
663572 pp.verboseLog(directive, "entering then branch of #elifndef", .{});
664573 }
665574 } 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);
673576 try pp.skip(&tokenizer, .until_else);
674577 if (pp.verbose) {
675578 pp.verboseLog(directive, "entering else branch of #elifndef", .{});
......@@ -693,15 +596,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
693596 } else if (if_level == 1) {
694597 guard_name = null;
695598 }
696 switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
599 switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
697600 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);
705602 if (pp.verbose) {
706603 pp.verboseLog(directive, "#else branch here", .{});
707604 }