Introduce hex/string printing in runtime.

This commit is contained in:
Gav
2018-01-27 13:42:40 +01:00
parent ace1387076
commit d97520c7f0
10 changed files with 34 additions and 12 deletions
+6 -1
View File
@@ -78,13 +78,18 @@ impl WritePrimitive<u32> for MemoryInstance {
}
impl_function_executor!(this: FunctionExecutor<'e, E>,
ext_print(utf8_data: *const u8, utf8_len: u32) => {
ext_print_utf8(utf8_data: *const u8, utf8_len: u32) => {
if let Ok(utf8) = this.memory.get(utf8_data, utf8_len as usize) {
if let Ok(message) = String::from_utf8(utf8) {
println!("Runtime: {}", message);
}
}
},
ext_print_hex(data: *const u8, len: u32) => {
if let Ok(hex) = this.memory.get(data, len as usize) {
println!("Runtime: {}", HexDisplay::from(&hex));
}
},
ext_print_num(number: u64) => {
println!("Runtime: {}", number);
},