home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Tex / Tex29 / StTeXsrc.zoo / src / evalstack.c < prev    next >
C/C++ Source or Header  |  1988-03-13  |  4KB  |  178 lines

  1.  
  2. /*
  3.  * @(#)evalstack.c 2.5 EPA
  4.  *
  5.  * Copyright 1987,1988 Pat J Monardo
  6.  *
  7.  * Redistribution of this file is permitted through
  8.  * the specifications in the file COPYING.
  9.  *
  10.  * 
  11.  */
  12.  
  13. #include "tex.h"
  14. #include "box.h"
  15. #include "page.h"
  16. #include "tokenstack.h"
  17. #include "evalstack.h"
  18.  
  19. list    cur_list;
  20. list    nest[NEST_SIZE];
  21. ptr     nest_ptr;
  22. int     max_nest_stack;
  23. int     shown_mode;
  24.  
  25. push_nest ()
  26. {
  27.     if (nest_ptr > max_nest_stack) {
  28.         max_nest_stack = nest_ptr;
  29.         if (nest_ptr == NEST_SIZE)
  30.             overflow("semantic nest size", NEST_SIZE);
  31.     }
  32.     nest[nest_ptr] = cur_list;
  33.     incr(nest_ptr);
  34.     head = get_avail();
  35.     tail = head;
  36.     prev_graf = 0;
  37.     mode_line = line;
  38. }
  39.  
  40. pop_nest ()
  41. {
  42.     free_avail(head);
  43.     decr(nest_ptr);
  44.     cur_list = nest[nest_ptr];
  45. }
  46.  
  47. print_mode (m)
  48.     int     m;
  49. {
  50.     if (m > 0) {
  51.         switch (m / (MAX_COMMAND + 1))
  52.         {
  53.         case 0:
  54.             print("vertical");
  55.             break;
  56.  
  57.         case 1:
  58.             print("horizontal");
  59.             break;
  60.  
  61.         case 2:
  62.             print("display math");
  63.             break;
  64.         }
  65.     } else if (m == 0)
  66.         print("no");
  67.      else { 
  68.         switch (-m / (MAX_COMMAND + 1)) 
  69.         {
  70.         case 0:
  71.             print("internal vertical");
  72.             break;
  73.  
  74.         case 1:
  75.             print("restricted horizontal");
  76.             break;
  77.  
  78.         case 2: 
  79.             print("math");
  80.             break;
  81.         }
  82.     }
  83.     print(" mode");
  84. }
  85.  
  86. show_activities ()
  87. {
  88.     val     a;
  89.     int     p;
  90.     int     m;
  91.     ptr     q;
  92.     ptr     r;
  93.     val     t;
  94.  
  95.     nest[nest_ptr] = cur_list;
  96.     print_nl("");
  97.     print_ln();
  98.     for (p = nest_ptr; p >= 0; decr(p)) {
  99.         m = nest[p].mode_field;
  100.         a = nest[p].aux_field;
  101.         print_nl("### ");
  102.         print_mode(m);
  103.         print(" entered at line ");
  104.         print_val(abs(nest[p].ml_field));
  105.         if (nest[p].ml_field < 0)
  106.             print(" (\\output routine)");
  107.         if (p == 0) {
  108.             if (page_head != page_tail) {
  109.                 print_nl("### current page:");
  110.                 if (output_active)
  111.                     print(" (held over for next output)");
  112.                 show_box(link(page_head));
  113.                 if (page_contents > EMPTY) {
  114.                     print_nl("total height ");
  115.                     print_totals();
  116.                     print_nl(" goal height ");
  117.                     print_scaled(page_goal);
  118.                     r = link(page_ins_head);
  119.                     while (r != page_ins_head) {
  120.                         print_ln();
  121.                         print_esc("insert");
  122.                         t = qo(subtype(r));
  123.                         print_int((int) t);
  124.                         print(" adds ");
  125.                         t = x_over_n(height(r), 1000L) * count(t);
  126.                         print_scaled((scal) t);
  127.                         if (type(r) == SPLIT_UP) {
  128.                             q = page_head;
  129.                             t = 0;
  130.                             do  {
  131.                                 q = link(q);
  132.                                 if (type(q) == INS_NODE && 
  133.                                     subtype(q) == subtype(r))
  134.                                     incr(t);
  135.                             } while (q != broken_ins(r));
  136.                             print(", #");
  137.                             print_int((int) t);
  138.                             print(" might split");
  139.                         }
  140.                         r = link(r);
  141.                     }
  142.                 }
  143.             }
  144.             if (link(contrib_head) != NULL)
  145.                 print_nl("### recent contributions:");
  146.         }
  147.         show_box(link(nest[p].head_field)); 
  148.         switch (abs(m) / (MAX_COMMAND + 1))
  149.         {
  150.         case 0:
  151.             print_nl("prevdepth ");
  152.             if (a <= IGNORE_DEPTH)
  153.                 print("ignored");
  154.             else print_scaled((scal) a);
  155.             if (nest[p].pg_field != 0) {
  156.                 print(", prevgraf ");
  157.                 print_int(nest[p].pg_field);
  158.                 print(" line");
  159.                 if (nest[p].pg_field != 1)
  160.                     print_char('s');
  161.             }
  162.             break;
  163.  
  164.         case 1:
  165.             print_nl("spacefactor ");
  166.             print_int((int) a);
  167.             break;
  168.  
  169.         case 2:
  170.             if (a != NULL) {
  171.                 print_nl("this will be denominator of:");
  172.                 show_box((ptr) a);
  173.             }
  174.             break;
  175.         }
  176.     }
  177. }
  178.