home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SHOWCF.C < prev    next >
Text File  |  1996-08-28  |  43KB  |  706 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   showcf.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*   Source File Display Formatting Routines                                 */
  7. /*                                                                           */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. #include "all.h"                        /* SD86 include files                */
  14.  
  15. static int iview=0;
  16.  
  17. extern uint   TopLine;
  18. extern uint   LinesPer;
  19. extern uint   NoPaint;
  20. extern uint   VideoCols;
  21. extern uchar  VideoAtr;
  22. extern uint   NActFrames;
  23. extern void*  ActLines[];
  24. extern uint   TidTab[];
  25. extern uint   ExprAddr;
  26. extern SCOPE  ExprScope;
  27. extern uint   ExprMid;
  28. extern uint   ExprLno;
  29. extern uint   ExprTid;
  30. extern uchar* ParseError;
  31. extern uchar  Reg_Display;
  32. extern UINT   FnameRow;
  33. extern UINT   MsgRow;
  34. #define MAXPOSLEN 19                    /* Size of "line xxxx of xxxx" field.*/
  35.  
  36. UINT DstatRow;                          /* data window status row.           */
  37.  
  38.  void
  39. fmtscr(AFILE *fp)
  40. {
  41.   if( !NoPaint )
  42.   {
  43.       ShowData( TopLine );
  44.       fmtfname( fp );
  45.       fmterr( NULL );
  46.   }
  47.   fmttxt( fp );
  48. }
  49. /*****************************************************************************/
  50. /*  fmtfname()                                                               */
  51. /*                                                                           */
  52. /* Description:                                                              */
  53. /*   Format the file name row of the display.                                */
  54. /*                                                                           */
  55. /* Parameters:                                                               */
  56. /*   fp        pointer to an afile structure.                                */
  57. /*                                                                           */
  58. /* Return:                                                                   */
  59. /*   void                                                                    */
  60. /*                                                                           */
  61. /* Assumptions:                                                              */
  62. /*  mid is valid else afile would not have been built at this point.         */
  63. /*                                                                           */
  64. /*                                                                           */
  65. /*****************************************************************************/
  66. #define FNAMELEN  60                    /*                                   */
  67.  void                                   /*                                   */
  68. fmtfname(AFILE *fp)                     /*                                   */
  69. {                                       /*                                   */
  70.  char     buffer[129];                  /* source filespec buffer            */
  71.  char    *bp;                           /* -> to fname row buffer            */
  72.  MFILE   *dfp;                          /* -> to debuf file info             */
  73.  int      i;
  74.  uchar   Clear[5] = { Attrib(00), RepCnt(00), ' ', 0 };
  75. /*****************************************************************************/
  76. /* We are going to build FNAMELEN characters of filename information in the  */
  77. /* following format:                                                         */
  78. /*                                                                           */
  79. /* debug filespec  <source filespec>                                         */
  80. /*                                                                           */
  81. /* If the combined fname row info exceeds FNAMELEN characters, then it is    */
  82. /* truncated to FNAMELEN. This may be inadequate for long pathnames.         */
  83. /*                                                                           */
  84. /* If the afile is for a fake module, then the filename in the afile will    */
  85. /* be the debug filespec and the source filespec will be null.               */
  86. /*                                                                           */
  87. /*****************************************************************************/
  88.  Clear[0] = Attrib( vaHelp );
  89.  Clear[1] = VideoCols - MAXPOSLEN;
  90.  VideoAtr = (uchar)vaInfo;
  91.  putrc( FnameRow, 0, Clear );
  92. #if 0
  93.  ClrScr( FnameRow, FnameRow, vaHelp );  /* clear fname row part of display   */
  94. #endif
  95.  memset(buffer,0,sizeof(buffer) );      /* init buffer to null  for later    */
  96.  if(fp->mid!=FAKEMID)                   /* concatenation.                    */
  97.  {                                      /*                                   */
  98.   dfp = fp->pdf->DebFilePtr;            /* establish pointer to file info    */
  99.   strcpy(buffer,dfp->fn);               /* put debug filespec  buffer        */
  100.   strcat(buffer," <");                  /* put in "<"                        */
  101.  }                                      /*                                   */
  102.  strncat(buffer,                        /* append the source filespec        */
  103.          fp->filename+1,                /*                                   */
  104.          fp->filename[0]                /*                                   */
  105.         );                              /*                                   */
  106.  
  107.  if(fp->mid==FAKEMID)
  108.   strcat(buffer," <>");                 /* put in ">"                        */
  109.  else
  110.   strcat(buffer,">");
  111.                                         /*                                   */
  112.  bp = buffer;                           /* point to buffer begin             */
  113.  if(strlen(buffer) > FNAMELEN )         /* if too much info then             */
  114.  {                                      /*                                   */
  115.   bp = buffer+strlen(buffer)-FNAMELEN;  /* truncate it.                      */
  116.   bp[0]='~';                            /* add truncation indicator on left  */
  117.   bp[FNAMELEN] = ' ';                                                   /*701*/
  118.   bp[FNAMELEN+1] = '\0';                                                /*701*/
  119.  }                                      /* margin.                           */
  120.  else                                                                   /*701*/
  121.  if( strlen( buffer ) < FNAMELEN )                                      /*701*/
  122.  {                                                                      /*701*/
  123.    for( i = strlen( buffer ); i <= FNAMELEN; i++ )                      /*701*/
  124.      buffer[i] = ' ';                                                   /*701*/
  125.    buffer[i] = '\0';                                                    /*701*/
  126.  }                                                                      /*701*/
  127.  putrc( FnameRow, 0, bp );              /* display it.                       */
  128. }                                       /* end fmtfname()                    */
  129.  
  130. /*****************************************************************************/
  131. /*  fmtpos()                                                                 */
  132. /*                                                                           */
  133. /* Description:                                                              */
  134. /*   format the "line xxxx of xxxx" field of the fname row.                  */
  135. /*                                                                           */
  136. /* Parameters:                                                               */
  137. /*   fp        pointer to an afile structure.                                */
  138. /*                                                                           */
  139. /* Return:                                                                   */
  140. /*   void                                                                    */
  141. /*                                                                           */
  142. /* Assumptions:                                                              */
  143. /*                                                                           */
  144. /*                                                                           */
  145. /*****************************************************************************/
  146.   /* Note:  Column number of cursor fp->skipcols + fp->csr.col + 1 */
  147.  
  148.                                         /*                                   */
  149.  void                                   /*                                   */
  150. fmtpos(AFILE *fp)                       /*                                   */
  151. {                                       /*                                   */
  152.  uint  n;                               /* # of chars formatted(field size). */
  153.  uchar buffer[ MAXPOSLEN+4 ];           /*                                   */
  154.                                         /*                                   */
  155.  if( !NoPaint )                         /*                                   */
  156.  {                                      /* Format the buffer.                */
  157.   n = sprintf( buffer,                  /*                                521*/
  158.               "%cline %u of %u",        /* Use this format                   */
  159.               Attrib(vaInfo),           /* and this attribute.               */
  160.               fp->csrline + fp->Nbias,  /* removed a +1.                  234*/
  161.               fp->Tlines                /* The number of lines in the file.  */
  162.             );                          /*                                   */
  163.   memset(buffer+n,' ',MAXPOSLEN+1-n );  /* Pad end of buffer with blanks. 100*/
  164.   buffer[ MAXPOSLEN+1 ] = 0;            /* terminate the string.             */
  165.   putrc( FnameRow,                      /* display the string.               */
  166.          FNAMELEN + 1,                  /*                                   */
  167.          buffer                         /*                                   */
  168.        );                               /*                                   */
  169.  }                                      /*                                   */
  170. }                                       /* end fmtpos()                      */
  171.  
  172.  
  173.  void
  174. fmttxt( AFILE *fp )
  175. {
  176.  uint n;
  177.  uint lno;
  178.  uint i;
  179.  uint ndigits;
  180.  uchar flag;
  181.  uchar *afline;
  182.  uchar attrs[MAXPER];
  183.  uchar digits[16];
  184.  ushort *offtab;                        /* changed to ushort.             101*/
  185.  uint limit;
  186.  uint xline;
  187.  uchar *base;
  188.  int special;
  189.  int xon;
  190.  LNOTAB *pExecLnoTabEntry;
  191.  
  192.  offtab  = fp->offtab;                  /* table of 2-byte values        100*/
  193.  limit   = fp->Nlines;
  194.  
  195.  pExecLnoTabEntry = GetExecLnoTabEntry();
  196.  xline = 0;
  197.  if( pExecLnoTabEntry )
  198.   xline = pExecLnoTabEntry->lno - fp->Nbias;
  199.  base    = fp->source;
  200.  special = 0;
  201.  xon     = -1;
  202.  
  203.     lno=fp->topline;
  204.     /*************************************************************************/
  205.     /* change lno < limit to lno <= limit.                                234*/
  206.     /*************************************************************************/
  207.     for( n=0 ; (n < LinesPer) && (lno <= limit) ; ++n, ++lno )          /*234*/
  208.     {
  209.         if( (flag = *(base + offtab[lno] - 1)) & LINE_BP )
  210.             attrs[n] = vaBptOn;
  211.         else if( flag & LINE_OK )
  212.             attrs[n] = vaBptOk;
  213.         else
  214.             attrs[n] = vaProgram;
  215.     }
  216.     fp->Nshown = n;
  217.  
  218.     if( NoPaint )
  219.         return;
  220.  
  221.     if( (fp == GetExecfp()) && ((xon = xline - fp->topline) >= 0) && (xon < (int)n) ){
  222.         if( *(base + offtab[xline] - 1) & LINE_BP ){
  223.             attrs[xon] = vaXlineOn;     /* breakpoint on exec line */
  224.             special = xon + 1;
  225.         }else
  226.             attrs[xon] = vaXline;
  227.     }
  228.  
  229.  
  230.     if(iview!=VIEW_DONT_SHOW)
  231.        putup( base,  offtab + fp->topline ,
  232.         TopLine, n, fp->skipcols, attrs );
  233.     if( n < LinesPer )
  234.         ClrScr( TopLine + n, TopLine + LinesPer - 1, vaProgram );
  235.     if( special )
  236.         if(iview!=VIEW_DONT_SHOW) putxb( TopLine + special - 1, '_' );
  237.  
  238.     HiFlat(afline) = ( ushort )fp->mid; /* higher 2-bytes                 100*/
  239.     limit = n + (lno = fp->topline + fp->Nbias);                        /*234*/
  240.     for( n=0; lno <= limit; ++n, ++lno ){                               /*234*/
  241.         LoFlat(afline) = ( ushort )lno; /* lower 2-bytes                  100*/
  242.         if( (i=IndexOfMidLnoForFrames( fp->mid, lno )) < NActFrames ){  /*107*/
  243.             if(iview!=VIEW_DONT_SHOW)
  244.             putxb( TopLine + n, ACTCALLSHADE );
  245.             ndigits = sprintf(digits, "%c (-%u)", Attrib(0), i+1) - 1;  /*521*/
  246. #if 0
  247.         DoAnnotation:
  248. #endif
  249.             putrc( TopLine + n, VideoCols - ndigits, digits );
  250.             continue; }
  251. #if 0
  252.         if( (Nthreads > 1) && (n != xon)
  253.          && ((i = lindex(ActLines, Nthreads, (ulong)afline)) < Nthreads)  ){
  254.            if(iview!=VIEW_DONT_SHOW)
  255.             putxb( TopLine + n, ACTIVESHADE );
  256.             ndigits = buffmt(digits, "%c [%u]", Attrib(0), TidTab[i]) - 1;
  257.             goto DoAnnotation;
  258.         }
  259. #endif
  260.     }
  261.     if(iview!=VIEW_DONT_SHOW) {
  262.     if(TestBit(Reg_Display,REGS386BIT)) /* if the register display flag   400*/
  263.        ShowvRegs();                     /* is set display the registers.  400*/
  264.     if(TestBit(Reg_Display,REGS387BIT)) /* if the coproregister display   401*/
  265.        ShowCoRegs();                    /* flag is set display the regs   401*/
  266.     }
  267. }
  268.  
  269.  
  270. /*****************************************************************************/
  271. /*  RefreshSrcPart()                                                      519*/
  272. /*                                                                           */
  273. /* Description:                                                              */
  274. /*   Refreshs the screen with the source view from a given row, for a        */
  275. /*   given number of rows.                                                   */
  276. /*                                                                           */
  277. /* Parameters:                                                               */
  278. /*   StartRow      - Screen Row where to start repainting.                   */
  279. /*   RowsToPaint   - Number of rows to be repainted.                         */
  280. /*   RowsToSkip    - Number of rows to be skipped.                           */
  281. /*                                                                           */
  282. /* Return:                                                                   */
  283. /*   void                                                                    */
  284. /*                                                                           */
  285. /*  Note: Logic is same as fmttxt except that it uses all passed variables   */
  286. /*        rather than global variables.                                      */
  287. /*****************************************************************************/
  288.  void                                                                   /*519*/
  289. RefreshSrcPart(AFILE *fp,int StartRow,int RowsToPaint,int RowsToSkip)   /*519*/
  290. {                                                                       /*519*/
  291.  uint n;                                                                /*519*/
  292.  uint lno;                                                              /*519*/
  293.  uchar flag;                                                            /*519*/
  294.  uchar attrs[MAXPER];                                                   /*519*/
  295.  ushort *offtab;                                                        /*519*/
  296.  uint limit;                                                            /*519*/
  297.  uint xline;                                                            /*519*/
  298.  uchar *base;                                                           /*519*/
  299.  int special;                                                           /*519*/
  300.  int xon;                                                               /*519*/
  301.  LNOTAB *pExecLnoTabEntry;
  302.                                                                         /*519*/
  303.  offtab  = fp->offtab;                                                  /*519*/
  304.  limit   = fp->Nlines;                                                  /*519*/
  305.  
  306.  pExecLnoTabEntry = GetExecLnoTabEntry();
  307.  xline = pExecLnoTabEntry->lno - fp->Nbias;
  308.  
  309.  base    = fp->source;                                                  /*519*/
  310.  special = 0;                                                           /*519*/
  311.  xon     = -1;                                                          /*519*/
  312.                                                                         /*519*/
  313.     lno = fp->topline + RowsToSkip ;                                    /*519*/
  314.     for( n=0 ; (n < RowsToPaint) && (lno <= limit) ; ++n, ++lno )       /*519*/
  315.     {                                                                   /*519*/
  316.         if ( (flag = *(base + offtab[lno] - 1)) & LINE_BP )             /*519*/
  317.            attrs[n] = vaBptOn;                                          /*519*/
  318.         else                                                            /*519*/
  319.            if ( flag & LINE_OK )                                        /*519*/
  320.               attrs[n] = vaBptOk;                                       /*519*/
  321.            else                                                         /*519*/
  322.               attrs[n] = vaProgram;                                     /*519*/
  323.     }                                                                   /*519*/
  324.                                                                         /*519*/
  325.     xon = xline - fp->topline - RowsToSkip;                             /*519*/
  326.     if ( (fp == GetExecfp()) && ( (xon >= 0) && (xon < (int)n) ) )      /*519*/
  327.     {                                                                   /*519*/
  328.        if ( *(base + offtab[xline] - 1) & LINE_BP )                     /*519*/
  329.        {                                                                /*519*/
  330.           attrs[xon] = vaXlineOn;                                       /*519*/
  331.           special = xon + 1;                                            /*519*/
  332.        }                                                                /*519*/
  333.        else                                                             /*519*/
  334.           attrs[xon] = vaXline;                                         /*519*/
  335.     }                                                                   /*519*/
  336.     if(iview!=VIEW_DONT_SHOW)                                           /*519*/
  337.     putup( base, offtab + fp->topline + RowsToSkip,                     /*519*/
  338.         StartRow, n, fp->skipcols, attrs);                              /*519*/
  339.                                                                         /*519*/
  340.     if( n < RowsToPaint)                                                /*519*/
  341.         ClrScr( StartRow + n, StartRow + RowsToPaint - 1, vaProgram );  /*519*/
  342.                                                                         /*519*/
  343.     if( special )                                                       /*519*/
  344.         if(iview!=VIEW_DONT_SHOW)
  345.         putxb( StartRow + special - 1, '_' );                           /*519*/
  346.                                                                         /*519*/
  347.     if(iview!=VIEW_DONT_SHOW) {
  348.     if(TestBit(Reg_Display,REGS386BIT)) /* if the register display flag   519*/
  349.        ShowvRegs();                     /* is set display the registers.  519*/
  350.     if(TestBit(Reg_Display,REGS387BIT)) /* if the coproregister display   519*/
  351.        ShowCoRegs();                    /* flag is set display the regs   519*/
  352.     }
  353. }                                                                       /*519*/
  354.  
  355.     AFILE *
  356. locatefp(uchar *lp,uint col)
  357. {
  358.     AFILE *fp = NULL;
  359.     uchar symbol[ MAXSYM+1 ];
  360.  
  361.  
  362.     if( !token(lp, col, symbol) )
  363.         fmterr( "Cursor must be on a function name");
  364.     else if( !(fp = FindFuncOrAddr(symbol,FALSE) ) )
  365.         fmt2err( "Can't find", symbol );
  366.     return( fp );
  367. }
  368.  
  369. /*****************************************************************************/
  370. /*  token()                                                                  */
  371. /*                                                                           */
  372. /* Description:                                                              */
  373. /*   display a variable.                                                     */
  374. /*                                                                           */
  375. /* Parameters:                                                               */
  376. /*   lp        input - pointer to block of text with the text line.          */
  377. /*   col       input - column were the token begins.                         */
  378. /*   tp        output- buffer where this routine stuffs the token.           */
  379. /*                                                                           */
  380. /* Return:                                                                   */
  381. /*             number of characters in the token                             */
  382. /*                                                                           */
  383. /* Assumptions:                                                              */
  384. /*                                                                           */
  385. /*                                                                           */
  386. /*****************************************************************************/
  387.  uint
  388. token(uchar *lp,uint col,uchar *tp)     /* start of text line                */
  389.                                         /* line offset to 1st char           */
  390.                                         /* buffer for token                  */
  391. {
  392.  uchar *cp;
  393.  uchar *op;
  394.  uint   n;                              /* an index                          */
  395.  uchar  line[MAXCOLS+1];                /* extracted line                    */
  396.  
  397.  
  398. /*****************************************************************************/
  399. /* The first thing we do here is extract the real text line from the raw     */
  400. /* piece of source buffer passed.                                            */
  401. /*                                                                           */
  402. /*****************************************************************************/
  403.  n=Decode(lp,line);                     /* extract the text line from the    */
  404.                                         /* source buffer. n=# chars in line. */
  405.  line[n]=0;                             /* make this line a Z string.        */
  406.  
  407. /*****************************************************************************/
  408. /* The line is scanned backwards from the start of the token and the token   */
  409. /* pointer is backed up to the first non valid character. This will be n=0   */
  410. /* if the token starts at the beginning of a line, else it will be one.      */
  411. /*                                                                           */
  412. /* I don't know why this code is necessary!!!!                               */
  413. /*****************************************************************************/
  414.  for( n=0, cp = line + col;             /* scan the line backwards           */
  415.       ;                                 /*                                   */
  416.       --cp                              /*                                   */
  417.     )                                   /*                                   */
  418.  {                                      /*                                   */
  419.   if( !IsOKchar(*cp) )                  /* if this is an invalid character,  */
  420.       break;                            /* then quit.                        */
  421.   if( cp == line )                      /*                                   */
  422.   {                                     /* if at line begin, then            */
  423.       n = 0;                            /*                                   */
  424.       break;                            /* we won't back up any chars and    */
  425.   }                                     /* quit.                             */
  426.   n = 1;                                /* backed up one char                */
  427.  }                                      /*                                   */
  428.                                         /*                                   */
  429. /*****************************************************************************/
  430. /* Here we copy the token from the line buffer to the callers buffer and tell*/
  431. /* him how many chars we copied.                                             */
  432. /*                                                                           */
  433. /*                                                                           */
  434. /*****************************************************************************/
  435.  for( op = tp, cp += n;                 /* initialize line and caller buffers*/
  436.       IsOKchar(*cp) &&                  /* stay in loop til end of token or  */
  437.       (tp - op) < MAXSYM;               /* we exceed max token length.       */
  438.     )                                   /*                                   */
  439.  {                                      /*                                   */
  440.   if( *cp == 0x15 )                     /* map  to @ for the italians.      */
  441.    *cp = '@';                           /*                                   */
  442.   *tp++ = *cp++;                        /* copy ok char to caller buf & bump */
  443.  }                                      /*                                   */
  444.  *tp = 0;                               /* make Z string out of token        */
  445.                                         /*                                   */
  446.  return( tp - op );                     /* # of chars in token (0..N)        */
  447. }                                       /* end token()                       */
  448. /*****************************************************************************/
  449. /*  dumpvar()                                                                */
  450. /*                                                                           */
  451. /* Description:                                                              */
  452. /*   display a variable.                                                     */
  453. /*                                                                           */
  454. /* Parameters:                                                               */
  455. /*   fp        the afile for this variable.                                  */
  456. /*   lp        the start of the text line.                                   */
  457. /*   line      source file line number.                                      */
  458. /*   col       source file column.                                           */
  459. /*   func      show variable or show what the variable points to selector.   */
  460. /*               SHOWVAR          = show the contents of a variable          */
  461. /*               SHOWVARPTSTO     = show contents var points to              */
  462. /*               PUTVARINSTG      = put a variable in the storage win        */
  463. /*               PUTVARPTSTOINSTG = put what variable points to in stg       */
  464. /*                                                                           */
  465. /* Return:                                                                   */
  466. /*                                                                           */
  467. /*   dfp                                                                     */
  468. /*                                                                           */
  469. /* Assumptions:                                                              */
  470. /*                                                                           */
  471. /*                                                                           */
  472. /*****************************************************************************/
  473. DFILE * dumpvar(AFILE *fp,
  474.                 UCHAR *lp,
  475.                 UINT   line,
  476.                 UINT   col,
  477.                 UINT   func,
  478.                 AFILE **fpp)
  479. {
  480.  DFILE  d;                              /* a DFILE to put the variable in    */
  481.  DFILE *dfp;                            /* appended dfile node.              */
  482.  uint   deref;                          /* 0=variable value                  */
  483.                                         /* 1=show what variable points to    */
  484.  uint   sfx;                            /* stack frame index for stack vars  */
  485.  uchar *cp;                             /*                                   */
  486.  uchar  symbol[MAXSYM+4];               /*                                   */
  487.  uchar  buffer[MAXSYM+25];              /*                                   */
  488.  uint   nchars;                         /* number of chars in token          */
  489.  uchar *procname;                       /* procedure name                    */
  490.  int    rcshower;                       /* return code from the shower.      */
  491.  int    n;                              /* just an integer.                  */
  492.  uint   rc;                             /* a return code.                    */
  493.  AFILE  *newfp;
  494.  
  495. /*****************************************************************************/
  496. /* The first thing to do is determine whether the user wants to show the     */
  497. /* variable or what the variable points to.                                  */
  498. /*                                                                           */
  499. /*****************************************************************************/
  500.  deref=0;                               /* assume values to be displayed     */
  501.  symbol[0]=' ';                         /*                                   */
  502.  if ( func == SHOWVARPTSTO ||           /* if user asked for "*" then        */
  503.       func == PUTVARPTSTOINSTG          /*                                   */
  504.     )                                   /*                                   */
  505.  {                                      /*                                   */
  506.   deref=1;                              /* set a flag and prefix the symbol  */
  507.   symbol[0] = '*';                      /* with "contents of" operator       */
  508.  }                                      /*                                   */
  509. /*****************************************************************************/
  510. /* Now we have to tokenize what the cursor points to and verify that it is   */
  511. /* a valid identifier. Then we verify that the identifier is a variable.     */
  512. /*                                                                           */
  513. /*****************************************************************************/
  514.  nchars=token(lp, col, symbol+deref);   /* Tokenize.                         */
  515.  if(nchars == 0 )
  516.  {
  517.   symbol[0] = 't';
  518.   symbol[1] = 'h';
  519.   symbol[2] = 'i';
  520.   symbol[3] = 's';
  521.   symbol[4] = '\0';
  522.  }
  523. #if 0
  524.  if(!nchars)                            /* If not a valid token, then        */
  525.  {                                      /*                                   */
  526.   fmterr("Cursor must be on a variable name");  /*                        701*/
  527.   return(NULL);                         /* return with bad name.             */
  528.  }                                      /*                                   */
  529. #endif
  530.  cp=ParseExpr(symbol, 0x10, fp->mid, line, fp->sfi);
  531.  
  532.  if( !cp || *cp )                       /* If it's not a variable we know    */
  533.  {                                      /*                                   */
  534.   fmterr(ParseError);                   /* return error in parse expressio   */
  535.   return(NULL);                         /*                                   */
  536.  }                                      /*                                   */
  537.                                         /*                                   */
  538.  fmterr( "");                           /* proceed with good variable name   */
  539. /*****************************************************************************/
  540. /* At this point ExprScope has been established by ParseExpr(). ExprScope    */
  541. /* points to the SSproc record in the symbols area for the function that     */
  542. /* contains the variable. sfx is the index of the stack frame that contains  */
  543. /* the variable. If the variable is not in an active stack frame, then       */
  544. /* sfx=0. ExprScope not NULL implies a stack variable.                       */
  545. /*                                                                           */
  546. /*****************************************************************************/
  547.  sfx=StackFrameIndex(ExprScope);        /* Get sfx for this variable.        */
  548.  if( ExprScope && !sfx )                /* If stack variable but not active, */
  549.  {                                      /*                                   */
  550.   procname=CopyProcName(ExprScope,      /* then copy function name over the  */
  551.                         symbol,         /* symbol name buffer and            */
  552.                         sizeof(symbol)  /*                                   */
  553.                        );               /*                                   */
  554.                                         /*                                   */
  555.   sprintf( buffer,                      /* build a  "function not active" 521*/
  556.           "\"%s\" not active",          /* message.                          */
  557.           procname);                    /*                                   */
  558.                                         /*                                   */
  559.   fmterr( buffer );                     /* format the error for later display*/
  560.   return(NULL);                         /* ret null if func is not active 300*/
  561.  }                                      /*                                   */
  562.  else                                   /*                                   */
  563.  {                                      /*                                   */
  564. /*****************************************************************************/
  565. /* At this point, the symbol is a one that we know about, and if it's a      */
  566. /* stack variable, then it's in an active stack frame. So, now we build a    */
  567. /* DFILE structure for it.                                                   */
  568. /*                                                                           */
  569. /*****************************************************************************/
  570.   memset( &d, 0, sizeof(d) );           /* clear the DFILE structure.     100*/
  571.                                         /* now add structure members:        */
  572.   memcpy( d.expr,symbol,sizeof(d.expr) );/*    symbol name in the expr fld100*/
  573.   d.mid = ExprMid;                      /*     mid containing the symbol     */
  574.   d.lno = ExprLno;                      /*     line number symbol is on      */
  575.   d.sfi = fp->sfi;                      /*     line number symbol is on      */
  576.   d.sfx = sfx;                          /*     stack frame index             */
  577.   d.scope = ExprScope;                  /*     scope if stack variable       */
  578.   d.datatype = ExprTid;                                              /*813512*/
  579.  
  580.   {
  581.    Trec        *tp;
  582.    TD_TYPELIST *pClassItemList;
  583.    USHORT       FirstItemInList;
  584.    USHORT       ItemListIndex;
  585.  
  586.    tp = (Trec *)QtypeRec(ExprMid, ExprTid );
  587.    if( tp && (tp->RecType == T_CLASS) )
  588.    {
  589.     ItemListIndex    = ((TD_CLASS*)tp)->ItemListIndex;
  590.     pClassItemList   = (TD_TYPELIST*)QtypeRec(ExprMid, ItemListIndex);
  591.     FirstItemInList  = pClassItemList->TypeIndex[0];
  592.     if( FirstItemInList == 0 )
  593.      d.DfpFlags.ClassType = DFP_BASE_CLASS;
  594.     else
  595.      d.DfpFlags.ClassType = DFP_DERIVED_CLASS;
  596.    }
  597.   }
  598.                                         /* Get primitive typeno in case   512*/
  599.                                         /* of primitive user defs.        512*/
  600.   d.baseaddr = ExprAddr;                /*     base address for data block.  */
  601.   SetShowType( &d, d.datatype );        /*     "show" function pointer.      */
  602.   n = SetShowLines( &d );               /* set num of node display lines.    */
  603.  
  604.   if (n == 0)                           /* if length of data = 0          223*/
  605.    {                                    /* search for symbol in globals   223*/
  606.     cp=ParseExpr(symbol, 0x20, fp->mid, line, fp->sfi);
  607.     d.datatype = ExprTid;                                            /*813512*/
  608.                                         /* Get primitive typeno in case   512*/
  609.                                         /* of primitive user defs.        512*/
  610.     d.mid = ExprMid;                    /* and mid containing the global  223*/
  611.     SetShowType( &d, d.datatype );      /* sym."show" function pointer.   223*/
  612.     n = SetShowLines( &d );             /* set num of node display lines. 223*/
  613.    }
  614.  
  615.   if( func == PUTVARINSTG ||            /* if the variable is destined for   */
  616.       func == PUTVARPTSTOINSTG          /* the storage window, then          */
  617.     )                                   /*                                   */
  618.   {                                     /*                                   */
  619.    dfp=AppendDataFile( &d );            /* append to the data file.          */
  620.    return( dfp );                       /* returndone.                       */
  621.   }                                     /*                                   */
  622. /*****************************************************************************/
  623. /* if func = SHOWVAR || SHOWVARPTSTO then we will display the data as we     */
  624. /* always did on the message line.                                           */
  625. /*                                                                           */
  626. /*****************************************************************************/
  627.   if( func == SHOWVAR ||                /* if the variable is destined for   */
  628.       func == SHOWVARPTSTO              /* message line, then                */
  629.     )                                   /*                                   */
  630.   {                                     /*                                   */
  631.    rcshower=(* d.shower)(&d,            /*  show the data and                */
  632.                          MsgRow,        /*  overlay the message row.         */
  633.                          1,             /*  show one data record.            */
  634.                          0              /*  don't skip any records.          */
  635.                         );              /*                                   */
  636.                                         /*                                   */
  637.    if( rcshower == FALSE )              /*  if can't show then beep          */
  638.     beep();                             /*                                   */
  639.   }
  640. #if 0
  641.   else if( func == MSHGET )             /* if the variable is destined for   */
  642.   {                                     /*                                   */
  643.    rcshower=(* d.finder)(&d,NULL,       /*  show the data and                */
  644.                          NULL);         /*  NULL => mshput_direct.           */
  645.                                         /*                                   */
  646.    if( rcshower == FALSE )              /*  if can't show then beep          */
  647.     beep();                             /*                                   */
  648.   }
  649.   else if( func == MSHPUT )             /* if the variable is destined for   */
  650.   {                                     /*                                   */
  651.    extern uchar       Re_Parse_Data;    /* flag to indicate wether all    244*/
  652.    rcshower=(* d.finder)(&d,NULL,       /*  show the data and                */
  653.              (MSHOBJECT *)-1);          /*  -1   => mshget_direct.           */
  654.    {                                                               /*903*/
  655.     extern int DataRecalc;                                         /*903*/
  656.     extern uchar       Re_Parse_Data;
  657.                                                                    /*903*/
  658.     DataRecalc = TRUE;                                             /*903*/
  659.     Re_Parse_Data=TRUE;                 /*                                   */
  660.    }                                                               /*903*/
  661.    Re_Parse_Data=TRUE;                  /*                                   */
  662.    if( rcshower == FALSE )              /*  if can't show then beep          */
  663.     beep();                             /*                                   */
  664.   }
  665. #endif
  666. /********************************************c********************************/
  667. /* if func = EXPANDVAR then we will display it in the expnsion window        */
  668. /* without putting in the data file ring.  In this scenario the parent node  */
  669. /* (dfp) is the node that we have built on the stack.                        */
  670. /*                                                                           */
  671. /*****************************************************************************/
  672.   dfp = &d;                             /* define -> to temporary parent node*/
  673.   if( func == EXPANDVAR                 /* if the variable is going to the   */
  674.     )                                   /* expansion window then ...         */
  675.   {                                     /*                                   */
  676.  
  677. #ifdef MSH
  678.    VideoBuffer *videoBuffer=SaveVideoBuffer();
  679. #endif
  680.  
  681.    DstatRow = TopLine;                  /* establish status line (0..N).     */
  682.    newfp = NULL;
  683.    rc=zoomrec( fp, dfp, 0, &newfp );
  684.    if( newfp )
  685.    {
  686.     *fpp = newfp;
  687.     return(0);
  688.    }
  689.    if(rc && rc!=ESC)                    /* back all the way out on ESC.      */
  690.    {                                    /*                                   */
  691.     beep();                             /*                                   */
  692.     putmsg("can't expand this data");   /*                                   */
  693.    }                                    /*                                   */
  694.    dovscr( fp, 0 );                     /* refresh source part of the screen.*/
  695. #ifdef MSH
  696. #if 0
  697.    dovscr( fp, 0 );                     /* refresh source part of the screen.*/
  698. #else
  699.    RestoreVideoBuffer(videoBuffer);
  700. #endif
  701. #endif
  702.   }                                     /*                                   */
  703.  }                                      /*                                   */
  704.  return(NULL);                          /* keep the compiler happy.          */
  705. }                                       /* end dumpvar()                     */
  706.