From 6a48f108666126893dcf7ff54b12172795858d3a Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 5 Jan 2021 09:28:28 +0800 Subject: fix. --- src/MoonP/moon_compiler.cpp | 36 ++++++++++++++++++------------------ src/MoonP/moonplus.cpp | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 6fdaa3c..73f1407 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -2322,22 +2322,22 @@ private: pushOptions(macro->m_begin.m_line - 1); // cur loadstring codes chunk options if (lua_pcall(L, 3, 2, 0) != 0) { // loadstring(codes,chunk,options), cur f err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to load macro codes\n"sv) + err, macro->macroLit)); + throw std::logic_error(_info.errorMessage(s("failed to load macro codes\n"sv) + err, macro->macroLit)); } // cur f err if (lua_isnil(L, -2) != 0) { // f == nil, cur f err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to load macro codes, at (macro "sv) + macroName + s("): "sv) + err, macro->macroLit)); + throw std::logic_error(_info.errorMessage(s("failed to load macro codes, at (macro "sv) + macroName + s("): "sv) + err, macro->macroLit)); } lua_pop(L, 1); // cur f pushMoonp("pcall"sv); // cur f pcall lua_insert(L, -2); // cur pcall f if (lua_pcall(L, 1, 2, 0) != 0) { // f(), cur success macro std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to generate macro function\n"sv) + err, macro->macroLit)); + throw std::logic_error(_info.errorMessage(s("failed to generate macro function\n"sv) + err, macro->macroLit)); } // cur success res if (lua_toboolean(L, -2) == 0) { std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to generate macro function\n"sv) + err, macro->macroLit)); + throw std::logic_error(_info.errorMessage(s("failed to generate macro function\n"sv) + err, macro->macroLit)); } // cur true macro lua_remove(L, -2); // cur macro if (exporting && !_moduleName.empty()) { @@ -3092,22 +3092,22 @@ private: pushOptions(args->back()->m_begin.m_line - 1); // loadstring codes chunk options if (lua_pcall(L, 3, 2, 0) != 0) { // loadstring(codes,chunk,options), f err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to load macro codes\n"sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to load macro codes\n"sv) + err, x)); } // f err if (lua_isnil(L, -2) != 0) { // f == nil, f err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to load macro codes, at (macro in-place): "sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to load macro codes, at (macro in-place): "sv) + err, x)); } lua_pop(L, 1); // f pushMoonp("pcall"sv); // f pcall lua_insert(L, -2); // pcall f if (lua_pcall(L, 1, 2, 0) != 0) { // f(), success macroFunc std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to generate macro function\n"sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to generate macro function\n"sv) + err, x)); } // success res if (lua_toboolean(L, -2) == 0) { std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to generate macro function\n"sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to generate macro function\n"sv) + err, x)); } // true macroFunc lua_remove(L, -2); // macroFunc pushMoonp("pcall"sv); // macroFunc pcall @@ -3115,11 +3115,11 @@ private: bool success = lua_pcall(L, 1, 2, 0) == 0; if (!success) { // err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to expand macro: "sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to expand macro: "sv) + err, x)); } // success err if (lua_toboolean(L, -2) == 0) { std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to expand macro: "sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to expand macro: "sv) + err, x)); } return {s("block"sv), Empty, {}}; } @@ -3183,11 +3183,11 @@ private: bool success = lua_pcall(L, static_cast(args->size()) + 1, 3, 0) == 0; if (!success) { // cur macro err std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to expand macro: "sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to expand macro: "sv) + err, x)); } // cur macro success res option if (lua_toboolean(L, -3) == 0) { std::string err = lua_tostring(L, -2); - throw std::logic_error(_info.errorMessage(s("fail to expand macro: "sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to expand macro: "sv) + err, x)); } lua_remove(L, -3); // cur macro res option if (lua_isstring(L, -2) == 0) { @@ -3271,7 +3271,7 @@ private: } if (!info.node) { info.error = info.error.substr(info.error.find(':') + 2); - throw std::logic_error(_info.errorMessage("fail to parse expanded codes: " + info.error, x)); + throw std::logic_error(_info.errorMessage("failed to parse expanded codes: " + info.error, x)); } int line = x->m_begin.m_line; int col = x->m_begin.m_col; @@ -5079,10 +5079,10 @@ private: lua_pushlstring(L, moduleName.c_str(), moduleName.size()); // cur find_modulepath moduleName if (lua_pcall(L, 1, 1, 0) != 0) { std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to resolve module path\n"sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to resolve module path\n"sv) + err, x)); } if (lua_isnil(L, -1) != 0) { - throw std::logic_error(_info.errorMessage(s("fail to find module '"sv) + moduleName + '\'', x)); + throw std::logic_error(_info.errorMessage(s("failed to find module '"sv) + moduleName + '\'', x)); } std::string moduleFullName = lua_tostring(L, -1); lua_pop(L, 1); // cur @@ -5091,10 +5091,10 @@ private: lua_pushlstring(L, moduleFullName.c_str(), moduleFullName.size()); // cur load_text moduleFullName if (lua_pcall(L, 1, 1, 0) != 0) { std::string err = lua_tostring(L, -1); - throw std::logic_error(_info.errorMessage(s("fail to read module file\n"sv) + err, x)); + throw std::logic_error(_info.errorMessage(s("failed to read module file\n"sv) + err, x)); } // cur text if (lua_isnil(L, -1) != 0) { - throw std::logic_error(_info.errorMessage("fail to get module text"sv, x)); + throw std::logic_error(_info.errorMessage("failed to get module text"sv, x)); } // cur text std::string text = lua_tostring(L, -1); auto compiler = MoonCompilerImpl(L, _luaOpen, false, moduleFullName); @@ -5105,7 +5105,7 @@ private: config.implicitReturnRoot = _config.implicitReturnRoot; auto result = compiler.compile(text, config); if (result.codes.empty() && !result.error.empty()) { - throw std::logic_error(_info.errorMessage(s("fail to compile module '"sv) + moduleName + s("\': "sv) + result.error, x)); + throw std::logic_error(_info.errorMessage(s("failed to compile module '"sv) + moduleName + s("\': "sv) + result.error, x)); } lua_pop(L, 1); // cur } diff --git a/src/MoonP/moonplus.cpp b/src/MoonP/moonplus.cpp index bea1d6e..47de01c 100644 --- a/src/MoonP/moonplus.cpp +++ b/src/MoonP/moonplus.cpp @@ -17,10 +17,10 @@ static const char moonplusCodes[] = static void init_moonplus(lua_State* L) { if (luaL_loadbuffer(L, moonplusCodes, sizeof(moonplusCodes) / sizeof(moonplusCodes[0]) - 1, "=(moonplus)") != 0) { - std::string err = std::string("fail to load moonplus module.\n") + lua_tostring(L, -1); + std::string err = std::string("failed to load moonplus module.\n") + lua_tostring(L, -1); luaL_error(L, err.c_str()); } else if (lua_pcall(L, 0, 0, 0) != 0) { - std::string err = std::string("fail to init moonplus module.\n") + lua_tostring(L, -1); + std::string err = std::string("failed to init moonplus module.\n") + lua_tostring(L, -1); luaL_error(L, err.c_str()); } } @@ -30,10 +30,10 @@ static const char stpCodes[] = static int init_stacktraceplus(lua_State* L) { if (luaL_loadbuffer(L, stpCodes, sizeof(stpCodes) / sizeof(stpCodes[0]) - 1, "=(stacktraceplus)") != 0) { - std::string err = std::string("fail to load stacktraceplus module.\n") + lua_tostring(L, -1); + std::string err = std::string("failed to load stacktraceplus module.\n") + lua_tostring(L, -1); luaL_error(L, err.c_str()); } else if (lua_pcall(L, 0, 1, 0) != 0) { - std::string err = std::string("fail to init stacktraceplus module.\n") + lua_tostring(L, -1); + std::string err = std::string("failed to init stacktraceplus module.\n") + lua_tostring(L, -1); luaL_error(L, err.c_str()); } return 1; -- cgit v1.2.3-55-g6feb