home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d110 / pdc.lha / Pdc / src / List.c < prev    next >
C/C++ Source or Header  |  1987-10-28  |  4KB  |  146 lines

  1. #include        <stdio.h>
  2. #include        "c.h"
  3. #include        "expr.h"
  4. #include        "gen.h"
  5. #include        "cglbdec.h"
  6.  
  7. /*
  8.  *68000 C compiler
  9.  *
  10.  *Copyright 1984, 1985, 1986 Matthew Brandt.
  11.  *  all commercial rights reserved.
  12.  *
  13.  *This compiler is intended as an instructive tool for personal use. Any
  14.  *use for profit without the written consent of the author is prohibited.
  15.  *
  16.  *This compiler may be distributed freely for non-commercial use as long
  17.  *as this notice stays intact. Please forward any enhancements or questions
  18.  *to:
  19.  *
  20.  *Matthew Brandt
  21.  *Box 920337
  22.  *Norcross, Ga 30092
  23.  */
  24.  
  25. put_sc(scl)
  26. enum e_sc    scl;
  27. {       switch(scl) {
  28.                 case sc_static:
  29.                         fprintf(list,"Static      ");
  30.                         break;
  31.                 case sc_auto:
  32.                         fprintf(list,"Auto        ");
  33.                         break;
  34.                 case sc_global:
  35.                         fprintf(list,"Global      ");
  36.                         break;
  37.                 case sc_external:
  38.                         fprintf(list,"External    ");
  39.                         break;
  40.                 case sc_type:
  41.                         fprintf(list,"Type        ");
  42.                         break;
  43.                 case sc_const:
  44.                         fprintf(list,"Constant    ");
  45.                         break;
  46.                 case sc_member:
  47.                         fprintf(list,"Member      ");
  48.                         break;
  49.                 case sc_label:
  50.                         fprintf(list,"Label");
  51.                         break;
  52.                 case sc_ulabel:
  53.                         fprintf(list,"Undefined label");
  54.                         break;
  55.                 }
  56. }
  57.  
  58. put_ty(tp)
  59. TYP     *tp;
  60. {       if(tp == 0)
  61.                 return;
  62.         switch(tp->type) {
  63.                 case bt_char:
  64.                         fprintf(list,"Char");
  65.                         break;
  66.                 case bt_short:
  67.                         fprintf(list,"Short");
  68.                         break;
  69.                 case bt_enum:
  70.                         fprintf(list,"enum ");
  71.                         goto ucont;
  72.                 case bt_long:
  73.                         fprintf(list,"Long");
  74.                         break;
  75.                 case bt_unsigned:
  76.                         fprintf(list,"unsigned long");
  77.                         break;
  78.                 case bt_float:
  79.                         fprintf(list,"Float");
  80.                         break;
  81.                 case bt_double:
  82.                         fprintf(list,"Double");
  83.                         break;
  84.                 case bt_pointer:
  85.                         if( tp->val_flag == 0)
  86.                                 fprintf(list,"Pointer to ");
  87.                         else
  88.                                 fprintf(list,"Array of ");
  89.                         put_ty(tp->btp);
  90.                         break;
  91.                 case bt_union:
  92.                         fprintf(list,"union ");
  93.                         goto ucont;
  94.                 case bt_struct:
  95.                         fprintf(list,"struct ");
  96. ucont:                  if(tp->sname == 0)
  97.                                 fprintf(list,"<no name> ");
  98.                         else
  99.                                 fprintf(list,"%s ",tp->sname);
  100.                         break;
  101.                 case bt_ifunc:
  102.                 case bt_func:
  103.                         fprintf(list,"Function returning ");
  104.                         put_ty(tp->btp);
  105.                         break;
  106.                 }
  107. }
  108.  
  109. list_var(sp,i)
  110. SYM     *sp;
  111. int     i;
  112. {       int     j;
  113.  
  114.         if ( Options.List )
  115.       {
  116.              for(j = i; j; --j)
  117.                 fprintf(list,"    ");
  118.              fprintf(list,"%-10s = %8ld ",sp->name,sp->value.u);
  119.              put_sc(sp->storage_class);
  120.              put_ty(sp->tp);
  121.              fprintf(list,"\n");
  122.       }
  123.         if( sp->storage_class == sc_external)
  124.                 fprintf(output,"\tXREF\t_%s\n",sp->name);
  125.         else if( sp->storage_class == sc_global )
  126.                 fprintf(output,"\tXDEF\t_%s\n",sp->name);
  127.         if(sp->tp == 0)
  128.                 return;
  129.         if((sp->tp->type == bt_struct || sp->tp->type == bt_union) &&
  130.                 sp->storage_class == sc_type)
  131.                 list_table(&(sp->tp->lst),i+1);
  132. }
  133.  
  134. list_table(t,i)
  135. TABLE   *t;
  136. int     i;
  137. {       SYM     *sp;
  138.         sp = t->head;
  139.         while(sp != NULL) {
  140.                 list_var(sp,i);
  141.                 sp = sp->next;
  142.                 }
  143. }
  144.  
  145.  
  146.