symsym.inc 74 KB

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