symtab.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Symbol table prototypes
  3. * (C) Mike van Emmerik
  4. */
  5. #pragma once
  6. /* * * * * * * * * * * * * * * * * */
  7. /* Symbol table structs and protos */
  8. /* * * * * * * * * * * * * * * * * */
  9. struct Function;
  10. struct SYMTABLE
  11. {
  12. std::string pSymName; /* Ptr to symbolic name or comment */
  13. dword symOff; /* Symbol image offset */
  14. Function *symProc; /* Procedure pointer */
  15. word preHash; /* Hash value before the modulo */
  16. word postHash; /* Hash value after the modulo */
  17. word nextOvf; /* Next entry this hash bucket, or -1 */
  18. word prevOvf; /* Back link in Ovf chain */
  19. SYMTABLE() : symOff(0),symProc(0) {}
  20. SYMTABLE(dword _sym,Function *_proc) : symOff(_sym),symProc(_proc)
  21. {}
  22. bool operator == (const SYMTABLE &other) const
  23. {
  24. // does not yse pSymName, to ease finding by symOff/symProc combo
  25. // in map<SYMTABLE,X>
  26. return (symOff==other.symOff) && symProc==(other.symProc);
  27. }
  28. };
  29. enum tableType /* The table types */
  30. {
  31. Label=0, /* The label table */
  32. Comment, /* The comment table */
  33. NUM_TABLE_TYPES /* Number of entries: must be last */
  34. };
  35. void createSymTables(void);
  36. void destroySymTables(void);
  37. void enterSym(char *symName, dword symOff, Function *symProc, boolT bSymToo);
  38. boolT readSym (char *symName, dword *pSymOff, Function **pSymProc);
  39. boolT readVal (char *symName, dword symOff, Function *symProc);
  40. void deleteSym(char *symName);
  41. void deleteVal(dword symOff, Function * symProc, boolT bSymToo);
  42. std::string findVal(dword symOff, Function * symProc, word *pIndex);
  43. word symHash(char *name, word *pre);
  44. word valHash(dword off, Function * proc, word *pre);
  45. void selectTable(tableType); /* Select a particular table */
  46. char *addStrTbl(char *pStr); /* Add string to string table */