symsym.inc 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382
  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. {$ifndef OLDPPU}
  24. inherited initname(n);
  25. {$else}
  26. left:=nil;
  27. right:=nil;
  28. setname(n);
  29. indexnb:=0;
  30. {$ifdef nextfield}
  31. nextsym:=nil;
  32. {$endif nextfield}
  33. {$endif}
  34. typ:=abstractsym;
  35. properties:=current_object_option;
  36. {$ifdef GDB}
  37. isstabwritten := false;
  38. {$endif GDB}
  39. fileinfo:=tokenpos;
  40. defref:=nil;
  41. lastwritten:=nil;
  42. refcount:=0;
  43. if (cs_browser in aktmoduleswitches) and make_ref then
  44. begin
  45. defref:=new(pref,init(defref,@tokenpos));
  46. inc(refcount);
  47. end;
  48. lastref:=defref;
  49. end;
  50. constructor tsym.load;
  51. begin
  52. {$ifndef OLDPPU}
  53. inherited init;
  54. indexnr:=readword;
  55. {$else}
  56. left:=nil;
  57. right:=nil;
  58. {$endif}
  59. setname(readstring);
  60. typ:=abstractsym;
  61. fillchar(fileinfo,sizeof(fileinfo),0);
  62. properties:=symprop(readbyte);
  63. lastref:=nil;
  64. defref:=nil;
  65. lastwritten:=nil;
  66. refcount:=0;
  67. {$ifdef GDB}
  68. isstabwritten := false;
  69. {$endif GDB}
  70. end;
  71. procedure tsym.load_references;
  72. var
  73. pos : tfileposinfo;
  74. move_last : boolean;
  75. begin
  76. move_last:=lastwritten=lastref;
  77. while (not current_ppu^.endofentry) do
  78. begin
  79. readposinfo(pos);
  80. inc(refcount);
  81. lastref:=new(pref,init(lastref,@pos));
  82. lastref^.is_written:=true;
  83. if refcount=1 then
  84. defref:=lastref;
  85. end;
  86. if move_last then
  87. lastwritten:=lastref;
  88. end;
  89. { big problem here :
  90. wrong refs were written because of
  91. interface parsing of other units PM
  92. moduleindex must be checked !! }
  93. function tsym.write_references : boolean;
  94. var
  95. ref : pref;
  96. symref_written,move_last : boolean;
  97. begin
  98. write_references:=false;
  99. if lastwritten=lastref then
  100. exit;
  101. { should we update lastref }
  102. move_last:=true;
  103. symref_written:=false;
  104. { write symbol refs }
  105. if assigned(lastwritten) then
  106. ref:=lastwritten
  107. else
  108. ref:=defref;
  109. while assigned(ref) do
  110. begin
  111. if ref^.moduleindex=current_module^.unit_index then
  112. begin
  113. { write address to this symbol }
  114. if not symref_written then
  115. begin
  116. writesymref(@self);
  117. symref_written:=true;
  118. end;
  119. writeposinfo(ref^.posinfo);
  120. ref^.is_written:=true;
  121. if move_last then
  122. lastwritten:=ref;
  123. end
  124. else if not ref^.is_written then
  125. move_last:=false
  126. else if move_last then
  127. lastwritten:=ref;
  128. ref:=ref^.nextref;
  129. end;
  130. if symref_written then
  131. current_ppu^.writeentry(ibsymref);
  132. write_references:=symref_written;
  133. end;
  134. {$ifdef BrowserLog}
  135. procedure tsym.add_to_browserlog;
  136. begin
  137. if assigned(defref) then
  138. begin
  139. browserlog.AddLog('***'+name+'***');
  140. browserlog.AddLogRefs(defref);
  141. end;
  142. end;
  143. {$endif BrowserLog}
  144. destructor tsym.done;
  145. begin
  146. if assigned(defref) then
  147. dispose(defref,done);
  148. {$ifndef OLDPPU}
  149. inherited done;
  150. {$else}
  151. {$ifdef tp}
  152. if not(use_big) then
  153. {$endif tp}
  154. strdispose(_name);
  155. if assigned(left) then
  156. dispose(left,done);
  157. if assigned(right) then
  158. dispose(right,done);
  159. {$endif}
  160. end;
  161. procedure tsym.write;
  162. begin
  163. {$ifndef OLDPPU}
  164. writeword(indexnr);
  165. {$endif}
  166. writestring(name);
  167. writebyte(byte(properties));
  168. end;
  169. procedure tsym.deref;
  170. begin
  171. end;
  172. {$ifdef OLDPPU}
  173. function tsym.name : string;
  174. {$ifdef tp}
  175. var
  176. s : string;
  177. b : byte;
  178. {$endif}
  179. begin
  180. {$ifdef tp}
  181. if use_big then
  182. begin
  183. symbolstream.seek(longint(_name));
  184. symbolstream.read(b,1);
  185. symbolstream.read(s[1],b);
  186. s[0]:=chr(b);
  187. name:=s;
  188. end
  189. else
  190. {$endif}
  191. if assigned(_name) then
  192. name:=strpas(_name)
  193. else
  194. name:='';
  195. end;
  196. procedure tsym.setname(const s : string);
  197. begin
  198. setstring(_name,s);
  199. end;
  200. {$endif}
  201. function tsym.mangledname : string;
  202. begin
  203. mangledname:=name;
  204. end;
  205. { for most symbol types there is nothing to do at all }
  206. procedure tsym.insert_in_data;
  207. begin
  208. end;
  209. {$ifdef GDB}
  210. function tsym.stabstring : pchar;
  211. begin
  212. stabstring:=strpnew('"'+name+'",'+tostr(N_LSYM)+',0,'+
  213. tostr(fileinfo.line)+',0');
  214. end;
  215. procedure tsym.concatstabto(asmlist : paasmoutput);
  216. var stab_str : pchar;
  217. begin
  218. if not isstabwritten then
  219. begin
  220. stab_str := stabstring;
  221. if asmlist = debuglist then do_count_dbx := true;
  222. { count_dbx(stab_str); moved to GDB.PAS }
  223. asmlist^.concat(new(pai_stabs,init(stab_str)));
  224. isstabwritten:=true;
  225. end;
  226. end;
  227. {$endif GDB}
  228. {****************************************************************************
  229. TLABELSYM
  230. ****************************************************************************}
  231. constructor tlabelsym.init(const n : string; l : plabel);
  232. begin
  233. inherited init(n);
  234. typ:=labelsym;
  235. number:=l;
  236. number^.is_used:=false;
  237. number^.is_set:=true;
  238. number^.refcount:=0;
  239. defined:=false;
  240. end;
  241. constructor tlabelsym.load;
  242. begin
  243. tsym.load;
  244. typ:=labelsym;
  245. { this is all dummy
  246. it is only used for local browsing }
  247. number:=nil;
  248. defined:=true;
  249. end;
  250. destructor tlabelsym.done;
  251. begin
  252. inherited done;
  253. end;
  254. function tlabelsym.mangledname : string;
  255. begin
  256. { this also sets the is_used field }
  257. mangledname:=lab2str(number);
  258. end;
  259. procedure tlabelsym.write;
  260. begin
  261. if owner^.symtabletype in [unitsymtable,globalsymtable] then
  262. Message(sym_e_ill_label_decl)
  263. else
  264. begin
  265. tsym.write;
  266. current_ppu^.writeentry(iblabelsym);
  267. end;
  268. end;
  269. {****************************************************************************
  270. TUNITSYM
  271. ****************************************************************************}
  272. constructor tunitsym.init(const n : string;ref : punitsymtable);
  273. var
  274. old_make_ref : boolean;
  275. begin
  276. old_make_ref:=make_ref;
  277. make_ref:=false;
  278. inherited init(n);
  279. make_ref:=old_make_ref;
  280. typ:=unitsym;
  281. unitsymtable:=ref;
  282. prevsym:=ref^.unitsym;
  283. ref^.unitsym:=@self;
  284. refs:=0;
  285. end;
  286. constructor tunitsym.load;
  287. begin
  288. tsym.load;
  289. typ:=unitsym;
  290. unitsymtable:=punitsymtable(current_module^.globalsymtable);
  291. prevsym:=nil;
  292. end;
  293. { we need to remove it from the prevsym chain ! }
  294. destructor tunitsym.done;
  295. var pus,ppus : punitsym;
  296. begin
  297. if assigned(unitsymtable) then
  298. begin
  299. ppus:=nil;
  300. pus:=unitsymtable^.unitsym;
  301. if pus=@self then
  302. unitsymtable^.unitsym:=prevsym
  303. else while assigned(pus) do
  304. begin
  305. if pus=@self then
  306. begin
  307. ppus^.prevsym:=prevsym;
  308. break;
  309. end
  310. else
  311. begin
  312. ppus:=pus;
  313. pus:=ppus^.prevsym;
  314. end;
  315. end;
  316. end;
  317. inherited done;
  318. end;
  319. procedure tunitsym.write;
  320. begin
  321. tsym.write;
  322. current_ppu^.writeentry(ibunitsym);
  323. end;
  324. {$ifdef GDB}
  325. procedure tunitsym.concatstabto(asmlist : paasmoutput);
  326. begin
  327. {Nothing to write to stabs !}
  328. end;
  329. {$endif GDB}
  330. {****************************************************************************
  331. TPROCSYM
  332. ****************************************************************************}
  333. constructor tprocsym.init(const n : string);
  334. begin
  335. tsym.init(n);
  336. typ:=procsym;
  337. definition:=nil;
  338. owner:=nil;
  339. {$ifdef GDB}
  340. is_global := false;
  341. {$endif GDB}
  342. end;
  343. constructor tprocsym.load;
  344. begin
  345. tsym.load;
  346. typ:=procsym;
  347. definition:=pprocdef(readdefref);
  348. {$ifdef GDB}
  349. is_global := false;
  350. {$endif GDB}
  351. end;
  352. destructor tprocsym.done;
  353. begin
  354. check_forward;
  355. tsym.done;
  356. end;
  357. function tprocsym.mangledname : string;
  358. begin
  359. mangledname:=definition^.mangledname;
  360. end;
  361. function tprocsym.demangledname:string;
  362. begin
  363. demangledname:=name+definition^.demangled_paras;
  364. end;
  365. procedure tprocsym.write_parameter_lists;
  366. var
  367. p : pprocdef;
  368. begin
  369. p:=definition;
  370. while assigned(p) do
  371. begin
  372. { force the error to be printed }
  373. Verbose.Message1(sym_b_param_list,name+p^.demangled_paras);
  374. p:=p^.nextoverloaded;
  375. end;
  376. end;
  377. procedure tprocsym.check_forward;
  378. var
  379. pd : pprocdef;
  380. oldaktfilepos : tfileposinfo;
  381. begin
  382. { don't check if errors !! }
  383. if Errorcount>0 then
  384. exit;
  385. pd:=definition;
  386. while assigned(pd) do
  387. begin
  388. if pd^.forwarddef then
  389. begin
  390. oldaktfilepos:=aktfilepos;
  391. aktfilepos:=fileinfo;
  392. if assigned(pd^._class) then
  393. Message1(sym_e_forward_not_resolved,pd^._class^.objname^+'.'+name+demangledparas(pd^.demangled_paras))
  394. else
  395. Message1(sym_e_forward_not_resolved,name+pd^.demangled_paras);
  396. aktfilepos:=oldaktfilepos;
  397. end;
  398. pd:=pd^.nextoverloaded;
  399. end;
  400. end;
  401. procedure tprocsym.deref;
  402. var
  403. t : ttoken;
  404. last : pprocdef;
  405. begin
  406. resolvedef(pdef(definition));
  407. if (definition^.options and pooperator) <> 0 then
  408. begin
  409. last:=definition;
  410. while assigned(last^.nextoverloaded) do
  411. last:=last^.nextoverloaded;
  412. for t:=first_overloaded to last_overloaded do
  413. if (name=overloaded_names[t]) then
  414. begin
  415. if assigned(overloaded_operators[t]) then
  416. last^.nextoverloaded:=overloaded_operators[t]^.definition;
  417. overloaded_operators[t]:=@self;
  418. end;
  419. end;
  420. end;
  421. procedure tprocsym.write;
  422. begin
  423. tsym.write;
  424. writedefref(pdef(definition));
  425. current_ppu^.writeentry(ibprocsym);
  426. end;
  427. procedure tprocsym.load_references;
  428. (* var
  429. prdef,prdef2 : pprocdef;
  430. b : byte; *)
  431. begin
  432. inherited load_references;
  433. (* prdef:=definition;
  434. { take care about operators !! }
  435. if (current_module^.flags and uf_has_browser) <>0 then
  436. while assigned(prdef) and (prdef^.owner=definition^.owner) do
  437. begin
  438. b:=current_ppu^.readentry;
  439. if b<>ibdefref then
  440. Message(unit_f_ppu_read_error);
  441. prdef2:=pprocdef(readdefref);
  442. resolvedef(prdef2);
  443. if prdef<>prdef2 then
  444. Message(unit_f_ppu_read_error);
  445. prdef^.load_references;
  446. prdef:=prdef^.nextoverloaded;
  447. end; *)
  448. end;
  449. function tprocsym.write_references : boolean;
  450. var
  451. prdef : pprocdef;
  452. begin
  453. write_references:=false;
  454. if not inherited write_references then
  455. exit;
  456. write_references:=true;
  457. prdef:=definition;
  458. while assigned(prdef) and (prdef^.owner=definition^.owner) do
  459. begin
  460. prdef^.write_references;
  461. prdef:=prdef^.nextoverloaded;
  462. end;
  463. end;
  464. {$ifdef BrowserLog}
  465. procedure tprocsym.add_to_browserlog;
  466. var
  467. prdef : pprocdef;
  468. begin
  469. inherited add_to_browserlog;
  470. prdef:=definition;
  471. while assigned(prdef) do
  472. begin
  473. pprocdef(prdef)^.add_to_browserlog;
  474. prdef:=pprocdef(prdef)^.nextoverloaded;
  475. end;
  476. end;
  477. {$endif BrowserLog}
  478. {$ifdef GDB}
  479. function tprocsym.stabstring : pchar;
  480. Var RetType : Char;
  481. Obj,Info : String;
  482. stabsstr : string;
  483. p : pchar;
  484. begin
  485. obj := name;
  486. info := '';
  487. if is_global then
  488. RetType := 'F'
  489. else
  490. RetType := 'f';
  491. if assigned(owner) then
  492. begin
  493. if (owner^.symtabletype = objectsymtable) then
  494. obj := owner^.name^+'__'+name;
  495. { this code was correct only as long as the local symboltable
  496. of the parent had the same name as the function
  497. but this is no true anymore !! PM
  498. if (owner^.symtabletype=localsymtable) and assigned(owner^.name) then
  499. info := ','+name+','+owner^.name^; }
  500. if (owner^.symtabletype=localsymtable) and assigned(owner^.defowner) and
  501. assigned(owner^.defowner^.sym) then
  502. info := ','+name+','+owner^.defowner^.sym^.name;
  503. end;
  504. stabsstr:=definition^.mangledname;
  505. getmem(p,length(stabsstr)+255);
  506. strpcopy(p,'"'+obj+':'+RetType
  507. +definition^.retdef^.numberstring+info+'",'+tostr(n_function)
  508. +',0,'+
  509. tostr(aktfilepos.line)
  510. +',');
  511. strpcopy(strend(p),stabsstr);
  512. stabstring:=strnew(p);
  513. freemem(p,length(stabsstr)+255);
  514. end;
  515. procedure tprocsym.concatstabto(asmlist : paasmoutput);
  516. begin
  517. if (definition^.options and pointernproc) <> 0 then exit;
  518. if not isstabwritten then
  519. asmlist^.concat(new(pai_stabs,init(stabstring)));
  520. isstabwritten := true;
  521. if assigned(definition^.parast) then
  522. definition^.parast^.concatstabto(asmlist);
  523. if assigned(definition^.localst) then
  524. definition^.localst^.concatstabto(asmlist);
  525. definition^.is_def_stab_written := true;
  526. end;
  527. {$endif GDB}
  528. {****************************************************************************
  529. TPROGRAMSYM
  530. ****************************************************************************}
  531. constructor tprogramsym.init(const n : string);
  532. begin
  533. inherited init(n);
  534. typ:=programsym;
  535. end;
  536. {****************************************************************************
  537. TERRORSYM
  538. ****************************************************************************}
  539. constructor terrorsym.init;
  540. begin
  541. inherited init('');
  542. typ:=errorsym;
  543. end;
  544. {****************************************************************************
  545. TPROPERTYSYM
  546. ****************************************************************************}
  547. constructor tpropertysym.init(const n : string);
  548. begin
  549. inherited init(n);
  550. typ:=propertysym;
  551. options:=0;
  552. proptype:=nil;
  553. readaccessdef:=nil;
  554. writeaccessdef:=nil;
  555. readaccesssym:=nil;
  556. writeaccesssym:=nil;
  557. storedsym:=nil;
  558. storeddef:=nil;
  559. index:=0;
  560. default:=0;
  561. end;
  562. destructor tpropertysym.done;
  563. begin
  564. inherited done;
  565. end;
  566. constructor tpropertysym.load;
  567. begin
  568. inherited load;
  569. typ:=propertysym;
  570. proptype:=readdefref;
  571. options:=readlong;
  572. index:=readlong;
  573. default:=readlong;
  574. { it's hack ... }
  575. readaccesssym:=psym(stringdup(readstring));
  576. writeaccesssym:=psym(stringdup(readstring));
  577. storedsym:=psym(stringdup(readstring));
  578. { now the defs: }
  579. readaccessdef:=readdefref;
  580. writeaccessdef:=readdefref;
  581. storeddef:=readdefref;
  582. end;
  583. procedure tpropertysym.deref;
  584. begin
  585. resolvedef(proptype);
  586. resolvedef(readaccessdef);
  587. resolvedef(writeaccessdef);
  588. resolvedef(storeddef);
  589. { solve the hack we did in load: }
  590. if pstring(readaccesssym)^<>'' then
  591. begin
  592. srsym:=search_class_member(pobjectdef(owner^.defowner),pstring(readaccesssym)^);
  593. if not(assigned(srsym)) then
  594. srsym:=generrorsym;
  595. end
  596. else
  597. srsym:=nil;
  598. stringdispose(pstring(readaccesssym));
  599. readaccesssym:=srsym;
  600. if pstring(writeaccesssym)^<>'' then
  601. begin
  602. srsym:=search_class_member(pobjectdef(owner^.defowner),pstring(writeaccesssym)^);
  603. if not(assigned(srsym)) then
  604. srsym:=generrorsym;
  605. end
  606. else
  607. srsym:=nil;
  608. stringdispose(pstring(writeaccesssym));
  609. writeaccesssym:=srsym;
  610. if pstring(storedsym)^<>'' then
  611. begin
  612. srsym:=search_class_member(pobjectdef(owner^.defowner),pstring(storedsym)^);
  613. if not(assigned(srsym)) then
  614. srsym:=generrorsym;
  615. end
  616. else
  617. srsym:=nil;
  618. stringdispose(pstring(storedsym));
  619. storedsym:=srsym;
  620. end;
  621. function tpropertysym.getsize : longint;
  622. begin
  623. getsize:=0;
  624. end;
  625. procedure tpropertysym.write;
  626. begin
  627. tsym.write;
  628. writedefref(proptype);
  629. writelong(options);
  630. writelong(index);
  631. writelong(default);
  632. if assigned(readaccesssym) then
  633. writestring(readaccesssym^.name)
  634. else
  635. writestring('');
  636. if assigned(writeaccesssym) then
  637. writestring(writeaccesssym^.name)
  638. else
  639. writestring('');
  640. if assigned(storedsym) then
  641. writestring(storedsym^.name)
  642. else
  643. writestring('');
  644. writedefref(readaccessdef);
  645. writedefref(writeaccessdef);
  646. writedefref(storeddef);
  647. current_ppu^.writeentry(ibpropertysym);
  648. end;
  649. {$ifdef GDB}
  650. function tpropertysym.stabstring : pchar;
  651. begin
  652. { !!!! don't know how to handle }
  653. stabstring:=strpnew('');
  654. end;
  655. procedure tpropertysym.concatstabto(asmlist : paasmoutput);
  656. begin
  657. { !!!! don't know how to handle }
  658. end;
  659. {$endif GDB}
  660. {****************************************************************************
  661. TFUNCRETSYM
  662. ****************************************************************************}
  663. constructor tfuncretsym.init(const n : string;approcinfo : pointer{pprocinfo});
  664. begin
  665. tsym.init(n);
  666. typ:=funcretsym;
  667. funcretprocinfo:=approcinfo;
  668. funcretdef:=pprocinfo(approcinfo)^.retdef;
  669. { address valid for ret in param only }
  670. { otherwise set by insert }
  671. address:=pprocinfo(approcinfo)^.retoffset;
  672. end;
  673. constructor tfuncretsym.load;
  674. begin
  675. tsym.load;
  676. funcretdef:=readdefref;
  677. address:=readlong;
  678. funcretprocinfo:=nil;
  679. typ:=funcretsym;
  680. end;
  681. procedure tfuncretsym.write;
  682. begin
  683. (*
  684. Normally all references are
  685. transfered to the function symbol itself !! PM *)
  686. tsym.write;
  687. writedefref(funcretdef);
  688. writelong(address);
  689. current_ppu^.writeentry(ibfuncretsym);
  690. end;
  691. procedure tfuncretsym.deref;
  692. begin
  693. resolvedef(funcretdef);
  694. end;
  695. {$ifdef GDB}
  696. procedure tfuncretsym.concatstabto(asmlist : paasmoutput);
  697. begin
  698. { Nothing to do here, it is done in genexitcode }
  699. end;
  700. {$endif GDB}
  701. procedure tfuncretsym.insert_in_data;
  702. var
  703. l : longint;
  704. begin
  705. { allocate space in local if ret in acc or in fpu }
  706. if ret_in_acc(procinfo.retdef) or (procinfo.retdef^.deftype=floatdef) then
  707. begin
  708. l:=funcretdef^.size;
  709. inc(owner^.datasize,l);
  710. {$ifdef m68k}
  711. { word alignment required for motorola }
  712. if (l=1) then
  713. inc(owner^.datasize,1)
  714. else
  715. {$endif}
  716. if (l>=4) and ((owner^.datasize and 3)<>0) then
  717. inc(owner^.datasize,4-(owner^.datasize and 3))
  718. else if (l>=2) and ((owner^.datasize and 1)<>0) then
  719. inc(owner^.datasize,2-(owner^.datasize and 1));
  720. address:=owner^.datasize;
  721. procinfo.retoffset:=-owner^.datasize;
  722. end;
  723. end;
  724. {****************************************************************************
  725. TABSOLUTESYM
  726. ****************************************************************************}
  727. constructor tabsolutesym.init(const n : string;p : pdef);
  728. begin
  729. inherited init(n,p);
  730. typ:=absolutesym;
  731. end;
  732. constructor tabsolutesym.load;
  733. begin
  734. tvarsym.load;
  735. typ:=absolutesym;
  736. ref:=nil;
  737. address:=0;
  738. asmname:=nil;
  739. abstyp:=absolutetyp(readbyte);
  740. absseg:=false;
  741. case abstyp of
  742. tovar :
  743. begin
  744. asmname:=stringdup(readstring);
  745. ref:=srsym;
  746. end;
  747. toasm :
  748. asmname:=stringdup(readstring);
  749. toaddr :
  750. begin
  751. address:=readlong;
  752. absseg:=boolean(readbyte);
  753. end;
  754. end;
  755. end;
  756. procedure tabsolutesym.write;
  757. begin
  758. tsym.write;
  759. writebyte(byte(varspez));
  760. if read_member then
  761. writelong(address);
  762. writedefref(definition);
  763. writebyte(var_options and (not vo_regable));
  764. writebyte(byte(abstyp));
  765. case abstyp of
  766. tovar :
  767. writestring(ref^.name);
  768. toasm :
  769. writestring(asmname^);
  770. toaddr :
  771. begin
  772. writelong(address);
  773. writebyte(byte(absseg));
  774. end;
  775. end;
  776. current_ppu^.writeentry(ibabsolutesym);
  777. end;
  778. procedure tabsolutesym.deref;
  779. begin
  780. resolvedef(definition);
  781. if (abstyp=tovar) and (asmname<>nil) then
  782. begin
  783. { search previous loaded symtables }
  784. getsym(asmname^,false);
  785. if not(assigned(srsym)) then
  786. getsymonlyin(owner,asmname^);
  787. if not(assigned(srsym)) then
  788. srsym:=generrorsym;
  789. ref:=srsym;
  790. stringdispose(asmname);
  791. end;
  792. end;
  793. function tabsolutesym.mangledname : string;
  794. begin
  795. case abstyp of
  796. tovar :
  797. mangledname:=ref^.mangledname;
  798. toasm :
  799. mangledname:=asmname^;
  800. toaddr :
  801. mangledname:='$'+tostr(address);
  802. else
  803. internalerror(10002);
  804. end;
  805. end;
  806. procedure tabsolutesym.insert_in_data;
  807. begin
  808. end;
  809. {$ifdef GDB}
  810. procedure tabsolutesym.concatstabto(asmlist : paasmoutput);
  811. begin
  812. { I don't know how to handle this !! }
  813. end;
  814. {$endif GDB}
  815. {****************************************************************************
  816. TVARSYM
  817. ****************************************************************************}
  818. constructor tvarsym.init(const n : string;p : pdef);
  819. begin
  820. tsym.init(n);
  821. typ:=varsym;
  822. definition:=p;
  823. _mangledname:=nil;
  824. varspez:=vs_value;
  825. address:=0;
  826. islocalcopy:=false;
  827. localvarsym:=nil;
  828. refs:=0;
  829. is_valid := 1;
  830. var_options:=0;
  831. { can we load the value into a register ? }
  832. case p^.deftype of
  833. pointerdef,
  834. enumdef,
  835. procvardef :
  836. var_options:=var_options or vo_regable;
  837. orddef :
  838. case porddef(p)^.typ of
  839. bool8bit,bool16bit,bool32bit,
  840. u8bit,u16bit,u32bit,
  841. s8bit,s16bit,s32bit :
  842. var_options:=var_options or vo_regable;
  843. else
  844. var_options:=var_options and not vo_regable;
  845. end;
  846. setdef:
  847. if psetdef(p)^.settype=smallset then
  848. var_options:=var_options or vo_regable;
  849. else
  850. var_options:=var_options and not vo_regable;
  851. end;
  852. reg:=R_NO;
  853. end;
  854. constructor tvarsym.init_dll(const n : string;p : pdef);
  855. begin
  856. { The tvarsym is necessary for 0.99.5 (PFV) }
  857. tvarsym.init(n,p);
  858. var_options:=var_options or vo_is_dll_var;
  859. end;
  860. constructor tvarsym.init_C(const n,mangled : string;p : pdef);
  861. begin
  862. { The tvarsym is necessary for 0.99.5 (PFV) }
  863. tvarsym.init(n,p);
  864. var_options:=var_options or vo_is_C_var;
  865. setmangledname(mangled);
  866. end;
  867. constructor tvarsym.load;
  868. begin
  869. tsym.load;
  870. typ:=varsym;
  871. _mangledname:=nil;
  872. reg:=R_NO;
  873. refs := 0;
  874. is_valid := 1;
  875. varspez:=tvarspez(readbyte);
  876. if read_member then
  877. address:=readlong
  878. else
  879. address:=0;
  880. islocalcopy:=false;
  881. localvarsym:=nil;
  882. definition:=readdefref;
  883. var_options:=readbyte;
  884. if (var_options and vo_is_C_var)<>0 then
  885. setmangledname(readstring);
  886. end;
  887. procedure tvarsym.deref;
  888. begin
  889. resolvedef(definition);
  890. end;
  891. procedure tvarsym.write;
  892. begin
  893. tsym.write;
  894. writebyte(byte(varspez));
  895. if read_member then
  896. writelong(address);
  897. writedefref(definition);
  898. { symbols which are load are never candidates for a register,
  899. turn of the regable }
  900. writebyte(var_options and (not vo_regable));
  901. if (var_options and vo_is_C_var)<>0 then
  902. writestring(mangledname);
  903. current_ppu^.writeentry(ibvarsym);
  904. end;
  905. procedure tvarsym.setmangledname(const s : string);
  906. begin
  907. _mangledname:=strpnew(s);
  908. end;
  909. function tvarsym.mangledname : string;
  910. var
  911. prefix : string;
  912. begin
  913. if assigned(_mangledname) then
  914. begin
  915. mangledname:=strpas(_mangledname);
  916. exit;
  917. end;
  918. case owner^.symtabletype of
  919. staticsymtable :
  920. if (cs_smartlink in aktmoduleswitches) then
  921. prefix:='_'+owner^.name^+'$$$_'
  922. else
  923. prefix:='_';
  924. unitsymtable,
  925. globalsymtable :
  926. prefix:='U_'+owner^.name^+'_';
  927. else
  928. Message(sym_e_invalid_call_tvarsymmangledname);
  929. end;
  930. mangledname:=prefix+name;
  931. end;
  932. function tvarsym.getsize : longint;
  933. begin
  934. if assigned(definition) and (varspez=vs_value) then
  935. getsize:=definition^.size
  936. else
  937. getsize:=0;
  938. end;
  939. function tvarsym.getpushsize : longint;
  940. begin
  941. if assigned(definition) then
  942. begin
  943. case varspez of
  944. vs_var :
  945. getpushsize:=target_os.size_of_pointer;
  946. vs_value,
  947. vs_const :
  948. begin
  949. case definition^.deftype of
  950. arraydef,
  951. setdef,
  952. stringdef,
  953. recorddef,
  954. objectdef :
  955. getpushsize:=target_os.size_of_pointer;
  956. else
  957. getpushsize:=definition^.size;
  958. end;
  959. end;
  960. end;
  961. end
  962. else
  963. getpushsize:=0;
  964. end;
  965. function data_align(length : longint) : longint;
  966. begin
  967. (* this is useless under go32v2 at least
  968. because the section are only align to dword
  969. if length>8 then
  970. data_align:=16
  971. else if length>4 then
  972. data_align:=8
  973. else *)
  974. if length>2 then
  975. data_align:=4
  976. else if length>1 then
  977. data_align:=2
  978. else
  979. data_align:=1;
  980. end;
  981. procedure tvarsym.insert_in_data;
  982. var
  983. l,ali,modulo : longint;
  984. begin
  985. if (var_options and vo_is_external)<>0 then
  986. exit;
  987. { handle static variables of objects especially }
  988. if read_member and (owner^.symtabletype=objectsymtable) and
  989. ((properties and sp_static)<>0) then
  990. begin
  991. { the data filed is generated in parser.pas
  992. with a tobject_FIELDNAME variable }
  993. { this symbol can't be loaded to a register }
  994. var_options:=var_options and not vo_regable;
  995. end
  996. else
  997. if not(read_member) then
  998. begin
  999. { made problems with parameters etc. ! (FK) }
  1000. { check for instance of an abstract object or class }
  1001. {
  1002. if (pvarsym(sym)^.definition^.deftype=objectdef) and
  1003. ((pobjectdef(pvarsym(sym)^.definition)^.options and oo_is_abstract)<>0) then
  1004. Message(sym_e_no_instance_of_abstract_object);
  1005. }
  1006. if ((var_options and vo_is_thread_var)<>0) then
  1007. l:=4
  1008. else
  1009. l:=getsize;
  1010. case owner^.symtabletype of
  1011. stt_exceptsymtable:
  1012. { can contain only one symbol, address calculated later }
  1013. ;
  1014. localsymtable :
  1015. begin
  1016. is_valid := 0;
  1017. modulo:=owner^.datasize and 3;
  1018. {$ifdef m68k}
  1019. { word alignment required for motorola }
  1020. if (l=1) then
  1021. l:=2
  1022. else
  1023. {$endif}
  1024. if (l>=4) and (modulo<>0) then
  1025. inc(l,4-modulo)
  1026. else
  1027. if (l>=2) and ((modulo and 1)<>0) then
  1028. inc(l,2-(modulo and 1));
  1029. inc(owner^.datasize,l);
  1030. address:=owner^.datasize;
  1031. end;
  1032. staticsymtable :
  1033. begin
  1034. { enable unitialized warning for local symbols }
  1035. is_valid := 0;
  1036. if (cs_smartlink in aktmoduleswitches) then
  1037. bsssegment^.concat(new(pai_cut,init));
  1038. ali:=data_align(l);
  1039. if ali>1 then
  1040. begin
  1041. (* this is done
  1042. either by the assembler or in ag386bin
  1043. bsssegment^.concat(new(pai_align,init(ali))); *)
  1044. modulo:=owner^.datasize mod ali;
  1045. if modulo>0 then
  1046. inc(owner^.datasize,ali-modulo);
  1047. end;
  1048. {$ifdef GDB}
  1049. if cs_debuginfo in aktmoduleswitches then
  1050. concatstabto(bsssegment);
  1051. {$endif GDB}
  1052. if (cs_smartlink in aktmoduleswitches) or
  1053. ((var_options and vo_is_c_var)<>0) then
  1054. bsssegment^.concat(new(pai_datablock,init_global(mangledname,l)))
  1055. else
  1056. bsssegment^.concat(new(pai_datablock,init(mangledname,l)));
  1057. { increase datasize }
  1058. inc(owner^.datasize,l);
  1059. { this symbol can't be loaded to a register }
  1060. var_options:=var_options and not vo_regable;
  1061. end;
  1062. globalsymtable :
  1063. begin
  1064. if (cs_smartlink in aktmoduleswitches) then
  1065. bsssegment^.concat(new(pai_cut,init));
  1066. ali:=data_align(l);
  1067. if ali>1 then
  1068. begin
  1069. (* this is done
  1070. either by the assembler or in ag386bin
  1071. bsssegment^.concat(new(pai_align,init(ali))); *)
  1072. modulo:=owner^.datasize mod ali;
  1073. if modulo>0 then
  1074. inc(owner^.datasize,ali-modulo);
  1075. end;
  1076. {$ifdef GDB}
  1077. if cs_debuginfo in aktmoduleswitches then
  1078. concatstabto(bsssegment);
  1079. {$endif GDB}
  1080. bsssegment^.concat(new(pai_datablock,init_global(mangledname,l)));
  1081. inc(owner^.datasize,l);
  1082. { this symbol can't be loaded to a register }
  1083. var_options:=var_options and not vo_regable;
  1084. end;
  1085. recordsymtable,
  1086. objectsymtable :
  1087. begin
  1088. { this symbol can't be loaded to a register }
  1089. var_options:=var_options and not vo_regable;
  1090. { align record and object fields }
  1091. if (l=1) or (aktpackrecords=1) then
  1092. begin
  1093. address:=owner^.datasize;
  1094. inc(owner^.datasize,l)
  1095. end
  1096. else
  1097. if (l=2) or (aktpackrecords=2) then
  1098. begin
  1099. owner^.datasize:=(owner^.datasize+1) and (not 1);
  1100. address:=owner^.datasize;
  1101. inc(owner^.datasize,l)
  1102. end
  1103. else
  1104. if (l<=4) or (aktpackrecords=4) then
  1105. begin
  1106. owner^.datasize:=(owner^.datasize+3) and (not 3);
  1107. address:=owner^.datasize;
  1108. inc(owner^.datasize,l);
  1109. end
  1110. else
  1111. if (l<=8) or (aktpackrecords=8) then
  1112. begin
  1113. owner^.datasize:=(owner^.datasize+7) and (not 7);
  1114. address:=owner^.datasize;
  1115. inc(owner^.datasize,l);
  1116. end
  1117. else
  1118. if (l<=16) or (aktpackrecords=16) then
  1119. begin
  1120. owner^.datasize:=(owner^.datasize+15) and (not 15);
  1121. address:=owner^.datasize;
  1122. inc(owner^.datasize,l);
  1123. end
  1124. else
  1125. if (l<=32) or (aktpackrecords=32) then
  1126. begin
  1127. owner^.datasize:=(owner^.datasize+31) and (not 31);
  1128. address:=owner^.datasize;
  1129. inc(owner^.datasize,l);
  1130. end;
  1131. end;
  1132. parasymtable :
  1133. begin
  1134. { here we need the size of a push instead of the
  1135. size of the data }
  1136. l:=getpushsize;
  1137. address:=owner^.datasize;
  1138. owner^.datasize:=align(owner^.datasize+l,target_os.stackalignment);
  1139. end
  1140. else
  1141. begin
  1142. modulo:=owner^.datasize and 3 ;
  1143. if (l>=4) and (modulo<>0) then
  1144. inc(owner^.datasize,4-modulo)
  1145. else
  1146. if (l>=2) and ((modulo and 1)<>0) then
  1147. inc(owner^.datasize);
  1148. address:=owner^.datasize;
  1149. inc(owner^.datasize,l);
  1150. end;
  1151. end;
  1152. end;
  1153. end;
  1154. {$ifdef GDB}
  1155. function tvarsym.stabstring : pchar;
  1156. var
  1157. st : char;
  1158. begin
  1159. if (owner^.symtabletype = objectsymtable) and
  1160. ((properties and sp_static)<>0) then
  1161. begin
  1162. if (cs_gdb_gsym in aktglobalswitches) then st := 'G' else st := 'S';
  1163. {$ifndef Delphi}
  1164. stabstring := strpnew('"'+owner^.name^+'__'+name+':'+
  1165. +definition^.numberstring+'",'+
  1166. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1167. {$endif}
  1168. end
  1169. else if (owner^.symtabletype = globalsymtable) or
  1170. (owner^.symtabletype = unitsymtable) then
  1171. begin
  1172. { Here we used S instead of
  1173. because with G GDB doesn't look at the address field
  1174. but searches the same name or with a leading underscore
  1175. but these names don't exist in pascal !}
  1176. if (cs_gdb_gsym in aktglobalswitches) then st := 'G' else st := 'S';
  1177. stabstring := strpnew('"'+name+':'+st
  1178. +definition^.numberstring+'",'+
  1179. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1180. end
  1181. else if owner^.symtabletype = staticsymtable then
  1182. begin
  1183. stabstring := strpnew('"'+name+':S'
  1184. +definition^.numberstring+'",'+
  1185. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1186. end
  1187. else if (owner^.symtabletype=parasymtable) then
  1188. begin
  1189. case varspez of
  1190. vs_var : st := 'v';
  1191. vs_value,
  1192. vs_const : if push_addr_param(definition) then
  1193. st := 'v' { should be 'i' but 'i' doesn't work }
  1194. else
  1195. st := 'p';
  1196. end;
  1197. stabstring := strpnew('"'+name+':'+st
  1198. +definition^.numberstring+'",'+
  1199. tostr(N_PSYM)+',0,'+tostr(fileinfo.line)+','+
  1200. tostr(address+owner^.address_fixup));
  1201. {offset to ebp => will not work if the framepointer is esp
  1202. so some optimizing will make things harder to debug }
  1203. end
  1204. else if (owner^.symtabletype=localsymtable) then
  1205. {$ifdef i386}
  1206. if reg<>R_NO then
  1207. begin
  1208. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1209. { this is the register order for GDB}
  1210. stabstring:=strpnew('"'+name+':r'
  1211. +definition^.numberstring+'",'+
  1212. tostr(N_RSYM)+',0,'+
  1213. tostr(fileinfo.line)+','+tostr(GDB_i386index[reg]));
  1214. end
  1215. else
  1216. {$endif i386}
  1217. stabstring := strpnew('"'+name+':'
  1218. +definition^.numberstring+'",'+
  1219. tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address))
  1220. else
  1221. stabstring := inherited stabstring;
  1222. end;
  1223. procedure tvarsym.concatstabto(asmlist : paasmoutput);
  1224. {$ifdef i386}
  1225. var stab_str : pchar;
  1226. {$endif i386}
  1227. begin
  1228. inherited concatstabto(asmlist);
  1229. {$ifdef i386}
  1230. if (owner^.symtabletype=parasymtable) and
  1231. (reg<>R_NO) then
  1232. begin
  1233. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1234. { this is the register order for GDB}
  1235. stab_str:=strpnew('"'+name+':r'
  1236. +definition^.numberstring+'",'+
  1237. tostr(N_RSYM)+',0,'+
  1238. tostr(fileinfo.line)+','+tostr(GDB_i386index[reg]));
  1239. asmlist^.concat(new(pai_stabs,init(stab_str)));
  1240. end;
  1241. {$endif i386}
  1242. end;
  1243. {$endif GDB}
  1244. destructor tvarsym.done;
  1245. begin
  1246. strdispose(_mangledname);
  1247. inherited done;
  1248. end;
  1249. {****************************************************************************
  1250. TTYPEDCONSTSYM
  1251. *****************************************************************************}
  1252. constructor ttypedconstsym.init(const n : string;p : pdef;really_const : boolean);
  1253. begin
  1254. tsym.init(n);
  1255. typ:=typedconstsym;
  1256. definition:=p;
  1257. is_really_const:=really_const;
  1258. prefix:=stringdup(procprefix);
  1259. end;
  1260. constructor ttypedconstsym.load;
  1261. begin
  1262. tsym.load;
  1263. typ:=typedconstsym;
  1264. definition:=readdefref;
  1265. {$ifdef DELPHI_CONST_IN_RODATA}
  1266. is_really_const:=boolean(readbyte);
  1267. {$else DELPHI_CONST_IN_RODATA}
  1268. is_really_const:=false;
  1269. {$endif DELPHI_CONST_IN_RODATA}
  1270. prefix:=stringdup(readstring);
  1271. end;
  1272. destructor ttypedconstsym.done;
  1273. begin
  1274. stringdispose(prefix);
  1275. tsym.done;
  1276. end;
  1277. function ttypedconstsym.mangledname : string;
  1278. begin
  1279. mangledname:='TC_'+prefix^+'_'+name;
  1280. end;
  1281. function ttypedconstsym.getsize : longint;
  1282. begin
  1283. if assigned(definition) then
  1284. getsize:=definition^.size
  1285. else
  1286. getsize:=0;
  1287. end;
  1288. procedure ttypedconstsym.deref;
  1289. begin
  1290. resolvedef(definition);
  1291. end;
  1292. procedure ttypedconstsym.write;
  1293. begin
  1294. tsym.write;
  1295. writedefref(definition);
  1296. writestring(prefix^);
  1297. {$ifdef DELPHI_CONST_IN_RODATA}
  1298. writebyte(byte(is_really_const));
  1299. {$endif DELPHI_CONST_IN_RODATA}
  1300. current_ppu^.writeentry(ibtypedconstsym);
  1301. end;
  1302. { for most symbol types ther is nothing to do at all }
  1303. procedure ttypedconstsym.insert_in_data;
  1304. begin
  1305. { here there is a problem for ansistrings !! }
  1306. { we must write the label only after the 12 header bytes (PM)
  1307. if not is_ansistring(definition) then
  1308. }
  1309. { solved, the ansis string is moved to consts (FK) }
  1310. really_insert_in_data;
  1311. end;
  1312. procedure ttypedconstsym.really_insert_in_data;
  1313. var curconstsegment : paasmoutput;
  1314. l,ali,modulo : longint;
  1315. begin
  1316. if is_really_const then
  1317. curconstsegment:=consts
  1318. else
  1319. curconstsegment:=datasegment;
  1320. if (cs_smartlink in aktmoduleswitches) then
  1321. curconstsegment^.concat(new(pai_cut,init));
  1322. l:=getsize;
  1323. ali:=data_align(l);
  1324. if ali>1 then
  1325. begin
  1326. curconstsegment^.concat(new(pai_align,init(ali)));
  1327. modulo:=owner^.datasize mod ali;
  1328. if modulo>0 then
  1329. inc(owner^.datasize,ali-modulo);
  1330. end;
  1331. { Why was there no owner size update here ??? }
  1332. inc(owner^.datasize,l);
  1333. {$ifdef GDB}
  1334. if cs_debuginfo in aktmoduleswitches then
  1335. concatstabto(curconstsegment);
  1336. {$endif GDB}
  1337. if owner^.symtabletype=globalsymtable then
  1338. begin
  1339. curconstsegment^.concat(new(pai_symbol,init_global(mangledname)));
  1340. end
  1341. else
  1342. if owner^.symtabletype<>unitsymtable then
  1343. begin
  1344. if (cs_smartlink in aktmoduleswitches) then
  1345. curconstsegment^.concat(new(pai_symbol,init_global(mangledname)))
  1346. else
  1347. curconstsegment^.concat(new(pai_symbol,init(mangledname)));
  1348. end;
  1349. end;
  1350. {$ifdef GDB}
  1351. function ttypedconstsym.stabstring : pchar;
  1352. var
  1353. st : char;
  1354. begin
  1355. if (cs_gdb_gsym in aktglobalswitches) and (owner^.symtabletype in [unitsymtable,globalsymtable]) then
  1356. st := 'G'
  1357. else
  1358. st := 'S';
  1359. stabstring := strpnew('"'+name+':'+st+
  1360. definition^.numberstring+'",'+tostr(n_STSYM)+',0,'+
  1361. tostr(fileinfo.line)+','+mangledname);
  1362. end;
  1363. {$endif GDB}
  1364. {****************************************************************************
  1365. TCONSTSYM
  1366. ****************************************************************************}
  1367. constructor tconstsym.init(const n : string;t : tconsttype;v : longint);
  1368. begin
  1369. inherited init(n);
  1370. typ:=constsym;
  1371. consttype:=t;
  1372. value:=v;
  1373. definition:=nil;
  1374. len:=0;
  1375. end;
  1376. constructor tconstsym.init_def(const n : string;t : tconsttype;v : longint;def : pdef);
  1377. begin
  1378. inherited init(n);
  1379. typ:=constsym;
  1380. consttype:=t;
  1381. value:=v;
  1382. definition:=def;
  1383. len:=0;
  1384. end;
  1385. constructor tconstsym.init_string(const n : string;t : tconsttype;str:pchar;l:longint);
  1386. begin
  1387. inherited init(n);
  1388. typ:=constsym;
  1389. consttype:=t;
  1390. value:=longint(str);
  1391. definition:=nil;
  1392. len:=l;
  1393. end;
  1394. constructor tconstsym.load;
  1395. var
  1396. pd : pbestreal;
  1397. ps : pnormalset;
  1398. begin
  1399. tsym.load;
  1400. typ:=constsym;
  1401. consttype:=tconsttype(readbyte);
  1402. case consttype of
  1403. constint,
  1404. constbool,
  1405. constchar : value:=readlong;
  1406. constord :
  1407. begin
  1408. definition:=readdefref;
  1409. value:=readlong;
  1410. end;
  1411. conststring :
  1412. begin
  1413. len:=readlong;
  1414. getmem(pchar(value),len+1);
  1415. current_ppu^.getdata(pchar(value)^,len);
  1416. end;
  1417. constreal :
  1418. begin
  1419. new(pd);
  1420. pd^:=readreal;
  1421. value:=longint(pd);
  1422. end;
  1423. constset :
  1424. begin
  1425. definition:=readdefref;
  1426. new(ps);
  1427. readnormalset(ps^);
  1428. value:=longint(ps);
  1429. end;
  1430. constnil : ;
  1431. else
  1432. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttype)));
  1433. end;
  1434. end;
  1435. destructor tconstsym.done;
  1436. begin
  1437. case consttype of
  1438. conststring :
  1439. freemem(pchar(value),len+1);
  1440. constreal :
  1441. dispose(pbestreal(value));
  1442. constset :
  1443. dispose(pnormalset(value));
  1444. end;
  1445. inherited done;
  1446. end;
  1447. function tconstsym.mangledname : string;
  1448. begin
  1449. mangledname:=name;
  1450. end;
  1451. procedure tconstsym.deref;
  1452. begin
  1453. if consttype in [constord,constset] then
  1454. resolvedef(pdef(definition));
  1455. end;
  1456. procedure tconstsym.write;
  1457. begin
  1458. tsym.write;
  1459. writebyte(byte(consttype));
  1460. case consttype of
  1461. constnil : ;
  1462. constint,
  1463. constbool,
  1464. constchar :
  1465. writelong(value);
  1466. constord :
  1467. begin
  1468. writedefref(definition);
  1469. writelong(value);
  1470. end;
  1471. conststring :
  1472. begin
  1473. writelong(len);
  1474. current_ppu^.putdata(pchar(value)^,len);
  1475. end;
  1476. constreal :
  1477. writereal(pbestreal(value)^);
  1478. constset :
  1479. begin
  1480. writedefref(definition);
  1481. writenormalset(pointer(value)^);
  1482. end;
  1483. else
  1484. internalerror(13);
  1485. end;
  1486. current_ppu^.writeentry(ibconstsym);
  1487. end;
  1488. {$ifdef GDB}
  1489. function tconstsym.stabstring : pchar;
  1490. var st : string;
  1491. begin
  1492. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  1493. case consttype of
  1494. conststring : begin
  1495. { I had to remove ibm2ascii !! }
  1496. st := pstring(value)^;
  1497. {st := ibm2ascii(pstring(value)^);}
  1498. st := 's'''+st+'''';
  1499. end;
  1500. constbool, constint, constord, constchar : st := 'i'+tostr(value);
  1501. constreal : begin
  1502. system.str(pbestreal(value)^,st);
  1503. st := 'r'+st;
  1504. end;
  1505. { if we don't know just put zero !! }
  1506. else st:='i0';
  1507. {***SETCONST}
  1508. {constset:;} {*** I don't know what to do with a set.}
  1509. { sets are not recognized by GDB}
  1510. {***}
  1511. end;
  1512. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  1513. tostr(fileinfo.line)+',0');
  1514. end;
  1515. procedure tconstsym.concatstabto(asmlist : paasmoutput);
  1516. begin
  1517. if consttype <> conststring then
  1518. inherited concatstabto(asmlist);
  1519. end;
  1520. {$endif GDB}
  1521. {****************************************************************************
  1522. TENUMSYM
  1523. ****************************************************************************}
  1524. constructor tenumsym.init(const n : string;def : penumdef;v : longint);
  1525. begin
  1526. tsym.init(n);
  1527. typ:=enumsym;
  1528. definition:=def;
  1529. value:=v;
  1530. if def^.min>v then
  1531. def^.setmin(v);
  1532. if def^.max<v then
  1533. def^.setmax(v);
  1534. order;
  1535. end;
  1536. constructor tenumsym.load;
  1537. begin
  1538. tsym.load;
  1539. typ:=enumsym;
  1540. definition:=penumdef(readdefref);
  1541. value:=readlong;
  1542. nextenum := Nil;
  1543. end;
  1544. procedure tenumsym.deref;
  1545. begin
  1546. resolvedef(pdef(definition));
  1547. order;
  1548. end;
  1549. procedure tenumsym.order;
  1550. var
  1551. sym : penumsym;
  1552. begin
  1553. sym := definition^.firstenum;
  1554. if sym = nil then
  1555. begin
  1556. definition^.firstenum := @self;
  1557. nextenum := nil;
  1558. exit;
  1559. end;
  1560. { reorder the symbols in increasing value }
  1561. if value < sym^.value then
  1562. begin
  1563. nextenum := sym;
  1564. definition^.firstenum := @self;
  1565. end
  1566. else
  1567. begin
  1568. while (sym^.value <= value) and assigned(sym^.nextenum) do
  1569. sym := sym^.nextenum;
  1570. nextenum := sym^.nextenum;
  1571. sym^.nextenum := @self;
  1572. end;
  1573. end;
  1574. procedure tenumsym.write;
  1575. begin
  1576. tsym.write;
  1577. writedefref(definition);
  1578. writelong(value);
  1579. current_ppu^.writeentry(ibenumsym);
  1580. end;
  1581. {$ifdef GDB}
  1582. procedure tenumsym.concatstabto(asmlist : paasmoutput);
  1583. begin
  1584. {enum elements have no stab !}
  1585. end;
  1586. {$EndIf GDB}
  1587. {****************************************************************************
  1588. TTYPESYM
  1589. ****************************************************************************}
  1590. constructor ttypesym.init(const n : string;d : pdef);
  1591. begin
  1592. tsym.init(n);
  1593. typ:=typesym;
  1594. definition:=d;
  1595. {$ifdef GDB}
  1596. isusedinstab := false;
  1597. {$endif GDB}
  1598. forwardpointer:=nil;
  1599. if assigned(definition) and not(assigned(definition^.sym)) then
  1600. definition^.sym:=@self;
  1601. end;
  1602. constructor ttypesym.load;
  1603. begin
  1604. tsym.load;
  1605. typ:=typesym;
  1606. forwardpointer:=nil;
  1607. {$ifdef GDB}
  1608. isusedinstab := false;
  1609. {$endif GDB}
  1610. definition:=readdefref;
  1611. end;
  1612. destructor ttypesym.done;
  1613. begin
  1614. if assigned(definition) then
  1615. if definition^.sym=@self then
  1616. definition^.sym:=nil;
  1617. inherited done;
  1618. end;
  1619. procedure ttypesym.deref;
  1620. begin
  1621. resolvedef(definition);
  1622. if assigned(definition) then
  1623. begin
  1624. if definition^.sym=nil then
  1625. definition^.sym:=@self;
  1626. if (definition^.deftype=recorddef) and assigned(precdef(definition)^.symtable) and
  1627. (definition^.sym=@self) then
  1628. precdef(definition)^.symtable^.name:=stringdup('record '+name);
  1629. end;
  1630. end;
  1631. procedure ttypesym.write;
  1632. begin
  1633. tsym.write;
  1634. writedefref(definition);
  1635. current_ppu^.writeentry(ibtypesym);
  1636. end;
  1637. procedure ttypesym.load_references;
  1638. begin
  1639. inherited load_references;
  1640. if (definition^.deftype=recorddef) then
  1641. precdef(definition)^.symtable^.load_browser;
  1642. if (definition^.deftype=objectdef) then
  1643. pobjectdef(definition)^.publicsyms^.load_browser;
  1644. end;
  1645. function ttypesym.write_references : boolean;
  1646. begin
  1647. if not inherited write_references then
  1648. { write address of this symbol if record or object
  1649. even if no real refs are there
  1650. because we need it for the symtable }
  1651. if (definition^.deftype=recorddef) or
  1652. (definition^.deftype=objectdef) then
  1653. begin
  1654. writesymref(@self);
  1655. current_ppu^.writeentry(ibsymref);
  1656. end;
  1657. write_references:=true;
  1658. if (definition^.deftype=recorddef) then
  1659. precdef(definition)^.symtable^.write_browser;
  1660. if (definition^.deftype=objectdef) then
  1661. pobjectdef(definition)^.publicsyms^.write_browser;
  1662. end;
  1663. procedure ttypesym.addforwardpointer(p:ppointerdef);
  1664. var
  1665. hfp : pforwardpointer;
  1666. begin
  1667. new(hfp);
  1668. hfp^.next:=forwardpointer;
  1669. hfp^.def:=p;
  1670. forwardpointer:=hfp;
  1671. end;
  1672. procedure ttypesym.updateforwarddef(p:pdef);
  1673. var
  1674. lasthfp,hfp : pforwardpointer;
  1675. begin
  1676. definition:=p;
  1677. properties:=current_object_option;
  1678. fileinfo:=tokenpos;
  1679. if assigned(definition) and not(assigned(definition^.sym)) then
  1680. definition^.sym:=@self;
  1681. { update all forwardpointers to this definition }
  1682. hfp:=forwardpointer;
  1683. while assigned(hfp) do
  1684. begin
  1685. lasthfp:=hfp;
  1686. hfp^.def^.definition:=definition;
  1687. hfp:=hfp^.next;
  1688. dispose(lasthfp);
  1689. end;
  1690. end;
  1691. {$ifdef BrowserLog}
  1692. procedure ttypesym.add_to_browserlog;
  1693. begin
  1694. inherited add_to_browserlog;
  1695. if (definition^.deftype=recorddef) then
  1696. precdef(definition)^.symtable^.writebrowserlog;
  1697. if (definition^.deftype=objectdef) then
  1698. pobjectdef(definition)^.publicsyms^.writebrowserlog;
  1699. end;
  1700. {$endif BrowserLog}
  1701. {$ifdef GDB}
  1702. function ttypesym.stabstring : pchar;
  1703. var stabchar : string[2];
  1704. short : string;
  1705. begin
  1706. if definition^.deftype in tagtypes then
  1707. stabchar := 'Tt'
  1708. else
  1709. stabchar := 't';
  1710. short := '"'+name+':'+stabchar+definition^.numberstring
  1711. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  1712. stabstring := strpnew(short);
  1713. end;
  1714. procedure ttypesym.concatstabto(asmlist : paasmoutput);
  1715. begin
  1716. {not stabs for forward defs }
  1717. if assigned(definition) then
  1718. if (definition^.sym = @self) then
  1719. definition^.concatstabto(asmlist)
  1720. else
  1721. inherited concatstabto(asmlist);
  1722. end;
  1723. {$endif GDB}
  1724. {****************************************************************************
  1725. TSYSSYM
  1726. ****************************************************************************}
  1727. constructor tsyssym.init(const n : string;l : longint);
  1728. begin
  1729. inherited init(n);
  1730. typ:=syssym;
  1731. number:=l;
  1732. end;
  1733. constructor tsyssym.load;
  1734. begin
  1735. tsym.load;
  1736. typ:=syssym;
  1737. number:=readlong;
  1738. end;
  1739. destructor tsyssym.done;
  1740. begin
  1741. inherited done;
  1742. end;
  1743. procedure tsyssym.write;
  1744. begin
  1745. {$ifndef OLDPPU}
  1746. tsym.write;
  1747. writelong(number);
  1748. current_ppu^.writeentry(ibsyssym);
  1749. {$endif}
  1750. end;
  1751. {$ifdef GDB}
  1752. procedure tsyssym.concatstabto(asmlist : paasmoutput);
  1753. begin
  1754. end;
  1755. {$endif GDB}
  1756. {****************************************************************************
  1757. TMACROSYM
  1758. ****************************************************************************}
  1759. constructor tmacrosym.init(const n : string);
  1760. begin
  1761. inherited init(n);
  1762. typ:=macrosym;
  1763. defined:=true;
  1764. buftext:=nil;
  1765. buflen:=0;
  1766. end;
  1767. destructor tmacrosym.done;
  1768. begin
  1769. if assigned(buftext) then
  1770. freemem(buftext,buflen);
  1771. inherited done;
  1772. end;
  1773. {
  1774. $Log$
  1775. Revision 1.86 1999-05-07 00:06:22 pierre
  1776. + added aligmnent of data for typed consts
  1777. for var it is done by AS or LD or in ag386bin for direct object output
  1778. Revision 1.85 1999/05/04 21:45:07 florian
  1779. * changes to compile it with Delphi 4.0
  1780. Revision 1.84 1999/05/04 16:05:13 pierre
  1781. * fix for unitsym problem
  1782. Revision 1.83 1999/04/28 06:02:13 florian
  1783. * changes of Bruessel:
  1784. + message handler can now take an explicit self
  1785. * typinfo fixed: sometimes the type names weren't written
  1786. * the type checking for pointer comparisations and subtraction
  1787. and are now more strict (was also buggy)
  1788. * small bug fix to link.pas to support compiling on another
  1789. drive
  1790. * probable bug in popt386 fixed: call/jmp => push/jmp
  1791. transformation didn't count correctly the jmp references
  1792. + threadvar support
  1793. * warning if ln/sqrt gets an invalid constant argument
  1794. Revision 1.82 1999/04/26 13:31:52 peter
  1795. * release storenumber,double_checksum
  1796. Revision 1.81 1999/04/25 22:38:39 pierre
  1797. + added is_really_const booleanfield for typedconstsym
  1798. for Delphi in $J- mode (not yet implemented !)
  1799. Revision 1.80 1999/04/21 09:43:54 peter
  1800. * storenumber works
  1801. * fixed some typos in double_checksum
  1802. + incompatible types type1 and type2 message (with storenumber)
  1803. Revision 1.79 1999/04/17 13:16:21 peter
  1804. * fixes for storenumber
  1805. Revision 1.78 1999/04/14 09:15:02 peter
  1806. * first things to store the symbol/def number in the ppu
  1807. Revision 1.77 1999/04/08 10:11:32 pierre
  1808. + enable uninitilized warnings for static symbols
  1809. Revision 1.76 1999/03/31 13:55:21 peter
  1810. * assembler inlining working for ag386bin
  1811. Revision 1.75 1999/03/24 23:17:27 peter
  1812. * fixed bugs 212,222,225,227,229,231,233
  1813. Revision 1.74 1999/02/23 18:29:27 pierre
  1814. * win32 compilation error fix
  1815. + some work for local browser (not cl=omplete yet)
  1816. Revision 1.73 1999/02/22 13:07:09 pierre
  1817. + -b and -bl options work !
  1818. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1819. is not enabled when quitting global section
  1820. * local vars and procedures are not yet stored into PPU
  1821. Revision 1.72 1999/02/08 09:51:22 pierre
  1822. * gdb info for local functions was wrong
  1823. Revision 1.71 1999/01/23 23:29:41 florian
  1824. * first running version of the new code generator
  1825. * when compiling exceptions under Linux fixed
  1826. Revision 1.70 1999/01/21 22:10:48 peter
  1827. * fixed array of const
  1828. * generic platform independent high() support
  1829. Revision 1.69 1999/01/20 10:20:20 peter
  1830. * don't make localvar copies for assembler procedures
  1831. Revision 1.68 1999/01/12 14:25:36 peter
  1832. + BrowserLog for browser.log generation
  1833. + BrowserCol for browser info in TCollections
  1834. * released all other UseBrowser
  1835. Revision 1.67 1998/12/30 22:15:54 peter
  1836. + farpointer type
  1837. * absolutesym now also stores if its far
  1838. Revision 1.66 1998/12/30 13:41:14 peter
  1839. * released valuepara
  1840. Revision 1.65 1998/12/26 15:35:44 peter
  1841. + read/write of constnil
  1842. Revision 1.64 1998/12/08 10:18:15 peter
  1843. + -gh for heaptrc unit
  1844. Revision 1.63 1998/11/28 16:20:56 peter
  1845. + support for dll variables
  1846. Revision 1.62 1998/11/27 14:50:48 peter
  1847. + open strings, $P switch support
  1848. Revision 1.61 1998/11/18 15:44:18 peter
  1849. * VALUEPARA for tp7 compatible value parameters
  1850. Revision 1.60 1998/11/16 10:13:51 peter
  1851. * label defines are checked at the end of the proc
  1852. Revision 1.59 1998/11/13 12:09:11 peter
  1853. * unused label is now a warning
  1854. Revision 1.58 1998/11/10 10:50:57 pierre
  1855. * temporary fix for long mangled procsym names
  1856. Revision 1.57 1998/11/05 23:39:31 peter
  1857. + typedconst.getsize
  1858. Revision 1.56 1998/10/28 18:26:18 pierre
  1859. * removed some erros after other errors (introduced by useexcept)
  1860. * stabs works again correctly (for how long !)
  1861. Revision 1.55 1998/10/20 08:07:00 pierre
  1862. * several memory corruptions due to double freemem solved
  1863. => never use p^.loc.location:=p^.left^.loc.location;
  1864. + finally I added now by default
  1865. that ra386dir translates global and unit symbols
  1866. + added a first field in tsymtable and
  1867. a nextsym field in tsym
  1868. (this allows to obtain ordered type info for
  1869. records and objects in gdb !)
  1870. Revision 1.54 1998/10/19 08:55:07 pierre
  1871. * wrong stabs info corrected once again !!
  1872. + variable vmt offset with vmt field only if required
  1873. implemented now !!!
  1874. Revision 1.53 1998/10/16 08:51:53 peter
  1875. + target_os.stackalignment
  1876. + stack can be aligned at 2 or 4 byte boundaries
  1877. Revision 1.52 1998/10/08 17:17:32 pierre
  1878. * current_module old scanner tagged as invalid if unit is recompiled
  1879. + added ppheap for better info on tracegetmem of heaptrc
  1880. (adds line column and file index)
  1881. * several memory leaks removed ith help of heaptrc !!
  1882. Revision 1.51 1998/10/08 13:48:50 peter
  1883. * fixed memory leaks for do nothing source
  1884. * fixed unit interdependency
  1885. Revision 1.50 1998/10/06 17:16:56 pierre
  1886. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1887. Revision 1.49 1998/10/01 09:22:55 peter
  1888. * fixed value openarray
  1889. * ungettemp of arrayconstruct
  1890. Revision 1.48 1998/09/26 17:45:44 peter
  1891. + idtoken and only one token table
  1892. Revision 1.47 1998/09/24 15:11:17 peter
  1893. * fixed enum for not GDB
  1894. Revision 1.46 1998/09/23 15:39:13 pierre
  1895. * browser bugfixes
  1896. was adding a reference when looking for the symbol
  1897. if -bSYM_NAME was used
  1898. Revision 1.45 1998/09/21 08:45:24 pierre
  1899. + added vmt_offset in tobjectdef.write for fututre use
  1900. (first steps to have objects without vmt if no virtual !!)
  1901. + added fpu_used field for tabstractprocdef :
  1902. sets this level to 2 if the functions return with value in FPU
  1903. (is then set to correct value at parsing of implementation)
  1904. THIS MIGHT refuse some code with FPU expression too complex
  1905. that were accepted before and even in some cases
  1906. that don't overflow in fact
  1907. ( like if f : float; is a forward that finally in implementation
  1908. only uses one fpu register !!)
  1909. Nevertheless I think that it will improve security on
  1910. FPU operations !!
  1911. * most other changes only for UseBrowser code
  1912. (added symtable references for record and objects)
  1913. local switch for refs to args and local of each function
  1914. (static symtable still missing)
  1915. UseBrowser still not stable and probably broken by
  1916. the definition hash array !!
  1917. Revision 1.44 1998/09/18 16:03:47 florian
  1918. * some changes to compile with Delphi
  1919. Revision 1.43 1998/09/18 08:01:38 pierre
  1920. + improvement on the usebrowser part
  1921. (does not work correctly for now)
  1922. Revision 1.42 1998/09/07 19:33:25 florian
  1923. + some stuff for property rtti added:
  1924. - NameIndex of the TPropInfo record is now written correctly
  1925. - the DEFAULT/NODEFAULT keyword is supported now
  1926. - the default value and the storedsym/def are now written to
  1927. the PPU fiel
  1928. Revision 1.41 1998/09/07 18:46:12 peter
  1929. * update smartlinking, uses getdatalabel
  1930. * renamed ptree.value vars to value_str,value_real,value_set
  1931. Revision 1.40 1998/09/07 17:37:04 florian
  1932. * first fixes for published properties
  1933. Revision 1.39 1998/09/05 22:11:02 florian
  1934. + switch -vb
  1935. * while/repeat loops accept now also word/longbool conditions
  1936. * makebooltojump did an invalid ungetregister32, fixed
  1937. Revision 1.38 1998/09/01 12:53:26 peter
  1938. + aktpackenum
  1939. Revision 1.37 1998/09/01 07:54:25 pierre
  1940. * UseBrowser a little updated (might still be buggy !!)
  1941. * bug in psub.pas in function specifier removed
  1942. * stdcall allowed in interface and in implementation
  1943. (FPC will not yet complain if it is missing in either part
  1944. because stdcall is only a dummy !!)
  1945. Revision 1.36 1998/08/25 13:09:26 pierre
  1946. * corrected mangling sheme :
  1947. cvar add Cprefix to the mixed case name whereas
  1948. export or public use direct name
  1949. Revision 1.35 1998/08/25 12:42:46 pierre
  1950. * CDECL changed to CVAR for variables
  1951. specifications are read in structures also
  1952. + started adding GPC compatibility mode ( option -Sp)
  1953. * names changed to lowercase
  1954. Revision 1.34 1998/08/21 14:08:53 pierre
  1955. + TEST_FUNCRET now default (old code removed)
  1956. works also for m68k (at least compiles)
  1957. Revision 1.33 1998/08/20 12:53:27 peter
  1958. * object_options are always written for object syms
  1959. Revision 1.32 1998/08/20 09:26:46 pierre
  1960. + funcret setting in underproc testing
  1961. compile with _dTEST_FUNCRET
  1962. Revision 1.31 1998/08/17 10:10:12 peter
  1963. - removed OLDPPU
  1964. Revision 1.30 1998/08/13 10:57:29 peter
  1965. * constant sets are now written correctly to the ppufile
  1966. Revision 1.29 1998/08/11 15:31:42 peter
  1967. * write extended to ppu file
  1968. * new version 0.99.7
  1969. Revision 1.28 1998/08/11 14:07:27 peter
  1970. * fixed pushing of high value for openarray
  1971. Revision 1.27 1998/08/10 14:50:31 peter
  1972. + localswitches, moduleswitches, globalswitches splitting
  1973. Revision 1.26 1998/08/10 10:18:35 peter
  1974. + Compiler,Comphook unit which are the new interface units to the
  1975. compiler
  1976. Revision 1.25 1998/07/30 11:18:19 florian
  1977. + first implementation of try ... except on .. do end;
  1978. * limitiation of 65535 bytes parameters for cdecl removed
  1979. Revision 1.24 1998/07/20 18:40:16 florian
  1980. * handling of ansi string constants should now work
  1981. Revision 1.23 1998/07/14 21:37:24 peter
  1982. * fixed packrecords as discussed at the alias
  1983. Revision 1.22 1998/07/14 14:47:08 peter
  1984. * released NEWINPUT
  1985. Revision 1.21 1998/07/13 21:17:38 florian
  1986. * changed to compile with TP
  1987. Revision 1.20 1998/07/10 00:00:05 peter
  1988. * fixed ttypesym bug finally
  1989. * fileinfo in the symtable and better using for unused vars
  1990. Revision 1.19 1998/07/07 17:40:39 peter
  1991. * packrecords 4 works
  1992. * word aligning of parameters
  1993. Revision 1.18 1998/07/07 11:20:15 peter
  1994. + NEWINPUT for a better inputfile and scanner object
  1995. Revision 1.17 1998/06/24 14:48:40 peter
  1996. * ifdef newppu -> ifndef oldppu
  1997. Revision 1.16 1998/06/19 15:40:42 peter
  1998. * removed cosntructor/constructor warning and 0.99.5 recompiles it again
  1999. Revision 1.15 1998/06/17 14:10:18 peter
  2000. * small os2 fixes
  2001. * fixed interdependent units with newppu (remake3 under linux works now)
  2002. Revision 1.14 1998/06/16 08:56:34 peter
  2003. + targetcpu
  2004. * cleaner pmodules for newppu
  2005. Revision 1.13 1998/06/15 15:38:10 pierre
  2006. * small bug in systems.pas corrected
  2007. + operators in different units better hanlded
  2008. Revision 1.12 1998/06/15 14:23:44 daniel
  2009. * Reverted my changes.
  2010. Revision 1.10 1998/06/13 00:10:18 peter
  2011. * working browser and newppu
  2012. * some small fixes against crashes which occured in bp7 (but not in
  2013. fpc?!)
  2014. Revision 1.9 1998/06/12 16:15:35 pierre
  2015. * external name 'C_var';
  2016. export name 'intern_C_var';
  2017. cdecl;
  2018. cdecl;external;
  2019. are now supported only with -Sv switch
  2020. Revision 1.8 1998/06/11 10:11:59 peter
  2021. * -gb works again
  2022. Revision 1.7 1998/06/09 16:01:51 pierre
  2023. + added procedure directive parsing for procvars
  2024. (accepted are popstack cdecl and pascal)
  2025. + added C vars with the following syntax
  2026. var C calias 'true_c_name';(can be followed by external)
  2027. reason is that you must add the Cprefix
  2028. which is target dependent
  2029. Revision 1.6 1998/06/08 22:59:53 peter
  2030. * smartlinking works for win32
  2031. * some defines to exclude some compiler parts
  2032. Revision 1.5 1998/06/04 23:52:02 peter
  2033. * m68k compiles
  2034. + .def file creation moved to gendef.pas so it could also be used
  2035. for win32
  2036. Revision 1.4 1998/06/04 09:55:46 pierre
  2037. * demangled name of procsym reworked to become independant of the mangling scheme
  2038. Revision 1.3 1998/06/03 22:14:20 florian
  2039. * problem with sizes of classes fixed (if the anchestor was declared
  2040. forward, the compiler doesn't update the child classes size)
  2041. Revision 1.2 1998/05/28 14:40:29 peter
  2042. * fixes for newppu, remake3 works now with it
  2043. Revision 1.1 1998/05/27 19:45:09 peter
  2044. * symtable.pas splitted into includefiles
  2045. * symtable adapted for $ifndef OLDPPU
  2046. }