Fix table indexing

This commit is contained in:
Rerumu 2021-11-17 00:30:07 -05:00
parent f8446971d6
commit 583f96f857
2 changed files with 2 additions and 2 deletions

View File

@ -238,7 +238,7 @@ impl<'a> Body<'a> {
}
Instruction::CallIndirect(i, t) => {
let index = func.var_name_of(self.reg.pop(1));
let name = format!("TABLE_LIST[{}][{}]", t, index);
let name = format!("TABLE_LIST[{}].data[{}]", t, index);
let types = m.parent.type_section().unwrap().types();
let arity = Arity::from_index(types, *i);

View File

@ -166,7 +166,7 @@ fn gen_element_list(m: &Module, w: Writer) -> Result<()> {
for v in element {
writeln!(w, "do")?;
writeln!(w, "local target = TABLE_LIST[{}]", v.index())?;
writeln!(w, "local target = TABLE_LIST[{}].data", v.index())?;
writeln!(w, "local offset =")?;
gen_init_expression(v.offset().as_ref().unwrap().code(), w)?;