diff options
author | bloodstalker <thabogre@gmail.com> | 2018-04-08 06:28:07 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2018-04-08 06:28:07 +0000 |
commit | adc7bcd0697131e1067763e9d1b96d6ece6f1e9f (patch) | |
tree | b065ea10ccd4dbe3c91454ed588a2d81953c0426 /bruiser/bruiser.cpp | |
parent | added some more features, a lil bit closer to getting the nested function cal... (diff) | |
download | mutator-adc7bcd0697131e1067763e9d1b96d6ece6f1e9f.tar.gz mutator-adc7bcd0697131e1067763e9d1b96d6ece6f1e9f.zip |
added some more cli options to load.py. added a new test file for bruiser to see how it fares against bigger files.
Diffstat (limited to '')
-rw-r--r-- | bruiser/bruiser.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index 82cd632..cdb4ef4 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -166,7 +166,10 @@ template <typename T> std::vector<T> getLuaTableInt(lua_State* __ls, int numargs, int argnum) { std::vector<T> ret; int table_length = lua_rawlen(__ls, argnum); - lua_checkstack(__ls, table_length); + if (!lua_checkstack(__ls, table_length)) { + std::cout << RED << "need to grow lua stack by " << table_length << ":"; + PRINT_WITH_COLOR_LB(RED, "cant grow lua stack by that much."); + } for (int i = 1; i <= table_length; ++i) { lua_rawgeti(__ls, argnum, i); ret.push_back(lua_tointeger(__ls, i + numargs)); @@ -177,7 +180,10 @@ std::vector<T> getLuaTableInt(lua_State* __ls, int numargs, int argnum) { std::vector<std::string> getLuaTableString(lua_State* __ls, int numargs, int argnum) { std::vector<std::string> ret; int table_length = lua_rawlen(__ls, argnum); - lua_checkstack(__ls, table_length); + if (!lua_checkstack(__ls, table_length)) { + std::cout << RED << "need to grow lua stack by " << table_length << ":"; + PRINT_WITH_COLOR_LB(RED, "cant grow lua stack by that much."); + } for (int i = 1; i <= table_length; ++i) { lua_rawgeti(__ls, argnum, i); ret.push_back(lua_tostring(__ls, i + numargs)); @@ -189,7 +195,10 @@ template <typename T> std::vector<T> getLuaTableNumber(lua_State* __ls, int numargs, int argnum) { std::vector<T> ret; int table_length = lua_rawlen(__ls, argnum); - lua_checkstack(__ls, table_length); + if (!lua_checkstack(__ls, table_length)) { + std::cout << RED << "need to grow lua stack by " << table_length << ":"; + PRINT_WITH_COLOR_LB(RED, "cant grow lua stack by that much."); + } for (int i = 1; i <= table_length; ++i) { lua_rawgeti(__ls, argnum, i); ret.push_back(lua_tonumber(__ls, i + numargs)); @@ -1605,7 +1614,9 @@ class LuaWrapper if (numargs != 2) {PRINT_WITH_COLOR_LB(RED, "expected exactly two args. did not get that.");return 0;} uint64_t size = lua_tointeger(__ls, 1); std::vector<uint8_t> code_v = getLuaTableInt<uint8_t>(__ls, 2, 2); + if (Verbose) PRINT_WITH_COLOR_LB(BLUE, "making jump table..."); auto head = makejmptable(size, code_v.data(), Verbose, __ls); + if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "finished makejmptable call."); jmpt_push_args(__ls, head); new_jmpt_2(__ls); return 1; |