home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / p_debug.c < prev    next >
C/C++ Source or Header  |  1993-01-19  |  2KB  |  119 lines

  1. /* ---------------------------------------------------------------------- */
  2. /*                   Copyright (C) 1992 by Natürlich!                     */
  3. /*                      This file is copyrighted!                         */
  4. /*                Refer to the documentation for details.                 */
  5. /* ---------------------------------------------------------------------- */
  6. #include <stdio.h>
  7. #include <setjmp.h>
  8. #include "defines.h"
  9. #include "nasm.h"
  10. #include "debug.h"
  11. #include "labels.h"
  12. #define  KEINE_CODE_INNEREIEN
  13. #include "code.h"
  14. #include "fix.h"
  15. #include "exprfast.h"
  16. #include "op.h"
  17. #include "ldebug.h"
  18.  
  19. extern label huge *h_global[SEP], huge *t_global[SEP], huge *l_global;
  20. #if ! LINKER
  21. extern label huge *h_local[SEP],  huge *t_local[SEP],  huge *l_local,
  22.              huge *h_macro[SEP],  huge *t_macro[SEP],  huge *l_macro;
  23. #endif
  24.  
  25. jmp_buf  escape;
  26.  
  27. #if ! VERSION
  28. static   check_imm( p)
  29. imm huge *p;
  30. {
  31.    if( p)
  32.    {
  33.       POINTER_CHECK( p);
  34.       POINTER_CHECK( p->block);
  35.    }
  36. }
  37.  
  38.  
  39. static   check_fix( p)
  40. fix huge *p;
  41. {
  42.    POINTER_CHECK( p);
  43.    check_imm( p->imm);
  44.    POINTER_CHECK( p->poof.label);
  45. }
  46.  
  47.  
  48. #define SUSPICIOUS   8
  49.  
  50. static   _check_expr( p, depth)
  51. expr huge   *p;
  52. {
  53.    if( p)
  54.    {
  55.       if( ++depth == SUSPICIOUS)
  56.       {
  57.          nwarning("Suspicious recursion depth");
  58.          longjmp( escape, 1);
  59.       }         
  60.       POINTER_CHECK( p);
  61.       _check_expr( p->l, depth);
  62.       _check_expr( p->r, depth);
  63.    }
  64. }
  65.  
  66.  
  67. static   check_expr( p)
  68. expr huge   *p;
  69. {
  70.    if( p)
  71.    {
  72.       while( ! p->fix)
  73.          p = p->zonk.t;
  74.       _check_expr( p, 0);
  75.       check_fix( p->zonk.fixp);
  76.    }
  77. }
  78.  
  79.  
  80. static label   *this_label;
  81.  
  82. check_label( p)
  83. label huge  *p;
  84. {
  85.    ref huge  *r;
  86.  
  87.    if( ! setjmp( escape))
  88.    {
  89.       this_label = p;
  90.       POINTER_CHECK( p);
  91.       POINTER_CHECK( p->before);
  92.       POINTER_CHECK( p->name);
  93.       for( r = p->refs; r; r = r->next)
  94.          check_expr( r->ref);
  95.    }         
  96. }
  97.  
  98.  
  99. void check_trees()
  100. {
  101.    label huge  *p;
  102.    int         i;
  103.  
  104.    for( i = 0; i != SEP; i++)
  105.       for( p = h_global[ i]; p; p = p->next)
  106.         check_label( p);
  107.  
  108. # if ! LINKER
  109.    for( i = 0; i != SEP; i++)
  110.       for( p = h_local[ i]; p; p = p->next)
  111.          check_label( p);
  112.  
  113.    for( i = 0; i != SEP; i++)
  114.       for( p = h_global[ i]; p; p = p->next)
  115.          check_label( p);
  116. # endif
  117. }
  118. #endif
  119.