Fix bit localizing

This commit is contained in:
Rerumu 2022-05-26 21:00:29 -04:00
parent 8d4da9547c
commit 08d2108a21
2 changed files with 9 additions and 3 deletions

View File

@ -232,9 +232,13 @@ fn build_func_list(wasm: &Module, type_info: &TypeInfo) -> Vec<Intermediate> {
fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> {
match (head, tail) {
("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _) | ("band" | "bor" | "bxor", _) => {
("band" | "bor" | "bxor", _) => {
write!(w, "local {head}_{tail} = bit.{head} ")
}
("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _) => {
write!(w, "local {head}_{tail} = math.{head} ")
}
_ => write!(w, "local {head}_{tail} = rt.{head}.{tail} "),
}
}

View File

@ -231,8 +231,10 @@ fn build_func_list(wasm: &Module, type_info: &TypeInfo) -> Vec<Intermediate> {
fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> {
match (head, tail) {
("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _)
| ("band" | "bor" | "bxor", "i32") => {
("band" | "bor" | "bxor", "i32") => {
write!(w, "local {head}_{tail} = bit32.{head} ")
}
("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _) => {
write!(w, "local {head}_{tail} = math.{head} ")
}
_ => write!(w, "local {head}_{tail} = rt.{head}.{tail} "),