-/*
- * 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 <map>
#include <set>
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) { }
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<std::string> &ExportedIdentifiers() const { return source.Exports(); }
void ReadObject(int typeId, int id, char *dest, const PropertyList &);
void ReadScript(const std::vector<ScriptToken *> &, common::Script *);
char *ReadScript(const std::vector<ScriptToken *> &);
- void ReadScriptAddress(const ScriptToken &t, unsigned char *dest);
- void ReadScriptInteger(const ScriptToken &t, unsigned char *dest);
- void ReadScriptVector(const ScriptToken &t, unsigned char *dest);
+ 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;
}
-#endif /* LOADER_INTERPRETER_H_ */
+#endif