summaryrefslogtreecommitdiff
path: root/src/map/script-parse.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-11-08 17:53:18 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-11-09 19:58:42 -0800
commit3cf55f763ef8c75e8e8c11fca3c3e564668aee52 (patch)
tree703a5744c4ee1cb807e59ca49df283d52250f613 /src/map/script-parse.cpp
parenta7333d7e59515db8a5f95f43a3b26793505b2aae (diff)
downloadtmwa-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.cpp9
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;
}