fix opts passing to cmd.moonc

This commit is contained in:
leaf corcoran 2015-02-28 11:47:58 -08:00
parent a79eb19f9e
commit 2d5dd107d4
4 changed files with 11 additions and 6 deletions

View File

@ -315,8 +315,13 @@ else
end
local success, err = compile_and_write(fname, target, {
print = opts.p
print = opts.p,
fname = fname,
benchmark = opts.b,
show_posmap = opts.X,
show_parse_tree = opts.T,
})
if not success then
io.stderr:write(fname .. "\t" .. err .. "\n")
os.exit(1)

View File

@ -55,7 +55,7 @@ do
end
end
end
compile_file_text = function(text, fname, opts)
compile_file_text = function(text, opts)
if opts == nil then
opts = { }
end
@ -97,7 +97,7 @@ compile_file_text = function(text, fname, opts)
end
if opts.benchmark then
print(table.concat({
fname,
opts.fname or "stdin",
"Parse time \t" .. format_time(parse_time),
"Compile time\t" .. format_time(compile_time),
""

View File

@ -63,7 +63,7 @@ gettime = do
-- compiles file to lua, returns lua code
-- returns nil, error on error
-- returns true if some option handled the output instead
compile_file_text = (text, fname, opts={}) ->
compile_file_text = (text, opts={}) ->
parse = require "moonscript.parse"
compile = require "moonscript.compile"
@ -100,7 +100,7 @@ compile_file_text = (text, fname, opts={}) ->
if opts.benchmark
print table.concat {
fname,
opts.fname or "stdin",
"Parse time \t" .. format_time(parse_time),
"Compile time\t" .. format_time(compile_time),
""

View File

@ -55,7 +55,7 @@ describe "moonc", ->
assert.same {
[[return print('hello')]]
}, {
moonc.compile_file_text "print'hello'", "test.moon"
moonc.compile_file_text "print'hello'", fname: "test.moon"
}
describe "stubbed lfs", ->