From 3cf55f763ef8c75e8e8c11fca3c3e564668aee52 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 8 Nov 2014 17:53:18 -0800 Subject: Make it easier to debug scripts, especially from coredumps --- src/map/script-parse.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/map/script-parse.cpp') 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 script_buf; + RString debug_name; + std::vector> 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 compile_script(const ast::script::ScriptBody& body, bool implicit_end) +std::unique_ptr compile_script(RString debug_name, const ast::script::ScriptBody& body, bool implicit_end) { - auto script_buf = make_unique(); + auto script_buf = make_unique(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(str), script_buf.size()); + debug_labels.push_back(std::make_pair(stringish(str), script_buf.size())); p = tmpp + 1; continue; } -- cgit v1.2.3-70-g09d2