p1_const(register Constp cp) #endif { int type = cp->vtype; expptr vleng = cp->vleng; union Constant *c = &cp->Const; char cdsbuf0[64], cdsbuf1[64]; char *cds0, *cds1; switch (type) { case TYINT1: case TYSHORT: case TYLONG: #ifdef TYQUAD0 case TYQUAD: #endif case TYLOGICAL: case TYLOGICAL1: case TYLOGICAL2: fprintf(pass1_file, "%d: %d %ld\n", P1_CONST, type, c->ci); break; #ifndef NO_LONG_LONG case TYQUAD: fprintf(pass1_file, "%d: %d %llx\n", P1_CONST, type, c->cq); break; #endif case TYREAL: case TYDREAL: fprintf(pass1_file, "%d: %d %s\n", P1_CONST, type, cp->vstg ? c->cds[0] : cds(dtos(c->cd[0]), cdsbuf0)); break; case TYCOMPLEX: case TYDCOMPLEX: if (cp->vstg) { cds0 = c->cds[0]; cds1 = c->cds[1]; } else { cds0 = cds(dtos(c->cd[0]), cdsbuf0); cds1 = cds(dtos(c->cd[1]), cdsbuf1); } fprintf(pass1_file, "%d: %d %s %s\n", P1_CONST, type, cds0, cds1); break; case TYCHAR: if (vleng && !ISICON (vleng)) err("p1_const: bad vleng\n"); else fprintf(pass1_file, "%d: %d %lx\n", P1_CONST, type, cpexpr((expptr)cp)); break; default: erri ("p1_const: bad constant type '%d'", type); break; } /* switch */ } /* p1_const */
prconr(FILEP fp, Constp x, int k) #endif { char *x0, *x1; char cdsbuf0[64], cdsbuf1[64]; if (k > 1) { if (x->vstg) { x0 = x->Const.cds[0]; x1 = x->Const.cds[1]; } else { x0 = cds(dtos(x->Const.cd[0]), cdsbuf0); x1 = cds(dtos(x->Const.cd[1]), cdsbuf1); } fprintf(fp, "\t%s %s\n", x0, x1); } else fprintf(fp, "\t%s\n", x->vstg ? x->Const.cds[0] : cds(dtos(x->Const.cd[0]), cdsbuf0)); }
void DbgDraw() { if( !s_dlDbg ) { Lock lock(s_csDbgObjects); if( !s_vDbgObjects.size() ) return; CompileDisplayList cds(s_dlDbg); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); for(size_t i = 0; i < s_vDbgObjects.size(); i++) s_vDbgObjects[i]->Draw(); glPopAttrib(); } s_dlDbg.Execute(); }
realpart(register Addrp p) #endif { register Addrp q; if (p->tag == TADDR && p->uname_tag == UNAM_CONST && ISCOMPLEX (p->vtype)) return (Addrp)mkrealcon (p -> vtype + TYREAL - TYCOMPLEX, p->user.kludge.vstg1 ? p->user.Const.cds[0] : cds(dtos(p->user.Const.cd[0]),CNULL)); q = (Addrp) cpexpr((expptr) p); if( ISCOMPLEX(p->vtype) ) q = mkfield (q, "r", p -> vtype + TYREAL - TYCOMPLEX); return(q); }
imagpart(register Addrp p) #endif { register Addrp q; if( ISCOMPLEX(p->vtype) ) { if (p->tag == TADDR && p->uname_tag == UNAM_CONST) return mkrealcon (p -> vtype + TYREAL - TYCOMPLEX, p->user.kludge.vstg1 ? p->user.Const.cds[1] : cds(dtos(p->user.Const.cd[1]),CNULL)); q = (Addrp) cpexpr((expptr) p); q = mkfield (q, "i", p -> vtype + TYREAL - TYCOMPLEX); return( (expptr) q ); } else /* Cast an integer type onto a Double Real type */ return( mkrealcon( ISINT(p->vtype) ? TYDREAL : p->vtype , "0")); }
int mkPhysDir(int dr, char *path) /* make physical path, that means, that for drive dr any SUBST/JOIN must be broken for mkdir dr: 0 == A: path: to make */ { CDS hdir, FAR*dir; int err, reSubst; unsigned joined; if((dir = cds(dr)) == NULL) fatal(E_cds, buf[0]); if(0 != (reSubst = (dir->flags & (SUBST | JOIN)))) { int oldCreatDir; char buf[sizeof(dummyDrvA)]; *strcpy(buf, dummyDrvA) += dr; oldCreatDir = creatDir; creatDir = 0; /* prevent from reEnter */ chkStruc(nrJoined); joined = *nrJoined; _fmemcpy(&hdir, dir, sizeof(hdir)); /* keep old CDS entry */ switchSubst(dr, buf, 0); /* log -> phys Mapping */ creatDir = oldCreatDir; } /* now: logical dr points to physical dr */ err = mkDir(dr, path, creatDir == 2); if(reSubst) { *nrJoined = joined; /* CDS restaurieren */ _fmemcpy(dir, &hdir, sizeof(hdir)); } return err; }
putconst(register Constp p) #endif { register Addrp q; struct Literal *litp, *lastlit; int k, len, type; int litflavor; double cd[2]; ftnint nblanks; char *strp; char cdsbuf0[64], cdsbuf1[64], *ds[2]; if (p->tag != TCONST) badtag("putconst", p->tag); q = ALLOC(Addrblock); q->tag = TADDR; type = p->vtype; q->vtype = ( type==TYADDR ? tyint : type ); q->vleng = (expptr) cpexpr(p->vleng); q->vstg = STGCONST; /* Create the new label for the constant. This is wasteful of labels because when the constant value already exists in the literal pool, this label gets thrown away and is never reclaimed. It might be cleaner to move this down past the first switch() statement below */ q->memno = newlabel(); q->memoffset = ICON(0); q -> uname_tag = UNAM_CONST; /* Copy the constant info into the Addrblock; do this by copying the largest storage elts */ q -> user.Const = p -> Const; q->user.kludge.vstg1 = p->vstg; /* distinguish string from binary fp */ /* check for value in literal pool, and update pool if necessary */ k = 1; switch(type) { case TYCHAR: if (halign) { strp = p->Const.ccp; nblanks = p->Const.ccp1.blanks; len = p->vleng->constblock.Const.ci; litflavor = LIT_CHAR; goto loop; } else q->memno = BAD_MEMNO; break; case TYCOMPLEX: case TYDCOMPLEX: k = 2; if (p->vstg) cd[1] = atof(ds[1] = p->Const.cds[1]); else ds[1] = cds(dtos(cd[1] = p->Const.cd[1]), cdsbuf1); case TYREAL: case TYDREAL: litflavor = LIT_FLOAT; if (p->vstg) cd[0] = atof(ds[0] = p->Const.cds[0]); else ds[0] = cds(dtos(cd[0] = p->Const.cd[0]), cdsbuf0); goto loop; case TYLOGICAL1: case TYLOGICAL2: case TYLOGICAL: type = tylogical; goto lit_int_flavor; case TYLONG: type = tyint; case TYSHORT: case TYINT1: #ifdef TYQUAD case TYQUAD: #endif lit_int_flavor: litflavor = LIT_INT; /* Scan the literal pool for this constant value. If this same constant has been assigned before, use the same label. Note that this routine does NOT consider two differently-typed constants with the same bit pattern to be the same constant */ loop: lastlit = litpool + nliterals; for(litp = litpool ; litp<lastlit ; ++litp) /* Remove this type checking to ensure that all bit patterns are reused */ if(type == litp->littype) switch(litflavor) { case LIT_CHAR: if (len == (int)litp->litval.litival2[0] && nblanks == litp->litval.litival2[1] && !memcmp(strp, litp->cds[0], len)) { q->memno = litp->litnum; frexpr((expptr)p); q->user.Const.ccp1.ccp0 = litp->cds[0]; return(q); } break; case LIT_FLOAT: if(cd[0] == litp->litval.litdval[0] && !strcmp(ds[0], litp->cds[0]) && (k == 1 || cd[1] == litp->litval.litdval[1] && !strcmp(ds[1], litp->cds[1]))) { ret: q->memno = litp->litnum; frexpr((expptr)p); return(q); } break; case LIT_INT: if(p->Const.ci == litp->litval.litival) goto ret; break; } /* If there's room in the literal pool, add this new value to the pool */ if(nliterals < maxliterals) { ++nliterals; /* litp now points to the next free elt */ litp->littype = type; litp->litnum = q->memno; switch(litflavor) { case LIT_CHAR: litp->litval.litival2[0] = len; litp->litval.litival2[1] = nblanks; q->user.Const.ccp = litp->cds[0] = memcpy(gmem(len,0), strp, len); break; case LIT_FLOAT: litp->litval.litdval[0] = cd[0]; litp->cds[0] = copys(ds[0]); if (k == 2) { litp->litval.litdval[1] = cd[1]; litp->cds[1] = copys(ds[1]); } break; case LIT_INT: litp->litval.litival = p->Const.ci; break; } /* switch (litflavor) */ } else many("literal constants", 'L', maxliterals); break; case TYADDR: break; default: badtype ("putconst", p -> vtype); break; } /* switch */ if (type != TYCHAR || halign) frexpr((expptr)p); return( q ); }