symsym.inc 74 KB

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