- Made obj_get and obj_get_name methods of SegManager (getObject and getObjectName, respectively)
- Renamed alloc_List -> allocateList, alloc_Node->allocateNode, alloc_hunk_entry->allocateHunkEntry, free_hunk_entry->freeHunkEntry, for consistency svn-id: r44039
This commit is contained in:
parent
5c2f872ba4
commit
90ae20c3ea
14 changed files with 108 additions and 112 deletions
|
@ -1401,11 +1401,11 @@ bool Console::segmentInfo(int nr) {
|
|||
for (uint i = 0; i < scr->_objects.size(); i++) {
|
||||
DebugPrintf(" ");
|
||||
// Object header
|
||||
Object *obj = obj_get(_vm->_gamestate->segMan, scr->_objects[i].pos);
|
||||
Object *obj = _vm->_gamestate->segMan->getObject(scr->_objects[i].pos);
|
||||
if (obj)
|
||||
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(scr->_objects[i].pos),
|
||||
obj_get_name(_vm->_gamestate->segMan,
|
||||
scr->_objects[i].pos), obj->_variables.size(), obj->methods_nr);
|
||||
_vm->_gamestate->segMan->getObjectName(scr->_objects[i].pos),
|
||||
obj->_variables.size(), obj->methods_nr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1446,12 +1446,12 @@ bool Console::segmentInfo(int nr) {
|
|||
reg_t objpos;
|
||||
objpos.offset = i;
|
||||
objpos.segment = nr;
|
||||
DebugPrintf(" [%04x] %s; copy of ", i, obj_get_name(_vm->_gamestate->segMan, objpos));
|
||||
DebugPrintf(" [%04x] %s; copy of ", i, _vm->_gamestate->segMan->getObjectName(objpos));
|
||||
// Object header
|
||||
Object *obj = obj_get(_vm->_gamestate->segMan, ct->_table[i].pos);
|
||||
Object *obj = _vm->_gamestate->segMan->getObject(ct->_table[i].pos);
|
||||
if (obj)
|
||||
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i].pos),
|
||||
obj_get_name(_vm->_gamestate->segMan, ct->_table[i].pos),
|
||||
_vm->_gamestate->segMan->getObjectName(ct->_table[i].pos),
|
||||
obj->_variables.size(), obj->methods_nr);
|
||||
}
|
||||
}
|
||||
|
@ -2054,7 +2054,7 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
|
|||
for (iter = _vm->_gamestate->_executionStack.begin();
|
||||
iter != _vm->_gamestate->_executionStack.end(); ++iter, ++i) {
|
||||
ExecStack &call = *iter;
|
||||
const char *objname = obj_get_name(_vm->_gamestate->segMan, call.sendp);
|
||||
const char *objname = _vm->_gamestate->segMan->getObjectName(call.sendp);
|
||||
int paramc, totalparamc;
|
||||
|
||||
switch (call.type) {
|
||||
|
@ -2196,7 +2196,7 @@ bool Console::cmdDissassemble(int argc, const char **argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Object *obj = obj_get(_vm->_gamestate->segMan, objAddr);
|
||||
Object *obj = _vm->_gamestate->segMan->getObject(objAddr);
|
||||
int selector_id = _vm->getKernel()->findSelector(argv[2]);
|
||||
reg_t addr;
|
||||
|
||||
|
@ -2304,7 +2304,7 @@ bool Console::cmdSend(int argc, const char **argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
o = obj_get(_vm->_gamestate->segMan, object);
|
||||
o = _vm->_gamestate->segMan->getObject(object);
|
||||
if (o == NULL) {
|
||||
DebugPrintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object));
|
||||
return true;
|
||||
|
@ -2909,7 +2909,7 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on
|
|||
}
|
||||
|
||||
if (valid) {
|
||||
const char *objname = obj_get_name(s->segMan, objpos);
|
||||
const char *objname = s->segMan->getObjectName(objpos);
|
||||
if (!strcmp(objname, str_objname)) {
|
||||
// Found a match!
|
||||
if ((index < 0) && (times_found > 0)) {
|
||||
|
@ -3051,7 +3051,7 @@ int Console::printNode(reg_t addr) {
|
|||
|
||||
int Console::printObject(reg_t pos) {
|
||||
EngineState *s = _vm->_gamestate; // for the several defines in this function
|
||||
Object *obj = obj_get(s->segMan, pos);
|
||||
Object *obj = s->segMan->getObject(pos);
|
||||
Object *var_container = obj;
|
||||
int i;
|
||||
SciVersion version = s->resMan->sciVersion(); // for the selector defines
|
||||
|
@ -3062,11 +3062,11 @@ int Console::printObject(reg_t pos) {
|
|||
}
|
||||
|
||||
// Object header
|
||||
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), obj_get_name(s->segMan, pos),
|
||||
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), s->segMan->getObjectName(pos),
|
||||
obj->_variables.size(), obj->methods_nr);
|
||||
|
||||
if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS))
|
||||
var_container = obj_get(s->segMan, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
var_container = s->segMan->getObject(obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
DebugPrintf(" -- member variables:\n");
|
||||
for (i = 0; (uint)i < obj->_variables.size(); i++) {
|
||||
printf(" ");
|
||||
|
@ -3078,9 +3078,9 @@ int Console::printObject(reg_t pos) {
|
|||
reg_t val = obj->_variables[i];
|
||||
DebugPrintf("%04x:%04x", PRINT_REG(val));
|
||||
|
||||
Object *ref = obj_get(s->segMan, val);
|
||||
Object *ref = s->segMan->getObject(val);
|
||||
if (ref)
|
||||
DebugPrintf(" (%s)", obj_get_name(s->segMan, val));
|
||||
DebugPrintf(" (%s)", s->segMan->getObjectName(val));
|
||||
|
||||
DebugPrintf("\n");
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
|
|||
return 0;
|
||||
}
|
||||
reg_t game_obj = script_lookup_export(segMan, 0, 0);
|
||||
const char *gameName = obj_get_name(segMan, game_obj);
|
||||
const char *gameName = segMan->getObjectName(game_obj);
|
||||
debug(2, "Detected ID: \"%s\" at %04x:%04x", gameName, PRINT_REG(game_obj));
|
||||
s_fallbackDesc.desc.gameid = convertSierraGameId(gameName, &s_fallbackDesc.desc.flags);
|
||||
delete segMan;
|
||||
|
|
|
@ -462,7 +462,7 @@ int game_init(EngineState *s) {
|
|||
// The first entry in the export table of script 0 points to the game object
|
||||
s->game_obj = script_lookup_export(s->segMan, 0, 0);
|
||||
uint32 gameFlags = 0; // unused
|
||||
s->_gameName = convertSierraGameId(obj_get_name(s->segMan, s->game_obj), &gameFlags);
|
||||
s->_gameName = convertSierraGameId(s->segMan->getObjectName(s->game_obj), &gameFlags);
|
||||
|
||||
debug(2, " \"%s\" at %04x:%04x", s->_gameName.c_str(), PRINT_REG(s->game_obj));
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ void Kernel::loadSelectorNames() {
|
|||
reg_t kalloc(SegManager *segMan, const char *type, int space) {
|
||||
reg_t reg;
|
||||
|
||||
segMan->alloc_hunk_entry(type, space, ®);
|
||||
segMan->allocateHunkEntry(type, space, ®);
|
||||
debugC(2, kDebugLevelMemory, "Allocated %d at hunk %04x:%04x (%s)\n", space, PRINT_REG(reg), type);
|
||||
|
||||
return reg;
|
||||
|
@ -479,7 +479,7 @@ byte *kmem(SegManager *segMan, reg_t handle) {
|
|||
|
||||
// Frees the specified handle. Returns 0 on success, 1 otherwise.
|
||||
int kfree(SegManager *segMan, reg_t handle) {
|
||||
segMan->free_hunk_entry(handle);
|
||||
segMan->freeHunkEntry(handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ int sane_listp(EngineState *s, reg_t addr) {
|
|||
reg_t kNewList(EngineState *s, int, int argc, reg_t *argv) {
|
||||
reg_t listbase;
|
||||
List *l;
|
||||
l = s->segMan->alloc_List(&listbase);
|
||||
l = s->segMan->allocateList(&listbase);
|
||||
l->first = l->last = NULL_REG;
|
||||
debugC(2, kDebugLevelNodes, "New listbase at %04x:%04x\n", PRINT_REG(listbase));
|
||||
|
||||
|
@ -171,7 +171,7 @@ reg_t kDisposeList(EngineState *s, int, int argc, reg_t *argv) {
|
|||
|
||||
reg_t _k_new_node(EngineState *s, reg_t value, reg_t key) {
|
||||
reg_t nodebase;
|
||||
Node *n = s->segMan->alloc_Node(&nodebase);
|
||||
Node *n = s->segMan->allocateNode(&nodebase);
|
||||
|
||||
if (!n) {
|
||||
error("[Kernel] Out of memory while creating a node");
|
||||
|
@ -445,7 +445,7 @@ reg_t kSort(EngineState *s, int, int argc, reg_t *argv) {
|
|||
return s->r_acc;
|
||||
|
||||
if (output_data.isNull()) {
|
||||
list = s->segMan->alloc_List(&output_data);
|
||||
list = s->segMan->allocateList(&output_data);
|
||||
list->first = list->last = NULL_REG;
|
||||
PUT_SEL32(dest, elements, output_data);
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ static void bresenham_autodetect(EngineState *s) {
|
|||
reg_t motion_class;
|
||||
|
||||
if (!parse_reg_t(s, "?Motion", &motion_class)) {
|
||||
Object *obj = obj_get(s->segMan, motion_class);
|
||||
Object *obj = s->segMan->getObject(motion_class);
|
||||
reg_t fptr;
|
||||
byte *buf;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
|
|||
}
|
||||
|
||||
bool is_object(SegManager *segMan, reg_t object) {
|
||||
return obj_get(segMan, object) != NULL;
|
||||
return segMan->getObject(object) != NULL;
|
||||
}
|
||||
|
||||
// Loads arbitrary resources of type 'restype' with resource numbers 'resnrs'
|
||||
|
@ -184,7 +184,7 @@ reg_t kResCheck(EngineState *s, int, int argc, reg_t *argv) {
|
|||
|
||||
reg_t kClone(EngineState *s, int, int argc, reg_t *argv) {
|
||||
reg_t parent_addr = argv[0];
|
||||
Object *parent_obj = obj_get(s->segMan, parent_addr);
|
||||
Object *parent_obj = s->segMan->getObject(parent_addr);
|
||||
reg_t clone_addr;
|
||||
Clone *clone_obj; // same as Object*
|
||||
|
||||
|
@ -223,7 +223,7 @@ extern void _k_view_list_mark_free(EngineState *s, reg_t off);
|
|||
reg_t kDisposeClone(EngineState *s, int, int argc, reg_t *argv) {
|
||||
SegManager *segMan = s->segMan;
|
||||
reg_t victim_addr = argv[0];
|
||||
Clone *victim_obj = obj_get(s->segMan, victim_addr);
|
||||
Clone *victim_obj = s->segMan->getObject(victim_addr);
|
||||
uint16 underBits;
|
||||
|
||||
if (!victim_obj) {
|
||||
|
@ -323,7 +323,7 @@ reg_t kDisposeScript(EngineState *s, int, int argc, reg_t *argv) {
|
|||
}
|
||||
|
||||
int is_heap_object(EngineState *s, reg_t pos) {
|
||||
Object *obj = obj_get(s->segMan, pos);
|
||||
Object *obj = s->segMan->getObject(pos);
|
||||
return (obj != NULL && (!(obj->flags & OBJECT_FLAG_FREED)) && (!s->segMan->scriptIsMarkedAsDeleted(pos.segment)));
|
||||
}
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) {
|
|||
int funct_area = READ_LE_UINT16( data + SCRIPT_FUNCTAREAPTR_OFFSET );
|
||||
Object *base_obj;
|
||||
|
||||
base_obj = obj_get(s->segMan, scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
base_obj = s->segMan->getObject(scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
|
||||
if (!base_obj) {
|
||||
warning("Object without a base class: Script %d, index %d (reg address %04x:%04x",
|
||||
|
@ -776,7 +776,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
|||
|
||||
retval->successor = NULL;
|
||||
retval->pic_priority_table = (int *)gfxop_get_pic_metainfo(retval->gfx_state);
|
||||
retval->_gameName = obj_get_name(retval->segMan, retval->game_obj);
|
||||
retval->_gameName = retval->segMan->getObjectName(retval->game_obj);
|
||||
|
||||
retval->_sound._it = NULL;
|
||||
retval->_sound._flags = s->_sound._flags;
|
||||
|
|
|
@ -66,7 +66,7 @@ extern const char *selector_name(EngineState *s, int selector);
|
|||
ScriptState scriptState;
|
||||
|
||||
int propertyOffsetToId(SegManager *segMan, int prop_ofs, reg_t objp) {
|
||||
Object *obj = obj_get(segMan, objp);
|
||||
Object *obj = segMan->getObject(objp);
|
||||
byte *selectoroffset;
|
||||
int selectors;
|
||||
SciVersion version = segMan->sciVersion(); // for the selector defines
|
||||
|
@ -82,7 +82,7 @@ int propertyOffsetToId(SegManager *segMan, int prop_ofs, reg_t objp) {
|
|||
selectoroffset = ((byte *)(obj->base_obj)) + SCRIPT_SELECTOR_OFFSET + selectors * 2;
|
||||
else {
|
||||
if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)) {
|
||||
obj = obj_get(segMan, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
obj = segMan->getObject(obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
selectoroffset = (byte *)obj->base_vars;
|
||||
} else
|
||||
selectoroffset = (byte *)obj->base_vars;
|
||||
|
@ -301,7 +301,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
|
|||
|
||||
selector = sb[- stackframe].offset;
|
||||
|
||||
name = obj_get_name(s->segMan, called_obj_addr);
|
||||
name = s->segMan->getObjectName(called_obj_addr);
|
||||
|
||||
if (!name)
|
||||
name = "<invalid>";
|
||||
|
|
|
@ -270,6 +270,45 @@ MemObjectType SegManager::getMemObjectType(SegmentId seg) {
|
|||
return _heap[seg]->getType();
|
||||
}
|
||||
|
||||
Object *SegManager::getObject(reg_t pos) {
|
||||
MemObject *mobj = getMemObject(pos.segment);
|
||||
SciVersion version = _resMan->sciVersion();
|
||||
Object *obj = NULL;
|
||||
|
||||
if (mobj != NULL) {
|
||||
if (mobj->getType() == MEM_OBJ_CLONES) {
|
||||
CloneTable *ct = (CloneTable *)mobj;
|
||||
if (ct->isValidEntry(pos.offset))
|
||||
obj = &(ct->_table[pos.offset]);
|
||||
} else if (mobj->getType() == MEM_OBJ_SCRIPT) {
|
||||
Script *scr = (Script *)mobj;
|
||||
if (pos.offset <= scr->buf_size && pos.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET
|
||||
&& RAW_IS_OBJECT(scr->buf + pos.offset)) {
|
||||
obj = scr->getObject(pos.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
const char *SegManager::getObjectName(reg_t pos) {
|
||||
Object *obj = getObject(pos);
|
||||
SciVersion version = _resMan->sciVersion();
|
||||
if (!obj)
|
||||
return "<no such object>";
|
||||
|
||||
reg_t nameReg = obj->_variables[SCRIPT_NAME_SELECTOR];
|
||||
if (nameReg.isNull())
|
||||
return "<no name>";
|
||||
|
||||
const char *name = (const char*)dereference(obj->_variables[SCRIPT_NAME_SELECTOR], NULL);
|
||||
if (!name)
|
||||
return "<invalid name>";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// validate the seg
|
||||
// return:
|
||||
// false - invalid seg
|
||||
|
@ -680,7 +719,7 @@ void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) {
|
|||
#if 0
|
||||
if (obj->_variables[5].offset != 0xffff) {
|
||||
obj->_variables[5] = INST_LOOKUP_CLASS(obj->_variables[5].offset);
|
||||
base_obj = obj_get(s->segMan, obj->_variables[5]);
|
||||
base_obj = s->segMan->getObject(obj->_variables[5]);
|
||||
obj->variable_names_nr = base_obj->variables_nr;
|
||||
obj->base_obj = base_obj->base_obj;
|
||||
}
|
||||
|
@ -751,7 +790,7 @@ uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
void SegManager::free_hunk_entry(reg_t addr) {
|
||||
void SegManager::freeHunkEntry(reg_t addr) {
|
||||
HunkTable *ht = (HunkTable *)GET_SEGMENT(*this, addr.segment, MEM_OBJ_HUNK);
|
||||
|
||||
if (!ht) {
|
||||
|
@ -762,7 +801,7 @@ void SegManager::free_hunk_entry(reg_t addr) {
|
|||
ht->freeEntry(addr.offset);
|
||||
}
|
||||
|
||||
Hunk *SegManager::alloc_hunk_entry(const char *hunk_type, int size, reg_t *reg) {
|
||||
Hunk *SegManager::allocateHunkEntry(const char *hunk_type, int size, reg_t *reg) {
|
||||
Hunk *h = alloc_Hunk(reg);
|
||||
|
||||
if (!h)
|
||||
|
@ -817,7 +856,7 @@ void SegManager::reconstructClones() {
|
|||
continue;
|
||||
|
||||
CloneTable::Entry &seeker = ct->_table[j];
|
||||
base_obj = obj_get(this, seeker._variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
base_obj = getObject(seeker._variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
if (!base_obj) {
|
||||
warning("Clone entry without a base class: %d", j);
|
||||
seeker.base = NULL;
|
||||
|
@ -836,7 +875,7 @@ void SegManager::reconstructClones() {
|
|||
} // end for
|
||||
}
|
||||
|
||||
List *SegManager::alloc_List(reg_t *addr) {
|
||||
List *SegManager::allocateList(reg_t *addr) {
|
||||
ListTable *table;
|
||||
int offset;
|
||||
|
||||
|
@ -850,7 +889,7 @@ List *SegManager::alloc_List(reg_t *addr) {
|
|||
return &(table->_table[offset]);
|
||||
}
|
||||
|
||||
Node *SegManager::alloc_Node(reg_t *addr) {
|
||||
Node *SegManager::allocateNode(reg_t *addr) {
|
||||
NodeTable *table;
|
||||
int offset;
|
||||
|
||||
|
|
|
@ -256,14 +256,14 @@ public:
|
|||
* @param[in] addr The offset of the freshly allocated list
|
||||
* @return Reference to the memory allocated for the list
|
||||
*/
|
||||
List *alloc_List(reg_t *addr);
|
||||
List *allocateList(reg_t *addr);
|
||||
|
||||
/**
|
||||
* Allocate a fresh node
|
||||
* @param[in] addr The offset of the freshly allocated node
|
||||
* @return Reference to the memory allocated for the node
|
||||
*/
|
||||
Node *alloc_Node(reg_t *addr);
|
||||
Node *allocateNode(reg_t *addr);
|
||||
|
||||
|
||||
// 8. Hunk Memory
|
||||
|
@ -277,13 +277,13 @@ public:
|
|||
* @return Reference to the memory allocated for the hunk
|
||||
* piece
|
||||
*/
|
||||
Hunk *alloc_hunk_entry(const char *hunk_type, int size, reg_t *addr);
|
||||
Hunk *allocateHunkEntry(const char *hunk_type, int size, reg_t *addr);
|
||||
|
||||
/**
|
||||
* Deallocates a hunk entry
|
||||
* @param[in] addr Offset of the hunk entry to delete
|
||||
*/
|
||||
void free_hunk_entry(reg_t addr);
|
||||
void freeHunkEntry(reg_t addr);
|
||||
|
||||
|
||||
// 9. Dynamic Memory
|
||||
|
@ -345,6 +345,22 @@ public:
|
|||
// TODO: document this
|
||||
MemObjectType getMemObjectType(SegmentId seg);
|
||||
|
||||
/**
|
||||
* Retrieves an object from the specified location
|
||||
* @param[in] offset Location (segment, offset) of the object
|
||||
* @return The object in question, or NULL if there is none
|
||||
*/
|
||||
Object *getObject(reg_t pos);
|
||||
|
||||
/**
|
||||
* Determines the name of an object
|
||||
* @param[in] pos Location (segment, offset) of the object
|
||||
* @return A name for that object, or a string describing an error
|
||||
* that occured while looking it up. The string is stored
|
||||
* in a static buffer and need not be freed (neither may
|
||||
* it be modified).
|
||||
*/
|
||||
const char *getObjectName(reg_t pos);
|
||||
|
||||
void heapRelocate(reg_t block);
|
||||
void scriptRelocateExportsSci11(SegmentId seg);
|
||||
|
|
|
@ -246,7 +246,7 @@ Common::String EngineState::strSplit(const char *str, const char *sep) {
|
|||
int EngineState::methodChecksum(reg_t objAddress, Selector sel, int offset, uint size) const {
|
||||
reg_t fptr;
|
||||
|
||||
Object *obj = obj_get(segMan, objAddress);
|
||||
Object *obj = segMan->getObject(objAddress);
|
||||
SelectorType selType = lookup_selector(segMan, objAddress, sel, NULL, &fptr);
|
||||
|
||||
if (!obj || (selType != kSelectorMethod))
|
||||
|
@ -350,7 +350,7 @@ SciVersion EngineState::detectLofsType() {
|
|||
Object *obj = NULL;
|
||||
|
||||
if (!parse_reg_t(this, "?Game", &gameClass))
|
||||
obj = obj_get(segMan, gameClass);
|
||||
obj = segMan->getObject(gameClass);
|
||||
|
||||
bool couldBeAbs = true;
|
||||
bool couldBeRel = true;
|
||||
|
|
|
@ -285,7 +285,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
|
|||
Breakpoint *bp;
|
||||
char method_name [256];
|
||||
|
||||
sprintf(method_name, "%s::%s", obj_get_name(s->segMan, send_obj), ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector).c_str());
|
||||
sprintf(method_name, "%s::%s", s->segMan->getObjectName(send_obj), ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector).c_str());
|
||||
|
||||
bp = s->bp_list;
|
||||
while (bp) {
|
||||
|
@ -520,7 +520,7 @@ void run_vm(EngineState *s, int restoring) {
|
|||
// Current execution data:
|
||||
scriptState.xs = &(s->_executionStack.back());
|
||||
ExecStack *xs_new = NULL;
|
||||
Object *obj = obj_get(s->segMan, scriptState.xs->objp);
|
||||
Object *obj = s->segMan->getObject(scriptState.xs->objp);
|
||||
Script *local_script = s->segMan->getScriptIfLoaded(scriptState.xs->local_segment);
|
||||
int old_execution_stack_base = s->execution_stack_base;
|
||||
// Used to detect the stack bottom, for "physical" returns
|
||||
|
@ -580,7 +580,7 @@ void run_vm(EngineState *s, int restoring) {
|
|||
scr = NULL;
|
||||
obj = NULL;
|
||||
} else {
|
||||
obj = obj_get(s->segMan, scriptState.xs->objp);
|
||||
obj = s->segMan->getObject(scriptState.xs->objp);
|
||||
code_buf = scr->buf;
|
||||
#ifndef DISABLE_VALIDATIONS
|
||||
code_buf_size = scr->buf_size;
|
||||
|
@ -1411,7 +1411,7 @@ static int _obj_locate_varselector(SegManager *segMan, Object *obj, Selector slc
|
|||
buf = obj->base_obj + selector_name_offset;
|
||||
} else {
|
||||
if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS))
|
||||
obj = obj_get(segMan, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
obj = segMan->getObject(obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
|
||||
buf = (byte *)obj->base_vars;
|
||||
varnum = obj->_variables[1].toUint16();
|
||||
|
@ -1455,7 +1455,7 @@ static SelectorType _lookup_selector_function(SegManager *segMan, int seg_id, Ob
|
|||
return kSelectorMethod;
|
||||
} else {
|
||||
seg_id = obj->_variables[SCRIPT_SUPERCLASS_SELECTOR].segment;
|
||||
obj = obj_get(segMan, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
obj = segMan->getObject(obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1463,7 +1463,7 @@ static SelectorType _lookup_selector_function(SegManager *segMan, int seg_id, Ob
|
|||
}
|
||||
|
||||
SelectorType lookup_selector(SegManager *segMan, reg_t obj_location, Selector selector_id, ObjVarRef *varp, reg_t *fptr) {
|
||||
Object *obj = obj_get(segMan, obj_location);
|
||||
Object *obj = segMan->getObject(obj_location);
|
||||
Object *species;
|
||||
int index;
|
||||
SciVersion version = segMan->sciVersion(); // for the selector defines
|
||||
|
@ -1482,7 +1482,7 @@ SelectorType lookup_selector(SegManager *segMan, reg_t obj_location, Selector se
|
|||
if (IS_CLASS(obj))
|
||||
species = obj;
|
||||
else
|
||||
species = obj_get(segMan, obj->_variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
species = segMan->getObject(obj->_variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
|
||||
|
||||
if (!obj) {
|
||||
|
@ -1703,7 +1703,7 @@ int script_instantiate_sci0(ResourceManager *resMan, SegManager *segMan, int scr
|
|||
// Instantiate the superclass, if neccessary
|
||||
obj->_variables[SCRIPT_SPECIES_SELECTOR] = INST_LOOKUP_CLASS(obj->_variables[SCRIPT_SPECIES_SELECTOR].offset);
|
||||
|
||||
base_obj = obj_get(segMan, obj->_variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
base_obj = segMan->getObject(obj->_variables[SCRIPT_SPECIES_SELECTOR]);
|
||||
obj->variable_names_nr = base_obj->_variables.size();
|
||||
obj->base_obj = base_obj->base_obj;
|
||||
// Copy base from species class, as we need its selector IDs
|
||||
|
@ -1932,46 +1932,6 @@ int game_run(EngineState **_s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Object *obj_get(SegManager *segMan, reg_t offset) {
|
||||
MemObject *mobj = segMan->getMemObject(offset.segment);
|
||||
SciVersion version = segMan->sciVersion();
|
||||
Object *obj = NULL;
|
||||
|
||||
if (mobj != NULL) {
|
||||
if (mobj->getType() == MEM_OBJ_CLONES) {
|
||||
CloneTable *ct = (CloneTable *)mobj;
|
||||
if (ct->isValidEntry(offset.offset))
|
||||
obj = &(ct->_table[offset.offset]);
|
||||
} else if (mobj->getType() == MEM_OBJ_SCRIPT) {
|
||||
Script *scr = (Script *)mobj;
|
||||
if (offset.offset <= scr->buf_size && offset.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET
|
||||
&& RAW_IS_OBJECT(scr->buf + offset.offset)) {
|
||||
obj = scr->getObject(offset.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
const char *obj_get_name(SegManager *segMan, reg_t pos) {
|
||||
Object *obj = obj_get(segMan, pos);
|
||||
SciVersion version = segMan->sciVersion();
|
||||
if (!obj)
|
||||
return "<no such object>";
|
||||
|
||||
reg_t nameReg = obj->_variables[SCRIPT_NAME_SELECTOR];
|
||||
if (nameReg.isNull())
|
||||
return "<no name>";
|
||||
|
||||
const char *name = (const char*)segMan->dereference(obj->_variables[SCRIPT_NAME_SELECTOR], NULL);
|
||||
if (!name)
|
||||
return "<invalid name>";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
void quit_vm() {
|
||||
script_abort_flag = 1; // Terminate VM
|
||||
scriptState.seeking = kDebugSeekNothing;
|
||||
|
@ -1988,7 +1948,7 @@ void shrink_execution_stack(EngineState *s, uint size) {
|
|||
}
|
||||
|
||||
reg_t* ObjVarRef::getPointer(SegManager *segMan) const {
|
||||
Object *o = obj_get(segMan, obj);
|
||||
Object *o = segMan->getObject(obj);
|
||||
if (!o) return 0;
|
||||
return &(o->_variables[varindex]);
|
||||
}
|
||||
|
|
|
@ -592,25 +592,6 @@ byte *kmem(SegManager *segMan, reg_t handle);
|
|||
*/
|
||||
int kfree(SegManager *segMan, reg_t handle);
|
||||
|
||||
/**
|
||||
* Determines the name of an object
|
||||
* @param[in] s Pointer to the EngineState to operate on
|
||||
* @param[in] pos Location of the object whose name we want to inspect
|
||||
* @return A name for that object, or a string describing an error
|
||||
* that occured while looking it up. The string is stored
|
||||
* in a static buffer and need not be freed (neither may
|
||||
* it be modified).
|
||||
*/
|
||||
const char *obj_get_name(SegManager *segMan, reg_t pos);
|
||||
|
||||
/**
|
||||
* Retrieves an object from the specified location
|
||||
* @param[in] s Pointer to the EngineState to operate on
|
||||
* @param[in] offset The object's offset
|
||||
* @return The object in question, or NULL if there is none
|
||||
*/
|
||||
Object *obj_get(SegManager *segMan, reg_t offset);
|
||||
|
||||
/**
|
||||
* Shrink execution stack to size.
|
||||
* Contains an assert it is not already smaller.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue