Skip to content

Commit

Permalink
refact(core): rename some files to .c.ri (to be used with C backend)
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Oct 30, 2023
1 parent f59feeb commit 5724c0d
Show file tree
Hide file tree
Showing 25 changed files with 22 additions and 21 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 10 additions & 9 deletions lib/rivet/src/ast/Table.ri
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,7 @@ public struct Table {
mut new_inputs := @vec(string, inputs.len);
for input in inputs {
basename_input := Path.basename(input);
if basename_input == "project.ri" {
continue; // Skip `project.ri` file, loaded after
} else if basename_input.count(".") == 1 {
if basename_input.count(".") == 1 {
new_inputs.push(input);
continue;
}
Expand All @@ -402,32 +400,35 @@ public struct Table {
}
already_exts.push(ext);
if ext.starts_with("d_") or ext.starts_with("notd_") {
should_compile = should_compile and if ext.starts_with("d_") {
should_compile = if ext.starts_with("d_") {
ext[2..] in self.prefs.flags
} else {
ext[2..] !in self.prefs.flags
};
} else if os := sys.OS.from_string(ext) {
should_compile = should_compile and self.prefs.target_os == os;
should_compile = self.prefs.target_os == os;
} else if arch := sys.Arch.from_string(ext) {
should_compile = should_compile and self.prefs.target_arch == arch;
should_compile = self.prefs.target_arch == arch;
} else if ext in ["x32", "x64"] {
should_compile = should_compile and if ext == "x32" {
should_compile = if ext == "x32" {
!self.prefs.target_is_64bit
} else {
self.prefs.target_is_64bit
};
} else if ext in ["little_endian", "big_endian"] {
should_compile = should_compile and if ext == "little_endian" {
should_compile = if ext == "little_endian" {
self.prefs.target_is_little_endian
} else {
!self.prefs.target_is_little_endian
};
} else if backend := prefs.Backend.from_string(ext) {
should_compile = should_compile and backend == self.prefs.target_backend;
should_compile = backend == self.prefs.target_backend;
} else {
utils.error("{}: unknown special extension `{}`", input, ext);
}
if !should_compile {
break;
}
}
if should_compile {
new_inputs.push(input);
Expand Down
24 changes: 12 additions & 12 deletions rivetc/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,30 +263,30 @@ def filter_files(self, inputs):
already_exts.append(ext)
if ext.startswith("d_") or ext.startswith("notd_"):
if ext.startswith("d_"):
should_compile = should_compile and ext[
2:] in self.prefs.flags
should_compile = ext[2:] in self.prefs.flags
else:
should_compile = should_compile and ext[
5:] not in self.prefs.flags
should_compile = ext[5:] not in self.prefs.flags
elif osf := prefs.OS.from_string(ext):
should_compile = should_compile and self.prefs.target_os == osf
should_compile = self.prefs.target_os == osf
elif arch := prefs.Arch.from_string(ext):
should_compile = should_compile and self.prefs.target_arch == arch
should_compile = self.prefs.target_arch == arch
elif ext in ("x32", "x64"):
if ext == "x32":
should_compile = should_compile and self.prefs.target_bits == Bits.X32
should_compile = self.prefs.target_bits == Bits.X32
else:
should_compile = should_compile and self.prefs.target_bits == Bits.X64
should_compile = self.prefs.target_bits == Bits.X64
elif ext in ("little_endian", "big_endian"):
if ext == "little_endian":
should_compile = should_compile and self.prefs.target_endian == Endian.Little
should_compile = self.prefs.target_endian == Endian.Little
else:
should_compile = should_compile and self.prefs.target_endian == Endian.Big
elif b := Backend.from_string(ext): # backends
should_compile = should_compile and self.prefs.target_backend == b
should_compile = self.prefs.target_endian == Endian.Big
elif b := prefs.Backend.from_string(ext): # backends
should_compile = self.prefs.target_backend == b
else:
error(f"{input}: unknown special extension `{ext}`")
break
if not should_compile:
break
if should_compile:
new_inputs.append(input)
return new_inputs
Expand Down

0 comments on commit 5724c0d

Please sign in to comment.