mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Change (read/write)PackedInt to (read/write)PackedIntNative in aro/Preprocessor
This commit is contained in:
parent
b1eaed6c8d
commit
8a4bcc4ec3
145
lib/compiler/aro/aro/Preprocessor.zig
vendored
145
lib/compiler/aro/aro/Preprocessor.zig
vendored
@ -390,7 +390,6 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
|
|
||||||
var if_level: u8 = 0;
|
var if_level: u8 = 0;
|
||||||
var if_kind: [64]u8 = .{0} ** 64;
|
var if_kind: [64]u8 = .{0} ** 64;
|
||||||
const native_endian = @import("builtin").cpu.arch.endian();
|
|
||||||
const until_else = 0;
|
const until_else = 0;
|
||||||
const until_endif = 1;
|
const until_endif = 1;
|
||||||
const until_endif_seen_else = 2;
|
const until_endif_seen_else = 2;
|
||||||
@ -431,24 +430,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
if_level = sum;
|
if_level = sum;
|
||||||
|
|
||||||
if (try pp.expr(&tokenizer)) {
|
if (try pp.expr(&tokenizer)) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering then branch of #if", .{});
|
pp.verboseLog(directive, "entering then branch of #if", .{});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #if", .{});
|
pp.verboseLog(directive, "entering else branch of #if", .{});
|
||||||
@ -464,24 +451,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
|
const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
|
||||||
try pp.expectNl(&tokenizer);
|
try pp.expectNl(&tokenizer);
|
||||||
if (pp.defines.get(macro_name) != null) {
|
if (pp.defines.get(macro_name) != null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering then branch of #ifdef", .{});
|
pp.verboseLog(directive, "entering then branch of #ifdef", .{});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #ifdef", .{});
|
pp.verboseLog(directive, "entering else branch of #ifdef", .{});
|
||||||
@ -497,21 +472,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
|
const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue;
|
||||||
try pp.expectNl(&tokenizer);
|
try pp.expectNl(&tokenizer);
|
||||||
if (pp.defines.get(macro_name) == null) {
|
if (pp.defines.get(macro_name) == null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -519,25 +482,13 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
if (if_level == 0) {
|
if (if_level == 0) {
|
||||||
try pp.err(directive, .elif_without_if);
|
try pp.err(directive, .elif_without_if);
|
||||||
if_level += 1;
|
if_level += 1;
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
} else if (if_level == 1) {
|
} else if (if_level == 1) {
|
||||||
guard_name = null;
|
guard_name = null;
|
||||||
}
|
}
|
||||||
switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
|
switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
|
||||||
until_else => if (try pp.expr(&tokenizer)) {
|
until_else => if (try pp.expr(&tokenizer)) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering then branch of #elif", .{});
|
pp.verboseLog(directive, "entering then branch of #elif", .{});
|
||||||
}
|
}
|
||||||
@ -559,27 +510,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
if (if_level == 0) {
|
if (if_level == 0) {
|
||||||
try pp.err(directive, .elifdef_without_if);
|
try pp.err(directive, .elifdef_without_if);
|
||||||
if_level += 1;
|
if_level += 1;
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
} else if (if_level == 1) {
|
} else if (if_level == 1) {
|
||||||
guard_name = null;
|
guard_name = null;
|
||||||
}
|
}
|
||||||
switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
|
switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
|
||||||
until_else => {
|
until_else => {
|
||||||
const macro_name = try pp.expectMacroName(&tokenizer);
|
const macro_name = try pp.expectMacroName(&tokenizer);
|
||||||
if (macro_name == null) {
|
if (macro_name == null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #elifdef", .{});
|
pp.verboseLog(directive, "entering else branch of #elifdef", .{});
|
||||||
@ -587,24 +526,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
} else {
|
} else {
|
||||||
try pp.expectNl(&tokenizer);
|
try pp.expectNl(&tokenizer);
|
||||||
if (pp.defines.get(macro_name.?) != null) {
|
if (pp.defines.get(macro_name.?) != null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering then branch of #elifdef", .{});
|
pp.verboseLog(directive, "entering then branch of #elifdef", .{});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #elifdef", .{});
|
pp.verboseLog(directive, "entering else branch of #elifdef", .{});
|
||||||
@ -624,27 +551,15 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
if (if_level == 0) {
|
if (if_level == 0) {
|
||||||
try pp.err(directive, .elifdef_without_if);
|
try pp.err(directive, .elifdef_without_if);
|
||||||
if_level += 1;
|
if_level += 1;
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
} else if (if_level == 1) {
|
} else if (if_level == 1) {
|
||||||
guard_name = null;
|
guard_name = null;
|
||||||
}
|
}
|
||||||
switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
|
switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
|
||||||
until_else => {
|
until_else => {
|
||||||
const macro_name = try pp.expectMacroName(&tokenizer);
|
const macro_name = try pp.expectMacroName(&tokenizer);
|
||||||
if (macro_name == null) {
|
if (macro_name == null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #elifndef", .{});
|
pp.verboseLog(directive, "entering else branch of #elifndef", .{});
|
||||||
@ -652,24 +567,12 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
} else {
|
} else {
|
||||||
try pp.expectNl(&tokenizer);
|
try pp.expectNl(&tokenizer);
|
||||||
if (pp.defines.get(macro_name.?) == null) {
|
if (pp.defines.get(macro_name.?) == null) {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering then branch of #elifndef", .{});
|
pp.verboseLog(directive, "entering then branch of #elifndef", .{});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
try pp.skip(&tokenizer, .until_else);
|
try pp.skip(&tokenizer, .until_else);
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "entering else branch of #elifndef", .{});
|
pp.verboseLog(directive, "entering else branch of #elifndef", .{});
|
||||||
@ -693,15 +596,9 @@ fn preprocessExtra(pp: *Preprocessor, source: Source) MacroError!TokenWithExpans
|
|||||||
} else if (if_level == 1) {
|
} else if (if_level == 1) {
|
||||||
guard_name = null;
|
guard_name = null;
|
||||||
}
|
}
|
||||||
switch (std.mem.readPackedInt(u2, &if_kind, if_level * 2, native_endian)) {
|
switch (std.mem.readPackedIntNative(u2, &if_kind, if_level * 2)) {
|
||||||
until_else => {
|
until_else => {
|
||||||
std.mem.writePackedInt(
|
std.mem.writePackedIntNative(u2, &if_kind, if_level * 2, until_endif_seen_else);
|
||||||
u2,
|
|
||||||
&if_kind,
|
|
||||||
if_level * 2,
|
|
||||||
until_endif_seen_else,
|
|
||||||
native_endian,
|
|
||||||
);
|
|
||||||
if (pp.verbose) {
|
if (pp.verbose) {
|
||||||
pp.verboseLog(directive, "#else branch here", .{});
|
pp.verboseLog(directive, "#else branch here", .{});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user