1: #include <stdio.h>
   2: #
   3: /*
   4: correct the flow of control in the new program - use GOTO's which may
   5: be changed later to NEXT, BREAK, etc.
   6: */
   7: #include "def.h"
   8: #include "3.def.h"
   9: 
  10: #define BRANCHTYPE(v)   (NTYPE(v) == GOVX )
  11: #define HASLEX(t)   (t != GOVX && t != COMPVX && t != ASGOVX  && t != ITERVX )
  12:             /* for these, control never flows directly to following statement */
  13: 
  14: 
  15: getflow()
  16:     {
  17:     fixflow(START,UNDEFINED);
  18:     }
  19: 
  20: 
  21: fixflow(v,autolex)
  22: VERT v;
  23: VERT autolex;       /* lexical successor of v */
  24:     {
  25:     VERT lex,chlex,z,x,w;
  26:     int i;
  27:     lex = lexval(v,autolex);
  28:     if (HASLEX(NTYPE(v)) && NTYPE(v) != ICASVX)
  29:         if (DEFINED(REACH(v)) && REACH(v) != lex)
  30:             insib(v,makebr(REACH(v)));
  31:         else if (NTYPE(v) == DOVX && ARC(v,1) != lex)
  32:             insib(v,makebr(ARC(v,1)));
  33:     if (NTYPE(v) == ITERVX)
  34:         {
  35:         BRK(v) = autolex;
  36:         chlex = v;
  37:         }
  38:     else
  39:         chlex = lexval(v,autolex);
  40: 
  41:     for (i = 0; i < CHILDNUM(v); ++i)
  42:         {
  43:         w = LCHILD(v,i);
  44:         if (DEFINED(w))
  45:             fixflow(w,chlex);
  46:         else
  47:             {
  48:             ASSERT(i < ARCNUM(v),fixflow);
  49:             z = ARC(v,i);
  50:             ASSERT(DEFINED(z), fixflow);
  51:             if (z != chlex)
  52:                 {
  53:                 x = makebr(z);
  54:                 LCHILD(v,i) = x;
  55:                 RSIB(x) = UNDEFINED;
  56:                 }
  57:             }
  58:         }
  59:     if (DEFINED(RSIB(v)))
  60:         fixflow(RSIB(v),autolex);
  61:     }
  62: 
  63: 
  64: lexval(v,lastlex)
  65: VERT v,lastlex;
  66:     {
  67:     VERT sib;
  68:     if (!HASLEX(NTYPE(v))) return(UNDEFINED);
  69:     sib = RSIB(v);
  70:     if (NTYPE(v) == ICASVX || NTYPE(v) == ACASVX)
  71:         return(lastlex);
  72:     else if (!DEFINED(sib))
  73:         return(lastlex);
  74:     else if (BRANCHTYPE(sib))
  75:         return(ARC(sib,0));
  76:     else return(sib);
  77:     }
  78: 
  79: 
  80: makebr(w)       /* make branching node leading to w */
  81: VERT w;
  82:     {
  83:     VERT new;
  84:     new = create(GOVX,1);
  85:     ARC(new,0) = w;
  86:     RSIB(new) = UNDEFINED;
  87:     REACH(new) = UNDEFINED;
  88:     return(new);
  89:     }

Defined functions

fixflow defined in line 21; used 5 times
getflow defined in line 15; used 1 times
lexval defined in line 64; used 2 times
makebr defined in line 80; used 3 times

Defined macros

BRANCHTYPE defined in line 10; used 1 times
  • in line 74
HASLEX defined in line 11; used 2 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 767
Valid CSS Valid XHTML 1.0 Strict