symsymh.inc 15 KB

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