diff options
Diffstat (limited to 'src/MoonP/moon_compiler.cpp')
| -rw-r--r-- | src/MoonP/moon_compiler.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 30adbae..d009fc9 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
| @@ -29,7 +29,7 @@ inline std::string s(std::string_view sv) { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | const char* moonScriptVersion() { | 31 | const char* moonScriptVersion() { |
| 32 | return "0.5.0-r0.1.0"; | 32 | return "0.5.0-r0.1.1"; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | class MoonCompiler { | 35 | class MoonCompiler { |
| @@ -1528,10 +1528,26 @@ private: | |||
| 1528 | } | 1528 | } |
| 1529 | if (isChainValueCall(chainValue)) { | 1529 | if (isChainValueCall(chainValue)) { |
| 1530 | auto last = chainValue->items.back(); | 1530 | auto last = chainValue->items.back(); |
| 1531 | _ast_list* args = nullptr; | ||
| 1531 | if (auto invoke = ast_cast<InvokeArgs_t>(last)) { | 1532 | if (auto invoke = ast_cast<InvokeArgs_t>(last)) { |
| 1532 | invoke->args.push_front(arg); | 1533 | args = &invoke->args; |
| 1533 | } else { | 1534 | } else { |
| 1534 | ast_to<Invoke_t>(last)->args.push_front(arg); | 1535 | args = &(ast_to<Invoke_t>(last)->args); |
| 1536 | } | ||
| 1537 | bool findPlaceHolder = false; | ||
| 1538 | for (auto a : args->objects()) { | ||
| 1539 | auto name = singleVariableFrom(a); | ||
| 1540 | if (name == "_"sv) { | ||
| 1541 | if (!findPlaceHolder) { | ||
| 1542 | args->swap(a, arg); | ||
| 1543 | findPlaceHolder = true; | ||
| 1544 | } else { | ||
| 1545 | throw std::logic_error(_info.errorMessage("backcall placeholder can be used only in one place."sv, a)); | ||
| 1546 | } | ||
| 1547 | } | ||
| 1548 | } | ||
| 1549 | if (!findPlaceHolder) { | ||
| 1550 | args->push_front(arg); | ||
| 1535 | } | 1551 | } |
| 1536 | } else { | 1552 | } else { |
| 1537 | auto invoke = x->new_ptr<Invoke_t>(); | 1553 | auto invoke = x->new_ptr<Invoke_t>(); |
