X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FCompiler.h;h=7afe633afd655db4434aaf283abbb32990785084;hb=8c8061a4f8b88410d6d93c039afe6affc4b69cf2;hp=ab26cea41e5ed955933c4a20e0598b9f1bbfc146;hpb=0f30d8254ff8b9e63795960ec031577cf68fbf95;p=l2e.git diff --git a/src/loader/Compiler.h b/src/loader/Compiler.h index ab26cea..7afe633 100644 --- a/src/loader/Compiler.h +++ b/src/loader/Compiler.h @@ -1,14 +1,9 @@ -/* - * 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 @@ -17,8 +12,6 @@ namespace loader { -class Interpreter; - class Compiler { public: @@ -29,36 +22,41 @@ private: Compiler &operator =(const Compiler &); public: - void Write(std::ostream &); + 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 Write(std::ostream &, const char *data, int amount); + void Relocate(std::iostream &); + void RelocateArray(char *, int size); + void Relocate(char *, const TypeDescription &); + + 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 GetTypeOffset(int typeId) const; - private: const Interpreter &intp; - int cursor; + unsigned int cursor; ObjectFileHeader fileHeader; - std::map objectOffsets; + std::map addressMap; }; } -#endif /* LOADER_COMPILER_H_ */ +#endif