symsym.inc 77 KB

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