From 28cd9ae0b7a09d8f2cd0cd929f1ebdce4b081502 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 15 May 2018 15:21:32 -0700 Subject: More API cleanup, and fixed a bug with optimized lua files generating spurious circular import errors. --- nomsu_tree.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'nomsu_tree.lua') diff --git a/nomsu_tree.lua b/nomsu_tree.lua index 1fd1687..1132dac 100644 --- a/nomsu_tree.lua +++ b/nomsu_tree.lua @@ -801,15 +801,17 @@ Tree("Number", { end }) Tree("Var", { - as_lua = function(self, nomsu) - local lua_id = "_" .. (self.value:gsub("%W", function(verboten) - if verboten == "_" then + as_lua_id = function(v) + return "_" .. (v:gsub("%W", function(c) + if c == "_" then return "__" else - return ("_%x"):format(verboten:byte()) + return ("_%x"):format(c:byte()) end end)) - return Lua.Value(self.source, lua_id) + end, + as_lua = function(self, nomsu) + return Lua.Value(self.source, self.as_lua_id(self.value)) end, as_nomsu = function(self, inline) if inline == nil then -- cgit v1.2.3