diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-24 18:01:46 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-24 18:01:46 +0800 |
| commit | 61bb3f1c6682dcaa05c67b60d3fd0d50e44e0761 (patch) | |
| tree | a52bc64c86ee3bc732740869ebd73083885329fc | |
| parent | 8f3462669e8d536c841d3ce07bfed5432cb379bc (diff) | |
| download | yuescript-61bb3f1c6682dcaa05c67b60d3fd0d50e44e0761.tar.gz yuescript-61bb3f1c6682dcaa05c67b60d3fd0d50e44e0761.tar.bz2 yuescript-61bb3f1c6682dcaa05c67b60d3fd0d50e44e0761.zip | |
Fixed issue #246.v0.33.5
| -rw-r--r-- | README.md | 28 | ||||
| -rw-r--r-- | doc/docs/doc/advanced/do.md | 2 | ||||
| -rw-r--r-- | doc/yue-de.md | 4 | ||||
| -rw-r--r-- | doc/yue-en.md | 4 | ||||
| -rw-r--r-- | doc/yue-id-id.md | 4 | ||||
| -rw-r--r-- | doc/yue-pt-br.md | 4 | ||||
| -rw-r--r-- | doc/yue-zh.md | 4 | ||||
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 10 |
8 files changed, 45 insertions, 15 deletions
| @@ -1,6 +1,30 @@ | |||
| 1 | # YueScript | 1 | # YueScript |
| 2 | 2 | ||
| 3 | <img src="doc/docs/.vitepress/public/image/yuescript.png" width="300" height="300" alt="YueScript logo"/> | 3 | <table align="center"> |
| 4 | <tr> | ||
| 5 | <td align="center" valign="middle" width="150" height="150"> | ||
| 6 | <img src="doc/docs/.vitepress/public/image/yuescript.png" alt="YueScript logo"/><br/> | ||
| 7 | </td> | ||
| 8 | <td valign="middle"> | ||
| 9 | <strong>A Language Compiles to Lua</strong><br/> | ||
| 10 | <sub>Dynamic, expressive, and concise syntax for Lua development.</sub><br/> | ||
| 11 | <sub> | ||
| 12 | <a href="https://yuescript.org/doc">Docs</a> · | ||
| 13 | <a href="https://yuescript.org/try">Try Online</a> · | ||
| 14 | <a href="https://discord.gg/cRJ2VAm2NV">Discord</a> | ||
| 15 | </sub> | ||
| 16 | </td> | ||
| 17 | </tr> | ||
| 18 | </table> | ||
| 19 | |||
| 20 | <p align="center"> | ||
| 21 | <img src="doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png" width="360" alt="Xiaoyu, the YueScript mascot"/> | ||
| 22 | </p> | ||
| 23 | |||
| 24 | |||
| 25 | <p align="center"> | ||
| 26 | <sub><b>Xiaoyu (小玉)</b> · Official YueScript Mascot</sub> | ||
| 27 | </p> | ||
| 4 | 28 | ||
| 5 | [](https://ippclub.org) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/ubuntu.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/windows.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/macos.yml) [](https://discord.gg/cRJ2VAm2NV) | 29 | [](https://ippclub.org) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/ubuntu.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/windows.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/macos.yml) [](https://discord.gg/cRJ2VAm2NV) |
| 6 | 30 | ||
| @@ -146,8 +170,6 @@ Options: | |||
| 146 | 170 | ||
| 147 | ## Mascot (Xiaoyu / 小玉) | 171 | ## Mascot (Xiaoyu / 小玉) |
| 148 | 172 | ||
| 149 | <img src="doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png" width="420" alt="Xiaoyu, the YueScript mascot"/> | ||
| 150 | |||
| 151 | Xiaoyu (小玉) is YueScript's official mascot, a cyber rabbit often seen perched on a crescent moon and coding on a laptop. | 173 | Xiaoyu (小玉) is YueScript's official mascot, a cyber rabbit often seen perched on a crescent moon and coding on a laptop. |
| 152 | 174 | ||
| 153 | - English page: [here](https://yuescript.org/doc/extras/mascot.html) | 175 | - English page: [here](https://yuescript.org/doc/extras/mascot.html) |
diff --git a/doc/docs/doc/advanced/do.md b/doc/docs/doc/advanced/do.md index 40fd9fe..4bfcc17 100644 --- a/doc/docs/doc/advanced/do.md +++ b/doc/docs/doc/advanced/do.md | |||
| @@ -20,7 +20,7 @@ print var -- nil here | |||
| 20 | 20 | ||
| 21 | </YueDisplay> | 21 | </YueDisplay> |
| 22 | 22 | ||
| 23 | YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. | 23 | YueScript's **do** can also be used an expression. Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. |
| 24 | 24 | ||
| 25 | ```yuescript | 25 | ```yuescript |
| 26 | counter = do | 26 | counter = do |
diff --git a/doc/yue-de.md b/doc/yue-de.md index 0db2bfe..aeaabf1 100644 --- a/doc/yue-de.md +++ b/doc/yue-de.md | |||
| @@ -15,6 +15,8 @@ do | |||
| 15 | print var -- nil hier | 15 | print var -- nil hier |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. | ||
| 19 | |||
| 18 | ```yuescript | 20 | ```yuescript |
| 19 | counter = do | 21 | counter = do |
| 20 | i = 0 | 22 | i = 0 |
| @@ -34,7 +36,7 @@ tbl = { | |||
| 34 | } | 36 | } |
| 35 | ``` | 37 | ``` |
| 36 | 38 | ||
| 37 | YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. `do`-Ausdrücke unterstützen die Verwendung von `break`, um den Kontrollfluss zu unterbrechen und mehrere Rückgabewerte vorzeitig zurückzugeben. | 39 | `do`-Ausdrücke unterstützen die Verwendung von `break`, um den Kontrollfluss zu unterbrechen und mehrere Rückgabewerte vorzeitig zurückzugeben. |
| 38 | 40 | ||
| 39 | ```yuescript | 41 | ```yuescript |
| 40 | status, value = do | 42 | status, value = do |
diff --git a/doc/yue-en.md b/doc/yue-en.md index a82ae9a..2cac78a 100644 --- a/doc/yue-en.md +++ b/doc/yue-en.md | |||
| @@ -15,6 +15,8 @@ do | |||
| 15 | print var -- nil here | 15 | print var -- nil here |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | YueScript's **do** can also be used an expression. Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. | ||
| 19 | |||
| 18 | ```yuescript | 20 | ```yuescript |
| 19 | counter = do | 21 | counter = do |
| 20 | i = 0 | 22 | i = 0 |
| @@ -34,8 +36,6 @@ tbl = { | |||
| 34 | } | 36 | } |
| 35 | ``` | 37 | ``` |
| 36 | 38 | ||
| 37 | YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. | ||
| 38 | |||
| 39 | `do` expressions also support using `break` to interrupt control flow and return multiple values early: | 39 | `do` expressions also support using `break` to interrupt control flow and return multiple values early: |
| 40 | 40 | ||
| 41 | ```yuescript | 41 | ```yuescript |
diff --git a/doc/yue-id-id.md b/doc/yue-id-id.md index d753e20..73bf1bb 100644 --- a/doc/yue-id-id.md +++ b/doc/yue-id-id.md | |||
| @@ -15,6 +15,8 @@ do | |||
| 15 | print var -- nil di sini | 15 | print var -- nil di sini |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | `do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. | ||
| 19 | |||
| 18 | ```yuescript | 20 | ```yuescript |
| 19 | counter = do | 21 | counter = do |
| 20 | i = 0 | 22 | i = 0 |
| @@ -34,7 +36,7 @@ tbl = { | |||
| 34 | } | 36 | } |
| 35 | ``` | 37 | ``` |
| 36 | 38 | ||
| 37 | `do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. Ekspresi `do` mendukung penggunaan `break` untuk memutus alur eksekusi dan mengembalikan banyak nilai lebih awal. | 39 | Ekspresi `do` mendukung penggunaan `break` untuk memutus alur eksekusi dan mengembalikan banyak nilai lebih awal. |
| 38 | 40 | ||
| 39 | ```yuescript | 41 | ```yuescript |
| 40 | status, value = do | 42 | status, value = do |
diff --git a/doc/yue-pt-br.md b/doc/yue-pt-br.md index 334e5fc..d48c19b 100644 --- a/doc/yue-pt-br.md +++ b/doc/yue-pt-br.md | |||
| @@ -15,6 +15,8 @@ do | |||
| 15 | print var -- nil aqui | 15 | print var -- nil aqui |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. | ||
| 19 | |||
| 18 | ```yuescript | 20 | ```yuescript |
| 19 | counter = do | 21 | counter = do |
| 20 | i = 0 | 22 | i = 0 |
| @@ -34,7 +36,7 @@ tbl = { | |||
| 34 | } | 36 | } |
| 35 | ``` | 37 | ``` |
| 36 | 38 | ||
| 37 | O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. Expressões `do` suportam usar `break` para interromper o fluxo de execução e retornar múltiplos valores antecipadamente. | 39 | Expressões `do` suportam usar `break` para interromper o fluxo de execução e retornar múltiplos valores antecipadamente. |
| 38 | 40 | ||
| 39 | ```yuescript | 41 | ```yuescript |
| 40 | status, value = do | 42 | status, value = do |
diff --git a/doc/yue-zh.md b/doc/yue-zh.md index 4585f53..dfc5996 100644 --- a/doc/yue-zh.md +++ b/doc/yue-zh.md | |||
| @@ -15,6 +15,8 @@ do | |||
| 15 | print var -- 这里是nil | 15 | print var -- 这里是nil |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 |   月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。 | ||
| 19 | |||
| 18 | ```yuescript | 20 | ```yuescript |
| 19 | counter = do | 21 | counter = do |
| 20 | i = 0 | 22 | i = 0 |
| @@ -34,7 +36,7 @@ tbl = { | |||
| 34 | } | 36 | } |
| 35 | ``` | 37 | ``` |
| 36 | 38 | ||
| 37 |   月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。`do` 表达式支持通过 `break` 打断执行流并提前返回多个值。 | 39 |   `do` 表达式支持通过 `break` 打断执行流并提前返回多个值。 |
| 38 | 40 | ||
| 39 | ```yuescript | 41 | ```yuescript |
| 40 | status, value = do | 42 | status, value = do |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 9f13098..5b8ca0d 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -78,7 +78,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 78 | "close"s // Lua 5.4 | 78 | "close"s // Lua 5.4 |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | const std::string_view version = "0.33.4"sv; | 81 | const std::string_view version = "0.33.5"sv; |
| 82 | const std::string_view extension = "yue"sv; | 82 | const std::string_view extension = "yue"sv; |
| 83 | 83 | ||
| 84 | class CompileError : public std::logic_error { | 84 | class CompileError : public std::logic_error { |
| @@ -10125,7 +10125,7 @@ private: | |||
| 10125 | transformAssignment(assignment, tmp); | 10125 | transformAssignment(assignment, tmp); |
| 10126 | } | 10126 | } |
| 10127 | if (extend) { | 10127 | if (extend) { |
| 10128 | _buf << indent() << "setmetatable("sv << baseVar << ", "sv << parentVar << ".__base)"sv << nl(classDecl); | 10128 | _buf << indent() << globalVar("setmetatable"sv, classDecl, AccessType::Read) << '(' << baseVar << ", "sv << parentVar << ".__base)"sv << nl(classDecl); |
| 10129 | } | 10129 | } |
| 10130 | _buf << indent() << classVar << " = "sv << globalVar("setmetatable"sv, classDecl, AccessType::Read) << "({"sv << nl(classDecl); | 10130 | _buf << indent() << classVar << " = "sv << globalVar("setmetatable"sv, classDecl, AccessType::Read) << "({"sv << nl(classDecl); |
| 10131 | if (!builtinFields.empty()) { | 10131 | if (!builtinFields.empty()) { |
| @@ -10162,9 +10162,9 @@ private: | |||
| 10162 | _buf << indent() << "}, {"sv << nl(classDecl); | 10162 | _buf << indent() << "}, {"sv << nl(classDecl); |
| 10163 | if (extend) { | 10163 | if (extend) { |
| 10164 | _buf << indent(1) << "__index = function(cls, name)"sv << nl(classDecl); | 10164 | _buf << indent(1) << "__index = function(cls, name)"sv << nl(classDecl); |
| 10165 | _buf << indent(2) << "local val = rawget("sv << baseVar << ", name)"sv << nl(classDecl); | 10165 | _buf << indent(2) << "local val = "sv << globalVar("rawget", classDecl, AccessType::Read) << '(' << baseVar << ", name)"sv << nl(classDecl); |
| 10166 | _buf << indent(2) << "if val == nil then"sv << nl(classDecl); | 10166 | _buf << indent(2) << "if val == nil then"sv << nl(classDecl); |
| 10167 | _buf << indent(3) << "local parent = rawget(cls, \"__parent\")"sv << nl(classDecl); | 10167 | _buf << indent(3) << "local parent = "sv << globalVar("rawget", classDecl, AccessType::Read) << "(cls, \"__parent\")"sv << nl(classDecl); |
| 10168 | _buf << indent(3) << "if parent then"sv << nl(classDecl); | 10168 | _buf << indent(3) << "if parent then"sv << nl(classDecl); |
| 10169 | _buf << indent(4) << "return parent[name]"sv << nl(classDecl); | 10169 | _buf << indent(4) << "return parent[name]"sv << nl(classDecl); |
| 10170 | _buf << indent(3) << "end"sv << nl(classDecl); | 10170 | _buf << indent(3) << "end"sv << nl(classDecl); |
| @@ -10179,7 +10179,7 @@ private: | |||
| 10179 | pushScope(); | 10179 | pushScope(); |
| 10180 | auto selfVar = getUnusedName("_self_"sv); | 10180 | auto selfVar = getUnusedName("_self_"sv); |
| 10181 | addToScope(selfVar); | 10181 | addToScope(selfVar); |
| 10182 | _buf << indent(1) << "local "sv << selfVar << " = setmetatable({ }, "sv << baseVar << ")"sv << nl(classDecl); | 10182 | _buf << indent(1) << "local "sv << selfVar << " = "sv << globalVar("setmetatable", classDecl, AccessType::Read) << "({ }, "sv << baseVar << ")"sv << nl(classDecl); |
| 10183 | _buf << indent(1) << "cls.__init("sv << selfVar << ", ...)"sv << nl(classDecl); | 10183 | _buf << indent(1) << "cls.__init("sv << selfVar << ", ...)"sv << nl(classDecl); |
| 10184 | _buf << indent(1) << "return "sv << selfVar << nl(classDecl); | 10184 | _buf << indent(1) << "return "sv << selfVar << nl(classDecl); |
| 10185 | popScope(); | 10185 | popScope(); |
