From 01a4f36398bfe66a7286a83fdd797c8b20541681 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 Jul 2018 14:30:32 -0700 Subject: Minor changes. --- code_obj.moon | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'code_obj.moon') 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 -- cgit v1.2.3