当前位置: 首页>>代码示例>>C++>>正文


C++ buildtree函数代码示例

本文整理汇总了C++中buildtree函数的典型用法代码示例。如果您正苦于以下问题:C++ buildtree函数的具体用法?C++ buildtree怎么用?C++ buildtree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了buildtree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: efcode

void
efcode(void)
{
	TWORD t;
	NODE *p, *q;

	/* code for the end of a function */
	if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
		return;

	t = PTR+BTYPE(cftnsp->stype);
	/* Create struct assignment */
	q = tempnode(strtemp, t, 0, cftnsp->sap);
	q = buildtree(UMUL, q, NIL);
	p = block(REG, NIL, NIL, t, 0, cftnsp->sap);
	regno(p) = R0;
	p = buildtree(UMUL, p, NIL);
	p = buildtree(ASSIGN, q, p);
	ecomp(p);

	/* put hidden arg in r0 on return */
	q = tempnode(strtemp, INT, 0, 0);
	p = block(REG, NIL, NIL, INT, 0, 0);
	regno(p) = R0;
        ecomp(buildtree(ASSIGN, p, q));
}
开发者ID:Sciumo,项目名称:pcc,代码行数:26,代码来源:code.c

示例2: bfcode

void
bfcode(struct symtab **sp, int cnt)
{
	int i, off;
	NODE *p, *q;
	struct symtab *sym;

	/* Process the first six arguments. */
	for (i=0; i < cnt && i < 6; i++) {
		sym = sp[i];
		q = block(REG, NIL, NIL, sym->stype, sym->sdf, sym->sap);
		q->n_rval = RETREG_PRE(sym->stype) + i;
		p = tempnode(0, sym->stype, sym->sdf, sym->sap);
		sym->soffset = regno(p);
		sym->sflags |= STNODE;
		p = buildtree(ASSIGN, p, q);
		ecomp(p);
	}

	/* Process the remaining arguments. */
	for (off = V9RESERVE; i < cnt; i++) {
		sym = sp[i];
		p = tempnode(0, sym->stype, sym->sdf, sym->sap);
		off = ALIGN(off, (tlen(p) - 1));
		sym->soffset = off * SZCHAR;
		off += tlen(p);
		p = buildtree(ASSIGN, p, nametree(sym));
		sym->soffset = regno(p->n_left);
		sym->sflags |= STNODE;
		ecomp(p);
	}
}
开发者ID:MoochMcGee,项目名称:pcc-optimized,代码行数:32,代码来源:code.c

示例3: bfcode

void
bfcode(struct symtab **sp, int n)
{
	struct symtab *sp2;
	NODE *p, *q;
	int i;

	if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
		/* Move return address into temporary */
		p = tempnode(0, INT, 0, 0);
		strtemp = regno(p);
		q = block(REG, 0, 0, INT, 0, 0);
		regno(q) = R1;
		ecomp(buildtree(ASSIGN, p, q));
	}
	if (xtemps == 0)
		return;

	/* put arguments in temporaries */
	for (i = 0; i < n; i++) {
		if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY ||
		    cisreg(sp[i]->stype) == 0)
			continue;
		if (cqual(sp[i]->stype, sp[i]->squal) & VOL)
			continue;
		sp2 = sp[i];
		p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->sap);
		p = buildtree(ASSIGN, p, nametree(sp2));
		sp[i]->soffset = regno(p->n_left);
		sp[i]->sflags |= STNODE;
		ecomp(p);
	}

}
开发者ID:Sciumo,项目名称:pcc,代码行数:34,代码来源:code.c

示例4: spalloc

/*
 * Allocate off bits on the stack.  p is a tree that when evaluated
 * is the multiply count for off, t is a storeable node where to write
 * the allocated address.
 */
void
spalloc(NODE *t, NODE *p, OFFSZ off)
{
	NODE *sp;

	p = buildtree(MUL, p, bcon(off/SZCHAR));
	p = buildtree(PLUS, p, bcon(30));
	p = buildtree(AND, p, xbcon(-16, NULL, UNSIGNED));
	p = cast(p, UNSIGNED, 0);

	/* sub the size from sp */
	sp = block(REG, NIL, NIL, UNSIGNED+PTR, 0, 0);
	slval(sp, 0);
	sp->n_rval = STKREG;
	p = (buildtree(MINUSEQ, sp, p));
	ecomp(p);

	/* save the address of sp */
	sp = block(REG, NIL, NIL, PTR+UNSIGNED, t->n_df, t->n_ap);
	slval(sp, 0);
	sp->n_rval = STKREG;
	t->n_type = sp->n_type;
	p = (buildtree(ASSIGN, t, sp)); /* Emit! */
	ecomp(p);

}
开发者ID:arnoldrobbins,项目名称:pcc-revived,代码行数:31,代码来源:local.c

