From: Daniel Karbach Date: Thu, 13 Sep 2012 20:43:45 +0000 (+0200) Subject: made Interpreter constructor explicit and added an error message X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=760eb1dd86170a14e0b0b5a2331f1225f0b06fdf;p=l2e.git made Interpreter constructor explicit and added an error message --- 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; }