From e07a2eb9c389f27103872a3b5a5bfe500d0c2d62 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 3 Nov 2020 14:21:17 +0800 Subject: fix issue #29 --- src/MoonP/moon_compiler.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index f24441f..138a6bf 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) { return std::string(sv); } -const std::string_view version = "0.4.19"sv; +const std::string_view version = "0.4.20"sv; const std::string_view extension = "mp"sv; class MoonCompilerImpl { @@ -3814,17 +3814,16 @@ private: void transformLoopBody(Body_t* body, str_list& out, const std::string& appendContent, ExpUsage usage, ExpList_t* assignList = nullptr) { str_list temp; bool withContinue = traversal::Stop == body->traverse([&](ast_node* node) { - switch (node->getId()) { - case id(): - case id(): - return traversal::Return; - case id(): { - return _parser.toString(node) == "continue"sv ? - traversal::Stop : traversal::Return; - } - default: + if (auto stmt = ast_cast(node)) { + if (stmt->content.is()) { + return _parser.toString(stmt->content) == "continue"sv ? + traversal::Stop : traversal::Return; + } else if (expListFrom(stmt)) { return traversal::Continue; + } + return traversal::Return; } + return traversal::Continue; }); if (withContinue) { auto continueVar = getUnusedName("_continue_"sv); -- cgit v1.2.3-55-g6feb