From 02db07fbdd774a0a3b10806aa77d782059ba62cc Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 13 Sep 2012 22:34:50 +0200 Subject: [PATCH] added linkage type and some getters to Interpreter --- src/loader/Interpreter.cpp | 6 +++--- src/loader/Interpreter.h | 37 +++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index 1005c64..97ed939 100644 --- a/src/loader/Interpreter.cpp +++ b/src/loader/Interpreter.cpp @@ -311,7 +311,7 @@ void Interpreter::ReadObject(int typeId, int id, char *object, const PropertyLis } } } else { - Postpone(typeId, id, fd.Offset(), i->second->GetIdentifier(), fd.TypeId()); + Postpone(typeId, id, fd.Offset(), i->second->GetIdentifier(), fd.TypeId(), !fd.IsReferenced()); } } } @@ -333,11 +333,11 @@ bool Interpreter::CanLink(const Value &v) const { return v.IsLiteral() || source.IsDefined(v.GetIdentifier()); } -void Interpreter::Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType) { +void Interpreter::Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType, bool inlined) { char *str(new char[identifier.size() + 1]); std::memcpy(str, identifier.c_str(), identifier.size()); str[identifier.size()] = '\0'; - postponedDefinitions.push_back(PostponedDefinition(type, id, offset, str, linkedType)); + postponedDefinitions.push_back(PostponedDefinition(type, id, offset, str, linkedType, inlined)); } diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index 3202482..b12efae 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -8,12 +8,14 @@ #ifndef LOADER_INTERPRETER_H_ #define LOADER_INTERPRETER_H_ +#include "ParsedSource.h" #include "TypeDescription.h" #include "../geometry/Vector.h" #include "../graphics/Color.h" #include "../graphics/ComplexAnimation.h" #include +#include #include #include #include @@ -48,7 +50,6 @@ namespace loader { class Definition; class Literal; -class ParsedSource; class PropertyList; class Value; @@ -72,17 +73,29 @@ public: void *GetObject(int typeId, const std::string &name); static void CreateTypeDescriptions(); + struct ParsedDefinition { + ParsedDefinition(const Definition *dfn, int type, int id) + : dfn(dfn), type(type), id(id) { } + const Definition *dfn; + int type; + int id; + }; struct PostponedDefinition { - PostponedDefinition(int type, int id, std::ptrdiff_t offset, const char *identifier, int linkedType) - : type(type), id(id), offset(offset), identifier(identifier), linkedType(linkedType) { } + PostponedDefinition(int type, int id, std::ptrdiff_t offset, const char *identifier, int linkedType, bool inlined) + : type(type), id(id), offset(offset), identifier(identifier), linkedType(linkedType), inlined(inlined) { } int type; int id; std::ptrdiff_t offset; const char *identifier; int linkedType; + bool inlined; }; - const std::vector &PostponedDefinitions() { return postponedDefinitions; } + const std::set &ExportedIdentifiers() const { return source.Exports(); } + const ParsedDefinition &GetDefinition(const std::string &identifier) const { return parsedDefinitions.at(identifier); } + const std::map &Images() const { return imageCache; } + const std::vector &PostponedDefinitions() const { return postponedDefinitions; } + const std::map > &Values() const { return values; } private: void ReadDefinition(const Definition &); @@ -95,23 +108,15 @@ private: SDL_Surface *GetImage(const std::string &); + bool CanLink(const Value &) const; + void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType, bool inlined); + private: const ParsedSource &source; - struct ParsedDefinition { - ParsedDefinition(const Definition *dfn, int type, int id) - : dfn(dfn), type(type), id(id) { } - const Definition *dfn; - int type; - int id; - }; - std::map parsedDefinitions; - bool CanLink(const Value &) const; - void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType); + std::map parsedDefinitions; std::vector postponedDefinitions; - std::map imageCache; - std::map > values; }; -- 2.39.2