From 446892d11ee712839084e4599a07d8decf6b3b54 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 24 May 2018 16:13:23 -0700 Subject: Consolidating code obj code and expunging all [[..]]-style lua strings. --- code_obj.lua | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'code_obj.lua') diff --git a/code_obj.lua b/code_obj.lua index ab0f1ac..f0440ca 100644 --- a/code_obj.lua +++ b/code_obj.lua @@ -101,20 +101,21 @@ do end, append = function(self, ...) local n = select("#", ...) - local bits = self.bits + local bits, indents = self.bits, self.indents + local match = string.match for i = 1, n do local b = select(i, ...) assert(b ~= self, "No recursion please.") bits[#bits + 1] = b if type(b) == 'string' then do - local spaces = b:match("\n([ ]*)[^\n]*$") + local spaces = match(b, "\n([ ]*)[^\n]*$") if spaces then self.current_indent = #spaces end end elseif self.current_indent ~= 0 then - self.indents[#bits] = self.current_indent + indents[#bits] = self.current_indent end end self.__str = nil @@ -151,26 +152,8 @@ do _class_0 = setmetatable({ __init = function(self, source, ...) self.source = source - self.bits = { - ... - } - local indent, indents = 0, { } - local match = string.match - for i, b in ipairs(self.bits) do - if type(b) == 'string' then - do - local spaces = match(b, "\n([ ]*)[^\n]*$") - if spaces then - indent = #spaces - end - end - elseif indent ~= 0 then - indents[i] = indent - end - end - self.current_indent = indent - self.indents = indents - self.__str = nil + self.bits, self.indents, self.current_indent = { }, { }, 0 + self:append(...) if type(self.source) == 'string' then local filename, start, stop = self.source:match("^(.-)%[(%d+):(%d+)%]$") if not (filename) then -- cgit v1.2.3