From f1a2c936de700ddf1c7ccb650be9598db40c13d4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 1 Nov 2017 16:49:11 -0700 Subject: Fixed some codegen stuff, optimized "say" for the common case of string literals. --- nomsu.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index da0c699..f7182ba 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -479,7 +479,12 @@ end);]]):format(statements or "", expr or "ret") self:errorln(debug.traceback()) self:error(ret) end - insert(buffer, tostring(statements or '') .. "\n" .. tostring(expr and "ret = " .. tostring(expr) .. ";" or '')) + if statements then + insert(buffer, statements) + end + if expr then + insert(buffer, "ret = " .. tostring(expr) .. ";") + end end if max_operations then debug.sethook() @@ -488,7 +493,7 @@ end);]]):format(statements or "", expr or "ret") local ret; %s return ret; -end);]]):format(concat(buffer, "")) +end);]]):format(concat(buffer, "\n")) return return_value, lua_code, vars end, tree_to_value = function(self, tree, vars) @@ -911,7 +916,7 @@ end)]]):format(concat(lua_bits, "\n")) end return concat(stub, " "), arg_names else - return self:error("Unsupported get stub type: " .. tostring(x.type)) + return self:error("Unsupported get stub type: " .. tostring(x.type) .. " for " .. tostring(repr(x))) end end, get_stubs = function(self, x) -- cgit v1.2.3