From 280979d00f4a0a5d12149c83d1ee5ab4e05d13a3 Mon Sep 17 00:00:00 2001 From: Rerumu Date: Fri, 20 May 2022 22:51:45 -0400 Subject: [PATCH] Remove local modules in tests --- dev-test/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dev-test/src/lib.rs b/dev-test/src/lib.rs index b32b0e4..b7f0a77 100644 --- a/dev-test/src/lib.rs +++ b/dev-test/src/lib.rs @@ -52,17 +52,18 @@ impl Target for LuaJIT { } fn write_register(post: &str, pre: &str, w: &mut dyn Write) -> IResult<()> { - writeln!(w, "local {} = module_{}", post, pre) + writeln!(w, "storage[\"{}\"] = storage[\"${}\"]", post, pre) } fn write_runtime(w: &mut dyn Write) -> IResult<()> { let runtime = codegen_luajit::RUNTIME; - writeln!(w, "local rt = (function() {runtime} end)()") + writeln!(w, "local rt = (function() {runtime} end)()")?; + writeln!(w, "local storage = {{}}") } fn write_module(data: TypedModule, w: &mut dyn Write) -> IResult<()> { - write!(w, "local module_{} = (function() ", data.name)?; + write!(w, "storage[\"${}\"] = (function() ", data.name)?; codegen_luajit::translate(data.module, &data.type_info, w)?; writeln!(w, "end)(nil)") } @@ -76,17 +77,18 @@ impl Target for Luau { } fn write_register(post: &str, pre: &str, w: &mut dyn Write) -> IResult<()> { - writeln!(w, "local {} = module_{}", post, pre) + writeln!(w, "storage[\"{}\"] = storage[\"${}\"]", post, pre) } fn write_runtime(w: &mut dyn Write) -> IResult<()> { let runtime = codegen_luau::RUNTIME; - writeln!(w, "local rt = (function() {runtime} end)()") + writeln!(w, "local rt = (function() {runtime} end)()")?; + writeln!(w, "local storage = {{}}") } fn write_module(data: TypedModule, w: &mut dyn Write) -> IResult<()> { - write!(w, "local module_{} = (function() ", data.name)?; + write!(w, "storage[\"${}\"] = (function() ", data.name)?; codegen_luau::translate(data.module, &data.type_info, w)?; writeln!(w, "end)(nil)") }