/* * Global symbol enumeration callback - fix up this symbol's compiler * metaclass identifier, if this is an object symbol. */ static void fix_obj_meta_cb(void *ctx0, CTcSymbol *sym) { /* cast our context and set up to access VM globals */ fix_obj_meta_cb_ctx *ctx = (fix_obj_meta_cb_ctx *)ctx0; VMGLOB_PTR(ctx->vmg); /* if this is an object symbol, fix up its metaclass identifier */ if (sym->get_type() == TC_SYM_OBJ) { CVmObject *obj; CVmMetaclass *meta; uint idx; tc_metaclass_t id; /* cast the symbol to an object symbol */ CTcSymObj *obj_sym = (CTcSymObj *)sym; /* get the object */ obj = vm_objp(vmg_ (vm_obj_id_t)obj_sym->get_obj_id()); /* look up its metaclass */ meta = obj->get_metaclass_reg(); /* get the registration table index */ idx = meta->get_reg_idx(); /* that's our index into the translation table - look it up */ id = ctx->xlat[idx]; /* store the compiler metaclass ID back in the symbol */ obj_sym->set_metaclass(id); } }
/* * restore */ void CVmObjFrameDesc::restore_from_file(VMG_ vm_obj_id_t self, class CVmFile *fp, class CVmObjFixup *fixups) { /* read the values */ vm_obj_id_t fref = fixups->get_new_id(vmg_ (vm_obj_id_t)fp->read_uint4()); int frame_idx = fp->read_int2(); uint ret_ofs = fp->read_uint2(); /* allocate the extension */ alloc_ext(vmg_ fref, frame_idx, ret_ofs); }