From 760eb1dd86170a14e0b0b5a2331f1225f0b06fdf Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 13 Sep 2012 22:43:45 +0200 Subject: [PATCH] made Interpreter constructor explicit and added an error message --- src/loader/Interpreter.cpp | 9 +++++++++ src/loader/Interpreter.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index 97ed939..0b81323 100644 --- a/src/loader/Interpreter.cpp +++ b/src/loader/Interpreter.cpp @@ -69,6 +69,15 @@ Interpreter::~Interpreter() { } +const Interpreter::ParsedDefinition &Interpreter::GetDefinition(const string &identifier) const { + try { + return parsedDefinitions.at(identifier); + } catch (...) { + throw std::runtime_error("cannot find definition for " + identifier); + } +} + + void *Interpreter::GetObject(int typeId, const std::string &name) { map::const_iterator i(parsedDefinitions.find(name)); if (i != parsedDefinitions.end()) { diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index b12efae..bfe18c2 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -62,7 +62,7 @@ public: }; public: - Interpreter(const ParsedSource &source) : source(source) { } + explicit Interpreter(const ParsedSource &source) : source(source) { } ~Interpreter(); private: Interpreter(const Interpreter &); @@ -92,7 +92,7 @@ public: }; const std::set &ExportedIdentifiers() const { return source.Exports(); } - const ParsedDefinition &GetDefinition(const std::string &identifier) const { return parsedDefinitions.at(identifier); } + const ParsedDefinition &GetDefinition(const std::string &identifier) const; const std::map &Images() const { return imageCache; } const std::vector &PostponedDefinitions() const { return postponedDefinitions; } const std::map > &Values() const { return values; } -- 2.39.2