symsym.inc 77 KB

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