symsymh.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Interface for the symbols types of the symtable
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {************************************************
  19. TSym
  20. ************************************************}
  21. { possible types for symtable entries }
  22. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,programsym,
  23. constsym,enumsym,typedconstsym,errorsym,syssym,
  24. labelsym,absolutesym,propertysym,funcretsym,
  25. macrosym);
  26. { this object is the base for all symbol objects }
  27. psym = ^tsym;
  28. tsym = object(tsymtableentry)
  29. typ : tsymtyp;
  30. symoptions : tsymoptions;
  31. fileinfo : tfileposinfo;
  32. {$ifdef GDB}
  33. isstabwritten : boolean;
  34. {$endif GDB}
  35. lastref,
  36. defref,
  37. lastwritten : pref;
  38. refcount : longint;
  39. constructor init(const n : string);
  40. constructor load;
  41. destructor done;virtual;
  42. procedure write;virtual;
  43. procedure deref;virtual;
  44. function mangledname : string;virtual;
  45. procedure insert_in_data;virtual;
  46. {$ifdef GDB}
  47. function stabstring : pchar;virtual;
  48. procedure concatstabto(asmlist : paasmoutput);virtual;
  49. {$endif GDB}
  50. procedure load_references;virtual;
  51. function write_references : boolean;virtual;
  52. {$ifdef BrowserLog}
  53. procedure add_to_browserlog;virtual;
  54. {$endif BrowserLog}
  55. end;
  56. plabelsym = ^tlabelsym;
  57. tlabelsym = object(tsym)
  58. lab : pasmlabel;
  59. defined : boolean;
  60. constructor init(const n : string; l : pasmlabel);
  61. destructor done;virtual;
  62. constructor load;
  63. function mangledname : string;virtual;
  64. procedure write;virtual;
  65. end;
  66. punitsym = ^tunitsym;
  67. tunitsym = object(tsym)
  68. unitsymtable : punitsymtable;
  69. prevsym : punitsym;
  70. refs : longint;
  71. constructor init(const n : string;ref : punitsymtable);
  72. constructor load;
  73. destructor done;virtual;
  74. procedure write;virtual;
  75. {$ifdef GDB}
  76. procedure concatstabto(asmlist : paasmoutput);virtual;
  77. {$endif GDB}
  78. end;
  79. pmacrosym = ^tmacrosym;
  80. tmacrosym = object(tsym)
  81. defined : boolean;
  82. buftext : pchar;
  83. buflen : longint;
  84. { macros aren't written to PPU files ! }
  85. constructor init(const n : string);
  86. destructor done;virtual;
  87. end;
  88. perrorsym = ^terrorsym;
  89. terrorsym = object(tsym)
  90. constructor init;
  91. end;
  92. tprocsym = object(tsym)
  93. definition : pprocdef;
  94. {$ifdef CHAINPROCSYMS}
  95. nextprocsym : pprocsym;
  96. {$endif CHAINPROCSYMS}
  97. {$ifdef GDB}
  98. is_global : boolean; { necessary for stab }
  99. {$endif GDB}
  100. constructor init(const n : string);
  101. constructor load;
  102. destructor done;virtual;
  103. function mangledname : string;virtual;
  104. function demangledname:string;
  105. { writes all declarations }
  106. procedure write_parameter_lists;
  107. { tests, if all procedures definitions are defined and not }
  108. { only forward }
  109. procedure check_forward;
  110. procedure write;virtual;
  111. procedure deref;virtual;
  112. procedure load_references;virtual;
  113. function write_references : boolean;virtual;
  114. {$ifdef BrowserLog}
  115. procedure add_to_browserlog;virtual;
  116. {$endif BrowserLog}
  117. {$ifdef GDB}
  118. function stabstring : pchar;virtual;
  119. procedure concatstabto(asmlist : paasmoutput);virtual;
  120. {$endif GDB}
  121. end;
  122. pforwardpointer=^tforwardpointer;
  123. tforwardpointer=record
  124. next : pforwardpointer;
  125. def : ppointerdef;
  126. end;
  127. ttypesym = object(tsym)
  128. definition : pdef;
  129. synonym : ptypesym;
  130. {$ifdef GDB}
  131. isusedinstab : boolean;
  132. {$endif GDB}
  133. constructor init(const n : string;d : pdef);
  134. constructor load;
  135. destructor done;virtual;
  136. procedure write;virtual;
  137. procedure deref;virtual;
  138. procedure addforwardpointer(p:ppointerdef);
  139. procedure updateforwarddef(p:pdef);
  140. procedure load_references;virtual;
  141. function write_references : boolean;virtual;
  142. {$ifdef BrowserLog}
  143. procedure add_to_browserlog;virtual;
  144. {$endif BrowserLog}
  145. {$ifdef GDB}
  146. function stabstring : pchar;virtual;
  147. procedure concatstabto(asmlist : paasmoutput);virtual;
  148. {$endif GDB}
  149. private
  150. forwardpointer : pforwardpointer;
  151. end;
  152. pvarsym = ^tvarsym;
  153. tvarsym = object(tsym)
  154. address : longint;
  155. localvarsym : pvarsym;
  156. islocalcopy : boolean;
  157. definition : pdef;
  158. definitionsym : ptypesym;
  159. refs : longint;
  160. varoptions : tvaroptions;
  161. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  162. varspez : tvarspez; { sets the type of access }
  163. varstate : tvarstate;
  164. constructor init(const n : string;p : pdef);
  165. constructor init_dll(const n : string;p : pdef);
  166. constructor init_C(const n,mangled : string;p : pdef);
  167. constructor initsym(const n : string;p : ptypesym);
  168. constructor initsym_dll(const n : string;p : ptypesym);
  169. constructor initsym_C(const n,mangled : string;p : ptypesym);
  170. constructor load;
  171. destructor done;virtual;
  172. procedure write;virtual;
  173. procedure deref;virtual;
  174. procedure setmangledname(const s : string);
  175. function mangledname : string;virtual;
  176. procedure insert_in_data;virtual;
  177. function getsize : longint;
  178. function getpushsize : longint;
  179. {$ifdef GDB}
  180. function stabstring : pchar;virtual;
  181. procedure concatstabto(asmlist : paasmoutput);virtual;
  182. {$endif GDB}
  183. private
  184. _mangledname : pchar;
  185. end;
  186. ppropsymlist = ^tpropsymlist;
  187. tpropsymlist = record
  188. sym : psym;
  189. next : ppropsymlist;
  190. end;
  191. ppropertysym = ^tpropertysym;
  192. tpropertysym = object(tsym)
  193. propoptions : tpropertyoptions;
  194. proptype : pdef;
  195. readaccesssym,writeaccesssym,storedsym : ppropsymlist;
  196. readaccessdef,writeaccessdef,storeddef : pdef;
  197. index,default : longint;
  198. constructor init(const n : string);
  199. destructor done;virtual;
  200. constructor load;
  201. function getsize : longint;virtual;
  202. procedure write;virtual;
  203. procedure deref;virtual;
  204. {$ifdef GDB}
  205. function stabstring : pchar;virtual;
  206. procedure concatstabto(asmlist : paasmoutput);virtual;
  207. {$endif GDB}
  208. end;
  209. pfuncretsym = ^tfuncretsym;
  210. tfuncretsym = object(tsym)
  211. funcretprocinfo : pointer{ should be pprocinfo};
  212. funcretdef : pdef;
  213. address : longint;
  214. constructor init(const n : string;approcinfo : pointer{pprocinfo});
  215. constructor load;
  216. procedure write;virtual;
  217. procedure deref;virtual;
  218. procedure insert_in_data;virtual;
  219. {$ifdef GDB}
  220. procedure concatstabto(asmlist : paasmoutput);virtual;
  221. {$endif GDB}
  222. end;
  223. absolutetyp = (tovar,toasm,toaddr);
  224. pabsolutesym = ^tabsolutesym;
  225. tabsolutesym = object(tvarsym)
  226. abstyp : absolutetyp;
  227. absseg : boolean;
  228. ref : psym;
  229. asmname : pstring;
  230. constructor init(const n : string;p : pdef);
  231. constructor load;
  232. procedure deref;virtual;
  233. function mangledname : string;virtual;
  234. procedure write;virtual;
  235. procedure insert_in_data;virtual;
  236. {$ifdef GDB}
  237. procedure concatstabto(asmlist : paasmoutput);virtual;
  238. {$endif GDB}
  239. end;
  240. ptypedconstsym = ^ttypedconstsym;
  241. ttypedconstsym = object(tsym)
  242. prefix : pstring;
  243. definition : pdef;
  244. definitionsym : ptypesym;
  245. is_really_const : boolean;
  246. constructor init(const n : string;p : pdef;really_const : boolean);
  247. constructor initsym(const n : string;p : ptypesym;really_const : boolean);
  248. constructor load;
  249. destructor done;virtual;
  250. function mangledname : string;virtual;
  251. procedure write;virtual;
  252. procedure deref;virtual;
  253. function getsize:longint;
  254. procedure insert_in_data;virtual;
  255. {$ifdef GDB}
  256. function stabstring : pchar;virtual;
  257. {$endif GDB}
  258. end;
  259. tconsttype = (constord,conststring,constreal,constbool,
  260. constint,constchar,constset,constnil,
  261. constresourcestring);
  262. pconstsym = ^tconstsym;
  263. tconstsym = object(tsym)
  264. definition : pdef;
  265. consttype : tconsttype;
  266. reshash, { needed for resource strings }
  267. value,
  268. len : longint; { len is needed for string length }
  269. constructor init(const n : string;t : tconsttype;v : longint);
  270. constructor init_def(const n : string;t : tconsttype;v : longint;def : pdef);
  271. constructor init_string(const n : string;t : tconsttype;str:pchar;l:longint);
  272. constructor load;
  273. destructor done;virtual;
  274. function mangledname : string;virtual;
  275. procedure deref;virtual;
  276. procedure write;virtual;
  277. {$ifdef GDB}
  278. function stabstring : pchar;virtual;
  279. procedure concatstabto(asmlist : paasmoutput);virtual;
  280. {$endif GDB}
  281. end;
  282. tenumsym = object(tsym)
  283. value : longint;
  284. definition : penumdef;
  285. nextenum : penumsym;
  286. constructor init(const n : string;def : penumdef;v : longint);
  287. constructor load;
  288. procedure write;virtual;
  289. procedure deref;virtual;
  290. procedure order;
  291. {$ifdef GDB}
  292. procedure concatstabto(asmlist : paasmoutput);virtual;
  293. {$endif GDB}
  294. end;
  295. pprogramsym = ^tprogramsym;
  296. tprogramsym = object(tsym)
  297. constructor init(const n : string);
  298. end;
  299. psyssym = ^tsyssym;
  300. tsyssym = object(tsym)
  301. number : longint;
  302. constructor init(const n : string;l : longint);
  303. constructor load;
  304. destructor done;virtual;
  305. procedure write;virtual;
  306. {$ifdef GDB}
  307. procedure concatstabto(asmlist : paasmoutput);virtual;
  308. {$endif GDB}
  309. end;
  310. {
  311. $Log$
  312. Revision 1.32 1999-08-14 00:39:01 peter
  313. * hack to support property with record fields
  314. Revision 1.31 1999/08/10 12:33:38 pierre
  315. * pprocsym defined earlier for use in tprocdef
  316. Revision 1.30 1999/08/03 22:03:21 peter
  317. * moved bitmask constants to sets
  318. * some other type/const renamings
  319. Revision 1.29 1999/07/27 23:42:23 peter
  320. * indirect type referencing is now allowed
  321. Revision 1.28 1999/07/24 15:13:01 michael
  322. changes for resourcestrings
  323. Revision 1.27 1999/07/22 09:37:57 florian
  324. + resourcestring implemented
  325. + start of longstring support
  326. Revision 1.26 1999/05/27 19:45:07 peter
  327. * removed oldasm
  328. * plabel -> pasmlabel
  329. * -a switches to source writing automaticly
  330. * assembler readers OOPed
  331. * asmsymbol automaticly external
  332. * jumptables and other label fixes for asm readers
  333. Revision 1.25 1999/05/21 13:55:23 peter
  334. * NEWLAB for label as symbol
  335. Revision 1.24 1999/05/20 22:22:45 pierre
  336. + added synonym filed for ttypesym
  337. allows a clean disposal of tdefs and related ttypesyms
  338. Revision 1.23 1999/05/13 21:59:47 peter
  339. * removed oldppu code
  340. * warning if objpas is loaded from uses
  341. * first things for new deref writing
  342. Revision 1.22 1999/04/26 13:31:53 peter
  343. * release storenumber,double_checksum
  344. Revision 1.21 1999/04/25 22:38:40 pierre
  345. + added is_really_const booleanfield for typedconstsym
  346. for Delphi in $J- mode (not yet implemented !)
  347. Revision 1.20 1999/04/21 09:43:56 peter
  348. * storenumber works
  349. * fixed some typos in double_checksum
  350. + incompatible types type1 and type2 message (with storenumber)
  351. Revision 1.19 1999/04/17 13:16:23 peter
  352. * fixes for storenumber
  353. Revision 1.18 1999/04/14 09:15:03 peter
  354. * first things to store the symbol/def number in the ppu
  355. Revision 1.17 1999/03/31 13:55:23 peter
  356. * assembler inlining working for ag386bin
  357. Revision 1.16 1999/03/24 23:17:29 peter
  358. * fixed bugs 212,222,225,227,229,231,233
  359. Revision 1.15 1999/02/22 13:07:11 pierre
  360. + -b and -bl options work !
  361. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  362. is not enabled when quitting global section
  363. * local vars and procedures are not yet stored into PPU
  364. Revision 1.14 1999/01/20 10:20:22 peter
  365. * don't make localvar copies for assembler procedures
  366. Revision 1.13 1999/01/14 21:49:59 peter
  367. * fixed forwardpointer problem with multiple forwards for the same
  368. typesym. It now uses a linkedlist instead of a single pointer
  369. Revision 1.12 1999/01/12 14:25:37 peter
  370. + BrowserLog for browser.log generation
  371. + BrowserCol for browser info in TCollections
  372. * released all other UseBrowser
  373. Revision 1.11 1998/12/30 22:15:55 peter
  374. + farpointer type
  375. * absolutesym now also stores if its far
  376. Revision 1.10 1998/12/30 13:41:15 peter
  377. * released valuepara
  378. Revision 1.9 1998/11/28 16:20:57 peter
  379. + support for dll variables
  380. Revision 1.8 1998/11/18 15:44:19 peter
  381. * VALUEPARA for tp7 compatible value parameters
  382. Revision 1.7 1998/11/16 10:13:50 peter
  383. * label defines are checked at the end of the proc
  384. Revision 1.6 1998/11/13 10:18:12 peter
  385. + nil constants
  386. Revision 1.5 1998/11/05 23:39:32 peter
  387. + typedconst.getsize
  388. Revision 1.4 1998/10/20 08:07:02 pierre
  389. * several memory corruptions due to double freemem solved
  390. => never use p^.loc.location:=p^.left^.loc.location;
  391. + finally I added now by default
  392. that ra386dir translates global and unit symbols
  393. + added a first field in tsymtable and
  394. a nextsym field in tsym
  395. (this allows to obtain ordered type info for
  396. records and objects in gdb !)
  397. Revision 1.3 1998/10/08 17:17:34 pierre
  398. * current_module old scanner tagged as invalid if unit is recompiled
  399. + added ppheap for better info on tracegetmem of heaptrc
  400. (adds line column and file index)
  401. * several memory leaks removed ith help of heaptrc !!
  402. Revision 1.2 1998/09/24 15:11:18 peter
  403. * fixed enum for not GDB
  404. Revision 1.1 1998/09/23 12:03:57 peter
  405. * overloading fix for array of const
  406. }