home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adaptor.zip / adapt.zip / adaptor / src / wtempora.c < prev    next >
Text File  |  1994-01-03  |  41KB  |  1,734 lines

  1. # include "Temporar.h"
  2. # include "yyATempo.w"
  3. # include <stdio.h>
  4. # if defined __STDC__ | defined __cplusplus
  5. #  include <stdlib.h>
  6. # else
  7.    extern void exit ();
  8. # endif
  9. # include "Tree.h"
  10. # include "Definiti.h"
  11.  
  12. # ifndef NULL
  13. # define NULL 0L
  14. # endif
  15. # ifndef false
  16. # define false 0
  17. # endif
  18. # ifndef true
  19. # define true 1
  20. # endif
  21.  
  22. # ifdef yyInline
  23. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
  24.   if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
  25.   free += nodesize [kind]; \
  26.   ptr->yyHead.yyMark = 0; \
  27.   ptr->Kind = kind;
  28. # else
  29. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
  30. # endif
  31.  
  32. # define yyWrite(s) (void) fputs (s, yyf)
  33. # define yyWriteNl (void) fputc ('\n', yyf)
  34.  
  35. # line 43 "AdaptTemporary.puma"
  36.  
  37. # include <stdio.h>
  38. # include "Idents.h"
  39. # include "StringMe.h"
  40.  
  41. # include "protocol.h"
  42.  
  43. # include "Types.h"
  44. # include "Transfor.h"    /* ReplaceACF, ... */
  45. # include "Shapes.h"
  46. # include "Expressi.h"  /* MakeNotExp     */
  47. # include "ShowDefs.h"     /* error messages */
  48. # include "TempScal.h"  /* ExtractScalarMovements */
  49. # include "TempVars.h"     /* MakeLocalExpression    */
  50.  
  51. static int   forall_loops;          /* global used for forall statements */
  52. static tTree forall_loopnest[10];
  53. static tTree forall_mask;
  54. static tTree forall_new_assigns;
  55.  
  56.  
  57.  
  58. static FILE * yyf = stdout;
  59.  
  60. static void yyAbort
  61. # ifdef __cplusplus
  62.  (char * yyFunction)
  63. # else
  64.  (yyFunction) char * yyFunction;
  65. # endif
  66. {
  67.  (void) fprintf (stderr, "Error: module AdaptTemporary, routine %s failed\n", yyFunction);
  68.  exit (1);
  69. }
  70.  
  71. void AdaptTemporary ARGS((tTree t));
  72. static tTree ACFScalarTemps ARGS((tTree t));
  73. static tTree AppendBody ARGS((tTree list1, tTree list2));
  74. static tTree TempScalarIO ARGS((tTree stmt));
  75. static void SwitchAssignments ARGS((tTree t));
  76. static tTree AdaptTempACF ARGS((tTree t));
  77. static tTree AdaptTempAssign ARGS((tTree assign));
  78. static void AdaptTempForall ARGS((tTree t));
  79. static void ForallNewAssigns ARGS((tTree t, int line));
  80. static tTree MakeOuterLoop ARGS((tTree loop, tTree body));
  81. static tTree AdaptTempWhereList ARGS((tTree t));
  82. static tTree AdaptTempWhere ARGS((tTree t));
  83. static bool WhereMaskUpdate ARGS((tTree wherelist));
  84. static bool HasMaskUpdate ARGS((tTree mask, tTree stmtlist));
  85. static tTree GetSplittedWhereList ARGS((tTree t));
  86. static tTree SplitWhere ARGS((tTree wherestmt, tTree tp1, tTree fp1, tTree tp2, tTree fp2));
  87. static void NormalizeWhere ARGS((tTree wherestmt));
  88. static void ListSplitUp ARGS((tTree list, tTree mask, tTree * s1, tTree * s2));
  89. static bool HasWhereMovement ARGS((tTree stmt, tTree where_exp));
  90.  
  91. void AdaptTemporary
  92. # if defined __STDC__ | defined __cplusplus
  93. (register tTree t)
  94. # else
  95. (t)
  96.  register tTree t;
  97. # endif
  98. {
  99.   if (t == NoTree) return;
  100.  
  101.   switch (t->Kind) {
  102.   case kCOMP_UNIT:
  103. # line 77 "AdaptTemporary.puma"
  104.   {
  105. # line 78 "AdaptTemporary.puma"
  106.    open_protocol ("adaptor.tmp");
  107. # line 79 "AdaptTemporary.puma"
  108.    AdaptTemporary (t->COMP_UNIT.COMP_ELEMENTS);
  109. # line 80 "AdaptTemporary.puma"
  110.    close_protocol ();
  111.   }
  112.    return;
  113.  
  114.   case kDECL_LIST:
  115. # line 85 "AdaptTemporary.puma"
  116.   {
  117. # line 86 "AdaptTemporary.puma"
  118.    AdaptTemporary (t->DECL_LIST.Elem);
  119. # line 87 "AdaptTemporary.puma"
  120.    AdaptTemporary (t->DECL_LIST.Next);
  121.   }
  122.    return;
  123.  
  124.   case kDECL_EMPTY:
  125. # line 90 "AdaptTemporary.puma"
  126.    return;
  127.  
  128.   case kPROGRAM_DECL:
  129. # line 93 "AdaptTemporary.puma"
  130.  {
  131.   tDefinitions Obj;
  132.   {
  133. # line 94 "AdaptTemporary.puma"
  134.    set_protocol_unit (t);
  135. # line 95 "AdaptTemporary.puma"
  136.    IsPure = false;
  137. # line 96 "AdaptTemporary.puma"
  138.  
  139. # line 97 "AdaptTemporary.puma"
  140.    Obj = GetDeclEntry (t->PROGRAM_DECL.Name, GetUnitEntries ());
  141. # line 98 "AdaptTemporary.puma"
  142.    OpenScope (Obj->ProcObject.Declarations);
  143. # line 99 "AdaptTemporary.puma"
  144.    AdaptTemporary (t->PROGRAM_DECL.PROGRAM_BODY);
  145. # line 100 "AdaptTemporary.puma"
  146.    Obj->ProcObject.Declarations = GetCurrentScope ();
  147. # line 101 "AdaptTemporary.puma"
  148.    CloseScope ();
  149.   }
  150.    return;
  151.  }
  152.  
  153.   case kPROC_DECL:
  154. # line 104 "AdaptTemporary.puma"
  155.  {
  156.   tDefinitions Obj;
  157.   {
  158. # line 105 "AdaptTemporary.puma"
  159.    set_protocol_unit (t);
  160. # line 106 "AdaptTemporary.puma"
  161.    IsPure = t->PROC_DECL.IsPure;
  162. # line 107 "AdaptTemporary.puma"
  163.  
  164. # line 108 "AdaptTemporary.puma"
  165.    Obj = GetDeclEntry (t->PROC_DECL.Name, GetUnitEntries ());
  166. # line 109 "AdaptTemporary.puma"
  167.    OpenScope (Obj->ProcObject.Declarations);
  168. # line 110 "AdaptTemporary.puma"
  169.    AdaptTemporary (t->PROC_DECL.PROC_BODY);
  170. # line 111 "AdaptTemporary.puma"
  171.    if (! (Obj->ProcObject.Declarations = GetCurrentScope ())) goto yyL5;
  172.   {
  173. # line 112 "AdaptTemporary.puma"
  174.    CloseScope ();
  175.   }
  176.   }
  177.    return;
  178.  }
  179. yyL5:;
  180.  
  181.   break;
  182.   case kFUNC_DECL:
  183. # line 115 "AdaptTemporary.puma"
  184.  {
  185.   tDefinitions Obj;
  186.   {
  187. # line 116 "AdaptTemporary.puma"
  188.    set_protocol_unit (t);
  189. # line 117 "AdaptTemporary.puma"
  190.    IsPure = t->FUNC_DECL.IsPure;
  191. # line 118 "AdaptTemporary.puma"
  192.  
  193. # line 119 "AdaptTemporary.puma"
  194.    Obj = GetDeclEntry (t->FUNC_DECL.Name, GetUnitEntries ());
  195. # line 120 "AdaptTemporary.puma"
  196.    OpenScope (Obj->FuncObject.Declarations);
  197. # line 121 "AdaptTemporary.puma"
  198.    AdaptTemporary (t->FUNC_DECL.FUNC_BODY);
  199. # line 122 "AdaptTemporary.puma"
  200.    if (! (Obj->FuncObject.Declarations = GetCurrentScope ())) goto yyL6;
  201.   {
  202. # line 123 "AdaptTemporary.puma"
  203.    CloseScope ();
  204.   }
  205.   }
  206.    return;
  207.  }
  208. yyL6:;
  209.  
  210.   break;
  211.   case kBLOCK_DATA_DECL:
  212. # line 126 "AdaptTemporary.puma"
  213.  {
  214.   tDefinitions Obj;
  215.   {
  216. # line 127 "AdaptTemporary.puma"
  217.    set_protocol_unit (t);
  218. # line 128 "AdaptTemporary.puma"
  219.    IsPure = false;
  220. # line 129 "AdaptTemporary.puma"
  221.  
  222. # line 130 "AdaptTemporary.puma"
  223.    Obj = GetDeclEntry (t->BLOCK_DATA_DECL.Name, GetUnitEntries ());
  224. # line 131 "AdaptTemporary.puma"
  225.    OpenScope (Obj->BlockObject.Declarations);
  226. # line 132 "AdaptTemporary.puma"
  227.    AdaptTemporary (t->BLOCK_DATA_DECL.DATA_BODY);
  228. # line 133 "AdaptTemporary.puma"
  229.    if (! (Obj->BlockObject.Declarations = GetCurrentScope ())) goto yyL7;
  230.   {
  231. # line 134 "AdaptTemporary.puma"
  232.    CloseScope ();
  233.   }
  234.   }
  235.    return;
  236.  }
  237. yyL7:;
  238.  
  239.   break;
  240.   case kBODY_NODE:
  241. # line 137 "AdaptTemporary.puma"
  242.   {
  243. # line 138 "AdaptTemporary.puma"
  244.    if (! ((IsPure == true))) goto yyL8;
  245.   }
  246.    return;
  247. yyL8:;
  248.  
  249. # line 142 "AdaptTemporary.puma"
  250.   {
  251. # line 143 "AdaptTemporary.puma"
  252.    TempScalarsInitBody (t);
  253. # line 144 "AdaptTemporary.puma"
  254.  t->BODY_NODE.STATS = ACFScalarTemps (t->BODY_NODE.STATS);
  255. # line 145 "AdaptTemporary.puma"
  256.    TempScalarsDoneBody (t);
  257. # line 146 "AdaptTemporary.puma"
  258.    TempVarsInitBody (t);
  259. # line 147 "AdaptTemporary.puma"
  260.  t->BODY_NODE.STATS = AdaptTempACF (t->BODY_NODE.STATS);
  261. # line 148 "AdaptTemporary.puma"
  262.    TempVarsDoneBody (t);
  263.   }
  264.    return;
  265.  
  266.   }
  267.  
  268. ;
  269. }
  270.  
  271. static tTree ACFScalarTemps
  272. # if defined __STDC__ | defined __cplusplus
  273. (register tTree t)
  274. # else
  275. (t)
  276.  register tTree t;
  277. # endif
  278. {
  279.   if (t->Kind == kACF_LIST) {
  280. # line 167 "AdaptTemporary.puma"
  281.  {
  282.   tTree newelem;
  283.   {
  284. # line 169 "AdaptTemporary.puma"
  285.  
  286. # line 171 "AdaptTemporary.puma"
  287.    set_protocol_stmt (t->ACF_LIST.Elem);
  288. # line 172 "AdaptTemporary.puma"
  289.  newelem = ACFScalarTemps (t->ACF_LIST.Elem);
  290.     t->ACF_LIST.Next    = ACFScalarTemps (t->ACF_LIST.Next);
  291.     newelem = ReplaceACF (t, newelem, t->ACF_LIST.Next);
  292.  
  293.   }
  294.   {
  295.    return newelem;
  296.   }
  297.  }
  298.  
  299.   }
  300.   if (t->Kind == kACF_EMPTY) {
  301. # line 179 "AdaptTemporary.puma"
  302.    return t;
  303.  
  304.   }
  305.   if (t->Kind == kACF_BASIC) {
  306.  
  307.   switch (t->ACF_BASIC.BASIC_STMT->Kind) {
  308.   case kIO_STMT:
  309. # line 183 "AdaptTemporary.puma"
  310.    return TempScalarIO (t);
  311.  
  312.   case kALLOCATE_STMT:
  313. # line 190 "AdaptTemporary.puma"
  314.   {
  315. # line 191 "AdaptTemporary.puma"
  316.    SetAllocateShapes (t->ACF_BASIC.BASIC_STMT->ALLOCATE_STMT.PARAMS);
  317.   }
  318.    return t;
  319.  
  320.   case kDEALLOCATE_STMT:
  321. # line 195 "AdaptTemporary.puma"
  322.   {
  323. # line 196 "AdaptTemporary.puma"
  324.    ResetDeallocateShapes (t->ACF_BASIC.BASIC_STMT->DEALLOCATE_STMT.PARAMS);
  325.   }
  326.    return t;
  327.  
  328.   case kCALL_STMT:
  329. # line 200 "AdaptTemporary.puma"
  330.    return t;
  331.  
  332.   case kREDUCE_STMT:
  333. # line 204 "AdaptTemporary.puma"
  334.    return t;
  335.  
  336.   case kSTOP_STMT:
  337. # line 208 "AdaptTemporary.puma"
  338.    return t;
  339.  
  340.   case kGOTO_STMT:
  341. # line 212 "AdaptTemporary.puma"
  342.    return t;
  343.  
  344.   case kCOMP_IF_STMT:
  345. # line 216 "AdaptTemporary.puma"
  346.    return t;
  347.  
  348.   case kASSIGN_STMT:
  349. # line 226 "AdaptTemporary.puma"
  350.    return t;
  351.  
  352.   }
  353.  
  354. # line 230 "AdaptTemporary.puma"
  355.    return t;
  356.  
  357.   }
  358.  
  359.   switch (t->Kind) {
  360.   case kACF_DUMMY:
  361. # line 234 "AdaptTemporary.puma"
  362.    return t;
  363.  
  364.   case kACF_WHILE:
  365. # line 238 "AdaptTemporary.puma"
  366.  {
  367.   tTree new;
  368.   {
  369. # line 240 "AdaptTemporary.puma"
  370.  
  371. # line 242 "AdaptTemporary.puma"
  372.   t->ACF_WHILE.WHILE_BODY = ACFScalarTemps (t->ACF_WHILE.WHILE_BODY);
  373.  
  374.      t->ACF_WHILE.WHILE_EXP  = ExtractScalarMovements (t->ACF_WHILE.WHILE_EXP, &new);
  375.  
  376.      if (new != NoTree)
  377.        {
  378.          t->ACF_WHILE.WHILE_BODY = AppendBody (t->ACF_WHILE.WHILE_BODY, CopyTree (new));
  379.          new  = CombineACF (new, mACF_LIST (t, NoTree));
  380.          tree_protocol ("DO WHILE with new scalars in exp:\n", new);
  381.        }
  382.       else
  383.        new = t;
  384.  
  385.   }
  386.   {
  387.    return new;
  388.   }
  389.  }
  390.  
  391.   case kACF_DO:
  392. # line 258 "AdaptTemporary.puma"
  393.  {
  394.   tTree new;
  395.   {
  396. # line 260 "AdaptTemporary.puma"
  397.  
  398. # line 262 "AdaptTemporary.puma"
  399.  t->ACF_DO.DO_BODY  = ACFScalarTemps (t->ACF_DO.DO_BODY);
  400.  
  401.     t->ACF_DO.DO_RANGE = ExtractScalarMovements (t->ACF_DO.DO_RANGE, &new);
  402.  
  403.     if (new != NoTree)
  404.       {
  405.         new = CombineACF (new, mACF_LIST (t, NoTree));
  406.         tree_protocol ("DO with new scalars in range:\n", new);
  407.       }
  408.      else
  409.       new = t;
  410.  
  411.   }
  412.   {
  413.    return new;
  414.   }
  415.  }
  416.  
  417.   case kACF_DOLOCAL:
  418. # line 277 "AdaptTemporary.puma"
  419.    return t;
  420.  
  421.   case kACF_FORALL:
  422. # line 282 "AdaptTemporary.puma"
  423.    return t;
  424.  
  425.   case kACF_IF:
  426. # line 286 "AdaptTemporary.puma"
  427.  {
  428.   tTree new;
  429.   {
  430. # line 288 "AdaptTemporary.puma"
  431.  
  432. # line 290 "AdaptTemporary.puma"
  433.  t->ACF_IF.THEN_PART = ACFScalarTemps (t->ACF_IF.THEN_PART);
  434.     t->ACF_IF.ELSE_PART = ACFScalarTemps (t->ACF_IF.ELSE_PART);
  435.     t->ACF_IF.IF_EXP = ExtractScalarMovements (t->ACF_IF.IF_EXP, &new);
  436.     if (new != NoTree)
  437.       { new = CombineACF (new, mACF_LIST (t, NoTree));
  438.         tree_protocol ("IF with new scalars : \n", new);
  439.       }
  440.      else
  441.       new = t;
  442.  
  443.   }
  444.   {
  445.    return new;
  446.   }
  447.  }
  448.  
  449.   case kACF_WHERE:
  450. # line 303 "AdaptTemporary.puma"
  451.    return t;
  452.  
  453.   case kACF_NODE:
  454.   case kACF_BASIC:
  455.   case kACF_SWITCH:
  456.   case kACF_ALTER:
  457.   case kACF_CASE:
  458.   case kACF_REPEAT:
  459.   case kACF_WITH:
  460.   case kACF_LOOP:
  461.   case kACF_DOVEC:
  462.   case kACF_DOALL:
  463.   case kACF_ON:
  464.   case kACF_BODY:
  465.   case kACF_FLOW_GRAPH:
  466.   case kACF_ENTRY:
  467. # line 308 "AdaptTemporary.puma"
  468.   {
  469. # line 309 "AdaptTemporary.puma"
  470.    error_protocol ("This statement is not handled");
  471.   }
  472.    return t;
  473.  
  474.   }
  475.  
  476. # line 313 "AdaptTemporary.puma"
  477.   {
  478. # line 314 "AdaptTemporary.puma"
  479.    tree_error_protocol ("ACFScalarTemps failed", t);
  480. # line 315 "AdaptTemporary.puma"
  481.    printf ("ACFScalarTemps failed\n");
  482. # line 316 "AdaptTemporary.puma"
  483.    WriteTree (stdout, t);
  484. # line 317 "AdaptTemporary.puma"
  485.    kill_in_protocol ();
  486.   }
  487.    return t;
  488.  
  489. }
  490.  
  491. static tTree AppendBody
  492. # if defined __STDC__ | defined __cplusplus
  493. (register tTree list1, register tTree list2)
  494. # else
  495. (list1, list2)
  496.  register tTree list1;
  497.  register tTree list2;
  498. # endif
  499. {
  500.   if (list1->Kind == kACF_EMPTY) {
  501. # line 332 "AdaptTemporary.puma"
  502.   {
  503. # line 333 "AdaptTemporary.puma"
  504.    if (! (list2 == NoTree)) goto yyL1;
  505.   }
  506.    return list1;
  507. yyL1:;
  508.  
  509.   if (list2->Kind == kACF_LIST) {
  510. # line 337 "AdaptTemporary.puma"
  511.   {
  512. # line 338 "AdaptTemporary.puma"
  513.  list2->ACF_LIST.Next = AppendBody (list1, list2->ACF_LIST.Next);
  514.   }
  515.    return list2;
  516.  
  517.   }
  518.   }
  519.   if (list1->Kind == kACF_LIST) {
  520. # line 342 "AdaptTemporary.puma"
  521.   {
  522. # line 343 "AdaptTemporary.puma"
  523.  list1->ACF_LIST.Next = AppendBody (list1->ACF_LIST.Next, list2);
  524.   }
  525.    return list1;
  526.  
  527.   }
  528.  yyAbort ("AppendBody");
  529. }
  530.  
  531. static tTree TempScalarIO
  532. # if defined __STDC__ | defined __cplusplus
  533. (register tTree stmt)
  534. # else
  535. (stmt)
  536.  register tTree stmt;
  537. # endif
  538. {
  539.   if (stmt->Kind == kACF_BASIC) {
  540.   if (stmt->ACF_BASIC.BASIC_STMT->Kind == kIO_STMT) {
  541.  {
  542.   tTree new;
  543.   if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("PRINT", 5))) {
  544. # line 355 "AdaptTemporary.puma"
  545.   {
  546. # line 357 "AdaptTemporary.puma"
  547.  
  548. # line 359 "AdaptTemporary.puma"
  549.  stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
  550.  
  551.      if (new != NoTree)
  552.        { stmt_protocol ("IO PRINT statement has new scalar variables");
  553.          tree_protocol ("new scalar assignments are : \n", new);
  554.  
  555.          new = CombineACF (new, mACF_LIST (stmt, NoTree));
  556.        }
  557.       else
  558.        new = stmt;
  559.  
  560.   }
  561.   {
  562.    return new;
  563.   }
  564.  
  565.   }
  566.  }
  567.  {
  568.   tTree new;
  569.   if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("WRITE", 5))) {
  570. # line 373 "AdaptTemporary.puma"
  571.   {
  572. # line 375 "AdaptTemporary.puma"
  573.  
  574. # line 377 "AdaptTemporary.puma"
  575.  stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
  576.  
  577.      if (new != NoTree)
  578.        { stmt_protocol ("IO WRITE statement has new scalar variables");
  579.          tree_protocol ("new scalar assignments are : \n", new);
  580.  
  581.          new = CombineACF (new, mACF_LIST (stmt, NoTree));
  582.        }
  583.       else
  584.        new = stmt;
  585.  
  586.   }
  587.   {
  588.    return new;
  589.   }
  590.  
  591.   }
  592.  }
  593.  {
  594.   tTree new;
  595.   if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("READ", 4))) {
  596. # line 391 "AdaptTemporary.puma"
  597.   {
  598. # line 393 "AdaptTemporary.puma"
  599.  
  600. # line 395 "AdaptTemporary.puma"
  601.  stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
  602.  
  603.      SwitchAssignments (new);
  604.  
  605.      if (new != NoTree)
  606.        { stmt_protocol ("IO READ statement has new scalar variables");
  607.          tree_protocol ("new scalar assignments are : \n", new);
  608.        }
  609.      new = CombineACF (stmt, new);
  610.  
  611.  
  612.   }
  613.   {
  614.    return new;
  615.   }
  616.  
  617.   }
  618.  }
  619. # line 409 "AdaptTemporary.puma"
  620.    return stmt;
  621.  
  622.   }
  623.   }
  624.  yyAbort ("TempScalarIO");
  625. }
  626.  
  627. static void SwitchAssignments
  628. # if defined __STDC__ | defined __cplusplus
  629. (register tTree t)
  630. # else
  631. (t)
  632.  register tTree t;
  633. # endif
  634. {
  635.   if (t == NoTree) return;
  636. # line 418 "AdaptTemporary.puma"
  637.   {
  638. # line 419 "AdaptTemporary.puma"
  639.    if (! (t == NoTree)) goto yyL1;
  640.   }
  641.    return;
  642. yyL1:;
  643.  
  644.   if (t->Kind == kACF_EMPTY) {
  645. # line 422 "AdaptTemporary.puma"
  646.    return;
  647.  
  648.   }
  649.   if (t->Kind == kACF_LIST) {
  650.   if (t->ACF_LIST.Elem->Kind == kACF_BASIC) {
  651.   if (t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  652.   if (t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP->Kind == kVAR_EXP) {
  653. # line 425 "AdaptTemporary.puma"
  654.  {
  655.   tTree hvar;
  656.   {
  657. # line 427 "AdaptTemporary.puma"
  658.  
  659. # line 428 "AdaptTemporary.puma"
  660.  hvar = t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR; t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR = t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP->VAR_EXP.V; t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->
  661. ASSIGN_STMT.ASSIGN_EXP->VAR_EXP.V = hvar;
  662. # line 429 "AdaptTemporary.puma"
  663.    SwitchAssignments (t->ACF_LIST.Next);
  664.   }
  665.    return;
  666.  }
  667.  
  668.   }
  669.   }
  670.   }
  671.   }
  672. # line 432 "AdaptTemporary.puma"
  673.   {
  674. # line 433 "AdaptTemporary.puma"
  675.    printf ("Something is wrong in SwitchAssignments for READ\n");
  676. # line 434 "AdaptTemporary.puma"
  677.    WriteTree (stdout, t);
  678. # line 435 "AdaptTemporary.puma"
  679.    FileUnparse (stdout, t);
  680. # line 436 "AdaptTemporary.puma"
  681.    kill_in_protocol ();
  682.   }
  683.    return;
  684.  
  685. ;
  686. }
  687.  
  688. static tTree AdaptTempACF
  689. # if defined __STDC__ | defined __cplusplus
  690. (register tTree t)
  691. # else
  692. (t)
  693.  register tTree t;
  694. # endif
  695. {
  696. # line 449 "AdaptTemporary.puma"
  697.  
  698. tObject Obj, Obj1;
  699. tTree newacf, hacf;
  700. int count;
  701.  
  702.  
  703.   switch (t->Kind) {
  704.   case kACF_LIST:
  705. # line 455 "AdaptTemporary.puma"
  706.   {
  707. # line 456 "AdaptTemporary.puma"
  708.    set_protocol_stmt (t->ACF_LIST.Elem);
  709. # line 457 "AdaptTemporary.puma"
  710.  newacf = AdaptTempACF (t->ACF_LIST.Elem);
  711.        t->ACF_LIST.Next   = AdaptTempACF (t->ACF_LIST.Next);
  712.        newacf = ReplaceACF (t, newacf, t->ACF_LIST.Next);
  713.  
  714.   }
  715.    return newacf;
  716.  
  717.   case kACF_EMPTY:
  718. # line 464 "AdaptTemporary.puma"
  719.    return t;
  720.  
  721.   case kACF_BASIC:
  722.  
  723.   switch (t->ACF_BASIC.BASIC_STMT->Kind) {
  724.   case kIO_STMT:
  725. # line 468 "AdaptTemporary.puma"
  726.    return t;
  727.  
  728.   case kALLOCATE_STMT:
  729. # line 480 "AdaptTemporary.puma"
  730.   {
  731. # line 481 "AdaptTemporary.puma"
  732.    SetAllocateShapes (t->ACF_BASIC.BASIC_STMT->ALLOCATE_STMT.PARAMS);
  733.   }
  734.    return t;
  735.  
  736.   case kDEALLOCATE_STMT:
  737. # line 485 "AdaptTemporary.puma"
  738.   {
  739. # line 486 "AdaptTemporary.puma"
  740.    ResetDeallocateShapes (t->ACF_BASIC.BASIC_STMT->DEALLOCATE_STMT.PARAMS);
  741.   }
  742.    return t;
  743.  
  744.   case kCALL_STMT:
  745. # line 490 "AdaptTemporary.puma"
  746.    return t;
  747.  
  748.   case kREDUCE_STMT:
  749. # line 494 "AdaptTemporary.puma"
  750.    return t;
  751.  
  752.   case kSTOP_STMT:
  753. # line 498 "AdaptTemporary.puma"
  754.    return t;
  755.  
  756.   case kGOTO_STMT:
  757. # line 502 "AdaptTemporary.puma"
  758.    return t;
  759.  
  760.   case kCOMP_IF_STMT:
  761. # line 506 "AdaptTemporary.puma"
  762.    return t;
  763.  
  764.   case kASSIGN_STMT:
  765. # line 516 "AdaptTemporary.puma"
  766.   {
  767. # line 517 "AdaptTemporary.puma"
  768.    if (! (CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP) == 0)) goto yyL11;
  769.   }
  770.    return t;
  771. yyL11:;
  772.  
  773. # line 522 "AdaptTemporary.puma"
  774.   {
  775. # line 523 "AdaptTemporary.puma"
  776.    stmt_protocol ("Old Statement requires movements");
  777. # line 524 "AdaptTemporary.puma"
  778.  newacf = AdaptTempAssign (t);
  779. # line 525 "AdaptTemporary.puma"
  780.    tree_protocol ("New Statements:\n", newacf);
  781.   }
  782.    return newacf;
  783.  
  784.   }
  785.  
  786. # line 529 "AdaptTemporary.puma"
  787.    return t;
  788.  
  789.   case kACF_DUMMY:
  790. # line 533 "AdaptTemporary.puma"
  791.    return t;
  792.  
  793.   case kACF_WHILE:
  794. # line 537 "AdaptTemporary.puma"
  795.   {
  796. # line 538 "AdaptTemporary.puma"
  797.    if (! (t->ACF_WHILE.WHILE_BODY = AdaptTempACF (t->ACF_WHILE.WHILE_BODY))) goto yyL15;
  798.   }
  799.    return t;
  800. yyL15:;
  801.  
  802.   break;
  803.   case kACF_DO:
  804. # line 542 "AdaptTemporary.puma"
  805.   {
  806. # line 543 "AdaptTemporary.puma"
  807.    if (! (t->ACF_DO.DO_BODY = AdaptTempACF (t->ACF_DO.DO_BODY))) goto yyL16;
  808.   }
  809.    return t;
  810. yyL16:;
  811.  
  812.   break;
  813.   case kACF_DOLOCAL:
  814. # line 547 "AdaptTemporary.puma"
  815.    return t;
  816.  
  817.   case kACF_FORALL:
  818. # line 552 "AdaptTemporary.puma"
  819.   {
  820. # line 554 "AdaptTemporary.puma"
  821.  
  822.        forall_loops = 0;
  823.        forall_mask  = NoTree;
  824.  
  825.        AdaptTempForall (t);
  826.  
  827.        if (forall_new_assigns != NoTree)
  828.           newacf = CombineACF (forall_new_assigns, mACF_LIST (t, NoTree));
  829.         else
  830.           newacf = t;
  831.  
  832.   }
  833.    return newacf;
  834.  
  835.   case kACF_IF:
  836. # line 569 "AdaptTemporary.puma"
  837.   {
  838. # line 571 "AdaptTemporary.puma"
  839.    if (! (t->ACF_IF.THEN_PART = AdaptTempACF (t->ACF_IF.THEN_PART))) goto yyL19;
  840.   {
  841. # line 572 "AdaptTemporary.puma"
  842.    if (! (t->ACF_IF.ELSE_PART = AdaptTempACF (t->ACF_IF.ELSE_PART))) goto yyL19;
  843.   }
  844.   }
  845.    return t;
  846. yyL19:;
  847.  
  848.   break;
  849.   }
  850.  
  851.   if (t->Kind == kACF_WHERE) {
  852. # line 576 "AdaptTemporary.puma"
  853.  {
  854.   tTree where_list;
  855.   {
  856. # line 578 "AdaptTemporary.puma"
  857.  
  858. # line 580 "AdaptTemporary.puma"
  859.  where_list = GetSplittedWhereList (t);
  860.  
  861.     if (TreeListLength (where_list) > 1)
  862.  
  863.       { tree_protocol ("splitted where : \n", where_list);
  864.         if (WhereMaskUpdate (where_list))
  865.           error_protocol ("update of where expression, needs a mask");
  866.       }
  867.  
  868.     where_list = AdaptTempWhereList (where_list);
  869.  
  870.   }
  871.   {
  872.    return where_list;
  873.   }
  874.  }
  875.  
  876.   }
  877.   if (Tree_IsType (t, kACF_NODE)) {
  878. # line 595 "AdaptTemporary.puma"
  879.   {
  880. # line 596 "AdaptTemporary.puma"
  881.    error_protocol ("This statement is not handled");
  882.   }
  883.    return t;
  884.  
  885.   }
  886. # line 600 "AdaptTemporary.puma"
  887.   {
  888. # line 601 "AdaptTemporary.puma"
  889.    tree_error_protocol ("AdaptTempACF failed", t);
  890. # line 602 "AdaptTemporary.puma"
  891.    printf ("AdaptTempACF failed\n");
  892. # line 603 "AdaptTemporary.puma"
  893.    WriteTree (stdout, t);
  894. # line 604 "AdaptTemporary.puma"
  895.    kill_in_protocol ();
  896.   }
  897.    return t;
  898.  
  899. }
  900.  
  901. static tTree AdaptTempAssign
  902. # if defined __STDC__ | defined __cplusplus
  903. (register tTree assign)
  904. # else
  905. (assign)
  906.  register tTree assign;
  907. # endif
  908. {
  909. # line 616 "AdaptTemporary.puma"
  910.  
  911. int needed;
  912. int no;
  913. bool simple;
  914. tTree new_assigns;
  915.  
  916.   if (assign->Kind == kACF_BASIC) {
  917.   if (assign->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  918. # line 629 "AdaptTemporary.puma"
  919.   {
  920. # line 631 "AdaptTemporary.puma"
  921.  if (IsVarInExp (TreeVarName(assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR), assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP))
  922.         no = 1;
  923.        else
  924.         no = 0;
  925.      simple = false;
  926.  
  927.      assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple, &needed, &new_assigns);
  928.  
  929.      new_assigns = CombineACF (new_assigns, mACF_LIST (assign, NoTree));
  930.  
  931.   }
  932.    return new_assigns;
  933.  
  934.   }
  935.   }
  936. # line 645 "AdaptTemporary.puma"
  937.   {
  938. # line 646 "AdaptTemporary.puma"
  939.    printf ("AdaptTempAssign failed\n");
  940. # line 647 "AdaptTemporary.puma"
  941.    WriteTree (stdout, assign);
  942. # line 648 "AdaptTemporary.puma"
  943.    kill_in_protocol ();
  944.   }
  945.    return NoTree;
  946.  
  947. }
  948.  
  949. static void AdaptTempForall
  950. # if defined __STDC__ | defined __cplusplus
  951. (register tTree t)
  952. # else
  953. (t)
  954.  register tTree t;
  955. # endif
  956. {
  957. # line 666 "AdaptTemporary.puma"
  958.  
  959. int count1, count2, needed, no;
  960. bool simple;
  961.  
  962.   if (t == NoTree) return;
  963.   if (t->Kind == kACF_FORALL) {
  964. # line 671 "AdaptTemporary.puma"
  965.   {
  966. # line 672 "AdaptTemporary.puma"
  967.  forall_loopnest[forall_loops] = t;
  968.      forall_loops += 1;
  969.  
  970. # line 675 "AdaptTemporary.puma"
  971.    AdaptTempForall (t->ACF_FORALL.FORALL_BODY);
  972.   }
  973.    return;
  974.  
  975.   }
  976.   if (t->Kind == kACF_IF) {
  977.   if (t->ACF_IF.ELSE_PART->Kind == kACF_EMPTY) {
  978. # line 678 "AdaptTemporary.puma"
  979.   {
  980. # line 679 "AdaptTemporary.puma"
  981.  if (forall_mask != NoTree)
  982.         error_protocol ("only one IF allowed in FORALL");
  983.      forall_mask = t->ACF_IF.IF_EXP;
  984.  
  985. # line 683 "AdaptTemporary.puma"
  986.    AdaptTempForall (t->ACF_IF.THEN_PART);
  987.   }
  988.    return;
  989.  
  990.   }
  991.   }
  992.   if (t->Kind == kACF_BASIC) {
  993.   if (t->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  994. # line 686 "AdaptTemporary.puma"
  995.   {
  996. # line 688 "AdaptTemporary.puma"
  997.  count1 = CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
  998.  
  999.      no = 1;
  1000.      simple = false;
  1001.  
  1002.      if (forall_mask != NoTree)
  1003.         { count2 = CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, forall_mask);
  1004.           simple = true;
  1005.         }
  1006.        else
  1007.          count2 = 0;
  1008.  
  1009.  
  1010.  
  1011.      forall_new_assigns = NoTree;
  1012.  
  1013.      if (count2 > 0)
  1014.  
  1015.  
  1016.  
  1017.         error_protocol ("Assignment in FORALL with MASK requires movements");
  1018.  
  1019.      else if (count1 > 0)
  1020.  
  1021.         {
  1022.  
  1023.           stmt_protocol ("Assignment in FORALL requires movements");
  1024.  
  1025.           t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, 1, simple,
  1026.                                      &needed, &forall_new_assigns);
  1027.  
  1028.           if (forall_new_assigns != NoTree)
  1029.              {
  1030.                ForallNewAssigns (forall_new_assigns, t->ACF_BASIC.Line);
  1031.                tree_protocol ("new assigns = \n", forall_new_assigns);
  1032.              };
  1033.           tree_protocol ("old statement becomes : \n", t);
  1034.         }
  1035.  
  1036.   }
  1037.    return;
  1038.  
  1039.   }
  1040.   }
  1041.   if (t->Kind == kACF_LIST) {
  1042.   if (t->ACF_LIST.Next->Kind == kACF_EMPTY) {
  1043. # line 730 "AdaptTemporary.puma"
  1044.   {
  1045. # line 731 "AdaptTemporary.puma"
  1046.    set_protocol_stmt (t->ACF_LIST.Elem);
  1047. # line 732 "AdaptTemporary.puma"
  1048.    AdaptTempForall (t->ACF_LIST.Elem);
  1049.   }
  1050.    return;
  1051.  
  1052.   }
  1053. # line 735 "AdaptTemporary.puma"
  1054.   {
  1055. # line 736 "AdaptTemporary.puma"
  1056.    error_protocol ("Too many Statement in FORALL");
  1057.   }
  1058.    return;
  1059.  
  1060.   }
  1061. # line 739 "AdaptTemporary.puma"
  1062.   {
  1063. # line 740 "AdaptTemporary.puma"
  1064.    error_protocol ("Illegal statements in FORALL for Temporaries");
  1065.   }
  1066.    return;
  1067.  
  1068. ;
  1069. }
  1070.  
  1071. static void ForallNewAssigns
  1072. # if defined __STDC__ | defined __cplusplus
  1073. (register tTree t, register int line)
  1074. # else
  1075. (t, line)
  1076.  register tTree t;
  1077.  register int line;
  1078. # endif
  1079. {
  1080.   if (t == NoTree) return;
  1081.   if (t->Kind == kACF_LIST) {
  1082. # line 753 "AdaptTemporary.puma"
  1083.  {
  1084.   int i;
  1085.   tTree s;
  1086.   {
  1087. # line 755 "AdaptTemporary.puma"
  1088.  
  1089. # line 756 "AdaptTemporary.puma"
  1090.  
  1091. # line 758 "AdaptTemporary.puma"
  1092.  s = t->ACF_LIST.Elem;
  1093.      s->ACF_NODE.Line = line;
  1094.      for (i=forall_loops-1; i>=0; i--)
  1095.         s = MakeOuterLoop (forall_loopnest[i], s);
  1096.      t->ACF_LIST.Elem = s;
  1097.      if (t->ACF_LIST.Next != NoTree)
  1098.         ForallNewAssigns (t->ACF_LIST.Next, line);
  1099.  
  1100.   }
  1101.    return;
  1102.  }
  1103.  
  1104.   }
  1105.   if (t->Kind == kACF_EMPTY) {
  1106. # line 768 "AdaptTemporary.puma"
  1107.    return;
  1108.  
  1109.   }
  1110. # line 771 "AdaptTemporary.puma"
  1111.   {
  1112. # line 772 "AdaptTemporary.puma"
  1113.    printf ("Internal Error in AdaptTemporary: ForallNewAssigns (line = %d\n", line);
  1114. # line 774 "AdaptTemporary.puma"
  1115.    FileUnparse (stdout, t);
  1116. # line 775 "AdaptTemporary.puma"
  1117.    kill_in_protocol ();
  1118.   }
  1119.    return;
  1120.  
  1121. ;
  1122. }
  1123.  
  1124. static tTree MakeOuterLoop
  1125. # if defined __STDC__ | defined __cplusplus
  1126. (register tTree loop, register tTree body)
  1127. # else
  1128. (loop, body)
  1129.  register tTree loop;
  1130.  register tTree body;
  1131. # endif
  1132. {
  1133. # line 786 "AdaptTemporary.puma"
  1134.  
  1135. tTree new;
  1136.  
  1137.   if (loop->Kind == kACF_FORALL) {
  1138. # line 790 "AdaptTemporary.puma"
  1139.   {
  1140. # line 791 "AdaptTemporary.puma"
  1141.  new = mACF_LIST (body, mACF_EMPTY ());
  1142.      new = mACF_FORALL (CopyTree(loop->ACF_FORALL.FORALL_ID), CopyTree(loop->ACF_FORALL.FORALL_RANGE), new);
  1143.      new->ACF_NODE.Line = loop->ACF_FORALL.Line;
  1144.      new->ACF_NODE.Label = 0;
  1145.  
  1146.   }
  1147.    return new;
  1148.  
  1149.   }
  1150.  yyAbort ("MakeOuterLoop");
  1151. }
  1152.  
  1153. static tTree AdaptTempWhereList
  1154. # if defined __STDC__ | defined __cplusplus
  1155. (register tTree t)
  1156. # else
  1157. (t)
  1158.  register tTree t;
  1159. # endif
  1160. {
  1161. # line 819 "AdaptTemporary.puma"
  1162.   {
  1163. # line 820 "AdaptTemporary.puma"
  1164.    if (! (t == NoTree)) goto yyL1;
  1165.   }
  1166.    return t;
  1167. yyL1:;
  1168.  
  1169.   if (t->Kind == kACF_LIST) {
  1170. # line 824 "AdaptTemporary.puma"
  1171.    return CombineACF (AdaptTempWhere (t->ACF_LIST.Elem), AdaptTempWhereList (t->ACF_LIST.Next));
  1172.  
  1173.   }
  1174.  yyAbort ("AdaptTempWhereList");
  1175. }
  1176.  
  1177. static tTree AdaptTempWhere
  1178. # if defined __STDC__ | defined __cplusplus
  1179. (register tTree t)
  1180. # else
  1181. (t)
  1182.  register tTree t;
  1183. # endif
  1184. {
  1185. # line 845 "AdaptTemporary.puma"
  1186.  
  1187. int count1, count2, needed, no;
  1188. bool simple;
  1189. tTree result, new_assigns;
  1190.  
  1191.   if (t->Kind == kACF_WHERE) {
  1192.   if (t->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
  1193.   if (t->ACF_WHERE.FALSE_PART->Kind == kACF_EMPTY) {
  1194. # line 851 "AdaptTemporary.puma"
  1195.    return mACF_LIST (t, NoTree);
  1196.  
  1197.   }
  1198. # line 855 "AdaptTemporary.puma"
  1199.   {
  1200. # line 859 "AdaptTemporary.puma"
  1201.    tree_error_protocol ("This call of AdaptTempWhere should not happen\n", t);
  1202.   }
  1203.    return mACF_LIST (t, NoTree);
  1204.  
  1205.   }
  1206.   if (t->ACF_WHERE.TRUE_PART->Kind == kACF_LIST) {
  1207.   if (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->Kind == kACF_BASIC) {
  1208.   if (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  1209. # line 863 "AdaptTemporary.puma"
  1210.   {
  1211. # line 867 "AdaptTemporary.puma"
  1212.    set_protocol_stmt (t);
  1213. # line 869 "AdaptTemporary.puma"
  1214.  
  1215.  
  1216.      no = 1;
  1217.      simple = true;
  1218.  
  1219.      count1 = CountMovements (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_WHERE.WHERE_EXP);
  1220.      count2 = CountMovements (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
  1221.  
  1222.      result = NoTree;
  1223.  
  1224.      if (count1 > 0)
  1225.        { stmt_protocol ("WHERE requires movement due to mask");
  1226.  
  1227.          t->ACF_WHERE.WHERE_EXP = MakeLocalExpression (t->ACF_WHERE.WHERE_EXP, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple,
  1228.                                      &needed, &new_assigns);
  1229.          no = needed + 1;
  1230.          tree_protocol ("New Asssigns : \n", new_assigns);
  1231.          stmt_protocol ("New WHERE");
  1232.  
  1233.          result = CombineACF (new_assigns, result);
  1234.        }
  1235.  
  1236.      if (count2 > 0)
  1237.        { stmt_protocol ("WHERE requires movement due to rhs of assign");
  1238.  
  1239.          t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->
  1240. ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple,
  1241.                                     &needed, &new_assigns);
  1242.          tree_protocol ("New Asssigns : \n", new_assigns);
  1243.          stmt_protocol ("New WHERE");
  1244.  
  1245.          result = CombineACF (new_assigns, result);
  1246.        }
  1247.  
  1248.      result = CombineACF (result, mACF_LIST (t, NoTree));
  1249.  
  1250.  
  1251.   }
  1252.    return result;
  1253.  
  1254.   }
  1255.   }
  1256.   }
  1257.   }
  1258.  yyAbort ("AdaptTempWhere");
  1259. }
  1260.  
  1261. static bool WhereMaskUpdate
  1262. # if defined __STDC__ | defined __cplusplus
  1263. (register tTree wherelist)
  1264. # else
  1265. (wherelist)
  1266.  register tTree wherelist;
  1267. # endif
  1268. {
  1269.   if (wherelist == NoTree) return false;
  1270. # line 920 "AdaptTemporary.puma"
  1271.   {
  1272. # line 921 "AdaptTemporary.puma"
  1273.    if (! (wherelist == NoTree)) goto yyL1;
  1274.   {
  1275. # line 922 "AdaptTemporary.puma"
  1276.    return false;
  1277.   }
  1278.   }
  1279. yyL1:;
  1280.  
  1281.   if (wherelist->Kind == kACF_LIST) {
  1282. # line 925 "AdaptTemporary.puma"
  1283.   {
  1284. # line 926 "AdaptTemporary.puma"
  1285.    if (! (wherelist->ACF_LIST.Next == NoTree)) goto yyL2;
  1286.   {
  1287. # line 927 "AdaptTemporary.puma"
  1288.    return false;
  1289.   }
  1290.   }
  1291. yyL2:;
  1292.  
  1293.   if (wherelist->ACF_LIST.Elem->Kind == kACF_WHERE) {
  1294. # line 930 "AdaptTemporary.puma"
  1295.   {
  1296. # line 931 "AdaptTemporary.puma"
  1297.    if (! (HasMaskUpdate (wherelist->ACF_LIST.Elem->ACF_WHERE.WHERE_EXP, wherelist->ACF_LIST.Elem->ACF_WHERE.TRUE_PART))) goto yyL3;
  1298.   }
  1299.    return true;
  1300. yyL3:;
  1301.  
  1302. # line 934 "AdaptTemporary.puma"
  1303.   {
  1304. # line 935 "AdaptTemporary.puma"
  1305.    if (! (HasMaskUpdate (wherelist->ACF_LIST.Elem->ACF_WHERE.WHERE_EXP, wherelist->ACF_LIST.Elem->ACF_WHERE.FALSE_PART))) goto yyL4;
  1306.   }
  1307.    return true;
  1308. yyL4:;
  1309.  
  1310. # line 938 "AdaptTemporary.puma"
  1311.   {
  1312. # line 939 "AdaptTemporary.puma"
  1313.    if (! (WhereMaskUpdate (wherelist->ACF_LIST.Next))) goto yyL5;
  1314.   }
  1315.    return true;
  1316. yyL5:;
  1317.  
  1318.   }
  1319.   }
  1320.   return false;
  1321. }
  1322.  
  1323. static bool HasMaskUpdate
  1324. # if defined __STDC__ | defined __cplusplus
  1325. (register tTree mask, register tTree stmtlist)
  1326. # else
  1327. (mask, stmtlist)
  1328.  register tTree mask;
  1329.  register tTree stmtlist;
  1330. # endif
  1331. {
  1332.   if (mask == NoTree) return false;
  1333.   if (stmtlist == NoTree) return false;
  1334.   if (stmtlist->Kind == kACF_LIST) {
  1335. # line 952 "AdaptTemporary.puma"
  1336.   {
  1337. # line 953 "AdaptTemporary.puma"
  1338.    if (! (HasMaskUpdate (mask, stmtlist->ACF_LIST.Elem))) goto yyL1;
  1339.   }
  1340.    return true;
  1341. yyL1:;
  1342.  
  1343. # line 956 "AdaptTemporary.puma"
  1344.   {
  1345. # line 957 "AdaptTemporary.puma"
  1346.    if (! (stmtlist->ACF_LIST.Next != NoTree)) goto yyL2;
  1347.   {
  1348. # line 958 "AdaptTemporary.puma"
  1349.    if (! (HasMaskUpdate (mask, stmtlist->ACF_LIST.Next))) goto yyL2;
  1350.   }
  1351.   }
  1352.    return true;
  1353. yyL2:;
  1354.  
  1355.   }
  1356.   if (stmtlist->Kind == kACF_BASIC) {
  1357.   if (stmtlist->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  1358. # line 961 "AdaptTemporary.puma"
  1359.   {
  1360. # line 962 "AdaptTemporary.puma"
  1361.    if (! (IsVarInExp (TreeVarName (stmtlist->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR), mask) == true)) goto yyL3;
  1362.   {
  1363. # line 963 "AdaptTemporary.puma"
  1364.    tree_error_protocol ("assignment updates mask : ", stmtlist->ACF_BASIC.BASIC_STMT);
  1365. # line 964 "AdaptTemporary.puma"
  1366.    tree_protocol ("mask is : ", mask);
  1367.   }
  1368.   }
  1369.    return true;
  1370. yyL3:;
  1371.  
  1372.   }
  1373.   }
  1374.   return false;
  1375. }
  1376.  
  1377. static tTree GetSplittedWhereList
  1378. # if defined __STDC__ | defined __cplusplus
  1379. (register tTree t)
  1380. # else
  1381. (t)
  1382.  register tTree t;
  1383. # endif
  1384. {
  1385.   if (t->Kind == kACF_WHERE) {
  1386.   if (t->ACF_WHERE.TRUE_PART->Kind == kACF_LIST) {
  1387. # line 979 "AdaptTemporary.puma"
  1388.  {
  1389.   tTree new_where;
  1390.   tTree help;
  1391.   {
  1392. # line 981 "AdaptTemporary.puma"
  1393.    if (! (HasWhereMovement (t->ACF_WHERE.TRUE_PART, t->ACF_WHERE.WHERE_EXP))) goto yyL1;
  1394.   {
  1395. # line 983 "AdaptTemporary.puma"
  1396.    if (! (((TreeListLength (t->ACF_WHERE.TRUE_PART->ACF_LIST.Next) > 0) || (TreeListLength (t->ACF_WHERE.FALSE_PART) > 0)))) goto yyL1;
  1397.   {
  1398. # line 987 "AdaptTemporary.puma"
  1399.  
  1400. # line 988 "AdaptTemporary.puma"
  1401.  
  1402. # line 990 "AdaptTemporary.puma"
  1403.  help = t->ACF_WHERE.TRUE_PART->ACF_LIST.Next;
  1404.      t->ACF_WHERE.TRUE_PART->ACF_LIST.Next = mACF_EMPTY();
  1405.      new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, mACF_EMPTY(), help, t->ACF_WHERE.FALSE_PART);
  1406.      new_where = GetSplittedWhereList (new_where);
  1407.  
  1408.   }
  1409.   }
  1410.   }
  1411.   {
  1412.    return CombineACF (t, new_where);
  1413.   }
  1414.  }
  1415. yyL1:;
  1416.  
  1417. # line 1001 "AdaptTemporary.puma"
  1418.  {
  1419.   tTree yyV1;
  1420.   tTree yyV2;
  1421.   tTree new_where;
  1422.   {
  1423. # line 1003 "AdaptTemporary.puma"
  1424.    ListSplitUp (t->ACF_WHERE.TRUE_PART, t->ACF_WHERE.WHERE_EXP, & yyV1, & yyV2);
  1425. # line 1005 "AdaptTemporary.puma"
  1426.    if (! (yyV2 != NoTree)) goto yyL2;
  1427.   {
  1428. # line 1007 "AdaptTemporary.puma"
  1429.  
  1430. # line 1009 "AdaptTemporary.puma"
  1431.  new_where = SplitWhere (t, yyV1, mACF_EMPTY(), yyV2, t->ACF_WHERE.FALSE_PART);
  1432.      new_where = GetSplittedWhereList (new_where);
  1433.  
  1434.   }
  1435.   }
  1436.   {
  1437.    return CombineACF (t, new_where);
  1438.   }
  1439.  }
  1440. yyL2:;
  1441.  
  1442. # line 1016 "AdaptTemporary.puma"
  1443.  {
  1444.   tTree new_where;
  1445.   {
  1446. # line 1021 "AdaptTemporary.puma"
  1447.    if (! (HasWhereMovement (t->ACF_WHERE.FALSE_PART, t->ACF_WHERE.WHERE_EXP))) goto yyL3;
  1448.   {
  1449. # line 1023 "AdaptTemporary.puma"
  1450.  
  1451. # line 1024 "AdaptTemporary.puma"
  1452.    if (! (new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, mACF_EMPTY (), mACF_EMPTY (), t->ACF_WHERE.FALSE_PART))) goto yyL3;
  1453.   {
  1454. # line 1025 "AdaptTemporary.puma"
  1455.    if (! (new_where = GetSplittedWhereList (new_where))) goto yyL3;
  1456.   }
  1457.   }
  1458.   }
  1459.   {
  1460.    return CombineACF (t, new_where);
  1461.   }
  1462.  }
  1463. yyL3:;
  1464.  
  1465.   }
  1466.   if (t->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
  1467.   if (t->ACF_WHERE.FALSE_PART->Kind == kACF_LIST) {
  1468. # line 1029 "AdaptTemporary.puma"
  1469.  {
  1470.   tTree h;
  1471.   {
  1472. # line 1033 "AdaptTemporary.puma"
  1473.  
  1474. # line 1035 "AdaptTemporary.puma"
  1475.  t->ACF_WHERE.WHERE_EXP  = MakeNotExp (t->ACF_WHERE.WHERE_EXP);
  1476.      h    = t->ACF_WHERE.FALSE_PART;
  1477.      t->ACF_WHERE.FALSE_PART   = t->ACF_WHERE.TRUE_PART;
  1478.      t->ACF_WHERE.TRUE_PART   = h;
  1479.  
  1480.   }
  1481.   {
  1482.    return GetSplittedWhereList (t);
  1483.   }
  1484.  }
  1485.  
  1486.   }
  1487.   }
  1488.   if (t->ACF_WHERE.FALSE_PART->Kind == kACF_LIST) {
  1489. # line 1044 "AdaptTemporary.puma"
  1490.  {
  1491.   tTree yyV1;
  1492.   tTree yyV2;
  1493.   tTree new_where;
  1494.   {
  1495. # line 1046 "AdaptTemporary.puma"
  1496.    ListSplitUp (t->ACF_WHERE.FALSE_PART, t->ACF_WHERE.WHERE_EXP, & yyV1, & yyV2);
  1497. # line 1048 "AdaptTemporary.puma"
  1498.    if (! (yyV2 != NoTree)) goto yyL5;
  1499.   {
  1500. # line 1050 "AdaptTemporary.puma"
  1501.  
  1502. # line 1052 "AdaptTemporary.puma"
  1503.    if (! (new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, yyV1, mACF_EMPTY (), yyV2))) goto yyL5;
  1504.   {
  1505. # line 1053 "AdaptTemporary.puma"
  1506.    if (! (new_where = GetSplittedWhereList (new_where))) goto yyL5;
  1507.   }
  1508.   }
  1509.   }
  1510.   {
  1511.    return CombineACF (t, new_where);
  1512.   }
  1513.  }
  1514. yyL5:;
  1515.  
  1516.   }
  1517. # line 1057 "AdaptTemporary.puma"
  1518.    return mACF_LIST (t, NoTree);
  1519.  
  1520.   }
  1521.  yyAbort ("GetSplittedWhereList");
  1522. }
  1523.  
  1524. static tTree SplitWhere
  1525. # if defined __STDC__ | defined __cplusplus
  1526. (register tTree wherestmt, register tTree tp1, register tTree fp1, register tTree tp2, register tTree fp2)
  1527. # else
  1528. (wherestmt, tp1, fp1, tp2, fp2)
  1529.  register tTree wherestmt;
  1530.  register tTree tp1;
  1531.  register tTree fp1;
  1532.  register tTree tp2;
  1533.  register tTree fp2;
  1534. # endif
  1535. {
  1536.   if (wherestmt->Kind == kACF_WHERE) {
  1537. # line 1082 "AdaptTemporary.puma"
  1538.  {
  1539.   tTree new_where;
  1540.   {
  1541. # line 1084 "AdaptTemporary.puma"
  1542.  
  1543. # line 1086 "AdaptTemporary.puma"
  1544.  new_where = mACF_WHERE (CopyTree(wherestmt->ACF_WHERE.WHERE_EXP), tp2, fp2);
  1545.      new_where->ACF_NODE.Label = wherestmt->ACF_WHERE.Label;
  1546.      new_where->ACF_NODE.Line  = wherestmt->ACF_WHERE.Line;
  1547.      wherestmt->ACF_WHERE.TRUE_PART = tp1;
  1548.      wherestmt->ACF_WHERE.FALSE_PART = fp1;
  1549.      NormalizeWhere (wherestmt);
  1550.      NormalizeWhere (new_where);
  1551.  
  1552.   }
  1553.   {
  1554.    return new_where;
  1555.   }
  1556.  }
  1557.  
  1558.   }
  1559.  yyAbort ("SplitWhere");
  1560. }
  1561.  
  1562. static void NormalizeWhere
  1563. # if defined __STDC__ | defined __cplusplus
  1564. (register tTree wherestmt)
  1565. # else
  1566. (wherestmt)
  1567.  register tTree wherestmt;
  1568. # endif
  1569. {
  1570.   if (wherestmt == NoTree) return;
  1571.   if (wherestmt->Kind == kACF_WHERE) {
  1572.   if (wherestmt->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
  1573.   if (wherestmt->ACF_WHERE.FALSE_PART->Kind == kACF_EMPTY) {
  1574. # line 1109 "AdaptTemporary.puma"
  1575.   {
  1576. # line 1111 "AdaptTemporary.puma"
  1577.    printf ("Empty WHERE statement will be normalized\n");
  1578. # line 1112 "AdaptTemporary.puma"
  1579.    kill_in_protocol ();
  1580.   }
  1581.    return;
  1582.  
  1583.   }
  1584. # line 1115 "AdaptTemporary.puma"
  1585.  {
  1586.   tTree h;
  1587.   {
  1588. # line 1117 "AdaptTemporary.puma"
  1589.  
  1590. # line 1119 "AdaptTemporary.puma"
  1591.  wherestmt->ACF_WHERE.WHERE_EXP = MakeNotExp (wherestmt->ACF_WHERE.WHERE_EXP);
  1592.      h   = wherestmt->ACF_WHERE.FALSE_PART;
  1593.      wherestmt->ACF_WHERE.FALSE_PART  = wherestmt->ACF_WHERE.TRUE_PART;
  1594.      wherestmt->ACF_WHERE.TRUE_PART  = h;
  1595.  
  1596.   }
  1597.    return;
  1598.  }
  1599.  
  1600.   }
  1601.   }
  1602. ;
  1603. }
  1604.  
  1605. static void ListSplitUp
  1606. # if defined __STDC__ | defined __cplusplus
  1607. (register tTree list, register tTree mask, register tTree * s1, register tTree * s2)
  1608. # else
  1609. (list, mask, s1, s2)
  1610.  register tTree list;
  1611.  register tTree mask;
  1612.  register tTree * s1;
  1613.  register tTree * s2;
  1614. # endif
  1615. {
  1616.   if (list == NoTree) return;
  1617.   if (mask == NoTree) return;
  1618.   if (list->Kind == kACF_LIST) {
  1619.   if (list->ACF_LIST.Next->Kind == kACF_EMPTY) {
  1620. # line 1141 "AdaptTemporary.puma"
  1621.    * s1 = list;
  1622.    * s2 = NoTree;
  1623.    return;
  1624.  
  1625.   }
  1626. # line 1144 "AdaptTemporary.puma"
  1627.  {
  1628.   tTree l1;
  1629.   tTree l2;
  1630.   {
  1631. # line 1146 "AdaptTemporary.puma"
  1632.    if (! (HasWhereMovement (list->ACF_LIST.Next, mask))) goto yyL2;
  1633.   {
  1634. # line 1148 "AdaptTemporary.puma"
  1635.  
  1636. # line 1149 "AdaptTemporary.puma"
  1637.  
  1638. # line 1151 "AdaptTemporary.puma"
  1639.  l2 = list->ACF_LIST.Next;
  1640.       list->ACF_LIST.Next = mACF_EMPTY ();
  1641.       l1 = list;
  1642.  
  1643.   }
  1644.   }
  1645.    * s1 = l1;
  1646.    * s2 = l2;
  1647.    return;
  1648.  }
  1649. yyL2:;
  1650.  
  1651. # line 1157 "AdaptTemporary.puma"
  1652.  {
  1653.   tTree back;
  1654.   tTree yyV1;
  1655.   tTree yyV2;
  1656.   {
  1657. # line 1159 "AdaptTemporary.puma"
  1658.  
  1659. # line 1161 "AdaptTemporary.puma"
  1660.    ListSplitUp (list->ACF_LIST.Next, mask, & yyV1, & yyV2);
  1661. # line 1163 "AdaptTemporary.puma"
  1662.  list->ACF_LIST.Next = yyV1;
  1663.       back = list;
  1664.  
  1665.   }
  1666.    * s1 = back;
  1667.    * s2 = yyV2;
  1668.    return;
  1669.  }
  1670.  
  1671.   }
  1672. ;
  1673. }
  1674.  
  1675. static bool HasWhereMovement
  1676. # if defined __STDC__ | defined __cplusplus
  1677. (register tTree stmt, register tTree where_exp)
  1678. # else
  1679. (stmt, where_exp)
  1680.  register tTree stmt;
  1681.  register tTree where_exp;
  1682. # endif
  1683. {
  1684.   if (stmt == NoTree) return false;
  1685.   if (where_exp == NoTree) return false;
  1686.   if (stmt->Kind == kACF_LIST) {
  1687. # line 1176 "AdaptTemporary.puma"
  1688.   {
  1689. # line 1177 "AdaptTemporary.puma"
  1690.    if (! (HasWhereMovement (stmt->ACF_LIST.Elem, where_exp))) goto yyL1;
  1691.   }
  1692.    return true;
  1693. yyL1:;
  1694.  
  1695.   }
  1696.   if (stmt->Kind == kACF_BASIC) {
  1697. # line 1180 "AdaptTemporary.puma"
  1698.   {
  1699. # line 1181 "AdaptTemporary.puma"
  1700.    if (! (HasWhereMovement (stmt->ACF_BASIC.BASIC_STMT, where_exp))) goto yyL2;
  1701.   }
  1702.    return true;
  1703. yyL2:;
  1704.  
  1705.   }
  1706.   if (stmt->Kind == kASSIGN_STMT) {
  1707. # line 1184 "AdaptTemporary.puma"
  1708.   {
  1709. # line 1185 "AdaptTemporary.puma"
  1710.    if (! (CountMovements (stmt->ASSIGN_STMT.ASSIGN_VAR, where_exp) > 0)) goto yyL3;
  1711.   }
  1712.    return true;
  1713. yyL3:;
  1714.  
  1715. # line 1188 "AdaptTemporary.puma"
  1716.   {
  1717. # line 1189 "AdaptTemporary.puma"
  1718.    if (! (CountMovements (stmt->ASSIGN_STMT.ASSIGN_VAR, stmt->ASSIGN_STMT.ASSIGN_EXP) > 0)) goto yyL4;
  1719.   }
  1720.    return true;
  1721. yyL4:;
  1722.  
  1723.   }
  1724.   return false;
  1725. }
  1726.  
  1727. void BeginAdaptTemporary ()
  1728. {
  1729. }
  1730.  
  1731. void CloseAdaptTemporary ()
  1732. {
  1733. }
  1734.