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.moon | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'code_obj.moon') diff --git a/code_obj.moon b/code_obj.moon index fbe202c..66b7978 100644 --- a/code_obj.moon +++ b/code_obj.moon @@ -62,18 +62,8 @@ Source = immutable {"filename","start","stop"}, { class Code new: (@source, ...)=> - @bits = {...} - indent, indents = 0, {} - match = string.match - for i,b in ipairs @bits - if type(b) == 'string' - if spaces = match(b, "\n([ ]*)[^\n]*$") - indent = #spaces - elseif indent != 0 - indents[i] = indent - @current_indent = indent - @indents = indents - @__str = nil + @bits, @indents, @current_indent = {}, {}, 0 + @append(...) if type(@source) == 'string' filename,start,stop = @source\match("^(.-)%[(%d+):(%d+)%]$") unless filename @@ -91,16 +81,17 @@ class Code append: (...)=> n = select("#",...) - bits = @bits + bits, indents = @bits, @indents + match = string.match for i=1,n b = select(i, ...) assert(b != self, "No recursion please.") bits[#bits+1] = b if type(b) == 'string' - if spaces = b\match("\n([ ]*)[^\n]*$") + if spaces = match(b, "\n([ ]*)[^\n]*$") @current_indent = #spaces elseif @current_indent != 0 - @indents[#bits] = @current_indent + indents[#bits] = @current_indent @__str = nil prepend: (...)=> -- cgit v1.2.3