|
|
1.1 ! root 1: /******************************************************************* ! 2: * * ! 3: * File: CIFPLOT/make.c * ! 4: * Written by Dan Fitzpatrick * ! 5: * copyright 1980 -- Regents of the University of California * ! 6: * * ! 7: ********************************************************************/ ! 8: ! 9: #include <stdio.h> ! 10: #include "defs.h" ! 11: #include "globals.h" ! 12: #include "parser_defs.h" ! 13: #include "structs.h" ! 14: #include "alloc.h" ! 15: ! 16: IMPORT Command *FindSymbol(); ! 17: IMPORT Command *alloc(); ! 18: IMPORT Command *palloc(); ! 19: IMPORT struct LCell *FindLayer(); ! 20: IMPORT Free(); ! 21: IMPORT State(); ! 22: IMPORT CopyDelete(); ! 23: IMPORT Error(); ! 24: IMPORT ZeroBBox(); ! 25: IMPORT CompBBox(); ! 26: IMPORT CompPtBBox(); ! 27: IMPORT MakeBBox(); ! 28: IMPORT transform *MakeTransform(); ! 29: IMPORT char *Concat(); ! 30: ! 31: extern Command *MakeComment(); /* Forward Reference */ ! 32: ! 33: Command * ! 34: MakePoly(p) ! 35: struct PathHeader *p; ! 36: { ! 37: Command *command; ! 38: command = GetCommand(); ! 39: command->type = POLYGON; ! 40: command->Ctype.Path = p->PHead; ! 41: Free(p); ! 42: command->CLink = NIL; ! 43: MakeBBox(&(command->CBBox),command); ! 44: return(command); ! 45: } ! 46: ! 47: Command * ! 48: MakeBox(length,width,center,direct) ! 49: real length,width; ! 50: point *center,*direct; ! 51: { ! 52: Command *command; ! 53: command = GetCommand(); ! 54: command->type = BOX; ! 55: command->CLink = NIL; ! 56: command->Ctype.Box.blength = length; ! 57: command->Ctype.Box.bwidth = width; ! 58: command->Ctype.Box.bcenter.x = center->x; ! 59: command->Ctype.Box.bcenter.y = center->y; ! 60: CheckPoint(direct); ! 61: command->Ctype.Box.bdirect.x = direct->x; ! 62: command->Ctype.Box.bdirect.y = direct->y; ! 63: MakeBBox(&(command->CBBox),command); ! 64: return(command); ! 65: } ! 66: ! 67: CheckPoint(pt) ! 68: point *pt; ! 69: { ! 70: if( (pt->x == 0.0) && (pt->y == 0.0) ) { ! 71: pt->x = 1.0; ! 72: return(0); ! 73: } ! 74: return(1); ! 75: } ! 76: ! 77: Command * ! 78: MakeFlash(dia,center) ! 79: real dia; ! 80: point *center; ! 81: { ! 82: Command *command; ! 83: command = GetCommand(); ! 84: command->type = FLASH; ! 85: command->CLink = NIL; ! 86: command->Ctype.Flash.fdia = dia; ! 87: command->Ctype.Flash.fcenter.x = center->x; ! 88: command->Ctype.Flash.fcenter.y = center->y; ! 89: MakeBBox(&(command->CBBox),command); ! 90: return(command); ! 91: } ! 92: ! 93: Command * ! 94: MakeWire(width,p) ! 95: real width; ! 96: struct PathHeader *p; ! 97: { ! 98: Command *command; ! 99: command = GetCommand(); ! 100: command->type = WIRE; ! 101: ZeroBBox(&(command->CBBox)); ! 102: command->CLink = NIL; ! 103: command->Ctype.Wire.WWidth = width; ! 104: command->Ctype.Wire.WPath = p->PHead; ! 105: command->Ctype.Wire.WIns = NIL; ! 106: Free(p); ! 107: MakeBBox(&(command->CBBox),command); ! 108: return(command); ! 109: } ! 110: ! 111: Command * ! 112: MakeSymbol(num,a,b) ! 113: int num,a,b; ! 114: { ! 115: Command *command,*p; ! 116: struct CCell *q; ! 117: char s[128]; ! 118: ! 119: switch(State(num)){ ! 120: case USED: ! 121: case UNUSED: ! 122: sprintf(s,"Symbol %d redefined",num); ! 123: Error(s,WARNING); ! 124: p = FindSymbol(num); ! 125: p->Ctype.Symbl.status = DELETED; ! 126: if(p->Ctype.Symbl.backTrace != NIL) ! 127: Error("Dangling References after Symbol Redefintion",WARNING); ! 128: for(q=p->Ctype.Symbl.backTrace; q!=NIL; q=q->CCLink) ! 129: CopyDelete(q->CCCom); ! 130: /* Fall through and create new symbol */ ! 131: case DELETED: ! 132: case NONEXIST: ! 133: command = GetCommand(); ! 134: command->type = SYMBOL; ! 135: command->Ctype.Symbl.SymNo = num; ! 136: command->Ctype.Symbl.backTrace = NIL; ! 137: command->Ctype.Symbl.status = UNUSED; ! 138: command->Ctype.Symbl.a = a; ! 139: command->Ctype.Symbl.b = b; ! 140: command->Ctype.Symbl.CStart = NIL; ! 141: command->Ctype.Symbl.CFinnish = NIL; ! 142: command->Ctype.Symbl.SName = Concat("",0); ! 143: command->CLink = NIL; ! 144: command->level = -1; ! 145: ZeroBBox(&(command->CBBox)); ! 146: return(command); ! 147: case UNDEFINED: ! 148: command = FindSymbol(num); ! 149: command->Ctype.Symbl.status = UNEXAMINED; ! 150: command->Ctype.Symbl.a = a; ! 151: command->Ctype.Symbl.b = b; ! 152: return(command); ! 153: default: ! 154: { char s[128]; ! 155: sprintf(s,"Symbol %d in unknown state\n",num); ! 156: Error(s,INTERNAL); ! 157: } ! 158: } ! 159: } ! 160: ! 161: Command * ! 162: AddCmd(h,c) ! 163: Command *h; ! 164: Command *c; ! 165: { ! 166: Command *p; ! 167: ! 168: switch(c->type) { ! 169: case COMMENT: ! 170: FreeCommand(c); ! 171: return(h); ! 172: case NAME: ! 173: if(*(h->Ctype.Symbl.SName) != '\0') { ! 174: char s[256],*msg; ! 175: sprintf(s,"Symbol %d has already been named ", ! 176: h->Ctype.Symbl.SymNo); ! 177: msg = Concat(s,h->Ctype.Symbl.SName,0); ! 178: Error(msg,WARNING); ! 179: Free(msg); ! 180: h->Ctype.Symbl.SName = Concat(h->Ctype.Symbl.SName, ! 181: "--",c->Ctype.s,0); ! 182: FreeCommand(c); ! 183: return(h); ! 184: } ! 185: h->Ctype.Symbl.SName = c->Ctype.s; ! 186: FreeCommand(c); ! 187: return(h); ! 188: case LAYER: ! 189: h->level = c->level; ! 190: FreeCommand(c); ! 191: return(h); ! 192: case WIRE: ! 193: case POLYGON: ! 194: case BOX: ! 195: case FLASH: ! 196: /* Check for valid layer description */ ! 197: if(h->level == -1) { ! 198: Error("Layer not Specified",RECOVERABLE); ! 199: h->level = 0; ! 200: } ! 201: case POINTNAME: ! 202: case TEXT: ! 203: case CALL: ! 204: case ARRAY: ! 205: /* Add new command to end of command list */ ! 206: if (h->Ctype.Symbl.CStart == NIL) ! 207: h->Ctype.Symbl.CFinnish = h->Ctype.Symbl.CStart = c; ! 208: else { ! 209: h->Ctype.Symbl.CFinnish->CLink = c; ! 210: h->Ctype.Symbl.CFinnish = c; ! 211: } ! 212: /* New Command may itself be a list (i.e. a wire) */ ! 213: for(p=c; p!=NIL; p= p->CLink) { ! 214: h->Ctype.Symbl.CFinnish = p; ! 215: /* Set to current level */ ! 216: p->level = h->level; ! 217: } ! 218: return(h); ! 219: default: ! 220: { char s[128]; ! 221: sprintf(s,"Unknown Command in Defintion of Symbol %d\n", ! 222: h->Ctype.Symbl.SymNo); ! 223: Error(s,INTERNAL); ! 224: } ! 225: } ! 226: } ! 227: ! 228: Command * ! 229: MakeCall(num,trans) ! 230: int num; ! 231: transform *trans; ! 232: { ! 233: Command *command; ! 234: command = GetCommand(); ! 235: command->type = CALL; ! 236: command->Ctype.Call.CallNo = num; ! 237: command->Ctype.Call.trans = trans; ! 238: command->Ctype.Call.CSymb = NIL; ! 239: ZeroBBox(&(command->CBBox)); ! 240: command->CLink = NIL; ! 241: return(command); ! 242: } ! 243: ! 244: Command * ! 245: MakeComment() ! 246: { ! 247: Command *command; ! 248: command = GetCommand(); ! 249: command->type = COMMENT; ! 250: ZeroBBox(&(command->CBBox)); ! 251: command->CLink = NIL; ! 252: return(command); ! 253: } ! 254: ! 255: struct PathHeader * ! 256: MakePath(pt) ! 257: point *pt; ! 258: { ! 259: PointList *path; ! 260: struct PathHeader *PH; ! 261: ! 262: path = (PointList *) alloc(sizeof(PointList)); ! 263: PH = (struct PathHeader *) alloc(sizeof(struct PathHeader)); ! 264: PH->PNo = 1; ! 265: PH->PHead = PH->PTail = path; ! 266: path->PLink = NIL; ! 267: path->pt.x = pt->x; ! 268: path->pt.y = pt->y; ! 269: return(PH); ! 270: } ! 271: ! 272: struct PathHeader * ! 273: AddPath(PH,pt) ! 274: struct PathHeader *PH; ! 275: point *pt; ! 276: { ! 277: PointList *newpath; ! 278: ! 279: newpath = (PointList *) alloc(sizeof(PointList)); ! 280: (PH->PNo)++; ! 281: PH->PTail->PLink = newpath; ! 282: PH->PTail = newpath; ! 283: newpath->PLink = NIL; ! 284: newpath->pt.x = pt->x; ! 285: newpath->pt.y = pt->y; ! 286: return(PH); ! 287: } ! 288: ! 289: ! 290: point * ! 291: MakePoint(x,y) ! 292: real x,y; ! 293: { ! 294: point *p; ! 295: p = (point *) alloc(sizeof(point)); ! 296: p->x = x; ! 297: p->y = y; ! 298: return(p); ! 299: } ! 300: ! 301: Command * ! 302: MakeArray(s,m,n,dx,dy) ! 303: int s,m,n; ! 304: real dx,dy; ! 305: { ! 306: Command *command; ! 307: transform *t; ! 308: ! 309: command = GetCommand(); ! 310: command->type = ARRAY; ! 311: ZeroBBox(&(command->CBBox)); ! 312: command->CLink = NIL; ! 313: t = MakeTransform(); ! 314: command->Ctype.Array.ACom = MakeCall(s,t); ! 315: command->Ctype.Array.As = s; ! 316: command->Ctype.Array.Am = m; ! 317: command->Ctype.Array.An = n; ! 318: command->Ctype.Array.Adx = dx; ! 319: command->Ctype.Array.Ady = dy; ! 320: return(command); ! 321: } ! 322: ! 323: Command * ! 324: MakePointName(s,pt,label) ! 325: char *s,*label; ! 326: point *pt; ! 327: { ! 328: Command *command; ! 329: command = GetCommand(); ! 330: command->type = POINTNAME; ! 331: command->Ctype.PointName.Name = s; ! 332: command->Ctype.PointName.loc.x = pt->x; ! 333: command->Ctype.PointName.loc.y = pt->y; ! 334: command->Ctype.PointName.Label = label; ! 335: if(strcmp(label,"all") == 0) ! 336: command->level = -1; ! 337: else { ! 338: struct LCell *p; ! 339: if((p=FindLayer(label)) == NIL) { ! 340: Error("Unknown layer",RECOVERABLE); ! 341: command->level = -1; ! 342: } ! 343: else ! 344: command->level = p->LNum; ! 345: } ! 346: MakeBBox(&(command->CBBox),command); ! 347: return(command); ! 348: } ! 349: ! 350: Command * ! 351: MakeName(s) ! 352: char *s; ! 353: { ! 354: Command *command; ! 355: command = GetCommand(); ! 356: command->type = NAME; ! 357: ZeroBBox(&(command->CBBox)); ! 358: command->CLink = NIL; ! 359: command->Ctype.s = s; ! 360: return(command); ! 361: } ! 362: ! 363: Command * ! 364: MakeText(s,t,c) ! 365: char *s; ! 366: transform *t; ! 367: char c; ! 368: { ! 369: Command *command; ! 370: command = GetCommand(); ! 371: command->type = TEXT; ! 372: command->Ctype.Text.TString = s; ! 373: command->Ctype.Text.TTrans = t; ! 374: command->Ctype.Text.TLoc = c; ! 375: ZeroBBox(&(command->CBBox)); ! 376: command->CLink = NIL; ! 377: return(command); ! 378: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.