diff options
author | Max Horn | 2010-07-01 16:05:29 +0000 |
---|---|---|
committer | Max Horn | 2010-07-01 16:05:29 +0000 |
commit | b8904a48ed81d04a2cbe84f78d80aaa75344d16e (patch) | |
tree | 0ca4fcea00f9aad9d14292b5ec393057b815abfb /engines | |
parent | c822cd67cbebf22999a6b4d95d965ea5873e1b9a (diff) | |
download | scummvm-rg350-b8904a48ed81d04a2cbe84f78d80aaa75344d16e.tar.gz scummvm-rg350-b8904a48ed81d04a2cbe84f78d80aaa75344d16e.tar.bz2 scummvm-rg350-b8904a48ed81d04a2cbe84f78d80aaa75344d16e.zip |
SCI: Make SegManager::_heap private
svn-id: r50552
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/gc.cpp | 24 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 11 |
3 files changed, 19 insertions, 18 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index 3dd7acfa1c..75456bcef0 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -51,12 +51,12 @@ struct WorklistManager { } }; -static reg_t_hash_map *normalise_hashmap_ptrs(SegManager *segMan, reg_t_hash_map &nonnormal_map) { +static reg_t_hash_map *normalizeAddresses(SegManager *segMan, reg_t_hash_map &nonnormal_map) { reg_t_hash_map *normal_map = new reg_t_hash_map(); for (reg_t_hash_map::iterator i = nonnormal_map.begin(); i != nonnormal_map.end(); ++i) { reg_t reg = i->_key; - SegmentObj *mobj = (reg.segment < segMan->_heap.size()) ? segMan->_heap[reg.segment] : NULL; + SegmentObj *mobj = segMan->getSegmentObj(reg.segment); if (mobj) { reg = mobj->findCanonicAddress(segMan, reg); @@ -113,11 +113,12 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { debugC(2, kDebugLevelGC, "[GC] -- Finished adding execution stack"); + const Common::Array<SegmentObj *> &heap = segMan->getSegments(); + // Init: Explicitly loaded scripts - for (i = 1; i < segMan->_heap.size(); i++) { - if (segMan->_heap[i] - && segMan->_heap[i]->getType() == SEG_TYPE_SCRIPT) { - Script *script = (Script *)segMan->_heap[i]; + for (i = 1; i < heap.size(); i++) { + if (heap[i] && heap[i]->getType() == SEG_TYPE_SCRIPT) { + Script *script = (Script *)heap[i]; if (script->getLockers()) { // Explicitly loaded? wm.pushArray(script->listObjectReferences()); @@ -134,15 +135,15 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { wm._worklist.pop_back(); if (reg.segment != stack_seg) { // No need to repeat this one debugC(2, kDebugLevelGC, "[GC] Checking %04x:%04x", PRINT_REG(reg)); - if (reg.segment < segMan->_heap.size() && segMan->_heap[reg.segment]) { + if (reg.segment < heap.size() && heap[reg.segment]) { // Valid heap object? Find its outgoing references! - wm.pushArray(segMan->_heap[reg.segment]->listAllOutgoingReferences(reg)); + wm.pushArray(heap[reg.segment]->listAllOutgoingReferences(reg)); } } } // Normalise - normal_map = normalise_hashmap_ptrs(segMan, wm._map); + normal_map = normalizeAddresses(segMan, wm._map); return normal_map; } @@ -162,8 +163,9 @@ void run_gc(EngineState *s) { // Iterate over all segments, and check for each whether it // contains stuff that can be collected. - for (uint seg = 1; seg < segMan->_heap.size(); seg++) { - SegmentObj *mobj = segMan->_heap[seg]; + const Common::Array<SegmentObj *> &heap = segMan->getSegments(); + for (uint seg = 1; seg < heap.size(); seg++) { + SegmentObj *mobj = heap[seg]; if (mobj != NULL) { const SegmentType type = mobj->getType(); segnames[type] = SegmentObj::getSegmentTypeName(type); diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index a5cfc5013b..185a266203 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -553,7 +553,7 @@ static void *derefPtr(SegManager *segMan, reg_t pointer, int entries, bool wantR if (ret.isRaw != wantRaw) { warning("Dereferencing pointer %04x:%04x (type %d) which is %s, but expected %s", PRINT_REG(pointer), - segMan->_heap[pointer.segment]->getType(), + segMan->getSegmentType(pointer.segment), ret.isRaw ? "raw" : "not raw", wantRaw ? "raw" : "not raw"); } diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 5bb6f7e524..a7f5f8517f 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -438,8 +438,8 @@ public: */ reg_t findObjectByName(const Common::String &name, int index = -1); - uint32 classTableSize() { return _classTable.size(); } - Class getClass(int index) { return _classTable[index]; } + uint32 classTableSize() const { return _classTable.size(); } + Class getClass(int index) const { return _classTable[index]; } void setClassOffset(int index, reg_t offset) { _classTable[index].reg = offset; } void resizeClassTable(uint32 size) { _classTable.resize(size); } @@ -460,9 +460,6 @@ public: return &_sysStrings->_strings[idx]; } -public: // TODO: make private - Common::Array<SegmentObj *> _heap; - #ifdef ENABLE_SCI32 SciArray<reg_t> *allocateArray(reg_t *addr); SciArray<reg_t> *lookupArray(reg_t addr); @@ -473,8 +470,10 @@ public: // TODO: make private SegmentId getStringSegmentId() { return _stringSegId; } #endif + const Common::Array<SegmentObj *> &getSegments() const { return _heap; } + private: - // Only accessible from saveLoadWithSerializer() + Common::Array<SegmentObj *> _heap; Common::Array<Class> _classTable; /**< Table of all classes */ /** Map script ids to segment ids. */ Common::HashMap<int, SegmentId> _scriptSegMap; |