From 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 8 Nov 2018 15:23:22 -0800 Subject: Major overhaul, splitting nomsu_compiler into nomsu_environment, nomsu_compiler, and nomsu_decompiler. Also added comprehensions. --- code_obj.moon | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'code_obj.moon') diff --git a/code_obj.moon b/code_obj.moon index cb8eae2..39a59c6 100644 --- a/code_obj.moon +++ b/code_obj.moon @@ -50,6 +50,8 @@ class Code --assert(@source and Source\is_instance(@source), "Source has the wrong type") @append(...) + @is_instance: (x)=> type(x) == 'table' and x.__class == @ + text: => if @__str == nil buff, indent = {}, 0 @@ -165,13 +167,7 @@ class LuaCode extends Code new: (...)=> super ... @free_vars = {} - @is_value = false - @Value = (...)-> - lua = LuaCode(...) - lua.is_value = true - return lua - add_free_vars: (vars)=> return unless #vars > 0 seen = {[v]:true for v in *@free_vars} @@ -219,7 +215,7 @@ class LuaCode extends Code return to_declare as_statements: (prefix="", suffix=";")=> - unless @is_value + if @text!\matches(";$") or @text! == "" return self statements = LuaCode(@source) if prefix != "" @@ -250,7 +246,6 @@ class LuaCode extends Code } parenthesize: => - assert @is_value, "Cannot parenthesize lua statements" @prepend "(" @append ")" -- cgit v1.2.3