+ } else {
+ throw Error("access to undefined Frame " + name);
+ }
+}
+
+Gauge *Interpreter::GetGauge(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == GAUGE) {
+ return gauges[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Gauge");
+ }
+ } else {
+ throw Error("access to undefined Gauge " + name);
+ }
+}
+
+Hero *Interpreter::GetHero(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == HERO) {
+ return heroes[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Hero");
+ }
+ } else {
+ throw Error("access to undefined Hero " + name);
+ }
+}
+
+Ikari *Interpreter::GetIkari(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == IKARI) {
+ return ikaris[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Ikari");
+ }
+ } else {
+ throw Error("access to undefined Ikari " + name);
+ }
+}
+
+Item *Interpreter::GetItem(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == ITEM) {
+ return items[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Item");
+ }
+ } else {
+ throw Error("access to undefined Item " + name);
+ }
+}
+
+Monster *Interpreter::GetMonster(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == MONSTER) {
+ return monsters[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Monster");
+ }
+ } else {
+ throw Error("access to undefined Monster " + name);
+ }
+}
+
+int Interpreter::GetNumber(const std::string &name) const {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == NUMBER) {
+ return numbers[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Number");
+ }
+ } else {
+ throw Error("access to undefined Number " + name);
+ }
+}
+
+PartyLayout *Interpreter::GetPartyLayout(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == PARTY_LAYOUT) {
+ return partyLayouts[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to PartyLayout");
+ }
+ } else {
+ throw Error("access to undefined PartyLayout " + name);
+ }
+}
+
+const char *Interpreter::GetPath(const std::string &name) const {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == PATH) {
+ return strings[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Path");
+ }
+ } else {
+ throw Error("access to undefined Path " + name);
+ }
+}
+
+Spell *Interpreter::GetSpell(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == SPELL) {
+ return spells[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Spell");
+ }
+ } else {
+ throw Error("access to undefined Spell " + name);
+ }
+}
+
+Sprite *Interpreter::GetSprite(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == SPRITE) {
+ return sprites[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Sprite");
+ }
+ } else {
+ throw Error("access to undefined Sprite " + name);
+ }
+}
+
+const char *Interpreter::GetString(const std::string &name) const {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ // TODO: enable path to string casting some time
+ if (i->second.type == STRING /* || i->second.type == PATH */) {
+ return strings[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to String");
+ }
+ } else {
+ throw Error("access to undefined String " + name);
+ }
+}
+
+TargetingMode *Interpreter::GetTargetingMode(const std::string &name) {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == TARGETING_MODE) {
+ return targetingModes[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to TargetingMode");
+ }
+ } else {
+ throw Error("access to undefined TargetingMode " + name);
+ }
+}
+
+Vector<int> Interpreter::GetVector(const std::string &name) const {
+ map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
+ if (i != parsedDefinitions.end()) {
+ if (i->second.type == VECTOR) {
+ return vectors[i->second.index];
+ } else {
+ throw Error("cannot cast " + i->second.dfn->TypeName() + " to Vector");
+ }
+ } else {
+ throw Error("access to undefined Vector " + name);
+ }
+}
+
+
+void Interpreter::ReadSource() {
+ for (set<string>::const_iterator i(source.Exports().begin()), end(source.Exports().end()); i != end; ++i) {
+ ReadDefinition(source.GetDefinition(*i));
+ }
+}
+
+void Interpreter::ReadDefinition(const Definition &dfn) {
+ if (parsedDefinitions.find(dfn.Identifier()) != parsedDefinitions.end()) {
+ return;
+ }
+ if (dfn.HasLiteralValue()) {
+ ReadLiteral(dfn);
+ } else {
+ ReadObject(dfn);