Store long-term pointers to object variables in a new ObjVarRef struct.

Storing them as reg_t* could cause the pointers to become invalid
when they pointed into CloneTable since CloneTable can be re-allocated.

svn-id: r41220
This commit is contained in:
Willem Jan Palenstijn 2009-06-06 11:38:20 +00:00
parent a5a0a95361
commit 60e02ad6a8
10 changed files with 91 additions and 58 deletions

View file

@ -32,16 +32,16 @@
namespace Sci {
reg_t read_selector(EngineState *s, reg_t object, Selector selector_id, const char *file, int line) {
reg_t *address;
ObjVarRef address;
if (lookup_selector(s, object, selector_id, &address, NULL) != kSelectorVariable)
return NULL_REG;
else
return *address;
return *address.getPointer(s);
}
void write_selector(EngineState *s, reg_t object, Selector selector_id, reg_t value, const char *fname, int line) {
reg_t *address;
ObjVarRef address;
if ((selector_id < 0) || (selector_id > (int)s->_kernel->getSelectorNamesSize())) {
warning("Attempt to write to invalid selector %d of"
@ -53,7 +53,7 @@ void write_selector(EngineState *s, reg_t object, Selector selector_id, reg_t va
warning("Selector '%s' of object at %04x:%04x could not be"
" written to (%s L%d)", s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line);
else
*address = value;
*address.getPointer(s) = value;
}
int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, int kfunct,