X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=5a8e3ab8aa424ed4db977e0c471c475cea05b8af;hb=087783315ac5955c17bb3b051c9351f321653df6;hp=15cebd5e2ff3f10e2adb57a48418c4efb1d1edf5;hpb=754442d4502b743a46831055484c3fa9fa621ec2;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index 15cebd5..5a8e3ab 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -1,23 +1,9 @@ -/* - * Interpreter.h - * - * Created on: Aug 26, 2012 - * Author: holy - */ - #ifndef LOADER_INTERPRETER_H_ #define LOADER_INTERPRETER_H_ -#include "fwd.h" #include "PagedAllocator.h" #include "ParsedSource.h" -#include "TypeDescription.h" -#include "../battle/fwd.h" -#include "../common/fwd.h" -#include "../geometry/Vector.h" -#include "../graphics/Color.h" -#include "../graphics/ComplexAnimation.h" -#include "../graphics/fwd.h" +#include "../common/Script.h" #include #include @@ -31,6 +17,15 @@ namespace loader { class Interpreter { public: + static const int BOOLEAN_ID = 1; + static const int COLOR_ID = 2; + static const int IMAGE_ID = 3; + static const int NUMBER_ID = 4; + static const int PATH_ID = 5; + static const int SCRIPT_ID = 6; + static const int STRING_ID = 7; + static const int VECTOR_ID = 8; + class Error: public std::runtime_error { public: Error(const std::string &msg) : std::runtime_error("interpreter error: " + msg) { } @@ -56,18 +51,26 @@ public: int id; }; struct PostponedDefinition { - 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; + PostponedDefinition( + char *dest, + const char *identifier, + int type, + bool inlined, + bool aggregate) + : dest(dest) + , identifier(identifier) + , type(type) + , inlined(inlined) + , aggregate(aggregate) { } + char *dest; const char *identifier; - int linkedType; + int type; bool inlined; + bool aggregate; }; const std::set &ExportedIdentifiers() const { return source.Exports(); } - const ParsedDefinition &GetDefinition(const std::string &identifier) const; + const ParsedDefinition &GetDefinition(const std::string &identifier); const std::map &Images() const { return imageCache; } const std::vector &PostponedDefinitions() const { return postponedDefinitions; } const std::map > &Values() const { return values; } @@ -80,11 +83,22 @@ private: void ReadLiteral(int typeId, int id, char *dest, const Literal &); void *GetObject(int typeId, const Value &value); void ReadObject(int typeId, int id, char *dest, const PropertyList &); + void ReadScript(const std::vector &, common::Script *); + char *ReadScript(const std::vector &); + common::Script::Code &CreateScriptCode(common::Script::Command c, char *dest); + void ReadScriptAddress(const ScriptToken &t, char *dest); + void ReadScriptInteger(const ScriptToken &t, char *dest); + void ReadScriptVector(const ScriptToken &t, char *dest); 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); + void Postpone( + char *dest, + const std::string &identifier, + int type, + bool inlined = true, + bool aggregate = false); private: const ParsedSource &source; @@ -100,4 +114,4 @@ private: } -#endif /* LOADER_INTERPRETER_H_ */ +#endif