static int vb_lua_match(lua_State *lua) { struct mini_lua *lexicon = luaL_checkudata(lua, 1, MN_MT); struct vb_query query = VB_QUERY_INIT; query.query = luaL_checklstring(lua, 2, &query.len); if (!lua_isnoneornil(lua, 3)) { luaL_checktype(lua, 3, LUA_TTABLE); map_params(lua, 3, &query); } lua_createtable(lua, query.page_size, 3); struct vb_lua_match_ctx ctx = {.lua = lua}; int ret = vb_match(lexicon->fsa, &query, vb_lua_match_handle, &ctx); if (ret) return luaL_error(lua, "%s", vb_strerror(ret)); lua_pushboolean(lua, query.pagination.last_page); lua_setfield(lua, -2, "last_page"); lua_pushnumber(lua, query.pagination.last_pos); lua_setfield(lua, -2, "last_pos"); lua_pushnumber(lua, query.pagination.last_weight); lua_setfield(lua, -2, "last_weight"); return 1; }
static int gnuv2_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr, int embedded_offset, CORE_ADDR address, const struct value *val) { struct type *basetype = TYPE_BASECLASS (type, index); if (BASETYPE_VIA_VIRTUAL (type, index)) { /* Must hunt for the pointer to this virtual baseclass. */ int i, len = TYPE_NFIELDS (type); int n_baseclasses = TYPE_N_BASECLASSES (type); /* First look for the virtual baseclass pointer in the fields. */ for (i = n_baseclasses; i < len; i++) { if (vb_match (type, i, basetype)) { struct type *field_type; int field_offset; int field_length; CORE_ADDR addr; field_type = check_typedef (TYPE_FIELD_TYPE (type, i)); field_offset = TYPE_FIELD_BITPOS (type, i) / 8; field_length = TYPE_LENGTH (field_type); if (!value_bytes_available (val, embedded_offset + field_offset, field_length)) throw_error (NOT_AVAILABLE_ERROR, _("Virtual baseclass pointer is not available")); addr = unpack_pointer (field_type, valaddr + embedded_offset + field_offset); return addr - (LONGEST) address + embedded_offset; } } /* Not in the fields, so try looking through the baseclasses. */ for (i = index + 1; i < n_baseclasses; i++) { /* Don't go through baseclass_offset, as that wraps exceptions, thus, inner exceptions would be wrapped more than once. */ int boffset = gnuv2_baseclass_offset (type, i, valaddr, embedded_offset, address, val); if (boffset) return boffset; } error (_("Baseclass offset not found")); } /* Baseclass is easily computed. */ return TYPE_BASECLASS_BITPOS (type, index) / 8; }
int gnuv2_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr, CORE_ADDR address) { struct type *basetype = TYPE_BASECLASS (type, index); if (BASETYPE_VIA_VIRTUAL (type, index)) { /* Must hunt for the pointer to this virtual baseclass. */ int i, len = TYPE_NFIELDS (type); int n_baseclasses = TYPE_N_BASECLASSES (type); /* First look for the virtual baseclass pointer in the fields. */ for (i = n_baseclasses; i < len; i++) { if (vb_match (type, i, basetype)) { CORE_ADDR addr = unpack_pointer (TYPE_FIELD_TYPE (type, i), valaddr + (TYPE_FIELD_BITPOS (type, i) / 8)); return addr - (LONGEST) address; } } /* Not in the fields, so try looking through the baseclasses. */ for (i = index + 1; i < n_baseclasses; i++) { int boffset = baseclass_offset (type, i, valaddr, address); if (boffset) return boffset; } /* Not found. */ return -1; } /* Baseclass is easily computed. */ return TYPE_BASECLASS_BITPOS (type, index) / 8; }