X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.h;h=5707959e49265d52b66ecd075ac64d569b7dc44c;hb=a3ba4dc677ad7c92eeb78b20b642241563605c9d;hp=b12efaedebb35fe3fac09057ffb13600aa3348ff;hpb=02db07fbdd774a0a3b10806aa77d782059ba62cc;p=l2e.git diff --git a/src/loader/Interpreter.h b/src/loader/Interpreter.h index b12efae..5707959 100644 --- a/src/loader/Interpreter.h +++ b/src/loader/Interpreter.h @@ -1,18 +1,17 @@ -/* - * 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 "../geometry/Vector.h" +#include "../battle/fwd.h" +#include "../common/fwd.h" +#include "../common/Script.h" +#include "../math/Vector.h" #include "../graphics/Color.h" #include "../graphics/ComplexAnimation.h" +#include "../graphics/fwd.h" #include #include @@ -21,48 +20,27 @@ #include #include -namespace battle { - class Hero; - class Monster; - class PartyLayout; - struct Resources; - class Stats; -} - -namespace common { - class Ikari; - class Item; - class Spell; - class TargetingMode; -} - -namespace graphics { - class Animation; - class Font; - class Frame; - class Gauge; - struct MenuProperties; - class SimpleAnimation; - class Sprite; -} - namespace loader { -class Definition; -class Literal; -class PropertyList; -class Value; - 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) { } }; public: - Interpreter(const ParsedSource &source) : source(source) { } + explicit Interpreter(const ParsedSource &source) : source(source), alloc(4096) { } ~Interpreter(); private: Interpreter(const Interpreter &); @@ -92,7 +70,7 @@ public: }; const std::set &ExportedIdentifiers() const { return source.Exports(); } - const ParsedDefinition &GetDefinition(const std::string &identifier) const { return parsedDefinitions.at(identifier); } + 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; } @@ -105,6 +83,12 @@ 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 &); @@ -114,6 +98,8 @@ private: private: const ParsedSource &source; + PagedAllocator alloc; + std::map parsedDefinitions; std::vector postponedDefinitions; std::map imageCache;