From 1de29826a82cc858cf6d9df9ead86655304251a4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 12 Apr 2018 18:01:51 -0700 Subject: Incremental progress towards working. --- lua_obj.moon | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lua_obj.moon') diff --git a/lua_obj.moon b/lua_obj.moon index 1565fcb..ef5dc7e 100644 --- a/lua_obj.moon +++ b/lua_obj.moon @@ -56,7 +56,8 @@ class Lua declare_locals: (skip={})=> if next(skip) == 1 skip = {[s]:true for s in *skip} - @prepend "local #{concat @free_vars, ", "};\n" + if #@free_vars > 0 + @prepend "local #{concat @free_vars, ", "};\n" for var in *@free_vars do skip[var] = true for bit in *@bits if type(bit) == Lua @@ -66,7 +67,9 @@ class Lua buff = {} for b in *@bits buff[#buff+1] = tostring(b) - return concat(buff, "") + ret = concat(buff, "") + assert(not ret\match(".*table: 0x.*")) + return ret __len: => len = 0 @@ -96,7 +99,6 @@ class Lua lua_filename:lua_chunkname, lua_file:lua_str lua_to_nomsu: {}, nomsu_to_lua: {} } - metadata, lua_offset = {}, 1 lua_offset = 1 walk = (lua)-> if type(lua) == 'string' @@ -106,7 +108,7 @@ class Lua for b in *lua.bits walk b lua_stop = lua_offset - nomsu_src, lua_src = lua.souce, Location(lua_chunkname, lua_str, lua_start, lua_stop) + nomsu_src, lua_src = lua.source, Location(lua_chunkname, lua_str, lua_start, lua_stop) metadata.lua_to_nomsu[lua_src] = nomsu_src metadata.nomsu_to_lua[nomsu_src] = lua_src walk self @@ -119,6 +121,14 @@ class LuaValue extends Lua new: (@source, ...)=> @bits = {...} + __tostring: => + buff = {} + for b in *@bits + buff[#buff+1] = tostring(b) + ret = concat(buff, "") + assert(not ret\match(".*table: 0x.*")) + return ret + as_statements: => bits = {unpack @bits} bits[#bits+1] = ";" -- cgit v1.2.3