aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_compiler.cpp
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-04-16 17:25:39 +0800
committerLi Jin <dragon-fly@qq.com>2021-04-16 17:25:39 +0800
commitce9f6632635222b38ef0b37b4b1273da4a1877b4 (patch)
tree04d4d3ea81749989015434333d3db1add7b0195a /src/yuescript/yue_compiler.cpp
parent3355b7c475bc4a3bc8c4f2e8a2f504bb3ccb9395 (diff)
downloadyuescript-ce9f6632635222b38ef0b37b4b1273da4a1877b4.tar.gz
yuescript-ce9f6632635222b38ef0b37b4b1273da4a1877b4.tar.bz2
yuescript-ce9f6632635222b38ef0b37b4b1273da4a1877b4.zip
fix small issues, add web assembly support.
Diffstat (limited to '')
-rw-r--r--src/yuescript/yue_compiler.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 6627189..caa5b9e 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -59,7 +59,7 @@ inline std::string s(std::string_view sv) {
59 return std::string(sv); 59 return std::string(sv);
60} 60}
61 61
62const std::string_view version = "0.7.5"sv; 62const std::string_view version = "0.7.6"sv;
63const std::string_view extension = "yue"sv; 63const std::string_view extension = "yue"sv;
64 64
65class YueCompilerImpl { 65class YueCompilerImpl {
@@ -3217,7 +3217,11 @@ private:
3217 auto x = chainList.front(); 3217 auto x = chainList.front();
3218 auto chain = x->new_ptr<ChainValue_t>(); 3218 auto chain = x->new_ptr<ChainValue_t>();
3219 if (opIt == chainList.begin() && ast_is<ColonChainItem_t, DotChainItem_t>(x)) { 3219 if (opIt == chainList.begin() && ast_is<ColonChainItem_t, DotChainItem_t>(x)) {
3220 chain->items.push_back(toAst<Callable_t>(_withVars.top(), x)); 3220 if (_withVars.empty()) {
3221 throw std::logic_error(_info.errorMessage("short dot/colon syntax must be called within a with block"sv, x));
3222 } else {
3223 chain->items.push_back(toAst<Callable_t>(_withVars.top(), x));
3224 }
3221 } 3225 }
3222 for (auto it = chainList.begin(); it != opIt; ++it) { 3226 for (auto it = chainList.begin(); it != opIt; ++it) {
3223 chain->items.push_back(*it); 3227 chain->items.push_back(*it);
@@ -3632,7 +3636,7 @@ private:
3632 } else { 3636 } else {
3633 if (!codes.empty()) { 3637 if (!codes.empty()) {
3634 if (isBlock) { 3638 if (isBlock) {
3635 info = _parser.parse<Block_t>(codes); 3639 info = _parser.parse<BlockEnd_t>(codes);
3636 if (!info.node) { 3640 if (!info.node) {
3637 info.error = info.error.substr(info.error.find(':') + 2); 3641 info.error = info.error.substr(info.error.find(':') + 2);
3638 throw std::logic_error(_info.errorMessage(s("failed to expanded macro as block: "sv) + info.error, x)); 3642 throw std::logic_error(_info.errorMessage(s("failed to expanded macro as block: "sv) + info.error, x));
@@ -3640,7 +3644,7 @@ private:
3640 } else { 3644 } else {
3641 info = _parser.parse<Exp_t>(codes); 3645 info = _parser.parse<Exp_t>(codes);
3642 if (!info.node && allowBlockMacroReturn) { 3646 if (!info.node && allowBlockMacroReturn) {
3643 info = _parser.parse<Block_t>(codes); 3647 info = _parser.parse<BlockEnd_t>(codes);
3644 if (!info.node) { 3648 if (!info.node) {
3645 info.error = info.error.substr(info.error.find(':') + 2); 3649 info.error = info.error.substr(info.error.find(':') + 2);
3646 throw std::logic_error(_info.errorMessage(s("failed to expanded macro as expr or block: "sv) + info.error, x)); 3650 throw std::logic_error(_info.errorMessage(s("failed to expanded macro as expr or block: "sv) + info.error, x));
@@ -3693,7 +3697,9 @@ private:
3693 info.node.set(exp); 3697 info.node.set(exp);
3694 } 3698 }
3695 } 3699 }
3696 if (auto block = info.node.as<Block_t>()) { 3700 if (auto blockEnd = info.node.as<BlockEnd_t>()) {
3701 auto block = blockEnd->block.get();
3702 info.node.set(block);
3697 for (auto stmt_ : block->statements.objects()) { 3703 for (auto stmt_ : block->statements.objects()) {
3698 auto stmt = static_cast<Statement_t*>(stmt_); 3704 auto stmt = static_cast<Statement_t*>(stmt_);
3699 if (auto global = stmt->content.as<Global_t>()) { 3705 if (auto global = stmt->content.as<Global_t>()) {