pub enum InputKind {
C,
CHeader,
PreprocessedC,
Ir,
Assembler,
AssemblerWithCpp,
LinkerInput,
}Expand description
What an input file is, which decides where in the pipeline it enters.
Variants§
C
C source. Extension .c, or -x c.
CHeader
A header compiled on its own. Extension .h with -x c-header, or -x c-header.
PreprocessedC
Already preprocessed C. Extension .i, or -x cpp-output.
Ir
The IR this compiler prints. Extension .ir, or -x ir.
Not a GCC input kind, because GCC has no textual IR. It is here because the IR’s
printer and its parser are a pair, and a pair is only known to agree if something reads
back what was written: rucc --emit=ir a.c -o a.ir and then rucc --emit=ir a.ir are
two files a byte comparison has an opinion about, over whatever code is at hand rather
than over the modules a test happens to build.
Assembler
Assembly. Extension .s, or -x assembler.
AssemblerWithCpp
Assembly that still needs the preprocessor. Extension .S or .sx, or
-x assembler-with-cpp.
LinkerInput
An object file, an archive or a shared library. Anything the linker takes directly.
Implementations§
Source§impl InputKind
impl InputKind
Sourcepub fn from_x_arg(name: &str) -> Result<InputKind, XError>
pub fn from_x_arg(name: &str) -> Result<InputKind, XError>
Parses the argument of -x.
§Errors
Returns the offending name when it is not one we accept. C++ gets its own message, because “unknown language c++” reads like an oversight and it is a decision.
Sourcepub fn from_path(path: &str) -> Result<InputKind, XError>
pub fn from_path(path: &str) -> Result<InputKind, XError>
Classifies an input by its extension, the way spec/04-driver-and-cli.md section 4.2
tabulates it.
An unrecognized extension is a linker input, which is GCC’s behavior and is what makes
rucc foo.o bar.builtin-suffix work. The exception is a C++ extension, which is a
hard error rather than a confusing link failure later.
§Errors
Returns the extension when it names a language that is permanently out of scope.
Trait Implementations§
impl Copy for InputKind
impl Eq for InputKind
impl StructuralPartialEq for InputKind
Auto Trait Implementations§
impl Freeze for InputKind
impl RefUnwindSafe for InputKind
impl Send for InputKind
impl Sync for InputKind
impl Unpin for InputKind
impl UnsafeUnpin for InputKind
impl UnwindSafe for InputKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.