l_state.str 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. /* Lint state stack */
  7. /* These datastructures are used to implement a stack on which the
  8. * state of automatic variables (including register variables) is
  9. * kept.
  10. * In this way it is possible to account for the flow of
  11. * control of the program.
  12. */
  13. #define TEST_VAR 0 /* not a constant */
  14. #define TEST_TRUE 1 /* always true */
  15. #define TEST_FALSE 2 /* always false */
  16. struct loop_state { /* used in lint_end_state only */
  17. int lps_test; /* is the test a constant? */
  18. struct state *lps_body;
  19. struct state *lps_loop;
  20. };
  21. struct switch_state { /* used in lint_end_state only */
  22. struct state *sws_case;
  23. struct state *sws_break;
  24. int sws_default_met;
  25. };
  26. /* This union describes the (possibly incomplete) state at the end of the
  27. mentioned construct.
  28. */
  29. union lint_end_state { /* used in lint_stack_entry only */
  30. struct state *ule_if;
  31. struct loop_state ule_loop;
  32. struct switch_state ule_switch;
  33. };
  34. struct lint_stack_entry {
  35. struct lint_stack_entry *next;
  36. struct lint_stack_entry *ls_previous;
  37. int ls_level;
  38. struct state *ls_current; /* used by all classes */
  39. short ls_class; /* IF, WHILE, DO, FOR, SWITCH, CASE */
  40. union lint_end_state ls_end;
  41. };
  42. /* ALLOCDEF "lint_stack_entry" 10 */
  43. /* macros to access the union */
  44. #define LS_IF ls_end.ule_if
  45. #define LS_TEST ls_end.ule_loop.lps_test
  46. #define LS_BODY ls_end.ule_loop.lps_body
  47. #define LS_LOOP ls_end.ule_loop.lps_loop
  48. #define LS_CASE ls_end.ule_switch.sws_case
  49. #define LS_BREAK ls_end.ule_switch.sws_break
  50. #define LS_DEFAULT_MET ls_end.ule_switch.sws_default_met
  51. /* describes a branch in the program, with its local idfs */
  52. struct state {
  53. struct state *next; /* only used by memory allocator */
  54. struct auto_def *st_auto_list;
  55. int st_notreached; /* set if not reached */
  56. int st_warned; /* set if warning issued */
  57. };
  58. /* ALLOCDEF "state" 15 */
  59. /* describes the state of a local idf in a given branch of the program */
  60. struct auto_def {
  61. struct auto_def *next;
  62. struct idf *ad_idf;
  63. struct def *ad_def;
  64. int ad_used;
  65. int ad_set;
  66. int ad_maybe_set;
  67. };
  68. /* ALLOCDEF "auto_def" 20 */
  69. /* describes the state of an idf during expression evaluation */
  70. struct expr_state { /*actually concerns idfs only */
  71. struct expr_state *next;
  72. struct idf *es_idf; /* the idf with its offset */
  73. arith es_offset;
  74. int es_used; /* value has been used */
  75. int es_referred; /* address has been taken */
  76. int es_set; /* has been assigned to */
  77. };
  78. /* ALLOCDEF "expr_state" 20 */