}
+bool ParsedSource::IsDeclared(const std::string &name) const {
+ return declarations.count(name);
+}
+
+Declaration &ParsedSource::GetDeclaration(const std::string &name) {
+ map<string, Declaration *>::const_iterator i(declarations.find(name));
+ if (i != declarations.end()) {
+ return *i->second;
+ } else {
+ throw runtime_error("undeclared identifier " + name);
+ }
+}
+
+const Declaration &ParsedSource::GetDeclaration(const std::string &name) const {
+ map<string, Declaration *>::const_iterator i(declarations.find(name));
+ if (i != declarations.end()) {
+ return *i->second;
+ } else {
+ throw runtime_error("undeclared identifier " + name);
+ }
+}
+
+bool ParsedSource::IsDefined(const std::string &name) const {
+ return definitions.count(name);
+}
+
+Definition &ParsedSource::GetDefinition(const std::string &name) {
+ map<string, Definition *>::const_iterator i(definitions.find(name));
+ if (i != definitions.end()) {
+ return *i->second;
+ } else {
+ throw runtime_error("undefined identifier " + name);
+ }
+}
+
+const Definition &ParsedSource::GetDefinition(const std::string &name) const {
+ map<string, Definition *>::const_iterator i(definitions.find(name));
+ if (i != definitions.end()) {
+ return *i->second;
+ } else {
+ throw runtime_error("undefined identifier " + name);
+ }
+}
+
+
void Definition::SetValue(Literal *v) {
value = v;
isLiteral = true;
void ExportDeclaration(Declaration *);
void ExportIdentifier(const std::string &);
+ bool IsDeclared(const std::string &) const;
+ Declaration &GetDeclaration(const std::string &);
+ const Declaration &GetDeclaration(const std::string &) const;
+ bool IsDefined(const std::string &) const;
+ Definition &GetDefinition(const std::string &);
+ const Definition &GetDefinition(const std::string &) const;
+
const std::map<std::string, Declaration *> &Declarations() const { return declarations; }
const std::map<std::string, Definition *> &Definitions() const { return definitions; }
const std::set<std::string> &Exports() const { return exports; }