1 #ifndef LOADER_COMPILER_H_
2 #define LOADER_COMPILER_H_
4 #include "Interpreter.h"
5 #include "ObjectFile.h"
6 #include "TypeDescription.h"
20 explicit Compiler(const Interpreter &intp);
23 Compiler(const Compiler &);
24 Compiler &operator =(const Compiler &);
27 void Write(std::iostream &);
30 void ReserveHeader(std::ostream &);
31 void WriteObjects(std::ostream &);
32 void WriteOwnStrings(std::ostream &);
33 void WriteArrays(std::ostream &);
34 void WriteHeader(std::ostream &);
35 void WriteExports(std::ostream &);
36 void WriteExternals(std::ostream &);
37 void WriteImages(std::ostream &);
38 void WriteScripts(std::ostream &);
40 void Relocate(std::iostream &);
41 void RelocateArray(char *, int size);
42 void Relocate(unsigned int pos, char *dest, const TypeDescription &);
43 void RelocateScript(char *, unsigned int);
45 void PrepareExport(Export &, const std::string &);
46 void PrepareExternal(External &, const Interpreter::PostponedDefinition &);
47 void PrepareObject(Object &, const TypeDescription &, void *);
49 void Write(std::ostream &, const void *data, int amount);
50 void Pad(std::ostream &, int to);
51 void Fill(std::ostream &, int count, char c = '\0');
52 static int Remaining(int value, int alignment);
55 const Interpreter &intp;
57 ObjectFileHeader fileHeader;
59 std::map<const void *, unsigned int> addressMap;
60 std::map<unsigned int, void *> images;
61 std::vector<std::pair<const char *, unsigned int> > scripts;