static void gen_expr_struct_lea(expr *e) { ASSERT_NOT_DOT(); gen_expr(e->lhs); /* cast for void* arithmetic */ out_change_type(type_ptr_to(type_nav_btype(cc1_type_nav, type_void))); out_push_l(type_nav_btype(cc1_type_nav, type_intptr_t), struct_offset(e)); /* integral offset */ out_op(op_plus); if(fopt_mode & FOPT_VERBOSE_ASM) out_comment("struct member %s", e->bits.struct_mem.d->spel); { decl *d = e->bits.struct_mem.d; out_change_type(type_ptr_to(d->ref)); /* set if we're a bitfield - out_deref() and out_store() * i.e. read + write then handle this */ if(d->bits.var.field_width){ unsigned w = const_fold_val_i(d->bits.var.field_width); out_set_bitfield(d->bits.var.struct_offset_bitfield, w); out_comment("struct bitfield lea"); } } }
static void fold_const_expr_struct(expr *e, consty *k) { /* if lhs is NULL (or some pointer constant), * const fold to struct offset, (obv. if !dot, which is taken care of in fold) */ ASSERT_NOT_DOT(); const_fold(e->lhs, k); switch(k->type){ case CONST_NO: case CONST_NEED_ADDR: case CONST_STRK: k->type = CONST_NO; break; case CONST_ADDR: /* not constant unless addressed e.g. &a->b (unless array/func) */ k->type = CONST_ADDR_OR_NEED(e->bits.struct_mem.d); /* don't touch k->bits.addr info */ /* obviously we offset this */ k->offset += struct_offset(e); break; case CONST_NUM: k->type = CONST_NEED_ADDR; /* e.g. &((A *)0)->b */ /* convert the val to a memaddr */ /* read num.val before we clobber it */ k->bits.addr.bits.memaddr = k->bits.num.val.i + struct_offset(e); k->offset = 0; k->bits.addr.is_lbl = 0; break; } }
void gen_expr_str_struct(expr *e) { decl *mem = e->bits.struct_mem.d; idt_printf("struct/union member %s offset %d\n", mem->spel, struct_offset(e)); if(mem->bits.var.field_width) idt_printf("bitfield offset %u, width %u\n", mem->bits.var.struct_offset_bitfield, (unsigned)const_fold_val_i(mem->bits.var.field_width)); gen_str_indent++; print_expr(e->lhs); gen_str_indent--; }
offset64_t eggListView_reg_info(HEGGLISTVIEW hEggListView, HEGGLISTINF hInfo) { if(EGGLISTVIEW_IS_INVALID(hEggListView)) { return EGG_FALSE; } hEggListView->hInfo = realloc(hEggListView->hInfo, hInfo->aSz); memcpy(hEggListView->hInfo, hInfo, hInfo->aSz); hEggListView->hInfo->ownOff = ViewStream_write(hEggListView->hViewStream, hInfo, hInfo->aSz); ViewStream_update_nolock(hEggListView->hViewStream, &hEggListView->hInfo->ownOff, sizeof(hEggListView->hInfo->ownOff), hEggListView->hInfo->ownOff + struct_offset(EGGLISTINF, ownOff)); return EGG_TRUE; }