symsymh.inc 14 KB

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