#include <cstring>
#include <fstream>
#include <stdexcept>
+#include <utility>
+using std::make_pair;
using std::map;
using std::string;
using std::vector;
LoadObjects(header->ident,
header->ObjectsBegin(),
header->ObjectsEnd());
+ LoadArrays(header->ident,
+ header->ArraysBegin(),
+ header->ArraysEnd());
} catch (...) {
delete[] block;
throw;
LoadedExport &exp(exports[identifier]);
exp.typeId = i->typeId;
exp.location = src + i->dataOffset;
+ exports.insert(make_pair(identifier, exp));
}
}
}
}
+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<char **>(j) =
+ src + *reinterpret_cast<unsigned int *>(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);
+ }
+ }
+ }
+}
+
}