diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-08 17:53:18 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-09 19:58:42 -0800 |
commit | 3cf55f763ef8c75e8e8c11fca3c3e564668aee52 (patch) | |
tree | 703a5744c4ee1cb807e59ca49df283d52250f613 /src/map/script-call.cpp | |
parent | a7333d7e59515db8a5f95f43a3b26793505b2aae (diff) | |
download | tmwa-3cf55f763ef8c75e8e8c11fca3c3e564668aee52.tar.gz tmwa-3cf55f763ef8c75e8e8c11fca3c3e564668aee52.tar.bz2 tmwa-3cf55f763ef8c75e8e8c11fca3c3e564668aee52.tar.xz tmwa-3cf55f763ef8c75e8e8c11fca3c3e564668aee52.zip |
Make it easier to debug scripts, especially from coredumps
Diffstat (limited to 'src/map/script-call.cpp')
-rw-r--r-- | src/map/script-call.cpp | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 8af5099..212e0e3 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -669,136 +669,6 @@ void run_func(ScriptState *st) } } -// pretend it's external so this can be called in the debugger -void dump_script(Borrowed<const ScriptBuffer> script); -void dump_script(Borrowed<const ScriptBuffer> script) -{ - ScriptPointer scriptp(script, 0); - while (scriptp.pos < reinterpret_cast<const std::vector<ByteCode> *>(&*script)->size()) - { - PRINTF("%6zu: "_fmt, scriptp.pos); - switch (ByteCode c = get_com(&scriptp)) - { - case ByteCode::EOL: - PRINTF("EOL\n"_fmt); // extra newline between functions - break; - case ByteCode::INT: - // synthesized! - PRINTF("INT %d"_fmt, get_num(&scriptp)); - break; - - case ByteCode::POS: - case ByteCode::VARIABLE: - case ByteCode::FUNC_REF: - case ByteCode::PARAM: - { - int arg = 0; - arg |= static_cast<uint8_t>(scriptp.pop()) << 0; - arg |= static_cast<uint8_t>(scriptp.pop()) << 8; - arg |= static_cast<uint8_t>(scriptp.pop()) << 16; - switch(c) - { - case ByteCode::POS: - PRINTF("POS %d"_fmt, arg); - break; - case ByteCode::VARIABLE: - PRINTF("VARIABLE %s"_fmt, variable_names.outtern(arg)); - break; - case ByteCode::FUNC_REF: - PRINTF("FUNC_REF %s"_fmt, builtin_functions[arg].name); - break; - case ByteCode::PARAM: - PRINTF("PARAM SP::#%d (sorry)"_fmt, arg); - break; - } - } - break; - case ByteCode::ARG: - PRINTF("ARG"_fmt); - break; - case ByteCode::STR: - PRINTF("STR \"%s\""_fmt, scriptp.pops()); - break; - case ByteCode::FUNC: - PRINTF("FUNC"_fmt); - break; - - case ByteCode::ADD: - PRINTF("ADD"_fmt); - break; - case ByteCode::SUB: - PRINTF("SUB"_fmt); - break; - case ByteCode::MUL: - PRINTF("MUL"_fmt); - break; - case ByteCode::DIV: - PRINTF("DIV"_fmt); - break; - case ByteCode::MOD: - PRINTF("MOD"_fmt); - break; - case ByteCode::EQ: - PRINTF("EQ"_fmt); - break; - case ByteCode::NE: - PRINTF("NE"_fmt); - break; - case ByteCode::GT: - PRINTF("GT"_fmt); - break; - case ByteCode::GE: - PRINTF("GE"_fmt); - break; - case ByteCode::LT: - PRINTF("LT"_fmt); - break; - case ByteCode::LE: - PRINTF("LE"_fmt); - break; - case ByteCode::AND: - PRINTF("AND"_fmt); - break; - case ByteCode::OR: - PRINTF("OR"_fmt); - break; - case ByteCode::XOR: - PRINTF("XOR"_fmt); - break; - case ByteCode::LAND: - PRINTF("LAND"_fmt); - break; - case ByteCode::LOR: - PRINTF("LOR"_fmt); - break; - case ByteCode::R_SHIFT: - PRINTF("R_SHIFT"_fmt); - break; - case ByteCode::L_SHIFT: - PRINTF("L_SHIFT"_fmt); - break; - case ByteCode::NEG: - PRINTF("NEG"_fmt); - break; - case ByteCode::NOT: - PRINTF("NOT"_fmt); - break; - case ByteCode::LNOT: - PRINTF("LNOT"_fmt); - break; - - case ByteCode::NOP: - PRINTF("NOP"_fmt); - break; - - default: - PRINTF("??? %d"_fmt, c); - break; - } - PRINTF("\n"_fmt); - } -} - /*========================================== * スクリプトの実行メイン部分 *------------------------------------------ |