aboutsummaryrefslogtreecommitdiff
path: root/code_obj.moon
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.moon
parent0c07968e0716745f7b510a76e94ccf0910e4c4e7 (diff)
Consolidating code obj code and expunging all [[..]]-style lua strings.
Diffstat (limited to 'code_obj.moon')
-rw-r--r--code_obj.moon21
1 files changed, 6 insertions, 15 deletions
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: (...)=>