}
}
} else {
- Postpone(typeId, id, fd.Offset(), i->second->GetIdentifier(), fd.TypeId());
+ Postpone(typeId, id, fd.Offset(), i->second->GetIdentifier(), fd.TypeId(), !fd.IsReferenced());
}
}
}
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));
}
#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 <map>
+#include <set>
#include <stdexcept>
#include <string>
#include <vector>
class Definition;
class Literal;
-class ParsedSource;
class PropertyList;
class Value;
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<PostponedDefinition> &PostponedDefinitions() { return postponedDefinitions; }
+ const std::set<std::string> &ExportedIdentifiers() const { return source.Exports(); }
+ const ParsedDefinition &GetDefinition(const std::string &identifier) const { return parsedDefinitions.at(identifier); }
+ const std::map<std::string, SDL_Surface *> &Images() const { return imageCache; }
+ const std::vector<PostponedDefinition> &PostponedDefinitions() const { return postponedDefinitions; }
+ const std::map<int, std::vector<void *> > &Values() const { return values; }
private:
void ReadDefinition(const Definition &);
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<std::string, ParsedDefinition> parsedDefinitions;
- bool CanLink(const Value &) const;
- void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType);
+ std::map<std::string, ParsedDefinition> parsedDefinitions;
std::vector<PostponedDefinition> postponedDefinitions;
-
std::map<std::string, SDL_Surface *> imageCache;
-
std::map<int, std::vector<void *> > values;
};