symsymh.inc 14 KB

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