Ejemplo n.º 1
0
Archivo: stmt.c Proyecto: 0culus/ioq3
Node jump(int lab) {
	Symbol p = findlabel(lab);

	p->ref++;
	return newnode(JUMP+V, newnode(ADDRG+ttob(voidptype), NULL, NULL, p),
		NULL, NULL);
}
Ejemplo n.º 2
0
static void I(defsymbol)(Symbol p) {
	if (p->scope == CONSTANTS)
		switch (optype(ttob(p->type))) {
		case I: p->x.name = stringf("%D", p->u.c.v.i); break;
		case U: p->x.name = stringf("%U", p->u.c.v.u); break;
		case P: p->x.name = stringf("%U", p->u.c.v.p); break;
		default: assert(0);
		}
	else if (p->scope >= LOCAL && p->sclass == STATIC)
		p->x.name = stringf("$%d", genlabel(1));
	else if (p->scope == LABELS || p->generated)
		p->x.name = stringf("$%s", p->name);
	else
		p->x.name = p->name;
}
Ejemplo n.º 3
0
Menu::Menu()
  {
  if(!menukmapset)
    {
    menukmapset=1;
    menukmap.add("Left",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Menu::umenuleft,NULL));
    menukmap.add("Right",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Menu::umenuright,NULL));
    menukmap.add("^[",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Menu::umenuesc,NULL));
    menukmap.add("Press1",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Menu::umenupress1,NULL));
    menukmap.add("Release1",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Menu::umenurelease1,NULL));
    menukmap.add("^I",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Widget::ufocusnext,NULL));
    menukmap.add("Down",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Widget::ufocusnext,NULL));
    menukmap.add("Up",new Mfn0_6<int,Menu,int,int,int,int,Time,Widget *>(&Widget::ufocusprev,NULL));
    }
  stkmap(&menukmap);
  stborder(new Shadow());
  stoverride();
  ttob(NULL,0);
  ledge(0);
  auxredge(0);
  disable();
  is_menu = 1;
  }
Ejemplo n.º 4
0
static void I(defsymbol)(Symbol p) {
	if (p->scope == CONSTANTS)
		switch (optype(ttob(p->type))) {
		case I: p->x.name = stringf("%D", p->u.c.v.i); break;
		case U: p->x.name = stringf("%U", p->u.c.v.u); break;
		case P: p->x.name = stringf("%U", p->u.c.v.p); break;
		case F:
			{	// JDC: added this to get inline floats
				floatint_t temp;

				temp.f = p->u.c.v.d;
				p->x.name = stringf("%U", temp.ui );
			}
			break;// JDC: added this
		default: assert(0);
		}
	else if (p->scope >= LOCAL && p->sclass == STATIC)
		p->x.name = stringf("$%d", genlabel(1));
	else if (p->scope == LABELS || p->generated)
		p->x.name = stringf("$%s", p->name);
	else
		p->x.name = p->name;
}
Ejemplo n.º 5
0
//function(..) module saved jan 1 2013 as part of prep for scrt integration
static void function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {
    int i, saved, sizefsave, sizeisave, varargs;
    Symbol r, argregs[NUM_ARG_REGS];

    usedmask[0] = usedmask[1] = 0;
    freemask[0] = freemask[1] = ~(unsigned)0;
    offset = maxoffset = maxargoffset = 0;
    for (i = 0; callee[i]; i++) //find last argument
        ;
    varargs = variadic(f->type) //see if variable arguments by type or by name of final argument
              || i > 0 && strcmp(callee[i-1]->name, "va_alist") == 0;
    for (i = 0; callee[i]; i++) {  //for each argument
        Symbol p = callee[i];
        Symbol q = caller[i];
        assert(q);
        offset = roundup(offset, q->type->align); //calculate the offset from the caller's sp
        p->x.offset = q->x.offset = offset;
        p->x.name = q->x.name = stringd(offset);
        r = argreg(i, offset, optype(ttob(q->type)), q->type->size, optype(ttob(caller[0]->type)));
        if (i < NUM_ARG_REGS)
            argregs[i] = r;
        offset = roundup(offset + q->type->size, 2); //i dunno
        if (varargs)
            p->sclass = AUTO;  //variable args are always auto?
        else if (r && ncalls == 0 &&  //I dunno
                 !isstruct(q->type) && !p->addressed &&
                 !(isfloat(q->type) && r->x.regnode->set == IREG)) {
            p->sclass = q->sclass = REGISTER;
            askregvar(p, r);
            assert(p->x.regnode && p->x.regnode->vbl == p);
            q->x = p->x;
            q->type = p->type;
        }
        else if (askregvar(p, rmap(ttob(p->type)))
                 && r != NULL
                 && (isint(p->type) || p->type == q->type)) {
            assert(q->sclass != REGISTER);
            p->sclass = q->sclass = REGISTER;
            q->type = p->type;
        }
    }
    assert(!caller[i]);  //done with arguments, their individual offsets and maxargoffset have been set
    offset = 0;
    gencode(caller, callee);
    if (ncalls) //prepare to save return address if necessary(i.e. we do calls of our own)
        usedmask[IREG] |= ((unsigned)1)<<REG_RETADDR;
    usedmask[IREG] &= INT_CALLEE_SAVE;  //limit saving to those we're responsible for
    usedmask[FREG] &= 0xfff00000;
    maxargoffset = roundup(maxargoffset, usedmask[FREG] ? 8 : 2);
    if (ncalls && maxargoffset < NUM_ARG_REGS*2)
        maxargoffset = NUM_ARG_REGS*2;
    sizefsave = 4*bitcount(usedmask[FREG]); //space needed to save the float regs
    sizeisave = 2*bitcount(usedmask[IREG]);  //space needed to save the int regs
    framesize = roundup(maxargoffset + sizefsave //space for outgoing arguments, space for saving floats,
                        + sizeisave + maxoffset, 2);  //space for saving ints, space for locals
    //segment(CODE);
    //printf("\talign 16\n");
    printf("%s:\n", f->x.name);
    i = maxargoffset + sizefsave - framesize;  //I dunno but it's -v and it's never used!
    if (framesize > 0)
        print("\talu2I sp,sp,%d,smi,smbi\n", framesize);
    saved = maxargoffset;
    /space needed for outgoing arguments