forked from AbleOS/ableos
rhai shell tinkering
This commit is contained in:
parent
19508c979e
commit
d4e4d70461
5
ableos/Cargo.lock
generated
5
ableos/Cargo.lock
generated
|
@ -46,6 +46,7 @@ dependencies = [
|
|||
"picorand",
|
||||
"pretty-hex",
|
||||
"rdrand",
|
||||
"rhai",
|
||||
"rkyv",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -483,9 +484,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rhai"
|
||||
version = "1.4.1"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "898b114d6cfa18af4593393fdc6c7437118e7e624d97f635fba8c75fd5c06f56"
|
||||
checksum = "49c94fda0280985896ed6d8bf0b43bbb5a7f0e39ccc8728ac907ddb4f06dae94"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"core-error",
|
||||
|
|
|
@ -62,7 +62,7 @@ picorand = "*"
|
|||
genfs = "0.1.0"
|
||||
# pc-beeper = "0.1.0"
|
||||
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
|
||||
|
||||
rhai = "1.5"
|
||||
|
||||
pci = {git="https://gitlab.com/robigalia/pci"}
|
||||
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
arch::{drivers::vga::WRITER, gdt},
|
||||
kernel_state::KERNEL_STATE,
|
||||
print, println,
|
||||
print, println, KEYBUFF,
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
@ -94,16 +94,13 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
|||
// WRITER.lock().backspace();
|
||||
}
|
||||
|
||||
// Enter
|
||||
0x0A => {
|
||||
// let _xyz = crate::kmain::KEY_BUFFER.lock();
|
||||
|
||||
// print!("{}", char::try_from(character).unwrap());
|
||||
}
|
||||
|
||||
0x5E => KERNEL_STATE.lock().shutdown(),
|
||||
|
||||
_ => {
|
||||
let mut buff = KEYBUFF.lock();
|
||||
|
||||
buff.push(character as u8 as char);
|
||||
|
||||
print!("{}", char::try_from(character).unwrap());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ pub fn kernel_main() -> ! {
|
|||
start_facepalm();
|
||||
scratchpad();
|
||||
|
||||
loop {
|
||||
if false {
|
||||
disable();
|
||||
let mut mode = SCREEN_BUFFER.lock();
|
||||
mode.force_redraw();
|
||||
|
@ -104,8 +104,6 @@ pub fn kernel_main() -> ! {
|
|||
// sloop::halt();
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
sloop()
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ pub fn scratchpad() {
|
|||
debug!("{}", key);
|
||||
}
|
||||
|
||||
interp();
|
||||
// interp();
|
||||
|
||||
rhai_shell();
|
||||
}
|
||||
|
||||
pub struct PciIO {}
|
||||
|
@ -61,7 +63,7 @@ impl PortOps for PciIO {
|
|||
cpuio::outl(val, port as u16);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// An experimental process message format
|
||||
pub struct ProcessMessage {
|
||||
pub to_pid: PID,
|
||||
|
@ -71,7 +73,7 @@ pub struct ProcessMessage {
|
|||
pub sender_time: SecondsTime,
|
||||
}
|
||||
//
|
||||
use libwasm::syscalls::time_calls::SecondsTime;
|
||||
// use libwasm::syscalls::time_calls::SecondsTime;
|
||||
|
||||
impl ProcessMessage {
|
||||
pub fn new(to_pid: PID, from_pid: PID, message: [u8; 2048]) -> Self {
|
||||
|
@ -86,3 +88,26 @@ impl ProcessMessage {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn rhai_shell() {
|
||||
let mut engine = rhai::Engine::new();
|
||||
|
||||
let ret = engine.eval::<i64>("1 + 2");
|
||||
|
||||
match ret {
|
||||
Ok(x) => println!("{}", x),
|
||||
Err(e) => println!("{}", e),
|
||||
}
|
||||
|
||||
loop {}
|
||||
}
|
||||
lazy_static::lazy_static!(
|
||||
pub static ref KEYBUFF: spin::Mutex<Vec<char>> = spin::Mutex::new(
|
||||
Vec::new())
|
||||
;
|
||||
);
|
||||
|
||||
use alloc::string::String;
|
||||
|
||||
use crate::arch::sloop;
|
||||
|
|
Loading…
Reference in a new issue