Exemple #1
0
void
myp2tree(NODE *p)
{
	struct symtab *sp;
	int o = p->n_op;

	if (o != FCON) 
		return;

	sp = inlalloc(sizeof(struct symtab));
	sp->sclass = STATIC;
	sp->ssue = 0;
	sp->slevel = 1; /* fake numeric label */
	sp->soffset = getlab();
	sp->sflags = 0;
	sp->stype = p->n_type;
	sp->squal = (CON >> TSHIFT);

	defloc(sp);
	ninval(0, sp->ssue->suesize, p);

	p->n_op = NAME;
	p->n_lval = 0;
	p->n_sp = sp;

}
Exemple #2
0
static char *
mk3str(char *s1, char *s2, char *s3)
{
	int len = strlen(s1) + strlen(s2) + strlen(s3) + 1;
	char *sd;

	sd = inlalloc(len);
	strlcpy(sd, s1, len);
	strlcat(sd, s2, len);
	strlcat(sd, s3, len);
	return sd;
}
Exemple #3
0
/*
 * special handling before tree is written out.
 */
void
myp2tree(NODE *p)
{
	struct symtab *sp;
	union dimfun *df;
	union arglist *al;
	NODE *q;
	int i;

	switch (p->n_op) {
	case MOD:
	case DIV:
		if (p->n_type == LONG || p->n_type == ULONG) {
			/* Swap arguments for hardops() later */
			q = p->n_left;
			p->n_left = p->n_right;
			p->n_right = q;
		}
		break;

	case CALL:
	case STCALL:
		/*
		 * inform pass2 about varargs.
		 * store first variadic argument number in n_stalign
		 * in the CM node.
		 */
		if (p->n_right->n_op != CM)
			break; /* nothing to care about */
		df = p->n_left->n_df;
		if (df && (al = df->dfun)) {
			for (i = 0; i < 6; i++, al++) {
				if (al->type == TELLIPSIS || al->type == TNULL)
					break;
			}
			p->n_right->n_stalign = al->type == TELLIPSIS ? i : 0;
		} else
			p->n_right->n_stalign = 0;
		break;

	case FCON:
		/* Write float constants to memory */
		sp = inlalloc(sizeof(struct symtab));
		sp->sclass = STATIC;
		sp->ssue = 0;
		sp->slevel = 1; /* fake numeric label */
		sp->soffset = getlab();
		sp->sflags = 0;
		sp->stype = p->n_type;
		sp->squal = (CON >> TSHIFT);

		defloc(sp);
		ninval(0, sp->ssue->suesize, p);

		p->n_op = NAME;
		p->n_lval = 0;
		p->n_sp = sp;
		break;
	}

}