Beispiel #1
0
void
walkf(NODE *t, void (*f)(NODE *, void *), void *arg)
{
	int opty;


	opty = OPTYPE(t->n_op);

	if (opty != LTYPE)
		walkf( t->n_left, f, arg );
	if (opty == BITYPE)
		walkf( t->n_right, f, arg );
	(*f)(t, arg);
}
/*
 * Determine if a value is known to be constant at compile-time and
 * hence that PCC can perform constant-folding on expressions involving
 * that value.
 */
static NODE *
builtin_constant_p(const struct bitable *bt, NODE *a)
{
    void putjops(NODE *p, void *arg);
    NODE *f;
    int isconst;

    walkf(a, putjops, 0);
    for (f = a; f->n_op == COMOP; f = f->n_right)
        ;
    isconst = nncon(f);
    tfree(a);
    return bcon(isconst);
}
Beispiel #3
0
/*
 * Determine if a value is known to be constant at compile-time and
 * hence that PCC can perform constant-folding on expressions involving
 * that value.
 */
static NODE *
builtin_constant_p(NODE *f, NODE *a, TWORD rt)
{
	void putjops(NODE *p, void *arg);
	int isconst;

	tfree(f);
	walkf(a, putjops, 0);
	for (f = a; f->n_op == COMOP; f = f->n_right)
		;
	isconst = nncon(f);
	tfree(a);
	return bcon(isconst);
}
Beispiel #4
0
void
myoptim(struct interpass * ipole)
{
	struct interpass *ip;

#ifdef PCC_DEBUG
	if (x2debug)
		printf("myoptim:\n");
#endif

#if 0
	stacksize = 0;
#endif

	DLIST_FOREACH(ip, ipole, qelem) {
		if (ip->type != IP_NODE)
			continue;
		if (bigendian)
			walkf(ip->ip_node, offchg, 0);
#if 0
		walkf(ip->ip_node, calcstacksize, 0);
#endif
	}
}
Beispiel #5
0
/*
 * free the tree p
 */
void
tfree(NODE *p)
{
	if (p->n_op != FREE)
		walkf(p, (void (*)(NODE *, void *))nfree, 0);
}
Beispiel #6
0
void
mycanon(NODE * p)
{
	walkf(p, pconv2, 0);
}
Beispiel #7
0
void
p2tree(NODE *p)
{
    walkf(p, fcheck, 0);
}