symsymh.inc 16 KB

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