示例#1
0
static void const_expr_string(expr *e, consty *k)
{
	CONST_FOLD_LEAF(k);
	k->type = CONST_STRK;
	k->bits.str = &e->bits.strlit.lit_at;
	k->offset = 0;
}
示例#2
0
static void const_expr_compound_lit(expr *e, consty *k)
{
	decl *d = e->bits.complit.decl;
	expr *nonstd = NULL;

	if(decl_init_is_const(d->bits.var.init.dinit, NULL, &nonstd)){
		CONST_FOLD_LEAF(k);
		k->type = CONST_ADDR_OR_NEED(d);
		k->bits.addr.is_lbl = 1;
		k->bits.addr.bits.lbl = decl_asm_spel(d);
		k->offset = 0;
		k->nonstandard_const = nonstd;
	}else{
		k->type = CONST_NO;
	}
}
示例#3
0
static void const_expr_addr(expr *e, consty *k)
{
	if(e->bits.lbl.spel){
		int static_ctx = e->bits.lbl.static_ctx; /* global or static */

		/*k->sym_lbl = e->bits.lbl.spel;*/
		CONST_FOLD_LEAF(k);
		k->type = CONST_ADDR;
		k->offset = 0;
		k->bits.addr.is_lbl = 1;

		if(static_ctx){
			e->bits.lbl.label->mustgen_spel = out_label_code("goto");

			k->bits.addr.bits.lbl = e->bits.lbl.label->mustgen_spel;
		}else{
			k->bits.addr.bits.lbl = e->bits.lbl.label->spel;
		}

	}else{
		const_fold(e->lhs, k);

		switch(k->type){
			case CONST_NEED_ADDR:
				/* it's a->b, a symbol, etc */
				k->type = CONST_ADDR; /* addr is const but with no value */
				break;

			case CONST_STRK:
			case CONST_ADDR:
				/* int x[]; int *p = &x;
				 * already addr, just roll with it.
				 * lvalue/etc checks are done in fold
				 */
				break;

			default:
				k->type = CONST_NO;
				break;
		}
	}
}