X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FCompiler.h;h=d406bbf2c8cbf016873472941c333e961ac65812;hb=b20681c1bf555c337b15796b3910d0d48488b102;hp=d2f036115733d2237f8f07508166c7135ff8f92b;hpb=587a9fc38235475f1c25424bee3e3aeb892a25e2;p=l2e.git diff --git a/src/loader/Compiler.h b/src/loader/Compiler.h index d2f0361..d406bbf 100644 --- a/src/loader/Compiler.h +++ b/src/loader/Compiler.h @@ -1,22 +1,19 @@ -/* - * Compiler.h - * - * Created on: Sep 11, 2012 - * Author: holy - */ - #ifndef LOADER_COMPILER_H_ #define LOADER_COMPILER_H_ +#include "Interpreter.h" +#include "ObjectFile.h" +#include "TypeDescription.h" + #include #include #include +#include +#include #include namespace loader { -class Interpreter; - class Compiler { public: @@ -27,64 +24,44 @@ private: Compiler &operator =(const Compiler &); public: - void Write(std::ostream &); - - struct Export { - int nameOffset; - int typeId; - int dataOffset; - }; - - struct External { - int nameOffset; - int referenceOffset; - int inlined; - }; - - struct ImageProperties { - Uint32 flags; - int width; - int height; - int depth; - Uint32 rmask; - Uint32 gmask; - Uint32 bmask; - Uint32 amask; - }; + void Write(std::iostream &); private: + void ReserveHeader(std::ostream &); + void WriteObjects(std::ostream &); + void WriteOwnStrings(std::ostream &); + void WriteArrays(std::ostream &); void WriteHeader(std::ostream &); void WriteExports(std::ostream &); void WriteExternals(std::ostream &); - void WriteExportStrings(std::ostream &); - void WriteExternalStrings(std::ostream &); void WriteImages(std::ostream &); - void WriteObjects(std::ostream &); + void WriteScripts(std::ostream &); - void Write(std::ostream &, const char *data, int amount); + void Relocate(std::iostream &); + void RelocateArray(char *, int size); + void Relocate(unsigned int pos, char *dest, const TypeDescription &); + void RelocateScript(char *, unsigned int); + + void PrepareExport(Export &, const std::string &); + void PrepareExternal(External &, const Interpreter::PostponedDefinition &); + void PrepareObject(Object &, const TypeDescription &, void *); + + void Write(std::ostream &, const void *data, int amount); void Pad(std::ostream &, int to); + void Fill(std::ostream &, int count, char c = '\0'); static int Remaining(int value, int alignment); - int ReferenceOffset(int typeId, int objectId, std::ptrdiff_t fieldOffset) const; - int ObjectOffset(int typeId, int objectId) const; - int TypeOffset(int typeId) const; - private: const Interpreter &intp; - int cursor; - - int exportsOffset; - int externalsOffset; - int externalStringsOffset; - int exportStringsOffset; - int imagesOffset; - int objectsOffset; + ObjectFileHeader fileHeader; - std::map objectOffsets; + std::map addressMap; + std::map images; + std::vector > scripts; }; } -#endif /* LOADER_COMPILER_H_ */ +#endif