From 5e566f8cf633882cd153731944cba9f5503cfb0a Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 16 Sep 2025 09:15:51 +0800 Subject: Increased call stack size. --- spec/inputs/unicode/macro.yue | 1 + spec/outputs/unicode/macro.lua | 23 +++++++++++++---------- src/yue.cpp | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/spec/inputs/unicode/macro.yue b/spec/inputs/unicode/macro.yue index 50656ae..79d3c07 100644 --- a/spec/inputs/unicode/macro.yue +++ b/spec/inputs/unicode/macro.yue @@ -201,6 +201,7 @@ $链式调用( 选择可见! 标签等于 "fx" 其中 (x)-> x.名称\结尾为 "(克隆)" + 摧毁! ) macro 链式调用B = (...)-> diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua index 986ff32..b4e78cd 100644 --- a/spec/outputs/unicode/macro.lua +++ b/spec/outputs/unicode/macro.lua @@ -273,19 +273,22 @@ local _call_1 = ((function() local _call_1 = ((function() local _call_1 = ((function() local _call_1 = ((function() - local _call_1 = (_anon_func_2(_u539f_u70b9)) - return _call_1["后代"](_call_1) + local _call_1 = ((function() + local _call_1 = (_anon_func_2(_u539f_u70b9)) + return _call_1["后代"](_call_1) + end)()) + return _call_1["选择启用"](_call_1) end)()) - return _call_1["选择启用"](_call_1) + return _call_1["选择可见"](_call_1) end)()) - return _call_1["选择可见"](_call_1) + return _call_1["标签等于"](_call_1, "fx") end)()) - return _call_1["标签等于"](_call_1, "fx") + return _call_1["其中"](_call_1, function(x) + local _call_2 = x["名称"] + return _call_2["结尾为"](_call_2, "(克隆)") + end) end)()) -_u7ed3_u679c = _call_1["其中"](_call_1, function(x) - local _call_2 = x["名称"] - return _call_2["结尾为"](_call_2, "(克隆)") -end) +_u7ed3_u679c = _call_1["摧毁"](_call_1) do do local _1 @@ -343,7 +346,7 @@ _u6253_u5370((setmetatable({ return 998 end })) -_u6253_u5370("当前代码行数: " .. tostring(267)) +_u6253_u5370("当前代码行数: " .. tostring(268)) do do -- 待实现 diff --git a/src/yue.cpp b/src/yue.cpp index fc57767..2c3a469 100644 --- a/src/yue.cpp +++ b/src/yue.cpp @@ -30,6 +30,38 @@ using namespace std::chrono_literals; #include "ghc/fs_std.hpp" #include "linenoise.hpp" +#if __has_include() +#include +template +std::future async(const std::function& f) { + using Fn = std::packaged_task; + auto task = new Fn(f); + std::future fut = task->get_future(); + + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, 8 * 1024 * 1024); + + pthread_t th; + pthread_create(&th, &attr, + [](void* p)->void* { + std::unique_ptr fn(static_cast(p)); + (*fn)(); + return nullptr; + }, + task); + pthread_attr_destroy(&attr); + pthread_detach(th); + return fut; +} +#else +template +std::future async(const std::function& f) { + // fallback: ignore stack size + return std::async(std::launch::async, f); +} +#endif + #if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY) #define _DEFER(code, line) std::shared_ptr _defer_##line(nullptr, [&](auto) { \ code; \ @@ -699,7 +731,7 @@ int main(int narg, const char** args) { } std::list> results; for (const auto& file : files) { - auto task = std::async(std::launch::async, [=]() { + auto task = async([=]() { #ifndef YUE_COMPILER_ONLY return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite); #else @@ -737,7 +769,7 @@ int main(int narg, const char** args) { #endif // YUE_NO_WATCHER std::list>> results; for (const auto& file : files) { - auto task = std::async(std::launch::async, [=]() { + auto task = async>([=]() { std::ifstream input(file.first, std::ios::in); if (input) { std::string s( -- cgit v1.2.3-55-g6feb