aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2025-09-16 09:15:51 +0800
committerLi Jin <dragon-fly@qq.com>2025-09-16 09:15:51 +0800
commit5e566f8cf633882cd153731944cba9f5503cfb0a (patch)
tree2ad130de6c655e4f87ca6f708fed8f2ff4304f72
parent3b97540cc9a9b9409998454632d242b9bb12cb13 (diff)
downloadyuescript-main.tar.gz
yuescript-main.tar.bz2
yuescript-main.zip
Increased call stack size.HEADmain
-rw-r--r--spec/inputs/unicode/macro.yue1
-rw-r--r--spec/outputs/unicode/macro.lua23
-rw-r--r--src/yue.cpp36
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 @@ $链式调用(
201 选择可见! 201 选择可见!
202 标签等于 "fx" 202 标签等于 "fx"
203 其中 (x)-> x.名称\结尾为 "(克隆)" 203 其中 (x)-> x.名称\结尾为 "(克隆)"
204 摧毁!
204) 205)
205 206
206macro 链式调用B = (...)-> 207macro 链式调用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()
273 local _call_1 = ((function() 273 local _call_1 = ((function()
274 local _call_1 = ((function() 274 local _call_1 = ((function()
275 local _call_1 = ((function() 275 local _call_1 = ((function()
276 local _call_1 = (_anon_func_2(_u539f_u70b9)) 276 local _call_1 = ((function()
277 return _call_1["后代"](_call_1) 277 local _call_1 = (_anon_func_2(_u539f_u70b9))
278 return _call_1["后代"](_call_1)
279 end)())
280 return _call_1["选择启用"](_call_1)
278 end)()) 281 end)())
279 return _call_1["选择"](_call_1) 282 return _call_1["选择"](_call_1)
280 end)()) 283 end)())
281 return _call_1["可见"](_call_1) 284 return _call_1["签等于"](_call_1, "fx")
282 end)()) 285 end)())
283 return _call_1["标签等于"](_call_1, "fx") 286 return _call_1["其中"](_call_1, function(x)
287 local _call_2 = x["名称"]
288 return _call_2["结尾为"](_call_2, "(克隆)")
289 end)
284end)()) 290end)())
285_u7ed3_u679c = _call_1["其中"](_call_1, function(x) 291_u7ed3_u679c = _call_1["摧毁"](_call_1)
286 local _call_2 = x["名称"]
287 return _call_2["结尾为"](_call_2, "(克隆)")
288end)
289do 292do
290 do 293 do
291 local _1 294 local _1
@@ -343,7 +346,7 @@ _u6253_u5370((setmetatable({
343 return 998 346 return 998
344 end 347 end
345})) 348}))
346_u6253_u5370("当前代码行数: " .. tostring(267)) 349_u6253_u5370("当前代码行数: " .. tostring(268))
347do 350do
348 do 351 do
349-- 待实现 352-- 待实现
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;
30#include "ghc/fs_std.hpp" 30#include "ghc/fs_std.hpp"
31#include "linenoise.hpp" 31#include "linenoise.hpp"
32 32
33#if __has_include(<pthread.h>)
34#include <pthread.h>
35template<class R>
36std::future<R> async(const std::function<R()>& f) {
37 using Fn = std::packaged_task<R()>;
38 auto task = new Fn(f);
39 std::future<R> fut = task->get_future();
40
41 pthread_attr_t attr;
42 pthread_attr_init(&attr);
43 pthread_attr_setstacksize(&attr, 8 * 1024 * 1024);
44
45 pthread_t th;
46 pthread_create(&th, &attr,
47 [](void* p)->void* {
48 std::unique_ptr<Fn> fn(static_cast<Fn*>(p));
49 (*fn)();
50 return nullptr;
51 },
52 task);
53 pthread_attr_destroy(&attr);
54 pthread_detach(th);
55 return fut;
56}
57#else
58template<class R>
59std::future<R> async(const std::function<R()>& f) {
60 // fallback: ignore stack size
61 return std::async(std::launch::async, f);
62}
63#endif
64
33#if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY) 65#if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY)
34#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { \ 66#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { \
35 code; \ 67 code; \
@@ -699,7 +731,7 @@ int main(int narg, const char** args) {
699 } 731 }
700 std::list<std::future<std::string>> results; 732 std::list<std::future<std::string>> results;
701 for (const auto& file : files) { 733 for (const auto& file : files) {
702 auto task = std::async(std::launch::async, [=]() { 734 auto task = async<std::string>([=]() {
703#ifndef YUE_COMPILER_ONLY 735#ifndef YUE_COMPILER_ONLY
704 return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite); 736 return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite);
705#else 737#else
@@ -737,7 +769,7 @@ int main(int narg, const char** args) {
737#endif // YUE_NO_WATCHER 769#endif // YUE_NO_WATCHER
738 std::list<std::future<std::tuple<int, std::string, std::string>>> results; 770 std::list<std::future<std::tuple<int, std::string, std::string>>> results;
739 for (const auto& file : files) { 771 for (const auto& file : files) {
740 auto task = std::async(std::launch::async, [=]() { 772 auto task = async<std::tuple<int, std::string, std::string>>([=]() {
741 std::ifstream input(file.first, std::ios::in); 773 std::ifstream input(file.first, std::ios::in);
742 if (input) { 774 if (input) {
743 std::string s( 775 std::string s(