2023-03-09 12:36:35 +00:00
|
|
|
#![feature(lang_items, prelude_import)]
|
|
|
|
#![feature(panic_info_message)]
|
|
|
|
#![no_std]
|
|
|
|
|
2023-03-30 18:53:52 +00:00
|
|
|
#[cfg(not(test))]
|
2023-03-09 12:36:35 +00:00
|
|
|
mod entry;
|
2023-03-30 18:53:52 +00:00
|
|
|
|
2023-03-30 06:31:55 +00:00
|
|
|
pub mod env;
|
2023-03-30 07:35:02 +00:00
|
|
|
pub mod exit;
|
2023-03-30 06:31:55 +00:00
|
|
|
pub mod io;
|
2023-03-30 18:53:52 +00:00
|
|
|
|
|
|
|
#[cfg(not(test))]
|
2023-03-09 12:36:35 +00:00
|
|
|
pub mod panic;
|
|
|
|
|
2023-03-30 18:53:52 +00:00
|
|
|
extern crate alloc;
|
|
|
|
|
2023-03-30 07:35:02 +00:00
|
|
|
use core::{arch::asm, fmt::Display};
|
2023-03-09 12:36:35 +00:00
|
|
|
|
|
|
|
#[prelude_import]
|
|
|
|
pub use prelude::rust_2021::*;
|
|
|
|
|
|
|
|
pub mod prelude;
|
|
|
|
|
|
|
|
use versioning::Version;
|
|
|
|
|
2023-05-09 06:07:52 +00:00
|
|
|
pub mod path;
|
|
|
|
|
2023-03-09 12:36:35 +00:00
|
|
|
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") _,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-03-30 06:31:55 +00:00
|
|
|
|
|
|
|
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") _,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-03-30 07:35:02 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct LocationInFile<'a> {
|
|
|
|
// TODO: replace &str with ableOS path
|
|
|
|
file_path: &'a str,
|
|
|
|
|
|
|
|
line: u16,
|
|
|
|
column: u16,
|
|
|
|
}
|
2023-03-30 10:21:18 +00:00
|
|
|
impl<'a> Display for LocationInFile<'a> {
|
2023-03-30 07:35:02 +00:00
|
|
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
|
|
write!(f, "{}{}{}", self.file_path, self.line, self.column)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-30 10:21:18 +00:00
|
|
|
pub trait Error {
|
|
|
|
fn id(&self) -> u128;
|
2023-03-30 07:35:02 +00:00
|
|
|
}
|