88 #include <unordered_map>
89 #include "../r_code/object.h"
90 #include "../r_code/list.h"
111 uint32 get_class_array_size();
112 uint32 get_classes_size();
113 uint32 get_sys_classes_size();
114 uint32 get_class_names_size();
115 uint32 get_operator_names_size();
116 uint32 get_function_names_size();
120 std::unordered_map<std::string, Class> classes_;
121 std::unordered_map<std::string, Class> sys_classes_;
129 Class *get_class(std::string &class_name);
130 Class *get_class(uint16 opcode);
132 void write(word32 *data);
133 void read(word32 *data, uint32 size);
141 void shift(uint16 offset);
143 void write(word32 *data);
144 void read(word32 *data, uint32 size);
145 uint32 get_size()
const;
154 void write(word32 *data);
155 void read(word32 *data, uint16 object_count);
161 std::unordered_map<uint32, std::string> symbols_;
165 void write(word32 *data);
166 void read(word32 *data);
174 uint32 findSymbol(
const std::string& name);
180 std::unordered_map<r_code::Code *, uint16> ptrs_to_indices_;
182 void add_object(
r_code::Code *
object,
bool include_invalidated);
184 uint32 get_reference_count(
const r_code::Code *
object)
const;
185 void build_references();
193 Timestamp timestamp_;
204 for (uint32 i = 0; i < code_segment_.objects_.size(); ++i) {
206 uint16 opcode = code_segment_.objects_[i]->code_[0].asOpcode();
207 ram_objects[i] =
new O(code_segment_.objects_[i]);
209 unpack_objects(ram_objects);
222 template<
class I> I *serialize() {
224 I *image = (I *)I::Build(timestamp_, object_map_.get_size(), code_segment_.get_size(), object_names_.get_size());
226 object_map_.shift(image->map_size());
227 object_map_.write(image->data());
228 code_segment_.write(image->data() + image->map_size());
229 object_names_.write(image->data() + image->map_size() + image->code_size());
234 template<
class I>
void load(I *image) {
236 timestamp_ = image->timestamp();
237 object_map_.read(image->data(), image->map_size());
238 code_segment_.read(image->data() + image->map_size(), image->map_size());
239 object_names_.read(image->data() + image->map_size() + image->code_size());