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-parse.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-parse.cpp')
-rw-r--r-- | src/map/script-parse.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp index 85e29a5..6fb94de 100644 --- a/src/map/script-parse.cpp +++ b/src/map/script-parse.cpp @@ -52,7 +52,11 @@ class ScriptBuffer typedef ZString::iterator ZSit; std::vector<ByteCode> script_buf; + RString debug_name; + std::vector<std::pair<ScriptLabel, size_t>> debug_labels; public: + ScriptBuffer(RString name) : debug_name(std::move(name)) {} + // construction methods void add_scriptc(ByteCode a); void add_scriptb(uint8_t a); @@ -694,9 +698,9 @@ void add_builtin_functions(void) } } -std::unique_ptr<const ScriptBuffer> compile_script(const ast::script::ScriptBody& body, bool implicit_end) +std::unique_ptr<const ScriptBuffer> compile_script(RString debug_name, const ast::script::ScriptBody& body, bool implicit_end) { - auto script_buf = make_unique<ScriptBuffer>(); + auto script_buf = make_unique<ScriptBuffer>(std::move(debug_name)); script_buf->parse_script(body.braced_body, body.span.begin.line, implicit_end); return std::move(script_buf); } @@ -769,6 +773,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) } set_label(ld, script_buf.size()); scriptlabel_db.insert(stringish<ScriptLabel>(str), script_buf.size()); + debug_labels.push_back(std::make_pair(stringish<ScriptLabel>(str), script_buf.size())); p = tmpp + 1; continue; } |