X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Floader%2FLoader.cpp;h=1e0050dbc022a64c1d7896428caad0b152dac2f0;hb=7b3710c47f24e64e0d01378a4564730bcb2f6ef2;hp=2403044ad20fb819a23fafc0b43c2ded125a317c;hpb=8c8061a4f8b88410d6d93c039afe6affc4b69cf2;p=l2e.git diff --git a/src/loader/Loader.cpp b/src/loader/Loader.cpp index 2403044..1e0050d 100644 --- a/src/loader/Loader.cpp +++ b/src/loader/Loader.cpp @@ -4,7 +4,9 @@ #include #include #include +#include +using std::make_pair; using std::map; using std::string; using std::vector; @@ -52,6 +54,9 @@ void Loader::Load(const std::string &filePath) { LoadObjects(header->ident, header->ObjectsBegin(), header->ObjectsEnd()); + LoadArrays(header->ident, + header->ArraysBegin(), + header->ArraysEnd()); } catch (...) { delete[] block; throw; @@ -65,6 +70,7 @@ void Loader::LoadExports(char *src, Export *begin, Export *end) { LoadedExport &exp(exports[identifier]); exp.typeId = i->typeId; exp.location = src + i->dataOffset; + exports.insert(make_pair(identifier, exp)); } } @@ -112,4 +118,22 @@ void Loader::LoadObject(char *src, char *object, const TypeDescription &td) { } } +void Loader::LoadArrays(char *src, Array *begin, Array *end) { + for (Array *i = begin; i < end; i = i->Next()) { + if (i->ref) { + for (char *j = i->Data(), *end = i->Data() + i->size; + j < end; j += sizeof(void *)) { + *reinterpret_cast(j) = + src + *reinterpret_cast(j); + } + } else { + const TypeDescription &td = TypeDescription::Get(i->typeId); + for (char *j = i->Data(), *end = i->Data() + i->size; + j < end; j += td.Size()) { + LoadObject(src, j, td); + } + } + } +} + }