diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:23:22 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:24:15 -0800 |
| commit | 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 (patch) | |
| tree | 8e335399e77b1893657b9fa985db0738034daac3 /code_obj.moon | |
| parent | 1f3660f393c1a17988a15b89f18686b28e51a9e7 (diff) | |
Major overhaul, splitting nomsu_compiler into nomsu_environment,
nomsu_compiler, and nomsu_decompiler. Also added comprehensions.
Diffstat (limited to 'code_obj.moon')
| -rw-r--r-- | code_obj.moon | 11 |
1 files changed, 3 insertions, 8 deletions
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 ")" |
