symsymh.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. { varsym_C,typedconstsym_C); }
  28. { this object is the base for all symbol objects }
  29. psym = ^tsym;
  30. tsym = object
  31. typ : tsymtyp;
  32. _name : pchar;
  33. left,right : psym;
  34. {$ifndef nonextfield}
  35. nextsym : psym;
  36. {$endif nextfield}
  37. speedvalue : longint;
  38. properties : symprop;
  39. owner : psymtable;
  40. indexnb : longint;
  41. fileinfo : tfileposinfo;
  42. {$ifdef GDB}
  43. isstabwritten : boolean;
  44. {$endif GDB}
  45. {$ifdef UseBrowser}
  46. lastref,
  47. defref,
  48. lastwritten : pref;
  49. refcount : longint;
  50. {$endif UseBrowser}
  51. constructor init(const n : string);
  52. constructor load;
  53. destructor done;virtual;
  54. procedure write;virtual;
  55. procedure deref;virtual;
  56. function name : string;
  57. function mangledname : string;virtual;
  58. procedure setname(const s : string);
  59. procedure insert_in_data;virtual;
  60. {$ifdef GDB}
  61. function stabstring : pchar;virtual;
  62. procedure concatstabto(asmlist : paasmoutput);virtual;
  63. {$endif GDB}
  64. {$ifdef UseBrowser}
  65. procedure load_references;virtual;
  66. function write_references : boolean;virtual;
  67. procedure add_to_browserlog;virtual;
  68. {$endif UseBrowser}
  69. end;
  70. plabelsym = ^tlabelsym;
  71. tlabelsym = object(tsym)
  72. number : plabel;
  73. defined : boolean;
  74. constructor init(const n : string; l : plabel);
  75. destructor done;virtual;
  76. constructor load;
  77. function mangledname : string;virtual;
  78. procedure write;virtual;
  79. end;
  80. punitsym = ^tunitsym;
  81. tunitsym = object(tsym)
  82. unitsymtable : punitsymtable;
  83. prevsym : punitsym;
  84. refs : longint;
  85. constructor init(const n : string;ref : punitsymtable);
  86. constructor load;
  87. destructor done;virtual;
  88. procedure write;virtual;
  89. {$ifdef GDB}
  90. procedure concatstabto(asmlist : paasmoutput);virtual;
  91. {$endif GDB}
  92. end;
  93. pmacrosym = ^tmacrosym;
  94. tmacrosym = object(tsym)
  95. defined : boolean;
  96. buftext : pchar;
  97. buflen : longint;
  98. { macros aren't written to PPU files ! }
  99. constructor init(const n : string);
  100. destructor done;virtual;
  101. end;
  102. perrorsym = ^terrorsym;
  103. terrorsym = object(tsym)
  104. constructor init;
  105. end;
  106. pprocsym = ^tprocsym;
  107. tprocsym = object(tsym)
  108. definition : pprocdef;
  109. {$ifdef CHAINPROCSYMS}
  110. nextprocsym : pprocsym;
  111. {$endif CHAINPROCSYMS}
  112. {$ifdef GDB}
  113. is_global : boolean;{necessary for stab}
  114. {$endif GDB}
  115. constructor init(const n : string);
  116. constructor load;
  117. destructor done;virtual;
  118. function mangledname : string;virtual;
  119. function demangledname:string;
  120. { writes all declarations }
  121. procedure write_parameter_lists;
  122. { tests, if all procedures definitions are defined and not }
  123. { only forward }
  124. procedure check_forward;
  125. procedure write;virtual;
  126. procedure deref;virtual;
  127. {$ifdef UseBrowser}
  128. procedure load_references;virtual;
  129. function write_references : boolean;virtual;
  130. procedure add_to_browserlog;virtual;
  131. {$endif UseBrowser}
  132. {$ifdef GDB}
  133. function stabstring : pchar;virtual;
  134. procedure concatstabto(asmlist : paasmoutput);virtual;
  135. {$endif GDB}
  136. end;
  137. ttypesym = object(tsym)
  138. definition : pdef;
  139. forwardpointer : ppointerdef;
  140. {$ifdef GDB}
  141. isusedinstab : boolean;
  142. {$endif GDB}
  143. constructor init(const n : string;d : pdef);
  144. constructor load;
  145. destructor done;virtual;
  146. procedure write;virtual;
  147. procedure deref;virtual;
  148. {$ifdef UseBrowser}
  149. procedure load_references;virtual;
  150. function write_references : boolean;virtual;
  151. procedure add_to_browserlog;virtual;
  152. {$endif UseBrowser}
  153. {$ifdef GDB}
  154. function stabstring : pchar;virtual;
  155. procedure concatstabto(asmlist : paasmoutput);virtual;
  156. {$endif GDB}
  157. end;
  158. pvarsym = ^tvarsym;
  159. tvarsym = object(tsym)
  160. address : longint;
  161. {$ifdef VALUEPARA}
  162. localaddress : longint; { address of the local copy of a value para, -1 means not used }
  163. islocalcopy : boolean;
  164. {$endif}
  165. definition : pdef;
  166. refs : longint;
  167. var_options : byte;
  168. _mangledname : pchar;
  169. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  170. varspez : tvarspez; { sets the type of access }
  171. is_valid : byte;
  172. constructor init(const n : string;p : pdef);
  173. constructor init_dll(const n : string;p : pdef);
  174. constructor init_C(const n,mangled : string;p : pdef);
  175. constructor load;
  176. destructor done;virtual;
  177. procedure write;virtual;
  178. procedure deref;virtual;
  179. procedure setmangledname(const s : string);
  180. function mangledname : string;virtual;
  181. procedure insert_in_data;virtual;
  182. function getsize : longint;
  183. {$ifdef VALUEPARA}
  184. function getpushsize : longint;
  185. {$endif}
  186. {$ifdef GDB}
  187. function stabstring : pchar;virtual;
  188. procedure concatstabto(asmlist : paasmoutput);virtual;
  189. {$endif GDB}
  190. end;
  191. ppropertysym = ^tpropertysym;
  192. tpropertysym = object(tsym)
  193. options : longint;
  194. proptype : pdef;
  195. { proppara : pdefcoll; }
  196. readaccesssym,writeaccesssym,storedsym : psym;
  197. readaccessdef,writeaccessdef,storeddef : pdef;
  198. index,default : longint;
  199. constructor init(const n : string);
  200. destructor done;virtual;
  201. constructor load;
  202. function getsize : longint;virtual;
  203. procedure write;virtual;
  204. procedure deref;virtual;
  205. {$ifdef GDB}
  206. { I don't know how (FK) }
  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. {$ifdef GDB}
  218. procedure concatstabto(asmlist : paasmoutput);virtual;
  219. {$endif GDB}
  220. end;
  221. absolutetyp = (tovar,toasm,toaddr);
  222. pabsolutesym = ^tabsolutesym;
  223. tabsolutesym = object(tvarsym)
  224. abstyp : absolutetyp;
  225. absseg : boolean;
  226. ref : psym;
  227. asmname : pstring;
  228. constructor load;
  229. procedure deref;virtual;
  230. function mangledname : string;virtual;
  231. procedure write;virtual;
  232. procedure insert_in_data;virtual;
  233. { this creates a problem in gen_vmt !!!!!
  234. because the pdef is not resolved yet !!
  235. we should fix this
  236. constructor init(const s : string;p : pdef;newref : psym);}
  237. {$ifdef GDB}
  238. procedure concatstabto(asmlist : paasmoutput);virtual;
  239. {$endif GDB}
  240. end;
  241. ptypedconstsym = ^ttypedconstsym;
  242. ttypedconstsym = object(tsym)
  243. prefix : pstring;
  244. definition : pdef;
  245. constructor init(const n : string;p : pdef);
  246. constructor load;
  247. destructor done;virtual;
  248. function mangledname : string;virtual;
  249. procedure write;virtual;
  250. procedure deref;virtual;
  251. function getsize:longint;
  252. procedure insert_in_data;virtual;
  253. procedure really_insert_in_data;
  254. {$ifdef GDB}
  255. function stabstring : pchar;virtual;
  256. {$endif GDB}
  257. end;
  258. tconsttype = (constord,conststring,constreal,constbool,
  259. constint,constchar,constset,constnil);
  260. pconstsym = ^tconstsym;
  261. tconstsym = object(tsym)
  262. definition : pdef;
  263. consttype : tconsttype;
  264. value : longint;
  265. constructor init(const n : string;t : tconsttype;v : longint;def : pdef);
  266. constructor load;
  267. function mangledname : string;virtual;
  268. destructor done;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. next : 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. procedure write;virtual;
  298. {$ifdef GDB}
  299. procedure concatstabto(asmlist : paasmoutput);virtual;
  300. {$endif GDB}
  301. end;
  302. {
  303. $Log$
  304. Revision 1.9 1998-11-28 16:20:57 peter
  305. + support for dll variables
  306. Revision 1.8 1998/11/18 15:44:19 peter
  307. * VALUEPARA for tp7 compatible value parameters
  308. Revision 1.7 1998/11/16 10:13:50 peter
  309. * label defines are checked at the end of the proc
  310. Revision 1.6 1998/11/13 10:18:12 peter
  311. + nil constants
  312. Revision 1.5 1998/11/05 23:39:32 peter
  313. + typedconst.getsize
  314. Revision 1.4 1998/10/20 08:07:02 pierre
  315. * several memory corruptions due to double freemem solved
  316. => never use p^.loc.location:=p^.left^.loc.location;
  317. + finally I added now by default
  318. that ra386dir translates global and unit symbols
  319. + added a first field in tsymtable and
  320. a nextsym field in tsym
  321. (this allows to obtain ordered type info for
  322. records and objects in gdb !)
  323. Revision 1.3 1998/10/08 17:17:34 pierre
  324. * current_module old scanner tagged as invalid if unit is recompiled
  325. + added ppheap for better info on tracegetmem of heaptrc
  326. (adds line column and file index)
  327. * several memory leaks removed ith help of heaptrc !!
  328. Revision 1.2 1998/09/24 15:11:18 peter
  329. * fixed enum for not GDB
  330. Revision 1.1 1998/09/23 12:03:57 peter
  331. * overloading fix for array of const
  332. }