1: #include <stdio.h> 2: #include "def.h" 3: #include "3.def.h" 4: 5: 6: getbranch(head) 7: VERT *head; 8: { 9: VERT v; 10: for (v = 0; v < nodenum; ++v) 11: LABEL(v) = FALSE; 12: for (v = START; DEFINED(v); v = RSIB(v)) 13: chkbranch(v,head); 14: addlab(START); 15: } 16: 17: 18: 19: chkbranch(v,head) 20: VERT v,*head; 21: { 22: VERT w; 23: int i; 24: switch(NTYPE(v)) 25: { 26: case GOVX: 27: for (i = 1, w = head[v]; DEFINED(w); w = head[w], ++i) 28: { 29: if (i > 1 && !levnxt && !levbrk) break; 30: if (ARC(v,0) == BRK(w) && (levbrk || i == 1)) 31: { 32: NTYPE(v) = BRKVX; 33: LEVEL(v) = i; 34: break; 35: } 36: else if (ARC(v,0) == NXT(w) && (levnxt || i == 1)) 37: { 38: NTYPE(v) = NXTVX; 39: LEVEL(v) = i; 40: break; 41: } 42: } 43: if (NTYPE(v) == GOVX) 44: { 45: if (ARC(v,0) == stopvert) 46: NTYPE(v) = STOPVX; 47: else if (ARC(v,0) == retvert) 48: NTYPE(v) = RETVX; 49: else LABEL(ARC(v,0)) = TRUE; 50: } 51: break; 52: case COMPVX: 53: case ASGOVX: 54: for (i = 0; i < ARCNUM(v); ++i) 55: LABEL(ARC(v,i)) = TRUE; 56: break; 57: case IOVX: 58: if (DEFINED(ARC(v,ENDEQ))) 59: LABEL(ARC(v,ENDEQ)) = TRUE; 60: if (DEFINED(ARC(v,ERREQ))) 61: LABEL(ARC(v,ERREQ)) = TRUE; 62: if (DEFINED(FMTREF(v))) 63: LABEL(FMTREF(v)) = TRUE; 64: break; 65: } 66: for (i = 0; i < CHILDNUM(v); ++i) 67: for (w = LCHILD(v,i); DEFINED(w); w = RSIB(w)) 68: chkbranch(w,head); 69: } 70: 71: 72: addlab(v) /* add labels */ 73: VERT v; 74: { 75: int recvar; 76: if (NTYPE(v) != ITERVX && LABEL(v) ) 77: LABEL(v) = nxtlab(); 78: RECURSE(addlab,v,recvar); 79: if (NTYPE(v) == ITERVX && LABEL(NXT(v))) 80: LABEL(NXT(v)) = nxtlab(); 81: } 82: 83: 84: nxtlab() 85: { 86: static count; 87: return(labinit + (count++) * labinc); 88: }