@@ -20,7 +20,10 @@ create_moonpath = function(package_path)
2020 end
2121 return concat (paths , " ;" )
2222end
23- to_lua = function (text )
23+ to_lua = function (text , options )
24+ if options == nil then
25+ options = { }
26+ end
2427 if " string" ~= type (text ) then
2528 local t = type (text )
2629 error (" expecting string (got " .. t .. " )" , 2 )
@@ -29,7 +32,7 @@ to_lua = function(text)
2932 if not tree then
3033 error (err , 2 )
3134 end
32- local code , ltable , pos = compile .tree (tree )
35+ local code , ltable , pos = compile .tree (tree , options )
3336 if not code then
3437 error (compile .format_error (ltable , pos , text ), 2 )
3538 end
6568if not _G .moon_no_loader then
6669 init_loader ()
6770end
68- loadstring = function (str , chunk_name )
71+ loadstring = function (str , chunk_name , options )
72+ if options == nil then
73+ options = nil
74+ end
6975 local passed , code , ltable = pcall (function ()
70- return to_lua (str )
76+ return to_lua (str , options )
7177 end )
7278 if not passed then
7379 error (chunk_name .. " : " .. code , 2 )
@@ -77,16 +83,19 @@ loadstring = function(str, chunk_name)
7783 end
7884 return lua .loadstring (code , chunk_name or " =(moonscript.loadstring)" )
7985end
80- loadfile = function (fname )
86+ loadfile = function (fname , options )
87+ if options == nil then
88+ options = nil
89+ end
8190 local file , err = io.open (fname )
8291 if not file then
8392 return nil , err
8493 end
8594 local text = assert (file :read (" *a" ))
8695 file :close ()
87- return loadstring (text , fname )
96+ return loadstring (text , fname , options )
8897end
89- dofile = function (fname )
98+ dofile = function (fname , options )
9099 local f = assert (loadfile (fname ))
91100 return f ()
92101end
0 commit comments