symbol.hh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* $Id$ */
  2. /* Symbol table data structure.
  3. Each identifier structure refers to a list of possible meanings of this
  4. identifier. Each of these meanings is represented by a "symbol" structure.
  5. */
  6. typedef union constant { /* depends on type */
  7. long co_ival;
  8. double co_rval;
  9. char *co_sval;
  10. char *co_setval;
  11. } t_const, *p_const;
  12. typedef struct name {
  13. long nm_value; /* address or offset */
  14. struct scope *nm_scope; /* for names that define a scope */
  15. } t_name, *p_name;
  16. typedef struct symbol {
  17. struct symbol *sy_next; /* link to next meaning */
  18. struct symbol *sy_prev_sc; /* link to previous decl in scope */
  19. struct type *sy_type; /* type of symbol */
  20. int sy_class;
  21. #define CONST 0x0001
  22. #define TYPE 0x0002
  23. #define TAG 0x0004
  24. #define MODULE 0x0008
  25. #define PROC 0x0010
  26. #define FUNCTION 0x0020
  27. #define VAR 0x0040
  28. #define REGVAR 0x0080
  29. #define LOCVAR 0x0100
  30. #define VARPAR 0x0200
  31. #define FIELD 0x0400
  32. #define FILESYM 0x0800 /* a filename */
  33. #define FILELINK 0x1000 /* a filename without its suffix */
  34. #define LBOUND 0x2000 /* lower bound of array descriptor */
  35. #define UBOUND 0x4000 /* upper bound of array descriptor */
  36. struct idf *sy_idf; /* reference back to its idf structure */
  37. struct scope *sy_scope; /* scope in which this symbol resides */
  38. union {
  39. t_const syv_const; /* CONST */
  40. t_name syv_name;
  41. struct file *syv_file; /* for FILESYM */
  42. struct symbol *syv_fllink; /* for FILELINK */
  43. struct symbol *syv_descr; /* for LBOUND and UBOUND */
  44. struct fields *syv_field;
  45. } sy_v;
  46. #define sy_const sy_v.syv_const
  47. #define sy_name sy_v.syv_name
  48. #define sy_file sy_v.syv_file
  49. #define sy_filelink sy_v.syv_fllink
  50. #define sy_field sy_v.syv_field
  51. #define sy_descr sy_v.syv_descr
  52. } t_symbol, *p_symbol;
  53. /* ALLOCDEF "symbol" 50 */
  54. extern p_symbol NewSymbol(), Lookup(), Lookfromscope(), add_file();
  55. extern p_symbol identify();
  56. extern p_symbol currfile, listfile;