Skip to content

Commit

Permalink
chore: bump lua build
Browse files Browse the repository at this point in the history
  • Loading branch information
rktjmp committed Aug 11, 2024
1 parent 281c787 commit de7f794
Showing 1 changed file with 130 additions and 117 deletions.
247 changes: 130 additions & 117 deletions lua/hotpot/lang/fennel/compiler.lua
Original file line number Diff line number Diff line change
@@ -1,124 +1,139 @@
local _local_1_ = string
local fmt = _local_1_["format"]
local fmt = string["format"]
local injected_macro_searcher_3f = false
local compiler_options_stack = {}
local function spooky_prepare_plugins_21(options)
local _let_2_ = require("hotpot.searcher")
local mod_search = _let_2_["mod-search"]
local _let_1_ = require("hotpot.searcher")
local mod_search = _let_1_["mod-search"]
local fennel = require("hotpot.fennel")
local plugins
do
local tbl_19_auto = {}
local i_20_auto = 0
local tbl_21_auto = {}
local i_22_auto = 0
for _i, plug in ipairs((options.plugins or {})) do
local val_21_auto
local val_23_auto
do
local _3_ = type(plug)
if (_3_ == "string") then
local _4_ = mod_search({prefix = "fnl", extension = "fnl", modnames = {plug}})
if ((_G.type(_4_) == "table") and (nil ~= _4_[1])) then
local path = _4_[1]
val_21_auto = fennel.dofile(path, {env = "_COMPILER", useMetadata = true, ["compiler-env"] = _G}, plug, path)
local _2_ = type(plug)
if (_2_ == "string") then
local _3_ = mod_search({prefix = "fnl", extension = "fnl", modnames = {plug}})
if ((_G.type(_3_) == "table") and (nil ~= _3_[1])) then
local path = _3_[1]
val_23_auto = fennel.dofile(path, {env = "_COMPILER", useMetadata = true, ["compiler-env"] = _G}, plug, path)
else
local _ = _4_
val_21_auto = error(string.format("Could not find fennel compiler plugin %q", plug))
local _ = _3_
val_23_auto = error(string.format("Could not find fennel compiler plugin %q", plug))
end
else
local _ = _3_
val_21_auto = plug
local _ = _2_
val_23_auto = plug
end
end
if (nil ~= val_21_auto) then
i_20_auto = (i_20_auto + 1)
do end (tbl_19_auto)[i_20_auto] = val_21_auto
if (nil ~= val_23_auto) then
i_22_auto = (i_22_auto + 1)
tbl_21_auto[i_22_auto] = val_23_auto
else
end
end
plugins = tbl_19_auto
plugins = tbl_21_auto
end
options.plugins = plugins
return nil
end
local function make_macro_loader(modname, fnl_path)
local fennel = require("hotpot.fennel")
local _let_8_ = require("hotpot.fs")
local read_file_21 = _let_8_["read-file!"]
local _let_7_ = require("hotpot.fs")
local read_file_21 = _let_7_["read-file!"]
local options
local function _9_(src)
return src
local or_8_ = compiler_options_stack[1]
if not or_8_ then
local function _9_(src)
return src
end
or_8_ = {modules = {}, macros = {env = "_COMPILER"}, preprocessor = _9_}
end
options = (compiler_options_stack[1] or {modules = {}, macros = {env = "_COMPILER"}, preprocessor = _9_})
options = or_8_
local preprocessor
local function _10_(_241)
return options.preprocessor(_241, {macro = true, ["macro?"] = true, path = fnl_path, modname = modname})
end
preprocessor = _10_
local options0
do
local _11_ = options.macros
_11_["error-pinpoint"] = false
_11_["filename"] = fnl_path
_11_["module-name"] = modname
options0 = _11_
local tmp_9_auto = options.macros
tmp_9_auto["error-pinpoint"] = false
tmp_9_auto["filename"] = fnl_path
tmp_9_auto["module-name"] = modname
options0 = tmp_9_auto
end
local _ = spooky_prepare_plugins_21(options0)
local fnl_code
do
local _12_, _13_ = read_file_21(fnl_path)
if (nil ~= _12_) then
local file_content = _12_
local _11_, _12_ = read_file_21(fnl_path)
if (nil ~= _11_) then
local file_content = _11_
fnl_code = preprocessor(file_content)
elseif ((_12_ == nil) and (nil ~= _13_)) then
local err = _13_
elseif ((_11_ == nil) and (nil ~= _12_)) then
local err = _12_
fnl_code = error(err)
else
fnl_code = nil
end
end
local function _15_(modname0)
local _let_16_ = require("hotpot.lang.fennel.dependency-tracker")
local set_macro_modname_path = _let_16_["set-macro-modname-path"]
local function _14_(modname0)
local _let_15_ = require("hotpot.lang.fennel.dependency-tracker")
local set_macro_modname_path = _let_15_["set-macro-modname-path"]
set_macro_modname_path(modname0, fnl_path)
return fennel.eval(fnl_code, options0, modname0)
end
return _15_
return _14_
end
local function macro_searcher(modname)
local _let_17_ = require("hotpot.searcher")
local mod_search = _let_17_["mod-search"]
local _let_16_ = require("hotpot.searcher")
local mod_search = _let_16_["mod-search"]
local spec = {prefix = "fnl", extension = "fnl", modnames = {(modname .. ".init-macros"), (modname .. ".init"), modname}}
local function _18_(...)
local _19_ = ...
if ((_G.type(_19_) == "table") and (nil ~= _19_[1])) then
local path = _19_[1]
local function _17_(...)
local _18_ = ...
if ((_G.type(_18_) == "table") and (nil ~= _18_[1])) then
local path = _18_[1]
return make_macro_loader(modname, path)
elseif ((_G.type(_19_) == "table") and (_19_[1] == nil)) then
elseif ((_G.type(_18_) == "table") and (_18_[1] == nil)) then
return nil
else
return nil
end
end
return _18_(mod_search(spec))
return _17_(mod_search(spec))
end
local function compile_string(source, modules_options, macros_options, _3fpreprocessor)
_G.assert((nil ~= macros_options), "Missing argument macros-options on fnl/hotpot/lang/fennel/compiler.fnl:72")
_G.assert((nil ~= modules_options), "Missing argument modules-options on fnl/hotpot/lang/fennel/compiler.fnl:72")
_G.assert((nil ~= source), "Missing argument source on fnl/hotpot/lang/fennel/compiler.fnl:72")
local fennel = require("hotpot.fennel")
local _let_21_ = require("hotpot.runtime")
local traceback = _let_21_["traceback"]
local saved_fennel_path = fennel.path
local saved_fennel_macro_path = fennel["macro-path"]
local _
fennel.path = ("./fnl/?.fnl;./fnl/?/init.fnl;" .. fennel.path)
_ = nil
local _0
fennel["macro-path"] = ("./fnl/?.fnl;./fnl/?/init-macros.fnl;./fnl/?/init.fnl;" .. fennel["macro-path"])
_0 = nil
local _let_20_ = require("hotpot.runtime")
local traceback = _let_20_["traceback"]
local options
do
modules_options["error-pinpoint"] = false
modules_options["filename"] = (modules_options.filename or "hotpot-compile-string")
options = modules_options
end
local _ = spooky_prepare_plugins_21(options)
local _1 = spooky_prepare_plugins_21(options)
local preprocessor
local function _22_(src)
return src
local or_21_ = _3fpreprocessor
if not or_21_ then
local function _22_(src)
return src
end
or_21_ = _22_
end
preprocessor = (_3fpreprocessor or _22_)
preprocessor = or_21_
local source0 = preprocessor(source, {path = modules_options.filename, modname = modules_options.modname, macro = false, ["macro?"] = false})
if not injected_macro_searcher_3f then
table.insert(fennel["macro-searchers"], 1, macro_searcher)
Expand All @@ -128,24 +143,25 @@ local function compile_string(source, modules_options, macros_options, _3fprepro
table.insert(compiler_options_stack, 1, {modules = modules_options, macros = macros_options, preprocessor = preprocessor})
local ok_3f, val = nil, nil
local function _24_()
local _25_ = fennel["compile-string"](source0, options)
return _25_
return (fennel["compile-string"](source0, options))
end
ok_3f, val = xpcall(_24_, traceback)
fennel.path = saved_fennel_path
fennel["macro-path"] = saved_fennel_macro_path
table.remove(compiler_options_stack, 1)
do end (modules_options)["filename"] = nil
modules_options["filename"] = nil
modules_options["module-name"] = nil
return ok_3f, val
end
local function compile_file(fnl_path, lua_path, modules_options, macros_options, _3fpreprocessor)
_G.assert((nil ~= macros_options), "Missing argument macros-options on fnl/hotpot/lang/fennel/compiler.fnl:106")
_G.assert((nil ~= modules_options), "Missing argument modules-options on fnl/hotpot/lang/fennel/compiler.fnl:106")
_G.assert((nil ~= lua_path), "Missing argument lua-path on fnl/hotpot/lang/fennel/compiler.fnl:106")
_G.assert((nil ~= fnl_path), "Missing argument fnl-path on fnl/hotpot/lang/fennel/compiler.fnl:106")
_G.assert((nil ~= macros_options), "Missing argument macros-options on fnl/hotpot/lang/fennel/compiler.fnl:113")
_G.assert((nil ~= modules_options), "Missing argument modules-options on fnl/hotpot/lang/fennel/compiler.fnl:113")
_G.assert((nil ~= lua_path), "Missing argument lua-path on fnl/hotpot/lang/fennel/compiler.fnl:113")
_G.assert((nil ~= fnl_path), "Missing argument fnl-path on fnl/hotpot/lang/fennel/compiler.fnl:113")
local function check_existing(path)
local uv = vim.loop
local _let_26_ = (uv.fs_stat(path) or {})
local type = _let_26_["type"]
local _let_25_ = (uv.fs_stat(path) or {})
local type = _let_25_["type"]
if not (("file" == type) or (nil == type)) then
local failed_what_1_auto = "(or (= \"file\" type) (= nil type))"
local err_2_auto = string.format("%s [failed: %s]", "Refusing to write to %q, it exists as a %s", failed_what_1_auto)
Expand All @@ -155,14 +171,14 @@ local function compile_file(fnl_path, lua_path, modules_options, macros_options,
end
end
local function do_compile()
local _let_28_ = require("hotpot.runtime")
local windows_3f = _let_28_["windows?"]
local _let_29_ = require("hotpot.fs")
local read_file_21 = _let_29_["read-file!"]
local write_file_21 = _let_29_["write-file!"]
local is_lua_path_3f = _let_29_["is-lua-path?"]
local is_fnl_path_3f = _let_29_["is-fnl-path?"]
local make_path = _let_29_["make-path"]
local _let_27_ = require("hotpot.runtime")
local windows_3f = _let_27_["windows?"]
local _let_28_ = require("hotpot.fs")
local read_file_21 = _let_28_["read-file!"]
local write_file_21 = _let_28_["write-file!"]
local is_lua_path_3f = _let_28_["is-lua-path?"]
local is_fnl_path_3f = _let_28_["is-fnl-path?"]
local make_path = _let_28_["make-path"]
local _
if not is_fnl_path_3f(fnl_path) then
local failed_what_1_auto = "(is-fnl-path? fnl-path)"
Expand All @@ -181,12 +197,12 @@ local function compile_file(fnl_path, lua_path, modules_options, macros_options,
end
local fnl_code
do
local _32_, _33_ = read_file_21(fnl_path)
if ((_32_ == nil) and (nil ~= _33_)) then
local err = _33_
local _31_, _32_ = read_file_21(fnl_path)
if ((_31_ == nil) and (nil ~= _32_)) then
local err = _32_
fnl_code = error(err)
elseif (nil ~= _32_) then
local src = _32_
elseif (nil ~= _31_) then
local src = _31_
fnl_code = src
else
fnl_code = nil
Expand All @@ -197,61 +213,58 @@ local function compile_file(fnl_path, lua_path, modules_options, macros_options,
modules_options["filename"] = fnl_path
else
end
local _36_, _37_ = compile_string(fnl_code, modules_options, macros_options, _3fpreprocessor)
if ((_36_ == true) and (nil ~= _37_)) then
local lua_code = _37_
local _35_, _36_ = compile_string(fnl_code, modules_options, macros_options, _3fpreprocessor)
if ((_35_ == true) and (nil ~= _36_)) then
local lua_code = _36_
check_existing(lua_path)
make_path(vim.fs.dirname(lua_path))
return write_file_21(lua_path, lua_code)
elseif ((_36_ == false) and (nil ~= _37_)) then
local errors = _37_
elseif ((_35_ == false) and (nil ~= _36_)) then
local errors = _36_
return error(errors)
else
return nil
end
end
local function _39_(_241)
local function _38_(_241)
local lines = vim.split(_241, "\n")
local function _41_()
local _var_42_ = {"", true}
local s = _var_42_[1]
local c = _var_42_[2]
local function _39_()
local s,c = "", true
for _, line in ipairs(lines) do
if not c then break end
local function _45_()
local _44_ = string.find(line, "stack traceback:", 1, true)
if (_44_ == 1) then
local function _41_()
local _40_ = string.find(line, "stack traceback:", 1, true)
if (_40_ == 1) then
return {s, false}
else
local _0 = _44_
local _0 = _40_
return {(s .. line .. "\n"), true}
end
end
local _set_43_ = _45_()
local _set_43_ = _41_()
s = _set_43_[1]
c = _set_43_[2]
end
return {s, c}
end
local _let_40_ = _41_()
local s = _let_40_[1]
local _ = _let_40_[2]
local _let_44_ = _39_()
local s = _let_44_[1]
local _ = _let_44_[2]
return s
end
return xpcall(do_compile, _39_)
return xpcall(do_compile, _38_)
end
local function compile_record(record, modules_options, macros_options, preprocessor)
_G.assert((nil ~= preprocessor), "Missing argument preprocessor on fnl/hotpot/lang/fennel/compiler.fnl:146")
_G.assert((nil ~= macros_options), "Missing argument macros-options on fnl/hotpot/lang/fennel/compiler.fnl:146")
_G.assert((nil ~= modules_options), "Missing argument modules-options on fnl/hotpot/lang/fennel/compiler.fnl:146")
_G.assert((nil ~= record), "Missing argument record on fnl/hotpot/lang/fennel/compiler.fnl:146")
local _let_47_ = record
local lua_path = _let_47_["lua-path"]
local src_path = _let_47_["src-path"]
local modname = _let_47_["modname"]
local _let_48_ = require("hotpot.lang.fennel.dependency-tracker")
local new_macro_dep_tracking_plugin = _let_48_["new"]
local deps_for_fnl_path = _let_48_["deps-for-fnl-path"]
_G.assert((nil ~= preprocessor), "Missing argument preprocessor on fnl/hotpot/lang/fennel/compiler.fnl:152")
_G.assert((nil ~= macros_options), "Missing argument macros-options on fnl/hotpot/lang/fennel/compiler.fnl:152")
_G.assert((nil ~= modules_options), "Missing argument modules-options on fnl/hotpot/lang/fennel/compiler.fnl:152")
_G.assert((nil ~= record), "Missing argument record on fnl/hotpot/lang/fennel/compiler.fnl:152")
local lua_path = record["lua-path"]
local src_path = record["src-path"]
local modname = record["modname"]
local _let_45_ = require("hotpot.lang.fennel.dependency-tracker")
local new_macro_dep_tracking_plugin = _let_45_["new"]
local deps_for_fnl_path = _let_45_["deps-for-fnl-path"]
local modules_options0
do
modules_options["module-name"] = modname
Expand All @@ -262,26 +275,26 @@ local function compile_record(record, modules_options, macros_options, preproces
local plugin = new_macro_dep_tracking_plugin(src_path, modname)
table.insert(modules_options0.plugins, 1, plugin)
local ok_3f, extra = nil, nil
local function _49_(...)
local _50_ = ...
if (_50_ == true) then
local function _51_(...)
local _52_ = ...
if (nil ~= _52_) then
local deps = _52_
local function _46_(...)
local _47_ = ...
if (_47_ == true) then
local function _48_(...)
local _49_ = ...
if (nil ~= _49_) then
local deps = _49_
return true, deps
else
local __85_auto = _52_
local __85_auto = _49_
return ...
end
end
return _51_((deps_for_fnl_path(src_path) or {}))
return _48_((deps_for_fnl_path(src_path) or {}))
else
local __85_auto = _50_
local __85_auto = _47_
return ...
end
end
ok_3f, extra = _49_(compile_file(src_path, lua_path, modules_options0, macros_options, preprocessor))
ok_3f, extra = _46_(compile_file(src_path, lua_path, modules_options0, macros_options, preprocessor))
table.remove(modules_options0.plugins, 1)
return ok_3f, extra
end
Expand Down

0 comments on commit de7f794

Please sign in to comment.