示例5: picext

/*
 * Create a reference for an extern variable.
 */
static NODE *
picext(NODE *p)
{
	NODE *q, *r;
	struct symtab *sp;
	char *name;

	q = tempnode(gotnr, PTR|VOID, 0, 0);
	name = getexname(p->n_sp);

#ifdef notdef
	struct attr *ga;
	if ((ga = attr_find(p->n_sp->sap, GCC_ATYP_VISIBILITY)) &&
	    strcmp(ga->sarg(0), "hidden") == 0) {
		/* For hidden vars use GOTOFF */
		sp = picsymtab("", name, "@GOTOFF");
		r = xbcon(0, sp, INT);
		q = buildtree(PLUS, q, r);
		q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_ap);
		q->n_sp = p->n_sp; /* for init */
		nfree(p);
		return q;
	}
#endif

	sp = picsymtab("", name, "@GOT");
	r = xbcon(0, sp, INT);
	q = buildtree(PLUS, q, r);
	q = block(UMUL, q, 0, PTR|VOID, 0, 0);
	q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_ap);
	q->n_sp = p->n_sp; /* for init */
	nfree(p);
	return q;
}
开发者ID:arnoldrobbins,项目名称:pcc-revived,代码行数:37,代码来源:local.c

示例6: buildtree

void buildtree(int s, int e,int & maximal, int & minimal) {
    if (e - s + 1 <= 0) {
        maximal = minimal = -1;
        return;
    }
    if (e - s + 1 == 1) {
        maximal = minimal = input[e];
        return;
    }
    if (e - s + 1 == 2) {
        maximal = input[s] > input[e] ? input[s] : input[e];
        minimal = input[s] > input[e] ? input[e] : input[s];
        return;
    }
    int temp = (s + e) / 2;
    arr[temp].max = input[temp];
    arr[temp].min = input[temp];
    int i, j;
    buildtree(s, temp - 1, i, j);
    if (i >= 0 && j >= 0) {
        if (i > arr[temp].max) arr[temp].max = i;
        if (j < arr[temp].min) arr[temp].min = j;
    }
    buildtree(temp + 1, e, i, j);
    if (i >= 0 && j >= 0) {
        if (i > arr[temp].max) arr[temp].max = i;
        if (j < arr[temp].min) arr[temp].min = j;
    }
    maximal = arr[temp].max;
    minimal = arr[temp].min;
}
开发者ID:Nightonke,项目名称:Sicily,代码行数:31,代码来源:01876_00.cpp

示例7: buildtree

/*
 * Builds a balanced tree from the N first elements of the
 * given sorted list.  Assigns the first, root and last node
 * pointers.
 */
static void buildtree(list_t *list, int N,
                      treenode_t **first, treenode_t **root, treenode_t **last)
{
    if (N == 1) {
        *first = *root = *last = newnode(list_popfirst(list));
    }
    else if (N == 2) {
    	*first = *root = newnode(list_popfirst(list));
    	*last = (*root)->right = (*root)->next = newnode(list_popfirst(list));
    }
    else if (N > 2) {
        treenode_t *left;       /* root of left subtree */
        treenode_t *leftlast;   /* last node in left subtree */
        treenode_t *right;      /* root of right subtree */
        treenode_t *rightfirst; /* first node in right subtree */

        buildtree(list, N - N/2 - 1, first, &left, &leftlast);
        *root = *last = newnode(list_popfirst(list));
        (*root)->left = left;
        (*root)->level = left->level + 1;
        leftlast->next = *root;
		buildtree(list, N/2, &rightfirst, &right, last);
        (*root)->right = right;
        (*root)->next = rightfirst;
    }
}
开发者ID:karoon,项目名称:src_search_engine,代码行数:31,代码来源:aatreeset.c

