symsym.inc 50 KB

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