symsym.inc 49 KB

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