示例8: efcode

/*
 * code for the end of a function
 * deals with struct return here
 */
void
efcode(void)
{
	NODE *p, *q;
	int tempnr;
	int ty;

	if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
		return;

	ty = cftnsp->stype - FTN;

	q = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->sap);
	q->n_rval = V0;
	p = tempnode(0, INCREF(ty), 0, cftnsp->sap);
	tempnr = regno(p);
	p = buildtree(ASSIGN, p, q);
	ecomp(p);

	q = tempnode(tempnr, INCREF(ty), 0, cftnsp->sap);
	q = buildtree(UMUL, q, NIL);

	p = tempnode(rvnr, INCREF(ty), 0, cftnsp->sap);
	p = buildtree(UMUL, p, NIL);

	p = buildtree(ASSIGN, p, q);
	ecomp(p);

	q = tempnode(rvnr, INCREF(ty), 0, cftnsp->sap);
	p = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->sap);
	p->n_rval = V0;
	p = buildtree(ASSIGN, p, q);
	ecomp(p);
}
开发者ID:JamesLinus,项目名称:pcc,代码行数:38,代码来源:code.c

示例9: mips_builtin_stdarg_start

/*
 * va_start(ap, last) implementation.
 *
 * f is the NAME node for this builtin function.
 * a is the argument list containing:
 *	   CM
 *	ap   last
 *
 * It turns out that this is easy on MIPS.  Just write the
 * argument registers to the stack in va_arg_start() and
 * use the traditional method of walking the stackframe.
 */
NODE *
mips_builtin_stdarg_start(NODE *f, NODE *a, TWORD t)
{
	NODE *p, *q;
	int sz = 1;

	/* check num args and type */
	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM ||
	    !ISPTR(a->n_left->n_type))
		goto bad;

	/* must first deal with argument size; use int size */
	p = a->n_right;
	if (p->n_type < INT) {
		/* round up to word */
		sz = SZINT / tsize(p->n_type, p->n_df, p->n_ap);
	}

	p = buildtree(ADDROF, p, NIL);	/* address of last arg */
	p = optim(buildtree(PLUS, p, bcon(sz)));
	q = block(NAME, NIL, NIL, PTR+VOID, 0, 0);
	q = buildtree(CAST, q, p);
	p = q->n_right;
	nfree(q->n_left);
	nfree(q);
	p = buildtree(ASSIGN, a->n_left, p);
	tfree(f);
	nfree(a);

	return p;

bad:
	uerror("bad argument to __builtin_stdarg_start");
	return bcon(0);
}
开发者ID:MoochMcGee,项目名称:pcc-optimized,代码行数:47,代码来源:local.c

示例10: builtin_stdarg_start

