symsym.inc 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Implementation 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 (base for all symtypes)
  20. ****************************************************************************}
  21. constructor tsym.init(const n : string);
  22. begin
  23. left:=nil;
  24. right:=nil;
  25. setname(n);
  26. typ:=abstractsym;
  27. properties:=current_object_option;
  28. {$ifdef GDB}
  29. isstabwritten := false;
  30. {$endif GDB}
  31. fileinfo:=aktfilepos;
  32. {$ifdef UseBrowser}
  33. defref:=nil;
  34. lastwritten:=nil;
  35. refcount:=0;
  36. if (cs_browser in aktmoduleswitches) and make_ref then
  37. begin
  38. defref:=new(pref,init(defref,@tokenpos));
  39. inc(refcount);
  40. end;
  41. lastref:=defref;
  42. {$endif UseBrowser}
  43. end;
  44. constructor tsym.load;
  45. begin
  46. left:=nil;
  47. right:=nil;
  48. setname(readstring);
  49. typ:=abstractsym;
  50. fillchar(fileinfo,sizeof(fileinfo),0);
  51. if object_options then
  52. properties:=symprop(readbyte)
  53. else
  54. properties:=sp_public;
  55. {$ifdef UseBrowser}
  56. lastref:=nil;
  57. defref:=nil;
  58. lastwritten:=nil;
  59. refcount:=0;
  60. {$endif UseBrowser}
  61. {$ifdef GDB}
  62. isstabwritten := false;
  63. {$endif GDB}
  64. end;
  65. {$ifdef UseBrowser}
  66. procedure tsym.load_references;
  67. var
  68. pos : tfileposinfo;
  69. begin
  70. while (not current_ppu^.endofentry) do
  71. begin
  72. readposinfo(pos);
  73. inc(refcount);
  74. lastref:=new(pref,init(lastref,@pos));
  75. if refcount=1 then
  76. defref:=lastref;
  77. end;
  78. lastwritten:=lastref;
  79. end;
  80. procedure tsym.write_references;
  81. var
  82. ref : pref;
  83. prdef : pdef;
  84. begin
  85. if lastwritten=lastref then
  86. exit;
  87. { write address to this symbol }
  88. writesymref(@self);
  89. { write symbol refs }
  90. if assigned(lastwritten) then
  91. ref:=lastwritten
  92. else
  93. ref:=defref;
  94. while assigned(ref) do
  95. begin
  96. writeposinfo(ref^.posinfo);
  97. ref:=ref^.nextref;
  98. end;
  99. lastwritten:=lastref;
  100. current_ppu^.writeentry(ibsymref);
  101. end;
  102. procedure tsym.add_to_browserlog;
  103. var
  104. prdef : pprocdef;
  105. begin
  106. if assigned(defref) then
  107. begin
  108. Browse.AddLog('***'+name+'***');
  109. Browse.AddLogRefs(defref);
  110. end;
  111. end;
  112. {$endif UseBrowser}
  113. destructor tsym.done;
  114. begin
  115. {$ifdef tp}
  116. if not(use_big) then
  117. {$endif tp}
  118. strdispose(_name);
  119. {$ifdef UseBrowser}
  120. if assigned(defref) then
  121. dispose(defref,done);
  122. {$endif UseBrowser}
  123. if assigned(left) then
  124. dispose(left,done);
  125. if assigned(right) then
  126. dispose(right,done);
  127. end;
  128. procedure tsym.write;
  129. begin
  130. writestring(name);
  131. if object_options then
  132. writebyte(byte(properties));
  133. {$ifdef UseBrowser}
  134. { if cs_browser in aktmoduleswitches then
  135. write_references; }
  136. {$endif UseBrowser}
  137. end;
  138. procedure tsym.deref;
  139. begin
  140. end;
  141. function tsym.name : string;
  142. {$ifdef tp}
  143. var
  144. s : string;
  145. b : byte;
  146. {$endif}
  147. begin
  148. {$ifdef tp}
  149. if use_big then
  150. begin
  151. symbolstream.seek(longint(_name));
  152. symbolstream.read(b,1);
  153. symbolstream.read(s[1],b);
  154. s[0]:=chr(b);
  155. name:=s;
  156. end
  157. else
  158. {$endif}
  159. if assigned(_name) then
  160. name:=strpas(_name)
  161. else
  162. name:='';
  163. end;
  164. function tsym.mangledname : string;
  165. begin
  166. mangledname:=name;
  167. end;
  168. procedure tsym.setname(const s : string);
  169. begin
  170. setstring(_name,s);
  171. end;
  172. { for most symbol types ther is nothing to do at all }
  173. procedure tsym.insert_in_data;
  174. begin
  175. end;
  176. {$ifdef GDB}
  177. function tsym.stabstring : pchar;
  178. begin
  179. stabstring:=strpnew('"'+name+'",'+tostr(N_LSYM)+',0,'+
  180. tostr(fileinfo.line)+',0');
  181. end;
  182. procedure tsym.concatstabto(asmlist : paasmoutput);
  183. var stab_str : pchar;
  184. begin
  185. if not isstabwritten then
  186. begin
  187. stab_str := stabstring;
  188. if asmlist = debuglist then do_count_dbx := true;
  189. { count_dbx(stab_str); moved to GDB.PAS }
  190. asmlist^.concat(new(pai_stabs,init(stab_str)));
  191. isstabwritten:=true;
  192. end;
  193. end;
  194. {$endif GDB}
  195. {****************************************************************************
  196. TLABELSYM
  197. ****************************************************************************}
  198. constructor tlabelsym.init(const n : string; l : plabel);
  199. begin
  200. inherited init(n);
  201. typ:=labelsym;
  202. number:=l;
  203. number^.is_used:=false;
  204. number^.is_set:=true;
  205. number^.refcount:=0;
  206. defined:=false;
  207. end;
  208. destructor tlabelsym.done;
  209. begin
  210. if not(defined) then
  211. Message1(sym_e_label_not_defined,name);
  212. inherited done;
  213. end;
  214. function tlabelsym.mangledname : string;
  215. begin
  216. { this also sets the is_used field }
  217. mangledname:=lab2str(number);
  218. end;
  219. procedure tlabelsym.write;
  220. begin
  221. Message(sym_e_ill_label_decl);
  222. end;
  223. {****************************************************************************
  224. TUNITSYM
  225. ****************************************************************************}
  226. constructor tunitsym.init(const n : string;ref : punitsymtable);
  227. var
  228. old_make_ref : boolean;
  229. begin
  230. old_make_ref:=make_ref;
  231. make_ref:=false;
  232. inherited init(n);
  233. make_ref:=old_make_ref;
  234. typ:=unitsym;
  235. unitsymtable:=ref;
  236. prevsym:=ref^.unitsym;
  237. ref^.unitsym:=@self;
  238. refs:=0;
  239. end;
  240. destructor tunitsym.done;
  241. begin
  242. if assigned(unitsymtable) and (unitsymtable^.unitsym=@self) then
  243. unitsymtable^.unitsym:=prevsym;
  244. inherited done;
  245. end;
  246. procedure tunitsym.write;
  247. begin
  248. end;
  249. {$ifdef GDB}
  250. procedure tunitsym.concatstabto(asmlist : paasmoutput);
  251. begin
  252. {Nothing to write to stabs !}
  253. end;
  254. {$endif GDB}
  255. {****************************************************************************
  256. TPROCSYM
  257. ****************************************************************************}
  258. constructor tprocsym.init(const n : string);
  259. begin
  260. tsym.init(n);
  261. typ:=procsym;
  262. definition:=nil;
  263. owner:=nil;
  264. {$ifdef GDB}
  265. is_global := false;
  266. {$endif GDB}
  267. end;
  268. constructor tprocsym.load;
  269. begin
  270. tsym.load;
  271. typ:=procsym;
  272. definition:=pprocdef(readdefref);
  273. {$ifdef GDB}
  274. is_global := false;
  275. {$endif GDB}
  276. end;
  277. destructor tprocsym.done;
  278. begin
  279. check_forward;
  280. tsym.done;
  281. end;
  282. function tprocsym.mangledname : string;
  283. begin
  284. mangledname:=definition^.mangledname;
  285. end;
  286. function tprocsym.demangledname:string;
  287. begin
  288. demangledname:=name+definition^.demangled_paras;
  289. end;
  290. procedure tprocsym.check_forward;
  291. var
  292. pd : pprocdef;
  293. oldaktfilepos : tfileposinfo;
  294. begin
  295. pd:=definition;
  296. while assigned(pd) do
  297. begin
  298. if pd^.forwarddef then
  299. begin
  300. oldaktfilepos:=aktfilepos;
  301. aktfilepos:=fileinfo;
  302. if assigned(pd^._class) then
  303. Message1(sym_e_forward_not_resolved,pd^._class^.name^+'.'+name+demangledparas(pd^.demangled_paras))
  304. else
  305. Message1(sym_e_forward_not_resolved,name+pd^.demangled_paras);
  306. aktfilepos:=oldaktfilepos;
  307. end;
  308. pd:=pd^.nextoverloaded;
  309. end;
  310. end;
  311. procedure tprocsym.deref;
  312. var t : ttoken;
  313. last : pprocdef;
  314. begin
  315. resolvedef(pdef(definition));
  316. if (definition^.options and pooperator) <> 0 then
  317. begin
  318. last:=definition;
  319. while assigned(last^.nextoverloaded) do
  320. last:=last^.nextoverloaded;
  321. for t:=PLUS to last_overloaded do
  322. if (name=overloaded_names[t]) then
  323. begin
  324. if assigned(overloaded_operators[t]) then
  325. last^.nextoverloaded:=overloaded_operators[t]^.definition;
  326. overloaded_operators[t]:=@self;
  327. end;
  328. end;
  329. end;
  330. procedure tprocsym.write;
  331. begin
  332. tsym.write;
  333. writedefref(pdef(definition));
  334. current_ppu^.writeentry(ibprocsym);
  335. end;
  336. {$ifdef UseBrowser}
  337. procedure tprocsym.load_references;
  338. var
  339. prdef : pprocdef;
  340. begin
  341. inherited load_references;
  342. prdef:=definition;
  343. { take care about operators !! }
  344. while assigned(prdef) and (prdef^.owner=definition^.owner) do
  345. begin
  346. prdef^.load_references;
  347. prdef:=prdef^.nextoverloaded;
  348. end;
  349. end;
  350. procedure tprocsym.write_references;
  351. var
  352. prdef : pprocdef;
  353. begin
  354. inherited write_references;
  355. prdef:=definition;
  356. while assigned(prdef) and (prdef^.owner=definition^.owner) do
  357. begin
  358. prdef^.write_references;
  359. prdef:=prdef^.nextoverloaded;
  360. end;
  361. end;
  362. procedure tprocsym.add_to_browserlog;
  363. var
  364. prdef : pprocdef;
  365. begin
  366. inherited add_to_browserlog;
  367. prdef:=definition;
  368. while assigned(prdef) do
  369. begin
  370. pprocdef(prdef)^.add_to_browserlog;
  371. prdef:=pprocdef(prdef)^.nextoverloaded;
  372. end;
  373. end;
  374. {$endif UseBrowser}
  375. {$ifdef GDB}
  376. function tprocsym.stabstring : pchar;
  377. Var RetType : Char;
  378. Obj,Info : String;
  379. begin
  380. obj := name;
  381. info := '';
  382. if is_global then
  383. RetType := 'F'
  384. else
  385. RetType := 'f';
  386. if assigned(owner) then
  387. begin
  388. if (owner^.symtabletype = objectsymtable) then
  389. obj := owner^.name^+'__'+name;
  390. if (owner^.symtabletype=localsymtable) and assigned(owner^.name) then
  391. info := ','+name+','+owner^.name^;
  392. end;
  393. stabstring :=strpnew('"'+obj+':'+RetType
  394. +definition^.retdef^.numberstring+info+'",'+tostr(n_function)
  395. +',0,'+
  396. tostr(aktfilepos.line)
  397. +','+definition^.mangledname);
  398. end;
  399. procedure tprocsym.concatstabto(asmlist : paasmoutput);
  400. begin
  401. if (definition^.options and pointernproc) <> 0 then exit;
  402. if not isstabwritten then
  403. asmlist^.concat(new(pai_stabs,init(stabstring)));
  404. isstabwritten := true;
  405. if assigned(definition^.parast) then
  406. definition^.parast^.concatstabto(asmlist);
  407. if assigned(definition^.localst) then
  408. definition^.localst^.concatstabto(asmlist);
  409. definition^.is_def_stab_written := true;
  410. end;
  411. {$endif GDB}
  412. {****************************************************************************
  413. TPROGRAMSYM
  414. ****************************************************************************}
  415. constructor tprogramsym.init(const n : string);
  416. begin
  417. inherited init(n);
  418. typ:=programsym;
  419. end;
  420. {****************************************************************************
  421. TERRORSYM
  422. ****************************************************************************}
  423. constructor terrorsym.init;
  424. begin
  425. inherited init('');
  426. typ:=errorsym;
  427. end;
  428. {****************************************************************************
  429. TPROPERTYSYM
  430. ****************************************************************************}
  431. constructor tpropertysym.init(const n : string);
  432. begin
  433. inherited init(n);
  434. typ:=propertysym;
  435. options:=0;
  436. proptype:=nil;
  437. readaccessdef:=nil;
  438. writeaccessdef:=nil;
  439. readaccesssym:=nil;
  440. writeaccesssym:=nil;
  441. index:=$0;
  442. end;
  443. destructor tpropertysym.done;
  444. begin
  445. inherited done;
  446. end;
  447. constructor tpropertysym.load;
  448. begin
  449. inherited load;
  450. typ:=propertysym;
  451. proptype:=readdefref;
  452. options:=readlong;
  453. index:=readlong;
  454. { it's hack ... }
  455. readaccesssym:=psym(stringdup(readstring));
  456. writeaccesssym:=psym(stringdup(readstring));
  457. { now the defs: }
  458. readaccessdef:=readdefref;
  459. writeaccessdef:=readdefref;
  460. end;
  461. procedure tpropertysym.deref;
  462. begin
  463. resolvedef(proptype);
  464. resolvedef(readaccessdef);
  465. resolvedef(writeaccessdef);
  466. { solve the hack we did in load: }
  467. if pstring(readaccesssym)^<>'' then
  468. begin
  469. srsym:=search_class_member(pobjectdef(owner^.defowner),pstring(readaccesssym)^);
  470. if not(assigned(srsym)) then
  471. srsym:=generrorsym;
  472. end
  473. else
  474. srsym:=nil;
  475. stringdispose(pstring(readaccesssym));
  476. readaccesssym:=srsym;
  477. if pstring(writeaccesssym)^<>'' then
  478. begin
  479. srsym:=search_class_member(pobjectdef(owner^.defowner),pstring(writeaccesssym)^);
  480. if not(assigned(srsym)) then
  481. srsym:=generrorsym;
  482. end
  483. else
  484. srsym:=nil;
  485. stringdispose(pstring(writeaccesssym));
  486. writeaccesssym:=srsym;
  487. end;
  488. function tpropertysym.getsize : longint;
  489. begin
  490. getsize:=0;
  491. end;
  492. procedure tpropertysym.write;
  493. begin
  494. tsym.write;
  495. writedefref(proptype);
  496. writelong(options);
  497. writelong(index);
  498. if assigned(readaccesssym) then
  499. writestring(readaccesssym^.name)
  500. else
  501. writestring('');
  502. if assigned(writeaccesssym) then
  503. writestring(writeaccesssym^.name)
  504. else
  505. writestring('');
  506. writedefref(readaccessdef);
  507. writedefref(writeaccessdef);
  508. current_ppu^.writeentry(ibpropertysym);
  509. end;
  510. {$ifdef GDB}
  511. function tpropertysym.stabstring : pchar;
  512. begin
  513. { !!!! don't know how to handle }
  514. stabstring:=strpnew('');
  515. end;
  516. procedure tpropertysym.concatstabto(asmlist : paasmoutput);
  517. begin
  518. { !!!! don't know how to handle }
  519. end;
  520. {$endif GDB}
  521. {****************************************************************************
  522. TFUNCRETSYM
  523. ****************************************************************************}
  524. constructor tfuncretsym.init(const n : string;approcinfo : pointer{pprocinfo});
  525. begin
  526. tsym.init(n);
  527. typ:=funcretsym;
  528. funcretprocinfo:=approcinfo;
  529. funcretdef:=pprocinfo(approcinfo)^.retdef;
  530. { address valid for ret in param only }
  531. { otherwise set by insert }
  532. address:=pprocinfo(approcinfo)^.retoffset;
  533. end;
  534. {$ifdef GDB}
  535. procedure tfuncretsym.concatstabto(asmlist : paasmoutput);
  536. begin
  537. { Nothing to do here, it is done in genexitcode }
  538. end;
  539. {$endif GDB}
  540. {****************************************************************************
  541. TABSOLUTESYM
  542. ****************************************************************************}
  543. { constructor tabsolutesym.init(const s : string;p : pdef;newref : psym);
  544. begin
  545. inherited init(s,p);
  546. ref:=newref;
  547. typ:=absolutesym;
  548. end; }
  549. constructor tabsolutesym.load;
  550. begin
  551. tvarsym.load;
  552. typ:=absolutesym;
  553. ref:=nil;
  554. address:=0;
  555. asmname:=nil;
  556. abstyp:=absolutetyp(readbyte);
  557. absseg:=false;
  558. case abstyp of
  559. tovar : begin
  560. asmname:=stringdup(readstring);
  561. ref:=srsym;
  562. end;
  563. toasm : asmname:=stringdup(readstring);
  564. toaddr : address:=readlong;
  565. end;
  566. end;
  567. procedure tabsolutesym.write;
  568. begin
  569. tsym.write;
  570. writebyte(byte(varspez));
  571. if read_member then
  572. writelong(address);
  573. writedefref(definition);
  574. writebyte(byte(abstyp));
  575. case abstyp of
  576. tovar : writestring(ref^.name);
  577. toasm : writestring(asmname^);
  578. toaddr : writelong(address);
  579. end;
  580. current_ppu^.writeentry(ibabsolutesym);
  581. end;
  582. procedure tabsolutesym.deref;
  583. begin
  584. resolvedef(definition);
  585. if (abstyp=tovar) and (asmname<>nil) then
  586. begin
  587. { search previous loaded symtables }
  588. getsym(asmname^,false);
  589. if not(assigned(srsym)) then
  590. getsymonlyin(owner,asmname^);
  591. if not(assigned(srsym)) then
  592. srsym:=generrorsym;
  593. ref:=srsym;
  594. stringdispose(asmname);
  595. end;
  596. end;
  597. function tabsolutesym.mangledname : string;
  598. begin
  599. case abstyp of
  600. tovar : mangledname:=ref^.mangledname;
  601. toasm : mangledname:=asmname^;
  602. toaddr : mangledname:='$'+tostr(address);
  603. else
  604. internalerror(10002);
  605. end;
  606. end;
  607. procedure tabsolutesym.insert_in_data;
  608. begin
  609. end;
  610. {$ifdef GDB}
  611. procedure tabsolutesym.concatstabto(asmlist : paasmoutput);
  612. begin
  613. { I don't know how to handle this !! }
  614. end;
  615. {$endif GDB}
  616. {****************************************************************************
  617. TVARSYM
  618. ****************************************************************************}
  619. constructor tvarsym.init(const n : string;p : pdef);
  620. begin
  621. tsym.init(n);
  622. typ:=varsym;
  623. definition:=p;
  624. _mangledname:=nil;
  625. varspez:=vs_value;
  626. address:=0;
  627. refs:=0;
  628. is_valid := 1;
  629. var_options:=0;
  630. { can we load the value into a register ? }
  631. case p^.deftype of
  632. pointerdef,
  633. enumdef,
  634. procvardef : var_options:=var_options or vo_regable;
  635. orddef : case porddef(p)^.typ of
  636. u8bit,u16bit,u32bit,
  637. bool8bit,bool16bit,bool32bit,
  638. s8bit,s16bit,s32bit :
  639. var_options:=var_options or vo_regable;
  640. else
  641. var_options:=var_options and not vo_regable;
  642. end;
  643. else
  644. var_options:=var_options and not vo_regable;
  645. end;
  646. reg:=R_NO;
  647. end;
  648. constructor tvarsym.load;
  649. begin
  650. tsym.load;
  651. typ:=varsym;
  652. _mangledname:=nil;
  653. varspez:=tvarspez(readbyte);
  654. if read_member then
  655. address:=readlong
  656. else
  657. address:=0;
  658. definition:=readdefref;
  659. refs := 0;
  660. is_valid := 1;
  661. { symbols which are load are never candidates for a register }
  662. var_options:=0;
  663. { was regable:=false; }
  664. reg:=R_NO;
  665. end;
  666. constructor tvarsym.init_C(const n,mangled : string;p : pdef);
  667. begin
  668. { The tvarsym is necessary for 0.99.5 (PFV) }
  669. tvarsym.init(n,p);
  670. var_options:=var_options or vo_is_C_var;
  671. { C prefix not allways added moved to
  672. pdecl PM }
  673. _mangledname:=strpnew(mangled);
  674. end;
  675. constructor tvarsym.load_C;
  676. begin
  677. { Adding tvarsym removes the warning }
  678. tvarsym.load;
  679. typ:=varsym;
  680. var_options:=readbyte;
  681. _mangledname:=strpnew(readstring);
  682. end;
  683. procedure tvarsym.deref;
  684. begin
  685. resolvedef(definition);
  686. end;
  687. procedure tvarsym.write;
  688. begin
  689. tsym.write;
  690. writebyte(byte(varspez));
  691. if read_member then
  692. writelong(address);
  693. writedefref(definition);
  694. if (var_options and vo_is_C_var)<>0 then
  695. begin
  696. writebyte(var_options);
  697. writestring(mangledname);
  698. end;
  699. if (var_options and vo_is_C_var)<>0 then
  700. current_ppu^.writeentry(ibvarsym_C)
  701. else
  702. current_ppu^.writeentry(ibvarsym);
  703. end;
  704. function tvarsym.mangledname : string;
  705. var
  706. prefix : string;
  707. begin
  708. if assigned(_mangledname) then
  709. begin
  710. mangledname:=strpas(_mangledname);
  711. exit;
  712. end;
  713. case owner^.symtabletype of
  714. staticsymtable : if (cs_smartlink in aktmoduleswitches) then
  715. prefix:='_'+owner^.name^+'$$$_'
  716. else
  717. prefix:='_';
  718. unitsymtable,
  719. globalsymtable : prefix:='U_'+owner^.name^+'_';
  720. else
  721. Message(sym_e_invalid_call_tvarsymmangledname);
  722. end;
  723. mangledname:=prefix+name;
  724. end;
  725. function tvarsym.getsize : longint;
  726. begin
  727. { only if the definition is set, we could determine the }
  728. { size, this is if an error occurs while reading the type }
  729. { also used for operator, this allows not to allocate the }
  730. { return size twice }
  731. if assigned(definition) then
  732. begin
  733. case varspez of
  734. vs_value : getsize:=definition^.size;
  735. vs_var : begin
  736. { open arrays push also the high valye }
  737. if (definition^.deftype=arraydef) and
  738. (parraydef(definition)^.lowrange=0) and
  739. (parraydef(definition)^.highrange=-1) then
  740. getsize:=sizeof(pointer)+4
  741. else
  742. getsize:=sizeof(pointer);
  743. end;
  744. vs_const : begin
  745. case definition^.deftype of
  746. stringdef,
  747. recorddef,
  748. objectdef,
  749. setdef : getsize:=sizeof(pointer);
  750. arraydef : begin
  751. { open arrays push also the high valye }
  752. if (parraydef(definition)^.lowrange=0) and
  753. (parraydef(definition)^.highrange=-1) then
  754. getsize:=sizeof(pointer)+4
  755. else
  756. getsize:=sizeof(pointer);
  757. end;
  758. else
  759. getsize:=definition^.size;
  760. end;
  761. end;
  762. end;
  763. end
  764. else
  765. getsize:=0;
  766. end;
  767. procedure tvarsym.insert_in_data;
  768. var
  769. l,modulo : longint;
  770. begin
  771. if (var_options and vo_is_external)<>0 then
  772. exit;
  773. { handle static variables of objects especially }
  774. if read_member and (owner^.symtabletype=objectsymtable) and
  775. ((properties and sp_static)<>0) then
  776. begin
  777. { the data filed is generated in parser.pas
  778. with a tobject_FIELDNAME variable }
  779. { this symbol can't be loaded to a register }
  780. var_options:=var_options and not vo_regable;
  781. end
  782. else
  783. if not(read_member) then
  784. begin
  785. { made problems with parameters etc. ! (FK) }
  786. { check for instance of an abstract object or class }
  787. {
  788. if (pvarsym(sym)^.definition^.deftype=objectdef) and
  789. ((pobjectdef(pvarsym(sym)^.definition)^.options and oois_abstract)<>0) then
  790. Message(sym_e_no_instance_of_abstract_object);
  791. }
  792. l:=getsize;
  793. case owner^.symtabletype of
  794. stt_exceptsymtable:
  795. { can contain only one symbol, address calculated later }
  796. ;
  797. localsymtable : begin
  798. is_valid := 0;
  799. modulo:=owner^.datasize and 3;
  800. {$ifdef m68k}
  801. { word alignment required for motorola }
  802. if (l=1) then
  803. l:=2
  804. else
  805. {$endif}
  806. if (l>=4) and (modulo<>0) then
  807. inc(l,4-modulo)
  808. else
  809. if (l>=2) and ((modulo and 1)<>0) then
  810. inc(l,2-(modulo and 1));
  811. inc(owner^.datasize,l);
  812. address:=owner^.datasize;
  813. end;
  814. staticsymtable : begin
  815. if (cs_smartlink in aktmoduleswitches) then
  816. bsssegment^.concat(new(pai_cut,init));
  817. {$ifdef GDB}
  818. if cs_debuginfo in aktmoduleswitches then
  819. concatstabto(bsssegment);
  820. {$endif GDB}
  821. if (cs_smartlink in aktmoduleswitches) or
  822. ((var_options and vo_is_c_var)<>0) then
  823. bsssegment^.concat(new(pai_datablock,init_global(mangledname,l)))
  824. else
  825. bsssegment^.concat(new(pai_datablock,init(mangledname,l)));
  826. { increase datasize }
  827. inc(owner^.datasize,l);
  828. { this symbol can't be loaded to a register }
  829. var_options:=var_options and not vo_regable;
  830. end;
  831. globalsymtable : begin
  832. if (cs_smartlink in aktmoduleswitches) then
  833. bsssegment^.concat(new(pai_cut,init));
  834. {$ifdef GDB}
  835. if cs_debuginfo in aktmoduleswitches then
  836. concatstabto(bsssegment);
  837. {$endif GDB}
  838. bsssegment^.concat(new(pai_datablock,init_global(mangledname,l)));
  839. inc(owner^.datasize,l);
  840. { this symbol can't be loaded to a register }
  841. var_options:=var_options and not vo_regable;
  842. end;
  843. recordsymtable,
  844. objectsymtable : begin
  845. { this symbol can't be loaded to a register }
  846. var_options:=var_options and not vo_regable;
  847. { align record and object fields }
  848. if (l=1) or (aktpackrecords=1) then
  849. begin
  850. address:=owner^.datasize;
  851. inc(owner^.datasize,l)
  852. end
  853. else
  854. if (l=2) or (aktpackrecords=2) then
  855. begin
  856. owner^.datasize:=(owner^.datasize+1) and (not 1);
  857. address:=owner^.datasize;
  858. inc(owner^.datasize,l)
  859. end
  860. else
  861. if (l<=4) or (aktpackrecords=4) then
  862. begin
  863. owner^.datasize:=(owner^.datasize+3) and (not 3);
  864. address:=owner^.datasize;
  865. inc(owner^.datasize,l);
  866. end
  867. else
  868. if (l<=16) or (aktpackrecords=16) then
  869. begin
  870. owner^.datasize:=(owner^.datasize+15) and (not 15);
  871. address:=owner^.datasize;
  872. inc(owner^.datasize,l);
  873. end;
  874. end;
  875. parasymtable : begin
  876. address:=owner^.datasize;
  877. { needs word alignment }
  878. if odd(l) then
  879. inc(owner^.datasize,l+1)
  880. else
  881. inc(owner^.datasize,l);
  882. end
  883. else
  884. begin
  885. modulo:=owner^.datasize and 3 ;
  886. if (l>=4) and (modulo<>0) then
  887. inc(owner^.datasize,4-modulo)
  888. else
  889. if (l>=2) and ((modulo and 1)<>0) then
  890. { nice piece of code !!
  891. inc(owner^.datasize,2-(datasize and 1));
  892. 2 - (datasize and 1) is allways 1 in this case
  893. Florian when will your global stream analyser
  894. find this out ?? }
  895. inc(owner^.datasize);
  896. address:=owner^.datasize;
  897. inc(owner^.datasize,l);
  898. end;
  899. end;
  900. end;
  901. end;
  902. {$ifdef GDB}
  903. function tvarsym.stabstring : pchar;
  904. var
  905. st : char;
  906. begin
  907. if (owner^.symtabletype = objectsymtable) and
  908. ((properties and sp_static)<>0) then
  909. begin
  910. if use_gsym then st := 'G' else st := 'S';
  911. stabstring := strpnew('"'+owner^.name^+'__'+name+':'+
  912. +definition^.numberstring+'",'+
  913. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  914. end
  915. else if (owner^.symtabletype = globalsymtable) or
  916. (owner^.symtabletype = unitsymtable) then
  917. begin
  918. { Here we used S instead of
  919. because with G GDB doesn't look at the address field
  920. but searches the same name or with a leading underscore
  921. but these names don't exist in pascal !}
  922. if use_gsym then st := 'G' else st := 'S';
  923. stabstring := strpnew('"'+name+':'+st
  924. +definition^.numberstring+'",'+
  925. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  926. end
  927. else if owner^.symtabletype = staticsymtable then
  928. begin
  929. stabstring := strpnew('"'+name+':S'
  930. +definition^.numberstring+'",'+
  931. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  932. end
  933. else if (owner^.symtabletype=parasymtable) then
  934. begin
  935. case varspez of
  936. vs_value : st := 'p';
  937. vs_var : st := 'v';
  938. vs_const : if dont_copy_const_param(definition) then
  939. st := 'v'{ should be 'i' but 'i' doesn't work }
  940. else
  941. st := 'p';
  942. end;
  943. stabstring := strpnew('"'+name+':'+st
  944. +definition^.numberstring+'",'+
  945. tostr(N_PSYM)+',0,'+tostr(fileinfo.line)+','+
  946. tostr(address+owner^.call_offset));
  947. {offset to ebp => will not work if the framepointer is esp
  948. so some optimizing will make things harder to debug }
  949. end
  950. else if (owner^.symtabletype=localsymtable) then
  951. {$ifdef i386}
  952. if reg<>R_NO then
  953. begin
  954. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  955. { this is the register order for GDB}
  956. stabstring:=strpnew('"'+name+':r'
  957. +definition^.numberstring+'",'+
  958. tostr(N_RSYM)+',0,'+
  959. tostr(fileinfo.line)+','+tostr(GDB_i386index[reg]));
  960. end
  961. else
  962. {$endif i386}
  963. stabstring := strpnew('"'+name+':'
  964. +definition^.numberstring+'",'+
  965. tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address))
  966. else
  967. stabstring := inherited stabstring;
  968. end;
  969. procedure tvarsym.concatstabto(asmlist : paasmoutput);
  970. {$ifdef i386}
  971. var stab_str : pchar;
  972. {$endif i386}
  973. begin
  974. inherited concatstabto(asmlist);
  975. {$ifdef i386}
  976. if (owner^.symtabletype=parasymtable) and
  977. (reg<>R_NO) then
  978. begin
  979. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  980. { this is the register order for GDB}
  981. stab_str:=strpnew('"'+name+':r'
  982. +definition^.numberstring+'",'+
  983. tostr(N_RSYM)+',0,'+
  984. tostr(fileinfo.line)+','+tostr(GDB_i386index[reg]));
  985. asmlist^.concat(new(pai_stabs,init(stab_str)));
  986. end;
  987. {$endif i386}
  988. end;
  989. {$endif GDB}
  990. destructor tvarsym.done;
  991. begin
  992. strdispose(_mangledname);
  993. inherited done;
  994. end;
  995. {****************************************************************************
  996. TTYPEDCONSTSYM
  997. *****************************************************************************}
  998. constructor ttypedconstsym.init(const n : string;p : pdef);
  999. begin
  1000. tsym.init(n);
  1001. typ:=typedconstsym;
  1002. definition:=p;
  1003. prefix:=stringdup(procprefix);
  1004. end;
  1005. constructor ttypedconstsym.load;
  1006. begin
  1007. tsym.load;
  1008. typ:=typedconstsym;
  1009. definition:=readdefref;
  1010. prefix:=stringdup(readstring);
  1011. end;
  1012. destructor ttypedconstsym.done;
  1013. begin
  1014. stringdispose(prefix);
  1015. tsym.done;
  1016. end;
  1017. function ttypedconstsym.mangledname : string;
  1018. begin
  1019. mangledname:='TC_'+prefix^+'_'+name;
  1020. end;
  1021. procedure ttypedconstsym.deref;
  1022. begin
  1023. resolvedef(definition);
  1024. end;
  1025. procedure ttypedconstsym.write;
  1026. begin
  1027. tsym.write;
  1028. writedefref(definition);
  1029. writestring(prefix^);
  1030. current_ppu^.writeentry(ibtypedconstsym);
  1031. end;
  1032. { for most symbol types ther is nothing to do at all }
  1033. procedure ttypedconstsym.insert_in_data;
  1034. begin
  1035. { here there is a problem for ansistrings !! }
  1036. { we must write the label only after the 12 header bytes (PM)
  1037. if not is_ansistring(definition) then
  1038. }
  1039. { solved, the ansis string is moved to consts (FK) }
  1040. really_insert_in_data;
  1041. end;
  1042. procedure ttypedconstsym.really_insert_in_data;
  1043. begin
  1044. if owner^.symtabletype=globalsymtable then
  1045. begin
  1046. if (cs_smartlink in aktmoduleswitches) then
  1047. datasegment^.concat(new(pai_cut,init));
  1048. {$ifdef GDB}
  1049. if cs_debuginfo in aktmoduleswitches then
  1050. concatstabto(datasegment);
  1051. {$endif GDB}
  1052. datasegment^.concat(new(pai_symbol,init_global(mangledname)));
  1053. end
  1054. else
  1055. if owner^.symtabletype<>unitsymtable then
  1056. begin
  1057. if (cs_smartlink in aktmoduleswitches) then
  1058. datasegment^.concat(new(pai_cut,init));
  1059. {$ifdef GDB}
  1060. if cs_debuginfo in aktmoduleswitches then
  1061. concatstabto(datasegment);
  1062. {$endif GDB}
  1063. if (cs_smartlink in aktmoduleswitches) then
  1064. datasegment^.concat(new(pai_symbol,init_global(mangledname)))
  1065. else
  1066. datasegment^.concat(new(pai_symbol,init(mangledname)));
  1067. end;
  1068. end;
  1069. {$ifdef GDB}
  1070. function ttypedconstsym.stabstring : pchar;
  1071. var
  1072. st : char;
  1073. begin
  1074. if use_gsym and (owner^.symtabletype in [unitsymtable,globalsymtable]) then
  1075. st := 'G'
  1076. else
  1077. st := 'S';
  1078. stabstring := strpnew('"'+name+':'+st+
  1079. definition^.numberstring+'",'+tostr(n_STSYM)+',0,'+
  1080. tostr(fileinfo.line)+','+mangledname);
  1081. end;
  1082. {$endif GDB}
  1083. {****************************************************************************
  1084. TCONSTSYM
  1085. ****************************************************************************}
  1086. constructor tconstsym.init(const n : string;t : tconsttype;v : longint;def : pdef);
  1087. begin
  1088. tsym.init(n);
  1089. typ:=constsym;
  1090. definition:=def;
  1091. consttype:=t;
  1092. value:=v;
  1093. end;
  1094. constructor tconstsym.load;
  1095. var
  1096. pd : pbestreal;
  1097. ps : pnormalset;
  1098. begin
  1099. tsym.load;
  1100. typ:=constsym;
  1101. consttype:=tconsttype(readbyte);
  1102. case consttype of
  1103. constint,
  1104. constbool,
  1105. constchar : value:=readlong;
  1106. constord : begin
  1107. definition:=readdefref;
  1108. value:=readlong;
  1109. end;
  1110. conststring : value:=longint(stringdup(readstring));
  1111. constreal : begin
  1112. new(pd);
  1113. pd^:=readreal;
  1114. value:=longint(pd);
  1115. end;
  1116. constseta : begin
  1117. definition:=readdefref;
  1118. new(ps);
  1119. readnormalset(ps^);
  1120. value:=longint(ps);
  1121. end;
  1122. else
  1123. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttype)));
  1124. end;
  1125. end;
  1126. destructor tconstsym.done;
  1127. begin
  1128. case consttype of
  1129. conststring : stringdispose(pstring(value));
  1130. constreal : dispose(pbestreal(value));
  1131. constseta : dispose(pnormalset(value));
  1132. end;
  1133. inherited done;
  1134. end;
  1135. function tconstsym.mangledname : string;
  1136. begin
  1137. mangledname:=name;
  1138. end;
  1139. procedure tconstsym.deref;
  1140. begin
  1141. if consttype in [constord,constseta] then
  1142. resolvedef(pdef(definition));
  1143. end;
  1144. procedure tconstsym.write;
  1145. begin
  1146. tsym.write;
  1147. writebyte(byte(consttype));
  1148. case consttype of
  1149. constint,
  1150. constbool,
  1151. constchar : writelong(value);
  1152. constord : begin
  1153. writedefref(definition);
  1154. writelong(value);
  1155. end;
  1156. conststring : writestring(pstring(value)^);
  1157. constreal : writereal(pbestreal(value)^);
  1158. constseta : begin
  1159. writedefref(definition);
  1160. writenormalset(pointer(value)^);
  1161. end;
  1162. else
  1163. internalerror(13);
  1164. end;
  1165. current_ppu^.writeentry(ibconstsym);
  1166. end;
  1167. {$ifdef GDB}
  1168. function tconstsym.stabstring : pchar;
  1169. var st : string;
  1170. begin
  1171. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  1172. case consttype of
  1173. conststring : begin
  1174. { I had to remove ibm2ascii !! }
  1175. st := pstring(value)^;
  1176. {st := ibm2ascii(pstring(value)^);}
  1177. st := 's'''+st+'''';
  1178. end;
  1179. constbool, constint, constord, constchar : st := 'i'+tostr(value);
  1180. constreal : begin
  1181. system.str(pbestreal(value)^,st);
  1182. st := 'r'+st;
  1183. end;
  1184. { if we don't know just put zero !! }
  1185. else st:='i0';
  1186. {***SETCONST}
  1187. {constset:;} {*** I don't know what to do with a set.}
  1188. { sets are not recognized by GDB}
  1189. {***}
  1190. end;
  1191. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  1192. tostr(fileinfo.line)+',0');
  1193. end;
  1194. procedure tconstsym.concatstabto(asmlist : paasmoutput);
  1195. begin
  1196. if consttype <> conststring then
  1197. inherited concatstabto(asmlist);
  1198. end;
  1199. {$endif GDB}
  1200. {****************************************************************************
  1201. TENUMSYM
  1202. ****************************************************************************}
  1203. constructor tenumsym.init(const n : string;def : penumdef;v : longint);
  1204. begin
  1205. tsym.init(n);
  1206. typ:=enumsym;
  1207. definition:=def;
  1208. value:=v;
  1209. if def^.min>v then
  1210. def^.setmin(v);
  1211. if def^.max<v then
  1212. def^.setmax(v);
  1213. {$ifdef GDB}
  1214. order;
  1215. {$endif GDB}
  1216. end;
  1217. constructor tenumsym.load;
  1218. begin
  1219. tsym.load;
  1220. typ:=enumsym;
  1221. definition:=penumdef(readdefref);
  1222. value:=readlong;
  1223. {$ifdef GDB}
  1224. next := Nil;
  1225. {$endif GDB}
  1226. end;
  1227. procedure tenumsym.deref;
  1228. begin
  1229. resolvedef(pdef(definition));
  1230. {$ifdef GDB}
  1231. order;
  1232. {$endif}
  1233. end;
  1234. {$ifdef GDB}
  1235. procedure tenumsym.order;
  1236. var sym : penumsym;
  1237. begin
  1238. sym := definition^.first;
  1239. if sym = nil then
  1240. begin
  1241. definition^.first := @self;
  1242. next := nil;
  1243. exit;
  1244. end;
  1245. {reorder the symbols in increasing value }
  1246. if value < sym^.value then
  1247. begin
  1248. next := sym;
  1249. definition^.first := @self;
  1250. end else
  1251. begin
  1252. while (sym^.value <= value) and assigned(sym^.next) do
  1253. sym := sym^.next;
  1254. next := sym^.next;
  1255. sym^.next := @self;
  1256. end;
  1257. end;
  1258. {$endif GDB}
  1259. procedure tenumsym.write;
  1260. begin
  1261. tsym.write;
  1262. writedefref(definition);
  1263. writelong(value);
  1264. current_ppu^.writeentry(ibenumsym);
  1265. end;
  1266. {$ifdef GDB}
  1267. procedure tenumsym.concatstabto(asmlist : paasmoutput);
  1268. begin
  1269. {enum elements have no stab !}
  1270. end;
  1271. {$EndIf GDB}
  1272. {****************************************************************************
  1273. TTYPESYM
  1274. ****************************************************************************}
  1275. constructor ttypesym.init(const n : string;d : pdef);
  1276. begin
  1277. tsym.init(n);
  1278. typ:=typesym;
  1279. definition:=d;
  1280. {$ifdef GDB}
  1281. isusedinstab := false;
  1282. {$endif GDB}
  1283. forwardpointer:=nil;
  1284. { this allows to link definitions with the type with declares }
  1285. { them }
  1286. if assigned(definition) then
  1287. if definition^.sym=nil then
  1288. definition^.sym:=@self;
  1289. end;
  1290. constructor ttypesym.load;
  1291. begin
  1292. tsym.load;
  1293. typ:=typesym;
  1294. forwardpointer:=nil;
  1295. {$ifdef GDB}
  1296. isusedinstab := false;
  1297. {$endif GDB}
  1298. definition:=readdefref;
  1299. end;
  1300. destructor ttypesym.done;
  1301. begin
  1302. if assigned(definition) then
  1303. if definition^.sym=@self then
  1304. definition^.sym:=nil;
  1305. inherited done;
  1306. end;
  1307. procedure ttypesym.deref;
  1308. begin
  1309. resolvedef(definition);
  1310. if assigned(definition) then
  1311. begin
  1312. if definition^.sym=nil then
  1313. definition^.sym:=@self;
  1314. if definition^.deftype=recorddef then
  1315. precdef(definition)^.symtable^.name:=stringdup('record '+name);
  1316. end;
  1317. end;
  1318. procedure ttypesym.write;
  1319. begin
  1320. tsym.write;
  1321. writedefref(definition);
  1322. current_ppu^.writeentry(ibtypesym);
  1323. end;
  1324. {$ifdef UseBrowser}
  1325. procedure ttypesym.load_references;
  1326. var
  1327. prdef : pdef;
  1328. begin
  1329. inherited load_references;
  1330. if (definition^.deftype=recorddef) then
  1331. precdef(definition)^.symtable^.load_browser;
  1332. if (definition^.deftype=objectdef) then
  1333. pobjectdef(definition)^.publicsyms^.load_browser;
  1334. end;
  1335. procedure ttypesym.write_references;
  1336. var
  1337. prdef : pdef;
  1338. begin
  1339. inherited write_references;
  1340. if (definition^.deftype=recorddef) then
  1341. precdef(definition)^.symtable^.write_browser;
  1342. if (definition^.deftype=objectdef) then
  1343. pobjectdef(definition)^.publicsyms^.write_browser;
  1344. end;
  1345. procedure ttypesym.add_to_browserlog;
  1346. var
  1347. aktobjdef : pobjectdef;
  1348. begin
  1349. inherited add_to_browserlog;
  1350. if (definition^.deftype=recorddef) then
  1351. precdef(definition)^.symtable^.writebrowserlog;
  1352. if (definition^.deftype=objectdef) then
  1353. pobjectdef(definition)^.publicsyms^.writebrowserlog;
  1354. end;
  1355. {$endif UseBrowser}
  1356. {$ifdef GDB}
  1357. function ttypesym.stabstring : pchar;
  1358. var stabchar : string[2];
  1359. short : string;
  1360. begin
  1361. if definition^.deftype in tagtypes then
  1362. stabchar := 'Tt'
  1363. else
  1364. stabchar := 't';
  1365. short := '"'+name+':'+stabchar+definition^.numberstring
  1366. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  1367. stabstring := strpnew(short);
  1368. end;
  1369. procedure ttypesym.concatstabto(asmlist : paasmoutput);
  1370. begin
  1371. {not stabs for forward defs }
  1372. if assigned(definition) then
  1373. if (definition^.sym = @self) then
  1374. definition^.concatstabto(asmlist)
  1375. else
  1376. inherited concatstabto(asmlist);
  1377. end;
  1378. {$endif GDB}
  1379. {****************************************************************************
  1380. TSYSSYM
  1381. ****************************************************************************}
  1382. constructor tsyssym.init(const n : string;l : longint);
  1383. begin
  1384. inherited init(n);
  1385. typ:=syssym;
  1386. number:=l;
  1387. end;
  1388. procedure tsyssym.write;
  1389. begin
  1390. end;
  1391. {$ifdef GDB}
  1392. procedure tsyssym.concatstabto(asmlist : paasmoutput);
  1393. begin
  1394. end;
  1395. {$endif GDB}
  1396. {****************************************************************************
  1397. TMACROSYM
  1398. ****************************************************************************}
  1399. constructor tmacrosym.init(const n : string);
  1400. begin
  1401. inherited init(n);
  1402. defined:=true;
  1403. buftext:=nil;
  1404. buflen:=0;
  1405. end;
  1406. destructor tmacrosym.done;
  1407. begin
  1408. if assigned(buftext) then
  1409. freemem(buftext,buflen);
  1410. inherited done;
  1411. end;
  1412. {
  1413. $Log$
  1414. Revision 1.38 1998-09-01 12:53:26 peter
  1415. + aktpackenum
  1416. Revision 1.37 1998/09/01 07:54:25 pierre
  1417. * UseBrowser a little updated (might still be buggy !!)
  1418. * bug in psub.pas in function specifier removed
  1419. * stdcall allowed in interface and in implementation
  1420. (FPC will not yet complain if it is missing in either part
  1421. because stdcall is only a dummy !!)
  1422. Revision 1.36 1998/08/25 13:09:26 pierre
  1423. * corrected mangling sheme :
  1424. cvar add Cprefix to the mixed case name whereas
  1425. export or public use direct name
  1426. Revision 1.35 1998/08/25 12:42:46 pierre
  1427. * CDECL changed to CVAR for variables
  1428. specifications are read in structures also
  1429. + started adding GPC compatibility mode ( option -Sp)
  1430. * names changed to lowercase
  1431. Revision 1.34 1998/08/21 14:08:53 pierre
  1432. + TEST_FUNCRET now default (old code removed)
  1433. works also for m68k (at least compiles)
  1434. Revision 1.33 1998/08/20 12:53:27 peter
  1435. * object_options are always written for object syms
  1436. Revision 1.32 1998/08/20 09:26:46 pierre
  1437. + funcret setting in underproc testing
  1438. compile with _dTEST_FUNCRET
  1439. Revision 1.31 1998/08/17 10:10:12 peter
  1440. - removed OLDPPU
  1441. Revision 1.30 1998/08/13 10:57:29 peter
  1442. * constant sets are now written correctly to the ppufile
  1443. Revision 1.29 1998/08/11 15:31:42 peter
  1444. * write extended to ppu file
  1445. * new version 0.99.7
  1446. Revision 1.28 1998/08/11 14:07:27 peter
  1447. * fixed pushing of high value for openarray
  1448. Revision 1.27 1998/08/10 14:50:31 peter
  1449. + localswitches, moduleswitches, globalswitches splitting
  1450. Revision 1.26 1998/08/10 10:18:35 peter
  1451. + Compiler,Comphook unit which are the new interface units to the
  1452. compiler
  1453. Revision 1.25 1998/07/30 11:18:19 florian
  1454. + first implementation of try ... except on .. do end;
  1455. * limitiation of 65535 bytes parameters for cdecl removed
  1456. Revision 1.24 1998/07/20 18:40:16 florian
  1457. * handling of ansi string constants should now work
  1458. Revision 1.23 1998/07/14 21:37:24 peter
  1459. * fixed packrecords as discussed at the alias
  1460. Revision 1.22 1998/07/14 14:47:08 peter
  1461. * released NEWINPUT
  1462. Revision 1.21 1998/07/13 21:17:38 florian
  1463. * changed to compile with TP
  1464. Revision 1.20 1998/07/10 00:00:05 peter
  1465. * fixed ttypesym bug finally
  1466. * fileinfo in the symtable and better using for unused vars
  1467. Revision 1.19 1998/07/07 17:40:39 peter
  1468. * packrecords 4 works
  1469. * word aligning of parameters
  1470. Revision 1.18 1998/07/07 11:20:15 peter
  1471. + NEWINPUT for a better inputfile and scanner object
  1472. Revision 1.17 1998/06/24 14:48:40 peter
  1473. * ifdef newppu -> ifndef oldppu
  1474. Revision 1.16 1998/06/19 15:40:42 peter
  1475. * removed cosntructor/constructor warning and 0.99.5 recompiles it again
  1476. Revision 1.15 1998/06/17 14:10:18 peter
  1477. * small os2 fixes
  1478. * fixed interdependent units with newppu (remake3 under linux works now)
  1479. Revision 1.14 1998/06/16 08:56:34 peter
  1480. + targetcpu
  1481. * cleaner pmodules for newppu
  1482. Revision 1.13 1998/06/15 15:38:10 pierre
  1483. * small bug in systems.pas corrected
  1484. + operators in different units better hanlded
  1485. Revision 1.12 1998/06/15 14:23:44 daniel
  1486. * Reverted my changes.
  1487. Revision 1.10 1998/06/13 00:10:18 peter
  1488. * working browser and newppu
  1489. * some small fixes against crashes which occured in bp7 (but not in
  1490. fpc?!)
  1491. Revision 1.9 1998/06/12 16:15:35 pierre
  1492. * external name 'C_var';
  1493. export name 'intern_C_var';
  1494. cdecl;
  1495. cdecl;external;
  1496. are now supported only with -Sv switch
  1497. Revision 1.8 1998/06/11 10:11:59 peter
  1498. * -gb works again
  1499. Revision 1.7 1998/06/09 16:01:51 pierre
  1500. + added procedure directive parsing for procvars
  1501. (accepted are popstack cdecl and pascal)
  1502. + added C vars with the following syntax
  1503. var C calias 'true_c_name';(can be followed by external)
  1504. reason is that you must add the Cprefix
  1505. which is target dependent
  1506. Revision 1.6 1998/06/08 22:59:53 peter
  1507. * smartlinking works for win32
  1508. * some defines to exclude some compiler parts
  1509. Revision 1.5 1998/06/04 23:52:02 peter
  1510. * m68k compiles
  1511. + .def file creation moved to gendef.pas so it could also be used
  1512. for win32
  1513. Revision 1.4 1998/06/04 09:55:46 pierre
  1514. * demangled name of procsym reworked to become independant of the mangling scheme
  1515. Revision 1.3 1998/06/03 22:14:20 florian
  1516. * problem with sizes of classes fixed (if the anchestor was declared
  1517. forward, the compiler doesn't update the child classes size)
  1518. Revision 1.2 1998/05/28 14:40:29 peter
  1519. * fixes for newppu, remake3 works now with it
  1520. Revision 1.1 1998/05/27 19:45:09 peter
  1521. * symtable.pas splitted into includefiles
  1522. * symtable adapted for $ifndef OLDPPU
  1523. }