symsymh.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. symprop = byte;
  22. { possible types for symtable entries }
  23. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,programsym,
  24. constsym,enumsym,typedconstsym,errorsym,syssym,
  25. labelsym,absolutesym,propertysym,funcretsym,
  26. macrosym);
  27. { this object is the base for all symbol objects }
  28. psym = ^tsym;
  29. tsym = object(tsymtableentry)
  30. typ : tsymtyp;
  31. properties : symprop;
  32. fileinfo : tfileposinfo;
  33. {$ifdef GDB}
  34. isstabwritten : boolean;
  35. {$endif GDB}
  36. lastref,
  37. defref,
  38. lastwritten : pref;
  39. refcount : longint;
  40. constructor init(const n : string);
  41. constructor load;
  42. destructor done;virtual;
  43. procedure write;virtual;
  44. procedure deref;virtual;
  45. function mangledname : string;virtual;
  46. procedure insert_in_data;virtual;
  47. {$ifdef GDB}
  48. function stabstring : pchar;virtual;
  49. procedure concatstabto(asmlist : paasmoutput);virtual;
  50. {$endif GDB}
  51. procedure load_references;virtual;
  52. function write_references : boolean;virtual;
  53. {$ifdef BrowserLog}
  54. procedure add_to_browserlog;virtual;
  55. {$endif BrowserLog}
  56. end;
  57. plabelsym = ^tlabelsym;
  58. tlabelsym = object(tsym)
  59. lab : pasmlabel;
  60. defined : boolean;
  61. constructor init(const n : string; l : pasmlabel);
  62. destructor done;virtual;
  63. constructor load;
  64. function mangledname : string;virtual;
  65. procedure write;virtual;
  66. end;
  67. punitsym = ^tunitsym;
  68. tunitsym = object(tsym)
  69. unitsymtable : punitsymtable;
  70. prevsym : punitsym;
  71. refs : longint;
  72. constructor init(const n : string;ref : punitsymtable);
  73. constructor load;
  74. destructor done;virtual;
  75. procedure write;virtual;
  76. {$ifdef GDB}
  77. procedure concatstabto(asmlist : paasmoutput);virtual;
  78. {$endif GDB}
  79. end;
  80. pmacrosym = ^tmacrosym;
  81. tmacrosym = object(tsym)
  82. defined : boolean;
  83. buftext : pchar;
  84. buflen : longint;
  85. { macros aren't written to PPU files ! }
  86. constructor init(const n : string);
  87. destructor done;virtual;
  88. end;
  89. perrorsym = ^terrorsym;
  90. terrorsym = object(tsym)
  91. constructor init;
  92. end;
  93. pprocsym = ^tprocsym;
  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. refs : longint;
  161. var_options : byte;
  162. _mangledname : pchar;
  163. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  164. varspez : tvarspez; { sets the type of access }
  165. is_valid : byte;
  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 load;
  170. destructor done;virtual;
  171. procedure write;virtual;
  172. procedure deref;virtual;
  173. procedure setmangledname(const s : string);
  174. function mangledname : string;virtual;
  175. procedure insert_in_data;virtual;
  176. function getsize : longint;
  177. function getpushsize : longint;
  178. {$ifdef GDB}
  179. function stabstring : pchar;virtual;
  180. procedure concatstabto(asmlist : paasmoutput);virtual;
  181. {$endif GDB}
  182. end;
  183. ppropertysym = ^tpropertysym;
  184. tpropertysym = object(tsym)
  185. options : longint;
  186. proptype : pdef;
  187. { proppara : pdefcoll; }
  188. readaccesssym,writeaccesssym,storedsym : psym;
  189. readaccessdef,writeaccessdef,storeddef : pdef;
  190. index,default : longint;
  191. constructor init(const n : string);
  192. destructor done;virtual;
  193. constructor load;
  194. function getsize : longint;virtual;
  195. procedure write;virtual;
  196. procedure deref;virtual;
  197. {$ifdef GDB}
  198. { I don't know how (FK) }
  199. function stabstring : pchar;virtual;
  200. procedure concatstabto(asmlist : paasmoutput);virtual;
  201. {$endif GDB}
  202. end;
  203. pfuncretsym = ^tfuncretsym;
  204. tfuncretsym = object(tsym)
  205. funcretprocinfo : pointer{ should be pprocinfo};
  206. funcretdef : pdef;
  207. address : longint;
  208. constructor init(const n : string;approcinfo : pointer{pprocinfo});
  209. constructor load;
  210. procedure write;virtual;
  211. procedure deref;virtual;
  212. procedure insert_in_data;virtual;
  213. {$ifdef GDB}
  214. procedure concatstabto(asmlist : paasmoutput);virtual;
  215. {$endif GDB}
  216. end;
  217. absolutetyp = (tovar,toasm,toaddr);
  218. pabsolutesym = ^tabsolutesym;
  219. tabsolutesym = object(tvarsym)
  220. abstyp : absolutetyp;
  221. absseg : boolean;
  222. ref : psym;
  223. asmname : pstring;
  224. constructor init(const n : string;p : pdef);
  225. constructor load;
  226. procedure deref;virtual;
  227. function mangledname : string;virtual;
  228. procedure write;virtual;
  229. procedure insert_in_data;virtual;
  230. { this creates a problem in gen_vmt !!!!!
  231. because the pdef is not resolved yet !!
  232. we should fix this
  233. constructor init(const s : string;p : pdef;newref : psym);}
  234. {$ifdef GDB}
  235. procedure concatstabto(asmlist : paasmoutput);virtual;
  236. {$endif GDB}
  237. end;
  238. ptypedconstsym = ^ttypedconstsym;
  239. ttypedconstsym = object(tsym)
  240. prefix : pstring;
  241. definition : pdef;
  242. is_really_const : boolean;
  243. constructor init(const n : string;p : pdef;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. procedure really_insert_in_data;
  252. {$ifdef GDB}
  253. function stabstring : pchar;virtual;
  254. {$endif GDB}
  255. end;
  256. tconsttype = (constord,conststring,constreal,constbool,
  257. constint,constchar,constset,constnil);
  258. pconstsym = ^tconstsym;
  259. tconstsym = object(tsym)
  260. definition : pdef;
  261. consttype : tconsttype;
  262. value,
  263. len : longint; { len is needed for string length }
  264. constructor init(const n : string;t : tconsttype;v : longint);
  265. constructor init_def(const n : string;t : tconsttype;v : longint;def : pdef);
  266. constructor init_string(const n : string;t : tconsttype;str:pchar;l:longint);
  267. constructor load;
  268. destructor done;virtual;
  269. function mangledname : string;virtual;
  270. procedure deref;virtual;
  271. procedure write;virtual;
  272. {$ifdef GDB}
  273. function stabstring : pchar;virtual;
  274. procedure concatstabto(asmlist : paasmoutput);virtual;
  275. {$endif GDB}
  276. end;
  277. tenumsym = object(tsym)
  278. value : longint;
  279. definition : penumdef;
  280. nextenum : penumsym;
  281. constructor init(const n : string;def : penumdef;v : longint);
  282. constructor load;
  283. procedure write;virtual;
  284. procedure deref;virtual;
  285. procedure order;
  286. {$ifdef GDB}
  287. procedure concatstabto(asmlist : paasmoutput);virtual;
  288. {$endif GDB}
  289. end;
  290. pprogramsym = ^tprogramsym;
  291. tprogramsym = object(tsym)
  292. constructor init(const n : string);
  293. end;
  294. psyssym = ^tsyssym;
  295. tsyssym = object(tsym)
  296. number : longint;
  297. constructor init(const n : string;l : longint);
  298. constructor load;
  299. destructor done;virtual;
  300. procedure write;virtual;
  301. {$ifdef GDB}
  302. procedure concatstabto(asmlist : paasmoutput);virtual;
  303. {$endif GDB}
  304. end;
  305. {
  306. $Log$
  307. Revision 1.26 1999-05-27 19:45:07 peter
  308. * removed oldasm
  309. * plabel -> pasmlabel
  310. * -a switches to source writing automaticly
  311. * assembler readers OOPed
  312. * asmsymbol automaticly external
  313. * jumptables and other label fixes for asm readers
  314. Revision 1.25 1999/05/21 13:55:23 peter
  315. * NEWLAB for label as symbol
  316. Revision 1.24 1999/05/20 22:22:45 pierre
  317. + added synonym filed for ttypesym
  318. allows a clean disposal of tdefs and related ttypesyms
  319. Revision 1.23 1999/05/13 21:59:47 peter
  320. * removed oldppu code
  321. * warning if objpas is loaded from uses
  322. * first things for new deref writing
  323. Revision 1.22 1999/04/26 13:31:53 peter
  324. * release storenumber,double_checksum
  325. Revision 1.21 1999/04/25 22:38:40 pierre
  326. + added is_really_const booleanfield for typedconstsym
  327. for Delphi in $J- mode (not yet implemented !)
  328. Revision 1.20 1999/04/21 09:43:56 peter
  329. * storenumber works
  330. * fixed some typos in double_checksum
  331. + incompatible types type1 and type2 message (with storenumber)
  332. Revision 1.19 1999/04/17 13:16:23 peter
  333. * fixes for storenumber
  334. Revision 1.18 1999/04/14 09:15:03 peter
  335. * first things to store the symbol/def number in the ppu
  336. Revision 1.17 1999/03/31 13:55:23 peter
  337. * assembler inlining working for ag386bin
  338. Revision 1.16 1999/03/24 23:17:29 peter
  339. * fixed bugs 212,222,225,227,229,231,233
  340. Revision 1.15 1999/02/22 13:07:11 pierre
  341. + -b and -bl options work !
  342. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  343. is not enabled when quitting global section
  344. * local vars and procedures are not yet stored into PPU
  345. Revision 1.14 1999/01/20 10:20:22 peter
  346. * don't make localvar copies for assembler procedures
  347. Revision 1.13 1999/01/14 21:49:59 peter
  348. * fixed forwardpointer problem with multiple forwards for the same
  349. typesym. It now uses a linkedlist instead of a single pointer
  350. Revision 1.12 1999/01/12 14:25:37 peter
  351. + BrowserLog for browser.log generation
  352. + BrowserCol for browser info in TCollections
  353. * released all other UseBrowser
  354. Revision 1.11 1998/12/30 22:15:55 peter
  355. + farpointer type
  356. * absolutesym now also stores if its far
  357. Revision 1.10 1998/12/30 13:41:15 peter
  358. * released valuepara
  359. Revision 1.9 1998/11/28 16:20:57 peter
  360. + support for dll variables
  361. Revision 1.8 1998/11/18 15:44:19 peter
  362. * VALUEPARA for tp7 compatible value parameters
  363. Revision 1.7 1998/11/16 10:13:50 peter
  364. * label defines are checked at the end of the proc
  365. Revision 1.6 1998/11/13 10:18:12 peter
  366. + nil constants
  367. Revision 1.5 1998/11/05 23:39:32 peter
  368. + typedconst.getsize
  369. Revision 1.4 1998/10/20 08:07:02 pierre
  370. * several memory corruptions due to double freemem solved
  371. => never use p^.loc.location:=p^.left^.loc.location;
  372. + finally I added now by default
  373. that ra386dir translates global and unit symbols
  374. + added a first field in tsymtable and
  375. a nextsym field in tsym
  376. (this allows to obtain ordered type info for
  377. records and objects in gdb !)
  378. Revision 1.3 1998/10/08 17:17:34 pierre
  379. * current_module old scanner tagged as invalid if unit is recompiled
  380. + added ppheap for better info on tracegetmem of heaptrc
  381. (adds line column and file index)
  382. * several memory leaks removed ith help of heaptrc !!
  383. Revision 1.2 1998/09/24 15:11:18 peter
  384. * fixed enum for not GDB
  385. Revision 1.1 1998/09/23 12:03:57 peter
  386. * overloading fix for array of const
  387. }