static NODE *
builtin_stdarg_start(const struct bitable *bt, NODE *a)
{
    NODE *p, *q;
    int sz;

    /* must first deal with argument size; use int size */
    p = a->n_right;
    if (p->n_type < INT) {
        sz = (int)(SZINT/tsize(p->n_type, p->n_df, p->n_ap));
    } else
        sz = 1;

    /* do the real job */
    p = buildtree(ADDROF, p, NIL); /* address of last arg */
#ifdef BACKAUTO
    p = optim(buildtree(PLUS, p, bcon(sz))); /* add one to it (next arg) */
#else
    p = optim(buildtree(MINUS, p, bcon(sz))); /* add one to it (next arg) */
#endif
    q = block(NAME, NIL, NIL, PTR+VOID, 0, 0); /* create cast node */
    q = buildtree(CAST, q, p); /* cast to void * (for assignment) */
    p = q->n_right;
    nfree(q->n_left);
    nfree(q);
    p = buildtree(ASSIGN, a->n_left, p); /* assign to ap */
    nfree(a);
    return p;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:29,代码来源:builtins.c

示例11: param_float

/* setup a float param on the stack
 * used by bfcode() */
static void
param_float(struct symtab *sym, int *argofsp, int dotemps)
{
	NODE *p, *q, *t;
	int tmpnr;

	/*
	 * we have to dump the float from the general register
	 * into a temp, since the register allocator doesn't like
	 * floats to be in CLASSA.  This may not work for -xtemps.
	 */

	t = tempnode(0, INT, 0, 0);
	tmpnr = regno(t);
	q = block(REG, NIL, NIL, INT, 0, 0);
	q->n_rval = R0 + (*argofsp)++;
	p = buildtree(ASSIGN, t, q);
	ecomp(p);

	if (dotemps) {
		sym->soffset = tmpnr;
		sym->sflags |= STNODE;
	} else {
		q = tempnode(tmpnr, sym->stype, sym->sdf, sym->sap);
		p = nametree(sym);
		p = buildtree(ASSIGN, p, q);
		ecomp(p);
	}
}
开发者ID:MoochMcGee,项目名称:pcc-optimized,代码行数:31,代码来源:code.c

示例12: amd64_builtin_va_copy

NODE *
amd64_builtin_va_copy(NODE *f, NODE *a, TWORD t)
{
	tfree(f);
	f = buildtree(ASSIGN, buildtree(UMUL, a->n_left, NIL),
	    buildtree(UMUL, a->n_right, NIL));
	nfree(a);
	return f;
}
开发者ID:fhector,项目名称:helenOS-0.5-Hector,代码行数:9,代码来源:code.c

示例13: moveargs

static NODE *
moveargs(NODE *p, int *regp)
{
        NODE *r, **rp;
	int lastreg;
	int reg;

        if (p->n_op == CM) {
                p->n_left = moveargs(p->n_left, regp);
                r = p->n_right;
		rp = &p->n_right;
        } else {
		r = p;
		rp = &p;
	}

 	lastreg = A0 + nargregs - 1;
        reg = *regp;

	if (reg > lastreg && r->n_op != STARG)
		*rp = block(FUNARG, r, NIL, r->n_type, r->n_df, r->n_ap);
	else if (r->n_op == STARG) {
		*rp = movearg_struct(r, p, regp);
	} else if (DEUNSIGN(r->n_type) == LONGLONG) {
		*rp = movearg_64bit(r, regp);
	} else if (r->n_type == DOUBLE || r->n_type == LDOUBLE) {
		/* XXX bounce in and out of temporary to change to longlong */
		NODE *t1 = tempnode(0, LONGLONG, 0, 0);
		int tmpnr = regno(t1);
		NODE *t2 = tempnode(tmpnr, r->n_type, r->n_df, r->n_ap);
		t1 =  movearg_64bit(t1, regp);
		r = block(ASSIGN, t2, r, r->n_type, r->n_df, r->n_ap);
		if (p->n_op == CM) {
			p->n_left = buildtree(CM, p->n_left, t1);
			p->n_right = r;
		} else {
			p = buildtree(CM, t1, r);
		}
	} else if (r->n_type == FLOAT) {
		/* XXX bounce in and out of temporary to change to int */
		NODE *t1 = tempnode(0, INT, 0, 0);
		int tmpnr = regno(t1);
		NODE *t2 = tempnode(tmpnr, r->n_type, r->n_df, r->n_ap);
		t1 =  movearg_32bit(t1, regp);
		r = block(ASSIGN, t2, r, r->n_type, r->n_df, r->n_ap);
		if (p->n_op == CM) {
			p->n_left = buildtree(CM, p->n_left, t1);
			p->n_right = r;
		} else {
			p = buildtree(CM, t1, r);
		}
	} else {
		*rp = movearg_32bit(r, regp);
	}

	return p;
}
开发者ID:JamesLinus,项目名称:pcc,代码行数:57,代码来源:code.c

示例14: builtin_bswap16

static NODE *
builtin_bswap16(const struct bitable *bt, NODE *a)
{
    NODE *f, *t1, *t2;

    t1 = buildtree(LS, buildtree(AND, ccopy(a), bcon(255)), bcon(8));
    t2 = buildtree(AND, buildtree(RS, a, bcon(8)), bcon(255));
    f = buildtree(OR, t1, t2);
    return f;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:10,代码来源:builtins.c

示例15: buildtree

void buildtree(int id,int l,int r)
{
 if(l==r) st[id]=a[l] ;
 else{
 	int mid=(l+r)/2;
 	buildtree(2*id,l,mid);
 	buildtree((2*id)+1,mid+1,r);
 	st[id]=st[2*id]+st[(2*id)+1];
 }
}
开发者ID:a00012025,项目名称:Online_Judge_Code,代码行数:10,代码来源:d784.cpp


注:本文中的buildtree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。