symsymh.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. number : plabel;
  60. defined : boolean;
  61. constructor init(const n : string; l : plabel);
  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. {$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. refs : longint;
  160. var_options : byte;
  161. _mangledname : pchar;
  162. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  163. varspez : tvarspez; { sets the type of access }
  164. is_valid : byte;
  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 load;
  169. destructor done;virtual;
  170. procedure write;virtual;
  171. procedure deref;virtual;
  172. procedure setmangledname(const s : string);
  173. function mangledname : string;virtual;
  174. procedure insert_in_data;virtual;
  175. function getsize : longint;
  176. function getpushsize : longint;
  177. {$ifdef GDB}
  178. function stabstring : pchar;virtual;
  179. procedure concatstabto(asmlist : paasmoutput);virtual;
  180. {$endif GDB}
  181. end;
  182. ppropertysym = ^tpropertysym;
  183. tpropertysym = object(tsym)
  184. options : longint;
  185. proptype : pdef;
  186. { proppara : pdefcoll; }
  187. readaccesssym,writeaccesssym,storedsym : psym;
  188. readaccessdef,writeaccessdef,storeddef : pdef;
  189. index,default : longint;
  190. constructor init(const n : string);
  191. destructor done;virtual;
  192. constructor load;
  193. function getsize : longint;virtual;
  194. procedure write;virtual;
  195. procedure deref;virtual;
  196. {$ifdef GDB}
  197. { I don't know how (FK) }
  198. function stabstring : pchar;virtual;
  199. procedure concatstabto(asmlist : paasmoutput);virtual;
  200. {$endif GDB}
  201. end;
  202. pfuncretsym = ^tfuncretsym;
  203. tfuncretsym = object(tsym)
  204. funcretprocinfo : pointer{ should be pprocinfo};
  205. funcretdef : pdef;
  206. address : longint;
  207. constructor init(const n : string;approcinfo : pointer{pprocinfo});
  208. constructor load;
  209. procedure write;virtual;
  210. procedure deref;virtual;
  211. procedure insert_in_data;virtual;
  212. {$ifdef GDB}
  213. procedure concatstabto(asmlist : paasmoutput);virtual;
  214. {$endif GDB}
  215. end;
  216. absolutetyp = (tovar,toasm,toaddr);
  217. pabsolutesym = ^tabsolutesym;
  218. tabsolutesym = object(tvarsym)
  219. abstyp : absolutetyp;
  220. absseg : boolean;
  221. ref : psym;
  222. asmname : pstring;
  223. constructor init(const n : string;p : pdef);
  224. constructor load;
  225. procedure deref;virtual;
  226. function mangledname : string;virtual;
  227. procedure write;virtual;
  228. procedure insert_in_data;virtual;
  229. { this creates a problem in gen_vmt !!!!!
  230. because the pdef is not resolved yet !!
  231. we should fix this
  232. constructor init(const s : string;p : pdef;newref : psym);}
  233. {$ifdef GDB}
  234. procedure concatstabto(asmlist : paasmoutput);virtual;
  235. {$endif GDB}
  236. end;
  237. ptypedconstsym = ^ttypedconstsym;
  238. ttypedconstsym = object(tsym)
  239. prefix : pstring;
  240. definition : pdef;
  241. is_really_const : boolean;
  242. constructor init(const n : string;p : pdef;really_const : boolean);
  243. constructor load;
  244. destructor done;virtual;
  245. function mangledname : string;virtual;
  246. procedure write;virtual;
  247. procedure deref;virtual;
  248. function getsize:longint;
  249. procedure insert_in_data;virtual;
  250. procedure really_insert_in_data;
  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. pconstsym = ^tconstsym;
  258. tconstsym = object(tsym)
  259. definition : pdef;
  260. consttype : tconsttype;
  261. value,
  262. len : longint; { len is needed for string length }
  263. constructor init(const n : string;t : tconsttype;v : longint);
  264. constructor init_def(const n : string;t : tconsttype;v : longint;def : pdef);
  265. constructor init_string(const n : string;t : tconsttype;str:pchar;l:longint);
  266. constructor load;
  267. destructor done;virtual;
  268. function mangledname : string;virtual;
  269. procedure deref;virtual;
  270. procedure write;virtual;
  271. {$ifdef GDB}
  272. function stabstring : pchar;virtual;
  273. procedure concatstabto(asmlist : paasmoutput);virtual;
  274. {$endif GDB}
  275. end;
  276. tenumsym = object(tsym)
  277. value : longint;
  278. definition : penumdef;
  279. nextenum : penumsym;
  280. constructor init(const n : string;def : penumdef;v : longint);
  281. constructor load;
  282. procedure write;virtual;
  283. procedure deref;virtual;
  284. procedure order;
  285. {$ifdef GDB}
  286. procedure concatstabto(asmlist : paasmoutput);virtual;
  287. {$endif GDB}
  288. end;
  289. pprogramsym = ^tprogramsym;
  290. tprogramsym = object(tsym)
  291. constructor init(const n : string);
  292. end;
  293. psyssym = ^tsyssym;
  294. tsyssym = object(tsym)
  295. number : longint;
  296. constructor init(const n : string;l : longint);
  297. constructor load;
  298. destructor done;virtual;
  299. procedure write;virtual;
  300. {$ifdef GDB}
  301. procedure concatstabto(asmlist : paasmoutput);virtual;
  302. {$endif GDB}
  303. end;
  304. {
  305. $Log$
  306. Revision 1.23 1999-05-13 21:59:47 peter
  307. * removed oldppu code
  308. * warning if objpas is loaded from uses
  309. * first things for new deref writing
  310. Revision 1.22 1999/04/26 13:31:53 peter
  311. * release storenumber,double_checksum
  312. Revision 1.21 1999/04/25 22:38:40 pierre
  313. + added is_really_const booleanfield for typedconstsym
  314. for Delphi in $J- mode (not yet implemented !)
  315. Revision 1.20 1999/04/21 09:43:56 peter
  316. * storenumber works
  317. * fixed some typos in double_checksum
  318. + incompatible types type1 and type2 message (with storenumber)
  319. Revision 1.19 1999/04/17 13:16:23 peter
  320. * fixes for storenumber
  321. Revision 1.18 1999/04/14 09:15:03 peter
  322. * first things to store the symbol/def number in the ppu
  323. Revision 1.17 1999/03/31 13:55:23 peter
  324. * assembler inlining working for ag386bin
  325. Revision 1.16 1999/03/24 23:17:29 peter
  326. * fixed bugs 212,222,225,227,229,231,233
  327. Revision 1.15 1999/02/22 13:07:11 pierre
  328. + -b and -bl options work !
  329. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  330. is not enabled when quitting global section
  331. * local vars and procedures are not yet stored into PPU
  332. Revision 1.14 1999/01/20 10:20:22 peter
  333. * don't make localvar copies for assembler procedures
  334. Revision 1.13 1999/01/14 21:49:59 peter
  335. * fixed forwardpointer problem with multiple forwards for the same
  336. typesym. It now uses a linkedlist instead of a single pointer
  337. Revision 1.12 1999/01/12 14:25:37 peter
  338. + BrowserLog for browser.log generation
  339. + BrowserCol for browser info in TCollections
  340. * released all other UseBrowser
  341. Revision 1.11 1998/12/30 22:15:55 peter
  342. + farpointer type
  343. * absolutesym now also stores if its far
  344. Revision 1.10 1998/12/30 13:41:15 peter
  345. * released valuepara
  346. Revision 1.9 1998/11/28 16:20:57 peter
  347. + support for dll variables
  348. Revision 1.8 1998/11/18 15:44:19 peter
  349. * VALUEPARA for tp7 compatible value parameters
  350. Revision 1.7 1998/11/16 10:13:50 peter
  351. * label defines are checked at the end of the proc
  352. Revision 1.6 1998/11/13 10:18:12 peter
  353. + nil constants
  354. Revision 1.5 1998/11/05 23:39:32 peter
  355. + typedconst.getsize
  356. Revision 1.4 1998/10/20 08:07:02 pierre
  357. * several memory corruptions due to double freemem solved
  358. => never use p^.loc.location:=p^.left^.loc.location;
  359. + finally I added now by default
  360. that ra386dir translates global and unit symbols
  361. + added a first field in tsymtable and
  362. a nextsym field in tsym
  363. (this allows to obtain ordered type info for
  364. records and objects in gdb !)
  365. Revision 1.3 1998/10/08 17:17:34 pierre
  366. * current_module old scanner tagged as invalid if unit is recompiled
  367. + added ppheap for better info on tracegetmem of heaptrc
  368. (adds line column and file index)
  369. * several memory leaks removed ith help of heaptrc !!
  370. Revision 1.2 1998/09/24 15:11:18 peter
  371. * fixed enum for not GDB
  372. Revision 1.1 1998/09/23 12:03:57 peter
  373. * overloading fix for array of const
  374. }