From 65ccda50c7c3826070b9933fac7e8d26bb1e270f Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sat, 3 Nov 2018 03:40:20 -0300 Subject: [PATCH] Debug fixups --- include/sirit/sirit.h | 5 ++++- src/insts/debug.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 9e50877..fc8c721 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -201,7 +201,10 @@ class Module { Id Name(Id target, const std::string& name); /// Assign a Result to a string for use by other debug instructions. - Id OpString(const std::string& string); + Id String(const std::string& string); + + /// Add source-level location information + Id OpLine(Id file, Literal line, Literal column); // Memory diff --git a/src/insts/debug.cpp b/src/insts/debug.cpp index 688862d..d61dec1 100644 --- a/src/insts/debug.cpp +++ b/src/insts/debug.cpp @@ -19,9 +19,19 @@ Id Module::Name(Id target, const std::string& name) { return target; } -Id Module::OpString(const std::string& string) { +Id Module::String(const std::string& string) { auto op{std::make_unique(spv::Op::OpString, bound++)}; op->Add(string); + const auto id = op.get(); + debug.push_back(std::move(op)); + return id; +} + +Id Module::OpLine(Id file, Literal line, Literal column) { + auto op{std::make_unique(spv::Op::OpLine)}; + op->Add(file); + op->Add(line); + op->Add(column); return AddCode(std::move(op)); }