aboutsummaryrefslogtreecommitdiff
path: root/code_obj.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-24 16:13:23 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-24 16:13:46 -0700
commit446892d11ee712839084e4599a07d8decf6b3b54 (patch)
tree7cf53ca93b179614ed8d1f390125e7ef50eb0716 /code_obj.lua
parent0c07968e0716745f7b510a76e94ccf0910e4c4e7 (diff)
Consolidating code obj code and expunging all [[..]]-style lua strings.
Diffstat (limited to 'code_obj.lua')
-rw-r--r--code_obj.lua29
1 files changed, 6 insertions, 23 deletions
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