aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-04-25 16:04:46 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-04-25 16:04:55 -0700
commit50a092e4b5cb82131c0c8f6f46c7d21a42198858 (patch)
tree2ed0726076e7cd7b8170b139cc3ab07808d763db /nomsu.moon
parentcb28f52b410f3fbcb01bcc8ef8668de46d8aba68 (diff)
Got nomsu codegen working again.
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon26
1 files changed, 10 insertions, 16 deletions
diff --git a/nomsu.moon b/nomsu.moon
index 60854b2..06d128a 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -317,7 +317,7 @@ class NomsuCompiler
tree = @parse(nomsu_code)
assert tree, "Failed to parse: #{nomsu_code}"
assert tree.type == "File", "Attempt to run non-file: #{tree.type}"
- lua = @tree_to_lua(tree)
+ lua = tree\as_lua(@)
lua\convert_to_statements!
lua\declare_locals!
lua\prepend "-- File: #{nomsu_code.source or ""}\n"
@@ -387,12 +387,9 @@ class NomsuCompiler
-- Special case for text literals
if tree.type == 'Text' and #tree.value == 1 and type(tree.value[1]) == 'string'
return tree.value[1]
- lua = Lua(tree.source, "return ",@tree_to_lua(tree),";")
+ lua = Lua(tree.source, "return ",tree\as_lua(@),";")
return @run_lua(lua)
- tree_to_nomsu: (tree)=>
- return tree\as_nomsu!
-
value_to_nomsu: (value)=>
switch type(value)
when "nil"
@@ -418,9 +415,6 @@ class NomsuCompiler
else
error("Unsupported value_to_nomsu type: #{type(value)}", 0)
- tree_to_lua: (tree)=>
- return tree\as_lua(self)
-
walk_tree: (tree, depth=0)=>
coroutine.yield(tree, depth)
return unless Types.is_node(tree)
@@ -567,7 +561,7 @@ class NomsuCompiler
get_line_no = -> "nomsu.moon:#{debug_getinfo(2).currentline}"
nomsu = self
@define_compile_action "immediately %block", get_line_no!, (_block)=>
- lua = nomsu\tree_to_lua(_block)
+ lua = _block\as_lua(nomsu)
lua\convert_to_statements!
lua\declare_locals!
nomsu\run_lua(lua)
@@ -582,7 +576,7 @@ class NomsuCompiler
if type(bit) == "string"
lua\append repr(bit)
else
- bit_lua = nomsu\tree_to_lua bit
+ bit_lua = bit\as_lua(nomsu)
unless bit_lua.is_value
line, src = bit.source\get_line!, bit.source\get_text!
error "#{line}: Cannot use #{colored.yellow src} as a string interpolation value, since it's not an expression."
@@ -615,14 +609,14 @@ class NomsuCompiler
@define_compile_action "lua> %code", get_line_no!, (_code)=>
if _code.type != "Text"
return Lua.Value @source, "nomsu:run_lua(Lua(",repr(_code.source),
- ", ",repr(tostring(nomsu\tree_to_lua(_code))),"))"
+ ", ",repr(tostring(_code\as_lua(nomsu))),"))"
lua = Lua(_code.source)
for bit in *_code.value
if type(bit) == "string"
lua\append bit
else
- bit_lua = nomsu\tree_to_lua bit
+ bit_lua = bit\as_lua(nomsu)
unless bit_lua.is_value
line, src = bit.source\get_line!, bit.source\get_text!
error "#{line}: Cannot use #{colored.yellow src} as a string interpolation value, since it's not an expression.", 0
@@ -632,14 +626,14 @@ class NomsuCompiler
@define_compile_action "=lua %code", get_line_no!, (_code)=>
if _code.type != "Text"
return Lua.Value @source, "nomsu:run_lua(Lua(",repr(_code.source),
- ", ",repr(tostring(nomsu\tree_to_lua(_code))),"))"
+ ", ",repr(tostring(_code\as_lua(nomsu))),"))"
lua = Lua.Value(@source)
for bit in *_code.value
if type(bit) == "string"
lua\append bit
else
- bit_lua = nomsu\tree_to_lua bit
+ bit_lua = bit\as_lua(nomsu)
unless lua.is_value
line, src = bit.source\get_line!, bit.source\get_text!
error "#{line}: Cannot use #{colored.yellow src} as a string interpolation value, since it's not an expression.", 0
@@ -819,8 +813,8 @@ if arg and debug_getinfo(2).func != require
--ProFi = require 'ProFi'
--ProFi\start()
- --require('ldt').guard run
- xpcall(run, err_hand)
+ require('ldt').guard run
+ --xpcall(run, err_hand)
--ProFi\stop()
--ProFi\writeReport( 'MyProfilingReport.txt' )