aboutsummaryrefslogtreecommitdiff
path: root/code_obj.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-13 14:30:32 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-13 14:30:39 -0700
commit01a4f36398bfe66a7286a83fdd797c8b20541681 (patch)
treeb2ef8fc3ff0459295d6165832f62f06d0dca3055 /code_obj.moon
parent84c0058e69a18d5aec0ca4641725e87eddf4362f (diff)
Minor changes.
Diffstat (limited to 'code_obj.moon')
-rw-r--r--code_obj.moon11
1 files changed, 10 insertions, 1 deletions
diff --git a/code_obj.moon b/code_obj.moon
index ce8e715..caca4cf 100644
--- a/code_obj.moon
+++ b/code_obj.moon
@@ -2,6 +2,7 @@
-- build up generated code, while keeping track of where it came from, and managing
-- indentation levels.
{:insert, :remove, :concat} = table
+{:repr} = require 'utils'
local LuaCode, NomsuCode, Source
export LINE_STARTS
@@ -44,6 +45,7 @@ class Source
return Source(@filename, @start+offset, @stop)
class Code
+ is_code: true
new: (@source, ...)=>
@bits = {}
@indents, @current_indent = {}, 0
@@ -60,9 +62,11 @@ class Code
for i=1,n
b = select(i, ...)
assert(b, "code bit is nil")
- if Source\is_instance(b) then require('ldt').breakpoint!
+ assert(not Source\is_instance(b), "code bit is a Source")
if b == '' then continue
bits[#bits+1] = b
+ if type(b) != 'string' and not (type(b) == 'table' and b.is_code)
+ b = repr(b)
if type(b) == 'string'
trailing_text, spaces = match(b, "\n(([ ]*)[^\n]*)$")
if trailing_text
@@ -131,6 +135,11 @@ class LuaCode extends Code
lua = LuaCode(...)
lua.is_value = true
return lua
+
+ @Comment = (...)->
+ lua = LuaCode(...)
+ lua.is_comment = true
+ return lua
add_free_vars: (vars)=>
return unless #vars > 0