78 lines
1.3 KiB
Rust
78 lines
1.3 KiB
Rust
#![feature(lang_items, prelude_import)]
|
|
#![feature(panic_info_message)]
|
|
#![no_std]
|
|
|
|
#[cfg(not(test))]
|
|
mod entry;
|
|
|
|
pub mod env;
|
|
pub mod exit;
|
|
pub mod io;
|
|
|
|
#[cfg(not(test))]
|
|
pub mod panic;
|
|
|
|
extern crate alloc;
|
|
|
|
use core::{arch::asm, fmt::Display};
|
|
|
|
#[prelude_import]
|
|
pub use prelude::rust_2021::*;
|
|
|
|
pub mod prelude;
|
|
|
|
use versioning::Version;
|
|
|
|
pub mod path;
|
|
|
|
pub const VERSION: Version = Version::new(0, 1, 0);
|
|
|
|
// extern crate alloc;
|
|
|
|
pub fn print(s: &str) {
|
|
unsafe {
|
|
asm!(
|
|
"syscall",
|
|
in("rax") 1,
|
|
in("rdi") 1,
|
|
in("rsi") s.as_ptr(),
|
|
in("rdx") s.len(),
|
|
out("rcx") _,
|
|
out("r11") _,
|
|
);
|
|
}
|
|
}
|
|
|
|
pub fn print_char(c: char) {
|
|
let array = [c];
|
|
|
|
unsafe {
|
|
asm!(
|
|
"syscall",
|
|
in("rax") 1,
|
|
in("rdi") 1,
|
|
in("rsi") array.as_ptr(),
|
|
in("rdx") 1,
|
|
out("rcx") _,
|
|
out("r11") _,
|
|
);
|
|
}
|
|
}
|
|
#[derive(Debug)]
|
|
pub struct LocationInFile<'a> {
|
|
// TODO: replace &str with ableOS path
|
|
file_path: &'a str,
|
|
|
|
line: u16,
|
|
column: u16,
|
|
}
|
|
impl<'a> Display for LocationInFile<'a> {
|
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
write!(f, "{}{}{}", self.file_path, self.line, self.column)
|
|
}
|
|
}
|
|
|
|
pub trait Error {
|
|
fn id(&self) -> u128;
|
|
}
|