Add indentation to LuaJIT output
This commit is contained in:
parent
369097c432
commit
7efeffeac6
@ -6,11 +6,37 @@ use std::{
|
||||
|
||||
use wasm_ast::node::BrTable;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! indentation {
|
||||
($mng:tt, $w:tt) => {{
|
||||
let mut iter = 0..$mng.indentation();
|
||||
|
||||
iter.try_for_each(|_| write!($w, "\t"))
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! indented {
|
||||
($mng:tt, $w:tt, $($args:tt)*) => {{
|
||||
indentation!($mng, $w)?;
|
||||
write!($w, $($args)*)
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! line {
|
||||
($mng:tt, $w:tt, $($args:tt)*) => {{
|
||||
indentation!($mng, $w)?;
|
||||
writeln!($w, $($args)*)
|
||||
}};
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Manager {
|
||||
table_map: HashMap<usize, usize>,
|
||||
label_list: Vec<usize>,
|
||||
num_label: usize,
|
||||
indentation: usize,
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
@ -38,6 +64,18 @@ impl Manager {
|
||||
pub fn pop_label(&mut self) {
|
||||
self.label_list.pop().unwrap();
|
||||
}
|
||||
|
||||
pub fn indentation(&self) -> usize {
|
||||
self.indentation
|
||||
}
|
||||
|
||||
pub fn indent(&mut self) {
|
||||
self.indentation += 1;
|
||||
}
|
||||
|
||||
pub fn dedent(&mut self) {
|
||||
self.indentation -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Driver {
|
||||
|
@ -9,7 +9,7 @@ use wasm_ast::node::{
|
||||
};
|
||||
use wasmparser::ValType;
|
||||
|
||||
use crate::analyzer::br_table;
|
||||
use crate::{analyzer::br_table, indentation, indented, line};
|
||||
|
||||
use super::{
|
||||
expression::Condition,
|
||||
@ -21,13 +21,14 @@ impl Driver for Br {
|
||||
let level = *mng.label_list().iter().nth_back(self.target()).unwrap();
|
||||
|
||||
if !self.align().is_aligned() {
|
||||
indentation!(mng, w)?;
|
||||
write_ascending("reg", self.align().new_range(), w)?;
|
||||
write!(w, " = ")?;
|
||||
write_ascending("reg", self.align().old_range(), w)?;
|
||||
write!(w, " ")?;
|
||||
writeln!(w)?;
|
||||
}
|
||||
|
||||
write!(w, "goto continue_at_{level} ")
|
||||
line!(mng, w, "goto continue_at_{level}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +37,6 @@ fn to_ordered_table<'a>(list: &'a [Br], default: &'a Br) -> Vec<&'a Br> {
|
||||
|
||||
data.sort_by_key(|v| v.target());
|
||||
data.dedup_by_key(|v| v.target());
|
||||
|
||||
data
|
||||
}
|
||||
|
||||
@ -54,39 +54,51 @@ fn write_search_layer(
|
||||
let br = list[center];
|
||||
|
||||
if range.start != center {
|
||||
write!(w, "if temp < {} then ", br.target())?;
|
||||
line!(mng, w, "if temp < {} then", br.target())?;
|
||||
mng.indent();
|
||||
write_search_layer(range.start..center, list, mng, w)?;
|
||||
write!(w, "else")?;
|
||||
mng.dedent();
|
||||
indented!(mng, w, "else")?;
|
||||
}
|
||||
|
||||
if range.end != center + 1 {
|
||||
write!(w, "if temp > {} then ", br.target())?;
|
||||
writeln!(w, "if temp > {} then", br.target())?;
|
||||
mng.indent();
|
||||
write_search_layer(center + 1..range.end, list, mng, w)?;
|
||||
write!(w, "else")?;
|
||||
mng.dedent();
|
||||
indented!(mng, w, "else")?;
|
||||
}
|
||||
|
||||
write!(w, " ")?;
|
||||
writeln!(w)?;
|
||||
mng.indent();
|
||||
br.write(mng, w)?;
|
||||
write!(w, "end ")
|
||||
mng.dedent();
|
||||
line!(mng, w, "end")
|
||||
}
|
||||
|
||||
fn write_table_setup(table: &BrTable, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
let id = mng.get_table_index(table);
|
||||
|
||||
write!(w, "if not br_map[{id}] then ")?;
|
||||
write!(w, "br_map[{id}] = (function() return {{[0] =")?;
|
||||
line!(mng, w, "if not br_map[{id}] then")?;
|
||||
mng.indent();
|
||||
line!(mng, w, "br_map[{id}] = (function()")?;
|
||||
mng.indent();
|
||||
indented!(mng, w, "return {{ [0] = ")?;
|
||||
|
||||
table
|
||||
.data()
|
||||
.iter()
|
||||
.try_for_each(|v| write!(w, "{}, ", v.target()))?;
|
||||
|
||||
write!(w, "}} end)()")?;
|
||||
write!(w, "end ")?;
|
||||
writeln!(w, "}}")?;
|
||||
mng.dedent();
|
||||
line!(mng, w, "end)()")?;
|
||||
mng.dedent();
|
||||
line!(mng, w, "end")?;
|
||||
|
||||
write!(w, "temp = br_map[{id}][")?;
|
||||
indented!(mng, w, "temp = br_map[{id}][")?;
|
||||
table.condition().write(w)?;
|
||||
write!(w, "] or {} ", table.default().target())
|
||||
writeln!(w, "] or {}", table.default().target())
|
||||
}
|
||||
|
||||
impl Driver for BrTable {
|
||||
@ -111,7 +123,7 @@ impl Driver for BrTable {
|
||||
impl Driver for Terminator {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
match self {
|
||||
Self::Unreachable => write!(w, "error(\"out of code bounds\")"),
|
||||
Self::Unreachable => line!(mng, w, r#"error("out of code bounds")"#),
|
||||
Self::Br(s) => s.write(mng, w),
|
||||
Self::BrTable(s) => s.write(mng, w),
|
||||
}
|
||||
@ -121,10 +133,11 @@ impl Driver for Terminator {
|
||||
fn write_inner_block(block: &Block, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
block.code().iter().try_for_each(|s| s.write(mng, w))?;
|
||||
|
||||
match block.last() {
|
||||
Some(v) => v.write(mng, w),
|
||||
None => Ok(()),
|
||||
if let Some(v) = block.last() {
|
||||
v.write(mng, w)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl Driver for Block {
|
||||
@ -134,18 +147,20 @@ impl Driver for Block {
|
||||
match self.label_type() {
|
||||
Some(LabelType::Forward) => {
|
||||
write_inner_block(self, mng, w)?;
|
||||
write!(w, "::continue_at_{label}::")?;
|
||||
line!(mng, w, "::continue_at_{label}::")?;
|
||||
}
|
||||
Some(LabelType::Backward) => {
|
||||
write!(w, "::continue_at_{label}::")?;
|
||||
write!(w, "while true do ")?;
|
||||
line!(mng, w, "::continue_at_{label}::")?;
|
||||
line!(mng, w, "while true do")?;
|
||||
mng.indent();
|
||||
write_inner_block(self, mng, w)?;
|
||||
|
||||
if self.last().is_none() {
|
||||
write!(w, "break ")?;
|
||||
line!(mng, w, "break")?;
|
||||
}
|
||||
|
||||
write!(w, "end ")?;
|
||||
mng.dedent();
|
||||
line!(mng, w, "end")?;
|
||||
}
|
||||
None => write_inner_block(self, mng, w)?,
|
||||
}
|
||||
@ -158,29 +173,34 @@ impl Driver for Block {
|
||||
|
||||
impl Driver for BrIf {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
write!(w, "if ")?;
|
||||
indented!(mng, w, "if ")?;
|
||||
Condition(self.condition()).write(w)?;
|
||||
write!(w, "then ")?;
|
||||
writeln!(w, " then")?;
|
||||
mng.indent();
|
||||
self.target().write(mng, w)?;
|
||||
write!(w, "end ")
|
||||
mng.dedent();
|
||||
line!(mng, w, "end")
|
||||
}
|
||||
}
|
||||
|
||||
impl Driver for If {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
write!(w, "if ")?;
|
||||
indented!(mng, w, "if ")?;
|
||||
Condition(self.condition()).write(w)?;
|
||||
write!(w, "then ")?;
|
||||
writeln!(w, " then")?;
|
||||
|
||||
mng.indent();
|
||||
self.on_true().write(mng, w)?;
|
||||
mng.dedent();
|
||||
|
||||
if let Some(v) = self.on_false() {
|
||||
write!(w, "else ")?;
|
||||
|
||||
line!(mng, w, "else")?;
|
||||
mng.indent();
|
||||
v.write(mng, w)?;
|
||||
mng.dedent();
|
||||
}
|
||||
|
||||
write!(w, "end ")
|
||||
line!(mng, w, "end")
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,19 +282,25 @@ impl DriverNoContext for MemoryGrow {
|
||||
}
|
||||
}
|
||||
|
||||
fn write_stat(stat: &dyn DriverNoContext, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
indentation!(mng, w)?;
|
||||
stat.write(w)?;
|
||||
writeln!(w)
|
||||
}
|
||||
|
||||
impl Driver for Statement {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
match self {
|
||||
Self::Block(s) => s.write(mng, w),
|
||||
Self::BrIf(s) => s.write(mng, w),
|
||||
Self::If(s) => s.write(mng, w),
|
||||
Self::Call(s) => s.write(w),
|
||||
Self::CallIndirect(s) => s.write(w),
|
||||
Self::SetTemporary(s) => s.write(w),
|
||||
Self::SetLocal(s) => s.write(w),
|
||||
Self::SetGlobal(s) => s.write(w),
|
||||
Self::StoreAt(s) => s.write(w),
|
||||
Self::MemoryGrow(s) => s.write(w),
|
||||
Self::Call(s) => write_stat(s, mng, w),
|
||||
Self::CallIndirect(s) => write_stat(s, mng, w),
|
||||
Self::SetTemporary(s) => write_stat(s, mng, w),
|
||||
Self::SetLocal(s) => write_stat(s, mng, w),
|
||||
Self::SetGlobal(s) => write_stat(s, mng, w),
|
||||
Self::StoreAt(s) => write_stat(s, mng, w),
|
||||
Self::MemoryGrow(s) => write_stat(s, mng, w),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,10 +308,10 @@ impl Driver for Statement {
|
||||
fn write_parameter_list(ast: &FuncData, w: &mut dyn Write) -> Result<()> {
|
||||
write!(w, "function(")?;
|
||||
write_ascending("loc", 0..ast.num_param(), w)?;
|
||||
write!(w, ")")
|
||||
writeln!(w, ")")
|
||||
}
|
||||
|
||||
fn write_variable_list(ast: &FuncData, w: &mut dyn Write) -> Result<()> {
|
||||
fn write_variable_list(ast: &FuncData, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
let mut total = ast.num_param();
|
||||
|
||||
for data in ast.local_data().iter().filter(|v| v.0 != 0) {
|
||||
@ -294,17 +320,17 @@ fn write_variable_list(ast: &FuncData, w: &mut dyn Write) -> Result<()> {
|
||||
|
||||
total = range.end;
|
||||
|
||||
write!(w, "local ")?;
|
||||
indented!(mng, w, "local ")?;
|
||||
write_ascending("loc", range.clone(), w)?;
|
||||
write!(w, " = ")?;
|
||||
write_separated(range, |_, w| w.write_all(typed), w)?;
|
||||
write!(w, " ")?;
|
||||
writeln!(w)?;
|
||||
}
|
||||
|
||||
if ast.num_stack() != 0 {
|
||||
write!(w, "local ")?;
|
||||
indented!(mng, w, "local ")?;
|
||||
write_ascending("reg", 0..ast.num_stack(), w)?;
|
||||
write!(w, " ")?;
|
||||
writeln!(w)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -314,22 +340,26 @@ impl Driver for FuncData {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
let br_map = br_table::visit(self);
|
||||
|
||||
mng.indent();
|
||||
|
||||
write_parameter_list(self, w)?;
|
||||
write_variable_list(self, w)?;
|
||||
write_variable_list(self, mng, w)?;
|
||||
|
||||
if !br_map.is_empty() {
|
||||
write!(w, "local br_map, temp = {{}}, nil ")?;
|
||||
line!(mng, w, "local br_map, temp = {{}}, nil")?;
|
||||
}
|
||||
|
||||
mng.set_table_map(br_map);
|
||||
self.code().write(mng, w)?;
|
||||
|
||||
if self.num_result() != 0 {
|
||||
write!(w, "return ")?;
|
||||
indented!(mng, w, "return ")?;
|
||||
write_ascending("reg", 0..self.num_result(), w)?;
|
||||
write!(w, " ")?;
|
||||
writeln!(w)?;
|
||||
}
|
||||
|
||||
write!(w, "end ")
|
||||
mng.dedent();
|
||||
|
||||
line!(mng, w, "end")
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ fn write_named_array(name: &str, len: usize, w: &mut dyn Write) -> Result<()> {
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
write!(w, "local {name} = table_new({len}, 1)")
|
||||
writeln!(w, "local {name} = table_new({len}, 1)")
|
||||
}
|
||||
|
||||
fn write_constant(init: &InitExpr, type_info: &TypeInfo, w: &mut dyn Write) -> Result<()> {
|
||||
@ -56,7 +56,7 @@ fn write_constant(init: &InitExpr, type_info: &TypeInfo, w: &mut dyn Write) -> R
|
||||
if let Some(Statement::SetTemporary(stat)) = func.code().code().last() {
|
||||
stat.value().write(w)
|
||||
} else {
|
||||
write!(w, r#"error("Valueless constant")"#)
|
||||
writeln!(w, r#"error("Valueless constant")"#)
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,8 @@ fn write_import_of(list: &[Import], wanted: External, w: &mut dyn Write) -> Resu
|
||||
.filter(|v| External::from(v.ty) == wanted)
|
||||
.enumerate()
|
||||
{
|
||||
write!(w, r#"{upper}[{i}] = wasm["{module}"].{lower}["{name}"]"#)?;
|
||||
write!(w, "\t")?;
|
||||
writeln!(w, r#"{upper}[{i}] = wasm["{module}"].{lower}["{name}"]"#)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -79,13 +80,14 @@ fn write_export_of(list: &[Export], wanted: External, w: &mut dyn Write) -> Resu
|
||||
let lower = wanted.as_ie_name();
|
||||
let upper = lower.to_uppercase();
|
||||
|
||||
write!(w, "{lower} = {{")?;
|
||||
writeln!(w, "\t\t{lower} = {{")?;
|
||||
|
||||
for Export { name, index, .. } in list.iter().filter(|v| External::from(v.kind) == wanted) {
|
||||
write!(w, r#"["{name}"] = {upper}[{index}],"#)?;
|
||||
write!(w, "\t\t\t")?;
|
||||
writeln!(w, r#"["{name}"] = {upper}[{index}],"#)?;
|
||||
}
|
||||
|
||||
write!(w, "}},")
|
||||
writeln!(w, "\t\t}},")
|
||||
}
|
||||
|
||||
fn write_import_list(list: &[Import], w: &mut dyn Write) -> Result<()> {
|
||||
@ -111,9 +113,9 @@ fn write_table_list(wasm: &Module, w: &mut dyn Write) -> Result<()> {
|
||||
let min = table.initial;
|
||||
let max = table.maximum.unwrap_or(0xFFFF);
|
||||
|
||||
write!(
|
||||
writeln!(
|
||||
w,
|
||||
"TABLE_LIST[{index}] = {{ min = {min}, max = {max}, data = {{}} }}"
|
||||
"\tTABLE_LIST[{index}] = {{ min = {min}, max = {max}, data = {{}} }}"
|
||||
)?;
|
||||
}
|
||||
|
||||
@ -129,7 +131,7 @@ fn write_memory_list(wasm: &Module, w: &mut dyn Write) -> Result<()> {
|
||||
let min = ty.initial;
|
||||
let max = ty.maximum.unwrap_or(0xFFFF);
|
||||
|
||||
write!(w, "MEMORY_LIST[{index}] = rt.allocator.new({min}, {max})")?;
|
||||
writeln!(w, "\tMEMORY_LIST[{index}] = rt.allocator.new({min}, {max})")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -142,9 +144,9 @@ fn write_global_list(wasm: &Module, type_info: &TypeInfo, w: &mut dyn Write) ->
|
||||
for (i, global) in global.iter().enumerate() {
|
||||
let index = offset + i;
|
||||
|
||||
write!(w, "GLOBAL_LIST[{index}] = {{ value =")?;
|
||||
write!(w, "\tGLOBAL_LIST[{index}] = {{ value = ")?;
|
||||
write_constant(&global.init_expr, type_info, w)?;
|
||||
write!(w, "}}")?;
|
||||
writeln!(w, " }}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -160,13 +162,14 @@ fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write)
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
|
||||
write!(w, "do ")?;
|
||||
write!(w, "local target = TABLE_LIST[{index}].data ")?;
|
||||
write!(w, "local offset =")?;
|
||||
writeln!(w, "\tdo")?;
|
||||
writeln!(w, "\t\tlocal target = TABLE_LIST[{index}].data")?;
|
||||
write!(w, "\t\tlocal offset = ")?;
|
||||
|
||||
write_constant(&init, type_info, w)?;
|
||||
|
||||
write!(w, "local data = {{")?;
|
||||
writeln!(w)?;
|
||||
write!(w, "\t\tlocal data = {{ ")?;
|
||||
|
||||
for item in element.items.get_items_reader().unwrap() {
|
||||
match item.unwrap() {
|
||||
@ -175,11 +178,9 @@ fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write)
|
||||
}?;
|
||||
}
|
||||
|
||||
write!(w, "}}")?;
|
||||
|
||||
write!(w, "table.move(data, 1, #data, offset, target)")?;
|
||||
|
||||
write!(w, "end ")?;
|
||||
writeln!(w, " }}")?;
|
||||
writeln!(w, "\t\ttable.move(data, 1, #data, offset, target)")?;
|
||||
writeln!(w, "\tend")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -195,10 +196,9 @@ fn write_data_list(list: &[Data], type_info: &TypeInfo, w: &mut dyn Write) -> Re
|
||||
} => (memory_index, init_expr),
|
||||
};
|
||||
|
||||
write!(w, "rt.store.string(")?;
|
||||
write!(w, "MEMORY_LIST[{index}],")?;
|
||||
write!(w, "\trt.store.string(MEMORY_LIST[{index}], ")?;
|
||||
write_constant(&init, type_info, w)?;
|
||||
write!(w, r#","{}")"#, data.data.escape_ascii())?;
|
||||
writeln!(w, r#","{}")"#, data.data.escape_ascii())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -229,7 +229,9 @@ fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()
|
||||
("rotr", _) => write!(w, "bit.ror"),
|
||||
("convert", "f32_i64" | "f64_i64") => write!(w, "tonumber"),
|
||||
_ => write!(w, "rt.{head}.{tail}"),
|
||||
}
|
||||
}?;
|
||||
|
||||
writeln!(w)
|
||||
}
|
||||
|
||||
fn write_localize_used(func_list: &[FuncData], w: &mut dyn Write) -> Result<BTreeSet<usize>> {
|
||||
@ -246,7 +248,7 @@ fn write_localize_used(func_list: &[FuncData], w: &mut dyn Write) -> Result<BTre
|
||||
}
|
||||
|
||||
for mem in &mem_set {
|
||||
write!(w, "local memory_at_{mem} ")?;
|
||||
writeln!(w, "local memory_at_{mem}")?;
|
||||
}
|
||||
|
||||
Ok(mem_set)
|
||||
@ -279,29 +281,30 @@ fn write_module_start(
|
||||
mem_set: &BTreeSet<usize>,
|
||||
w: &mut dyn Write,
|
||||
) -> Result<()> {
|
||||
write!(w, "local function run_init_code()")?;
|
||||
writeln!(w, "local function run_init_code()")?;
|
||||
write_table_list(wasm, w)?;
|
||||
write_memory_list(wasm, w)?;
|
||||
write_global_list(wasm, type_info, w)?;
|
||||
write_element_list(wasm.element_section(), type_info, w)?;
|
||||
write_data_list(wasm.data_section(), type_info, w)?;
|
||||
write!(w, "end ")?;
|
||||
writeln!(w, "end")?;
|
||||
|
||||
write!(w, "return function(wasm)")?;
|
||||
writeln!(w, "return function(wasm)")?;
|
||||
write_import_list(wasm.import_section(), w)?;
|
||||
write!(w, "run_init_code()")?;
|
||||
writeln!(w, "\trun_init_code()")?;
|
||||
|
||||
for mem in mem_set {
|
||||
write!(w, "memory_at_{mem} = MEMORY_LIST[{mem}]")?;
|
||||
writeln!(w, "\tmemory_at_{mem} = MEMORY_LIST[{mem}]")?;
|
||||
}
|
||||
|
||||
if let Some(start) = wasm.start_section() {
|
||||
write!(w, "FUNC_LIST[{start}]()")?;
|
||||
writeln!(w, "\tFUNC_LIST[{start}]()")?;
|
||||
}
|
||||
|
||||
write!(w, "return {{")?;
|
||||
writeln!(w, "\treturn {{")?;
|
||||
write_export_list(wasm.export_section(), w)?;
|
||||
write!(w, "}} end ")
|
||||
writeln!(w, "\t}}")?;
|
||||
writeln!(w, "end")
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
@ -318,7 +321,7 @@ pub fn from_module_typed(wasm: &Module, type_info: &TypeInfo, w: &mut dyn Write)
|
||||
let func_list = build_func_list(wasm, type_info);
|
||||
let mem_set = write_localize_used(&func_list, w)?;
|
||||
|
||||
write!(w, "local table_new = require(\"table.new\")")?;
|
||||
writeln!(w, "local table_new = require(\"table.new\")")?;
|
||||
write_named_array("FUNC_LIST", wasm.function_space(), w)?;
|
||||
write_named_array("TABLE_LIST", wasm.table_space(), w)?;
|
||||
write_named_array("MEMORY_LIST", wasm.memory_space(), w)?;
|
||||
|
@ -92,7 +92,7 @@ impl Target for LuaJIT {
|
||||
};
|
||||
let data = Module::from_data(&bytes);
|
||||
|
||||
write!(w, "assert_trap((function() ")?;
|
||||
writeln!(w, "assert_trap((function()")?;
|
||||
codegen_luajit::from_module_untyped(&data, w)?;
|
||||
writeln!(w, "end)(), linked)")
|
||||
}
|
||||
@ -140,7 +140,7 @@ impl Target for LuaJIT {
|
||||
let runtime = codegen_luajit::RUNTIME;
|
||||
|
||||
writeln!(w, "local rt = (function()")?;
|
||||
writeln!(w, "{runtime}")?;
|
||||
write!(w, "{runtime}")?;
|
||||
writeln!(w, "end)()")?;
|
||||
|
||||
writeln!(w, "{ASSERTION}")
|
||||
@ -149,7 +149,7 @@ impl Target for LuaJIT {
|
||||
fn write_module(data: &Module, name: Option<&str>, w: &mut dyn Write) -> Result<()> {
|
||||
let type_info = TypeInfo::from_module(data);
|
||||
|
||||
write!(w, r#"loaded["temp"] = (function() "#)?;
|
||||
writeln!(w, r#"loaded["temp"] = (function()"#)?;
|
||||
codegen_luajit::from_module_typed(data, &type_info, w)?;
|
||||
writeln!(w, "end)()(linked)")?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user