use core_wasm_ast as ast;
use std::io::Write;
use std::sync::Arc;
use std::sync::Mutex;
pub(crate) fn str(offset: u32, text: &str) -> Vec<u8> {
let mut bytes = vec![];
bytes
.write_all(&(offset + (4 * 2) as u32).to_le_bytes())
.unwrap();
bytes.write_all(&(text.len() as u32).to_le_bytes()).unwrap();
bytes.write_all(text.as_bytes()).unwrap();
bytes
}
pub(crate) fn print(fd_write: u32, ptr: u32) -> Vec<ast::Value<ast::Instr>> {
let fd_write = Arc::new(Mutex::new(ast::Value::new(fd_write)));
vec![
ast::Value::new(ast::Instr::i32_const(1)), ast::Value::new(ast::Instr::i32_const(ptr as i64)), ast::Value::new(ast::Instr::i32_const(1)), ast::Value::new(ast::Instr::i32_const(1020)), ast::Value::new(ast::Instr::call(fd_write)),
ast::Value::new(ast::Instr::drop),
]
}