print SYSCALL works
This commit is contained in:
parent
9e836f8098
commit
9d1cb9c640
|
@ -8,7 +8,7 @@ const ADD_FUNC_INDEX: usize = 0;
|
|||
const GET_TIME_INDEX: usize = 2;
|
||||
const GET_RANDOM_INDEX: usize = 3;
|
||||
const GET_INPUT_INDEX: usize = 4;
|
||||
const PRINT_CLEVER_HACK: usize = 5;
|
||||
const PRINT_CHAR: usize = 6;
|
||||
const SEND_SIGNAL_INDEX: usize = 1;
|
||||
|
||||
pub struct HostExternals;
|
||||
|
@ -100,8 +100,8 @@ impl HostExternals {
|
|||
true
|
||||
}
|
||||
|
||||
PRINT_CLEVER_HACK => {
|
||||
let (params, ret_ty): (&[ValueType], Option<ValueType>) = (&[ValueType::I64], None);
|
||||
PRINT_CHAR => {
|
||||
let (params, ret_ty): (&[ValueType], Option<ValueType>) = (&[ValueType::I32], None);
|
||||
if params.len() != signature.params().len() {
|
||||
return false;
|
||||
}
|
||||
|
@ -178,20 +178,12 @@ impl Externals for HostExternals {
|
|||
Ok(Some(ret))
|
||||
}
|
||||
|
||||
PRINT_CLEVER_HACK => {
|
||||
// println!("SYSCALL: print clever hack");
|
||||
|
||||
let combinated = args.nth_checked::<u64>(0).unwrap().to_le_bytes();
|
||||
|
||||
for x in combinated.iter() {
|
||||
let chr = *x as char;
|
||||
print!("{}", chr);
|
||||
}
|
||||
|
||||
println!("\n");
|
||||
PRINT_CHAR => {
|
||||
let chr: u8 = args.nth_checked(0)?;
|
||||
trace!("SYSCALL: print: {}", chr);
|
||||
print!("{}", char::from(chr));
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
_ => {
|
||||
error!("Unimplemented function at {}", index);
|
||||
Err(Trap::new(wasmi::TrapKind::Unreachable))
|
||||
|
@ -208,7 +200,7 @@ impl ModuleImportResolver for HostExternals {
|
|||
"get_time" => GET_TIME_INDEX,
|
||||
"get_random" => GET_RANDOM_INDEX,
|
||||
"get_input" => GET_INPUT_INDEX,
|
||||
"print_clever_hack" => PRINT_CLEVER_HACK,
|
||||
"print_char" => PRINT_CHAR,
|
||||
_ => {
|
||||
return Err(Error::Instantiation(format!(
|
||||
"Export {} not found",
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue