- Write(out, "L2O\n", 4);
- Write(out, reinterpret_cast<const char *>(&exportsOffset), sizeof(int));
- Write(out, reinterpret_cast<const char *>(&externalsOffset), sizeof(int));
- Write(out, reinterpret_cast<const char *>(&externalStringsOffset), sizeof(int));
- Write(out, reinterpret_cast<const char *>(&exportStringsOffset), sizeof(int));
- Write(out, reinterpret_cast<const char *>(&imagesOffset), sizeof(int));
- Write(out, reinterpret_cast<const char *>(&objectsOffset), sizeof(int));
- for(map<int, vector<void *> >::const_iterator i(intp.Values().begin()), end(intp.Values().end()); i != end; ++i) {
- Write(out, reinterpret_cast<const char *>(&i->first), sizeof(int));
- int typeOffset(TypeOffset(i->first));
- Write(out, reinterpret_cast<const char *>(&typeOffset), sizeof(int));
+ Write(out, &fileHeader, sizeof(ObjectFileHeader));
+}
+
+void Compiler::WriteOwnStrings(ostream &out) {
+ for (set<string>::const_iterator
+ i(intp.ExportedIdentifiers().begin()),
+ end(intp.ExportedIdentifiers().end());
+ i != end; ++i) {
+ Object object;
+ object.typeId = Interpreter::STRING_ID;
+ object.size = i->size() + 1;
+ Write(out, &object, sizeof(Object));
+ addressMap.insert(make_pair(i->c_str(), out.tellp()));
+ Write(out, i->c_str(), object.size);
+ }
+ for(vector<Interpreter::PostponedDefinition>::const_iterator
+ i(intp.PostponedDefinitions().begin()),
+ end(intp.PostponedDefinitions().end());
+ i != end; ++i) {
+ Object object;
+ object.typeId = Interpreter::STRING_ID;
+ object.size = i->identifier.size() + 1;
+ Write(out, &object, sizeof(Object));
+ addressMap.insert(make_pair(
+ i->identifier.c_str(), out.tellp()));
+ Write(out, i->identifier.c_str(), object.size);
+ }
+ for (std::map<std::string, SDL_Surface *>::const_iterator
+ i(intp.Images().begin()), end(intp.Images().end());
+ i != end; ++i) {
+ addressMap.insert(make_pair(
+ i->second, 0));
+ Object object;
+ object.typeId = Interpreter::STRING_ID;
+ object.size = i->first.size() + 1;
+ Write(out, &object, sizeof(Object));
+ addressMap.insert(make_pair(
+ i->first.c_str(), out.tellp()));
+ Write(out, i->first.c_str(), object.size);