symdef.inc 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Symbol table implementation for the defenitions
  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. TDEF (base class for definitions)
  20. ****************************************************************************}
  21. const
  22. { if you change one of the following contants, }
  23. { you have also to change the typinfo unit }
  24. tkUnknown = 0;
  25. tkInteger = 1;
  26. tkChar = 2;
  27. tkEnumeration = 3;
  28. tkFloat = 4;
  29. tkSet = 6;
  30. tkMethod = 7;
  31. tkSString = 8;
  32. tkString = tkSString;
  33. tkLString = 9;
  34. tkAString = 10;
  35. tkWString = 11;
  36. tkVariant = 12;
  37. tkArray = 13;
  38. tkRecord = 14;
  39. tkInterface = 15;
  40. tkClass = 16;
  41. tkObject = 17;
  42. tkWChar = 18;
  43. tkBool = 19;
  44. otSByte = 0;
  45. otUByte = 1;
  46. otSWord = 2;
  47. otUWord = 3;
  48. otSLong = 4;
  49. otULong = 5;
  50. ftSingle = 0;
  51. ftDouble = 1;
  52. ftExtended = 2;
  53. ftComp = 3;
  54. ftCurr = 4;
  55. ftFixed16 = 5;
  56. ftFixed32 = 6;
  57. constructor tdef.init;
  58. begin
  59. deftype:=abstractdef;
  60. owner := nil;
  61. next := nil;
  62. sym := nil;
  63. indexnb := 0;
  64. if registerdef then
  65. symtablestack^.registerdef(@self);
  66. has_rtti:=false;
  67. has_inittable:=false;
  68. {$ifdef GDB}
  69. is_def_stab_written := false;
  70. globalnb := 0;
  71. if assigned(lastglobaldef) then
  72. begin
  73. lastglobaldef^.nextglobal := @self;
  74. previousglobal:=lastglobaldef;
  75. end
  76. else
  77. begin
  78. firstglobaldef := @self;
  79. previousglobal := nil;
  80. end;
  81. lastglobaldef := @self;
  82. nextglobal := nil;
  83. {$endif GDB}
  84. end;
  85. constructor tdef.load;
  86. begin
  87. deftype:=abstractdef;
  88. indexnb := 0;
  89. sym := nil;
  90. owner := nil;
  91. next := nil;
  92. has_rtti:=false;
  93. has_inittable:=false;
  94. {$ifdef GDB}
  95. is_def_stab_written := false;
  96. globalnb := 0;
  97. if assigned(lastglobaldef) then
  98. begin
  99. lastglobaldef^.nextglobal := @self;
  100. previousglobal:=lastglobaldef;
  101. end
  102. else
  103. begin
  104. firstglobaldef := @self;
  105. previousglobal:=nil;
  106. end;
  107. lastglobaldef := @self;
  108. nextglobal := nil;
  109. {$endif GDB}
  110. end;
  111. destructor tdef.done;
  112. begin
  113. {$ifdef GDB}
  114. { first element ? }
  115. if not(assigned(previousglobal)) then
  116. begin
  117. firstglobaldef := nextglobal;
  118. if assigned(firstglobaldef) then
  119. firstglobaldef^.previousglobal:=nil;
  120. end
  121. else
  122. begin
  123. { remove reference in the element before }
  124. previousglobal^.nextglobal:=nextglobal;
  125. end;
  126. { last element ? }
  127. if not(assigned(nextglobal)) then
  128. begin
  129. lastglobaldef := previousglobal;
  130. if assigned(lastglobaldef) then
  131. lastglobaldef^.nextglobal:=nil;
  132. end
  133. else
  134. nextglobal^.previousglobal:=previousglobal;
  135. previousglobal:=nil;
  136. nextglobal:=nil;
  137. {$endif GDB}
  138. end;
  139. procedure tdef.write;
  140. begin
  141. {$ifdef GDB}
  142. if globalnb = 0 then
  143. begin
  144. if assigned(owner) then
  145. globalnb := owner^.getnewtypecount
  146. else
  147. begin
  148. globalnb := PGlobalTypeCount^;
  149. Inc(PGlobalTypeCount^);
  150. end;
  151. end;
  152. {$endif GDB}
  153. end;
  154. function tdef.size : longint;
  155. begin
  156. size:=savesize;
  157. end;
  158. {$ifdef GDB}
  159. procedure tdef.set_globalnb;
  160. begin
  161. globalnb :=PGlobalTypeCount^;
  162. inc(PglobalTypeCount^);
  163. end;
  164. function tdef.stabstring : pchar;
  165. begin
  166. stabstring := strpnew('t'+numberstring+';');
  167. end;
  168. function tdef.numberstring : string;
  169. var table : psymtable;
  170. begin
  171. {formal def have no type !}
  172. if deftype = formaldef then
  173. begin
  174. numberstring := voiddef^.numberstring;
  175. exit;
  176. end;
  177. if (not assigned(sym)) or (not sym^.isusedinstab) then
  178. begin
  179. {set even if debuglist is not defined}
  180. if assigned(sym) then
  181. sym^.isusedinstab := true;
  182. if assigned(debuglist) and not is_def_stab_written then
  183. concatstabto(debuglist);
  184. end;
  185. if not use_dbx then
  186. begin
  187. if globalnb = 0 then
  188. set_globalnb;
  189. numberstring := tostr(globalnb);
  190. end
  191. else
  192. begin
  193. if globalnb = 0 then
  194. begin
  195. if assigned(owner) then
  196. globalnb := owner^.getnewtypecount
  197. else
  198. begin
  199. globalnb := PGlobalTypeCount^;
  200. Inc(PGlobalTypeCount^);
  201. end;
  202. end;
  203. if assigned(sym) then
  204. begin
  205. table := sym^.owner;
  206. if table^.unitid > 0 then
  207. numberstring := '('+tostr(table^.unitid)+','
  208. +tostr(sym^.definition^.globalnb)+')'
  209. else
  210. numberstring := tostr(globalnb);
  211. exit;
  212. end;
  213. numberstring := tostr(globalnb);
  214. end;
  215. end;
  216. function tdef.allstabstring : pchar;
  217. var stabchar : string[2];
  218. ss,st : pchar;
  219. name : string;
  220. sym_line_no : longint;
  221. begin
  222. ss := stabstring;
  223. getmem(st,strlen(ss)+512);
  224. stabchar := 't';
  225. if deftype in tagtypes then
  226. stabchar := 'Tt';
  227. if assigned(sym) then
  228. begin
  229. name := sym^.name;
  230. sym_line_no:=sym^.fileinfo.line;
  231. end
  232. else
  233. begin
  234. name := ' ';
  235. sym_line_no:=0;
  236. end;
  237. strpcopy(st,'"'+name+':'+stabchar+numberstring+'=');
  238. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  239. allstabstring := strnew(st);
  240. freemem(st,strlen(ss)+512);
  241. strdispose(ss);
  242. end;
  243. procedure tdef.concatstabto(asmlist : paasmoutput);
  244. var stab_str : pchar;
  245. begin
  246. if ((sym = nil) or sym^.isusedinstab or use_dbx)
  247. and not is_def_stab_written then
  248. begin
  249. If use_dbx then
  250. begin
  251. { otherwise you get two of each def }
  252. If assigned(sym) then
  253. begin
  254. if sym^.typ=typesym then
  255. sym^.isusedinstab:=true;
  256. if (sym^.owner = nil) or
  257. ((sym^.owner^.symtabletype = unitsymtable) and
  258. punitsymtable(sym^.owner)^.dbx_count_ok) then
  259. begin
  260. {with DBX we get the definition from the other objects }
  261. is_def_stab_written := true;
  262. exit;
  263. end;
  264. end;
  265. end;
  266. { to avoid infinite loops }
  267. is_def_stab_written := true;
  268. stab_str := allstabstring;
  269. if asmlist = debuglist then do_count_dbx := true;
  270. { count_dbx(stab_str); moved to GDB.PAS}
  271. asmlist^.concat(new(pai_stabs,init(stab_str)));
  272. end;
  273. end;
  274. {$endif GDB}
  275. procedure tdef.deref;
  276. begin
  277. end;
  278. { rtti generation }
  279. procedure tdef.generate_rtti;
  280. begin
  281. has_rtti:=true;
  282. getlabel(rtti_label);
  283. write_child_rtti_data;
  284. rttilist^.concat(new(pai_label,init(rtti_label)));
  285. write_rtti_data;
  286. end;
  287. function tdef.get_rtti_label : plabel;
  288. begin
  289. if not(has_rtti) then
  290. generate_rtti;
  291. get_rtti_label:=rtti_label;
  292. end;
  293. { init table handling }
  294. function tdef.needs_inittable : boolean;
  295. begin
  296. needs_inittable:=false;
  297. end;
  298. procedure tdef.generate_inittable;
  299. begin
  300. has_inittable:=true;
  301. getlabel(inittable_label);
  302. write_child_init_data;
  303. rttilist^.concat(new(pai_label,init(inittable_label)));
  304. write_init_data;
  305. end;
  306. procedure tdef.write_init_data;
  307. begin
  308. write_rtti_data;
  309. end;
  310. procedure tdef.write_child_init_data;
  311. begin
  312. write_child_rtti_data;
  313. end;
  314. function tdef.get_inittable_label : plabel;
  315. begin
  316. if not(has_inittable) then
  317. generate_inittable;
  318. get_inittable_label:=inittable_label;
  319. end;
  320. procedure tdef.writename;
  321. var
  322. str : string;
  323. begin
  324. { name }
  325. if assigned(sym) then
  326. begin
  327. str:=sym^.name;
  328. rttilist^.concat(new(pai_string,init(chr(length(str))+str)));
  329. end
  330. else
  331. rttilist^.concat(new(pai_string,init(#0)))
  332. end;
  333. { returns true, if the definition can be published }
  334. function tdef.is_publishable : boolean;
  335. begin
  336. is_publishable:=false;
  337. end;
  338. procedure tdef.write_rtti_data;
  339. begin
  340. end;
  341. procedure tdef.write_child_rtti_data;
  342. begin
  343. end;
  344. {****************************************************************************
  345. TSTRINGDEF
  346. ****************************************************************************}
  347. constructor tstringdef.init(l : byte);
  348. begin
  349. tdef.init;
  350. string_typ:=st_shortstring;
  351. deftype:=stringdef;
  352. len:=l;
  353. savesize:=len+1;
  354. end;
  355. constructor tstringdef.load;
  356. begin
  357. tdef.load;
  358. string_typ:=st_shortstring;
  359. deftype:=stringdef;
  360. len:=readbyte;
  361. savesize:=len+1;
  362. end;
  363. constructor tstringdef.longinit(l : longint);
  364. begin
  365. tdef.init;
  366. string_typ:=st_longstring;
  367. deftype:=stringdef;
  368. len:=l;
  369. savesize:=Sizeof(pointer);
  370. end;
  371. constructor tstringdef.longload;
  372. begin
  373. tdef.load;
  374. deftype:=stringdef;
  375. string_typ:=st_longstring;
  376. len:=readlong;
  377. savesize:=Sizeof(pointer);
  378. end;
  379. constructor tstringdef.ansiinit(l : longint);
  380. begin
  381. tdef.init;
  382. string_typ:=st_ansistring;
  383. deftype:=stringdef;
  384. len:=l;
  385. savesize:=sizeof(pointer);
  386. end;
  387. constructor tstringdef.ansiload;
  388. begin
  389. tdef.load;
  390. deftype:=stringdef;
  391. string_typ:=st_ansistring;
  392. len:=readlong;
  393. savesize:=sizeof(pointer);
  394. end;
  395. constructor tstringdef.wideinit(l : longint);
  396. begin
  397. tdef.init;
  398. string_typ:=st_widestring;
  399. deftype:=stringdef;
  400. len:=l;
  401. savesize:=sizeof(pointer);
  402. end;
  403. constructor tstringdef.wideload;
  404. begin
  405. tdef.load;
  406. deftype:=stringdef;
  407. string_typ:=st_widestring;
  408. len:=readlong;
  409. savesize:=sizeof(pointer);
  410. end;
  411. function tstringdef.size : longint;
  412. begin
  413. size:=savesize;
  414. end;
  415. procedure tstringdef.write;
  416. begin
  417. tdef.write;
  418. if string_typ=st_shortstring then
  419. writebyte(len)
  420. else
  421. writelong(len);
  422. case string_typ of
  423. st_shortstring : current_ppu^.writeentry(ibstringdef);
  424. st_longstring : current_ppu^.writeentry(iblongstringdef);
  425. st_ansistring : current_ppu^.writeentry(ibansistringdef);
  426. st_widestring : current_ppu^.writeentry(ibwidestringdef);
  427. end;
  428. end;
  429. {$ifdef GDB}
  430. function tstringdef.stabstring : pchar;
  431. var
  432. bytest,charst,longst : string;
  433. begin
  434. case string_typ of
  435. st_shortstring:
  436. begin
  437. charst := typeglobalnumber('char');
  438. { this is what I found in stabs.texinfo but
  439. gdb 4.12 for go32 doesn't understand that !! }
  440. {$IfDef GDBknowsstrings}
  441. stabstring := strpnew('n'+charst+';'+tostr(len));
  442. {$else}
  443. bytest := typeglobalnumber('byte');
  444. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  445. +',0,8;st:ar'+bytest
  446. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  447. {$EndIf}
  448. end;
  449. st_longstring:
  450. begin
  451. charst := typeglobalnumber('char');
  452. { this is what I found in stabs.texinfo but
  453. gdb 4.12 for go32 doesn't understand that !! }
  454. {$IfDef GDBknowsstrings}
  455. stabstring := strpnew('n'+charst+';'+tostr(len));
  456. {$else}
  457. bytest := typeglobalnumber('byte');
  458. longst := typeglobalnumber('longint');
  459. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  460. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  461. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  462. {$EndIf}
  463. end;
  464. st_ansistring:
  465. begin
  466. { an ansi string looks like a pchar easy !! }
  467. stabstring:=strpnew('*'+typeglobalnumber('char'));
  468. end;
  469. st_widestring:
  470. begin
  471. { an ansi string looks like a pchar easy !! }
  472. stabstring:=strpnew('*'+typeglobalnumber('char'));
  473. end;
  474. end;
  475. end;
  476. procedure tstringdef.concatstabto(asmlist : paasmoutput);
  477. begin
  478. inherited concatstabto(asmlist);
  479. end;
  480. {$endif GDB}
  481. function tstringdef.needs_inittable : boolean;
  482. begin
  483. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  484. end;
  485. procedure tstringdef.write_rtti_data;
  486. begin
  487. case string_typ of
  488. st_ansistring:
  489. begin
  490. rttilist^.concat(new(pai_const,init_8bit(tkAString)));
  491. end;
  492. st_widestring:
  493. begin
  494. rttilist^.concat(new(pai_const,init_8bit(tkWString)));
  495. end;
  496. st_longstring:
  497. begin
  498. rttilist^.concat(new(pai_const,init_8bit(tkLString)));
  499. end;
  500. st_shortstring:
  501. begin
  502. rttilist^.concat(new(pai_const,init_8bit(tkSString)));
  503. rttilist^.concat(new(pai_const,init_8bit(len)));
  504. end;
  505. end;
  506. end;
  507. function tstringdef.is_publishable : boolean;
  508. begin
  509. is_publishable:=true;
  510. end;
  511. {****************************************************************************
  512. TENUMDEF
  513. ****************************************************************************}
  514. constructor tenumdef.init;
  515. begin
  516. tdef.init;
  517. deftype:=enumdef;
  518. minval:=0;
  519. maxval:=0;
  520. calcsavesize;
  521. has_jumps:=false;
  522. basedef:=nil;
  523. first:=nil;
  524. end;
  525. constructor tenumdef.init_subrange(_basedef:penumdef;_min,_max:longint);
  526. begin
  527. tdef.init;
  528. deftype:=enumdef;
  529. minval:=_min;
  530. maxval:=_max;
  531. basedef:=_basedef;
  532. calcsavesize;
  533. has_jumps:=false;
  534. first:=nil;
  535. end;
  536. constructor tenumdef.load;
  537. begin
  538. tdef.load;
  539. deftype:=enumdef;
  540. basedef:=penumdef(readdefref);
  541. minval:=readlong;
  542. maxval:=readlong;
  543. savesize:=readlong;
  544. has_jumps:=false;
  545. first:=Nil;
  546. end;
  547. procedure tenumdef.calcsavesize;
  548. begin
  549. if (aktpackenum=4) or (min<0) or (max>65535) then
  550. savesize:=4
  551. else
  552. if (aktpackenum=2) or (min<0) or (max>255) then
  553. savesize:=2
  554. else
  555. savesize:=1;
  556. end;
  557. procedure tenumdef.setmax(_max:longint);
  558. begin
  559. maxval:=_max;
  560. calcsavesize;
  561. end;
  562. procedure tenumdef.setmin(_min:longint);
  563. begin
  564. minval:=_min;
  565. calcsavesize;
  566. end;
  567. function tenumdef.min:longint;
  568. begin
  569. min:=minval;
  570. end;
  571. function tenumdef.max:longint;
  572. begin
  573. max:=maxval;
  574. end;
  575. procedure tenumdef.deref;
  576. begin
  577. resolvedef(pdef(basedef));
  578. end;
  579. destructor tenumdef.done;
  580. begin
  581. inherited done;
  582. end;
  583. procedure tenumdef.write;
  584. begin
  585. tdef.write;
  586. writedefref(basedef);
  587. writelong(min);
  588. writelong(max);
  589. writelong(savesize);
  590. current_ppu^.writeentry(ibenumdef);
  591. end;
  592. {$ifdef GDB}
  593. function tenumdef.stabstring : pchar;
  594. var st,st2 : pchar;
  595. p : penumsym;
  596. s : string;
  597. memsize : word;
  598. begin
  599. memsize := memsizeinc;
  600. getmem(st,memsize);
  601. strpcopy(st,'e');
  602. p := first;
  603. while assigned(p) do
  604. begin
  605. s :=p^.name+':'+tostr(p^.value)+',';
  606. { place for the ending ';' also }
  607. if (strlen(st)+length(s)+1<memsize) then
  608. strpcopy(strend(st),s)
  609. else
  610. begin
  611. getmem(st2,memsize+memsizeinc);
  612. strcopy(st2,st);
  613. freemem(st,memsize);
  614. st := st2;
  615. memsize := memsize+memsizeinc;
  616. strpcopy(strend(st),s);
  617. end;
  618. p := p^.next;
  619. end;
  620. strpcopy(strend(st),';');
  621. stabstring := strnew(st);
  622. freemem(st,memsize);
  623. end;
  624. {$endif GDB}
  625. procedure tenumdef.write_child_rtti_data;
  626. begin
  627. if assigned(basedef) then
  628. basedef^.get_rtti_label;
  629. end;
  630. procedure tenumdef.write_rtti_data;
  631. begin
  632. rttilist^.concat(new(pai_const,init_8bit(tkEnumeration)));
  633. case savesize of
  634. 1:
  635. rttilist^.concat(new(pai_const,init_8bit(otUByte)));
  636. 2:
  637. rttilist^.concat(new(pai_const,init_8bit(otUWord)));
  638. 4:
  639. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  640. end;
  641. rttilist^.concat(new(pai_const,init_32bit(min)));
  642. rttilist^.concat(new(pai_const,init_32bit(max)));
  643. if assigned(basedef) then
  644. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(basedef^.get_rtti_label)))))
  645. else
  646. rttilist^.concat(new(pai_const,init_32bit(0)));
  647. {!!!!!!! Name list }
  648. end;
  649. function tenumdef.is_publishable : boolean;
  650. begin
  651. is_publishable:=true;
  652. end;
  653. {****************************************************************************
  654. TORDDEF
  655. ****************************************************************************}
  656. constructor torddef.init(t : tbasetype;v,b : longint);
  657. begin
  658. inherited init;
  659. deftype:=orddef;
  660. low:=v;
  661. high:=b;
  662. typ:=t;
  663. setsize;
  664. end;
  665. constructor torddef.load;
  666. begin
  667. inherited load;
  668. deftype:=orddef;
  669. typ:=tbasetype(readbyte);
  670. low:=readlong;
  671. high:=readlong;
  672. rangenr:=0;
  673. setsize;
  674. end;
  675. procedure torddef.setsize;
  676. begin
  677. if typ=uauto then
  678. begin
  679. { generate a unsigned range if high<0 and low>=0 }
  680. if (low>=0) and (high<0) then
  681. begin
  682. savesize:=4;
  683. typ:=u32bit;
  684. end
  685. else if (low>=0) and (high<=255) then
  686. begin
  687. savesize:=1;
  688. typ:=u8bit;
  689. end
  690. else if (low>=-128) and (high<=127) then
  691. begin
  692. savesize:=1;
  693. typ:=s8bit;
  694. end
  695. else if (low>=0) and (high<=65536) then
  696. begin
  697. savesize:=2;
  698. typ:=u16bit;
  699. end
  700. else if (low>=-32768) and (high<=32767) then
  701. begin
  702. savesize:=2;
  703. typ:=s16bit;
  704. end
  705. else
  706. begin
  707. savesize:=4;
  708. typ:=s32bit;
  709. end;
  710. end
  711. else
  712. begin
  713. case typ of
  714. u8bit,s8bit,
  715. uchar,bool8bit : savesize:=1;
  716. u16bit,s16bit,
  717. bool16bit : savesize:=2;
  718. s32bit,u32bit,
  719. bool32bit : savesize:=4;
  720. else
  721. savesize:=0;
  722. end;
  723. end;
  724. { there are no entrys for range checking }
  725. rangenr:=0;
  726. end;
  727. procedure torddef.genrangecheck;
  728. begin
  729. if rangenr=0 then
  730. begin
  731. { generate two constant for bounds }
  732. getlabelnr(rangenr);
  733. if (cs_smartlink in aktmoduleswitches) then
  734. datasegment^.concat(new(pai_symbol,init_global('R_'+current_module^.modulename^+tostr(rangenr))))
  735. else
  736. datasegment^.concat(new(pai_symbol,init('R_'+tostr(rangenr))));
  737. if low<=high then
  738. begin
  739. datasegment^.concat(new(pai_const,init_32bit(low)));
  740. datasegment^.concat(new(pai_const,init_32bit(high)));
  741. end
  742. { for u32bit we need two bounds }
  743. else
  744. begin
  745. datasegment^.concat(new(pai_const,init_32bit(low)));
  746. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  747. inc(nextlabelnr);
  748. if (cs_smartlink in aktmoduleswitches) then
  749. datasegment^.concat(new(pai_symbol,init_global('R_'+current_module^.modulename^+tostr(rangenr+1))))
  750. else
  751. datasegment^.concat(new(pai_symbol,init('R_'+tostr(rangenr+1))));
  752. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  753. datasegment^.concat(new(pai_const,init_32bit(high)));
  754. end;
  755. end;
  756. end;
  757. procedure torddef.write;
  758. begin
  759. tdef.write;
  760. writebyte(byte(typ));
  761. writelong(low);
  762. writelong(high);
  763. current_ppu^.writeentry(iborddef);
  764. end;
  765. {$ifdef GDB}
  766. function torddef.stabstring : pchar;
  767. begin
  768. case typ of
  769. uvoid : stabstring := strpnew(numberstring+';');
  770. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  771. bool8bit,
  772. bool16bit,
  773. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  774. { u32bit : stabstring := strpnew('r'+
  775. s32bitdef^.numberstring+';0;-1;'); }
  776. else
  777. stabstring := strpnew('r'+s32bitdef^.numberstring+';'+tostr(low)+';'+tostr(high)+';');
  778. end;
  779. end;
  780. {$endif GDB}
  781. procedure torddef.write_rtti_data;
  782. const
  783. trans : array[uchar..bool8bit] of byte =
  784. (otUByte,otUByte,otUWord,otULong,otSByte,otSWord,otSLong,otUByte);
  785. begin
  786. case typ of
  787. bool8bit:
  788. rttilist^.concat(new(pai_const,init_8bit(tkBool)));
  789. uchar:
  790. rttilist^.concat(new(pai_const,init_8bit(tkChar)));
  791. else
  792. rttilist^.concat(new(pai_const,init_8bit(tkInteger)));
  793. end;
  794. rttilist^.concat(new(pai_const,init_32bit(low)));
  795. rttilist^.concat(new(pai_const,init_32bit(high)));
  796. end;
  797. function torddef.is_publishable : boolean;
  798. begin
  799. is_publishable:=typ in [uchar..bool8bit];
  800. end;
  801. {****************************************************************************
  802. TFLOATDEF
  803. ****************************************************************************}
  804. constructor tfloatdef.init(t : tfloattype);
  805. begin
  806. inherited init;
  807. deftype:=floatdef;
  808. typ:=t;
  809. setsize;
  810. end;
  811. constructor tfloatdef.load;
  812. begin
  813. inherited load;
  814. deftype:=floatdef;
  815. typ:=tfloattype(readbyte);
  816. setsize;
  817. end;
  818. procedure tfloatdef.setsize;
  819. begin
  820. case typ of
  821. f16bit : savesize:=2;
  822. f32bit,
  823. s32real : savesize:=4;
  824. s64real : savesize:=8;
  825. s64bit : savesize:=8;
  826. s80real : savesize:=extended_size;
  827. else
  828. savesize:=0;
  829. end;
  830. end;
  831. procedure tfloatdef.write;
  832. begin
  833. inherited write;
  834. writebyte(byte(typ));
  835. current_ppu^.writeentry(ibfloatdef);
  836. end;
  837. {$ifdef GDB}
  838. function tfloatdef.stabstring : pchar;
  839. begin
  840. case typ of
  841. s32real,
  842. s64real : stabstring := strpnew('r'+
  843. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  844. { for fixed real use longint instead to be able to }
  845. { debug something at least }
  846. f32bit:
  847. stabstring := s32bitdef^.stabstring;
  848. f16bit:
  849. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  850. tostr($ffff)+';');
  851. { found this solution in stabsread.c from GDB v4.16 }
  852. s64bit : stabstring := strpnew('r'+
  853. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  854. {$ifdef i386}
  855. { under dos at least you must give a size of twelve instead of 10 !! }
  856. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  857. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  858. {$endif i386}
  859. else
  860. internalerror(10005);
  861. end;
  862. end;
  863. {$endif GDB}
  864. procedure tfloatdef.write_rtti_data;
  865. const
  866. translate : array[tfloattype] of byte =
  867. (ftFixed32,ftSingle,ftDouble,ftExtended,ftComp,ftFixed16);
  868. begin
  869. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  870. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  871. end;
  872. function tfloatdef.is_publishable : boolean;
  873. begin
  874. is_publishable:=true;
  875. end;
  876. {****************************************************************************
  877. TFILEDEF
  878. ****************************************************************************}
  879. constructor tfiledef.init(ft : tfiletype;tas : pdef);
  880. begin
  881. inherited init;
  882. deftype:=filedef;
  883. filetype:=ft;
  884. typed_as:=tas;
  885. setsize;
  886. end;
  887. constructor tfiledef.load;
  888. begin
  889. inherited load;
  890. deftype:=filedef;
  891. filetype:=tfiletype(readbyte);
  892. if filetype=ft_typed then
  893. typed_as:=readdefref
  894. else
  895. typed_as:=nil;
  896. setsize;
  897. end;
  898. procedure tfiledef.deref;
  899. begin
  900. if filetype=ft_typed then
  901. resolvedef(typed_as);
  902. end;
  903. procedure tfiledef.setsize;
  904. begin
  905. case filetype of
  906. ft_text : savesize:=572;
  907. ft_typed,
  908. ft_untyped : savesize:=316;
  909. end;
  910. end;
  911. procedure tfiledef.write;
  912. begin
  913. inherited write;
  914. writebyte(byte(filetype));
  915. if filetype=ft_typed then
  916. writedefref(typed_as);
  917. current_ppu^.writeentry(ibfiledef);
  918. end;
  919. {$ifdef GDB}
  920. function tfiledef.stabstring : pchar;
  921. begin
  922. {$IfDef GDBknowsfiles}
  923. case filetyp of
  924. ft_typed : stabstring := strpnew('d'+typed_as^.numberstring{+';'});
  925. ft_untyped : stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  926. ft_text : stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  927. end;
  928. {$Else}
  929. {based on
  930. FileRec = Packed Record
  931. Handle,
  932. Mode,
  933. RecSize : longint;
  934. _private : array[1..32] of byte;
  935. UserData : array[1..16] of byte;
  936. name : array[0..255] of char;
  937. End; }
  938. { the buffer part is still missing !! (PM) }
  939. { but the string could become too long !! }
  940. stabstring := strpnew('s'+tostr(savesize)+
  941. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  942. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  943. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  944. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  945. +',96,256;'+
  946. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  947. +',352,128;'+
  948. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  949. +',480,2048;;');
  950. {$EndIf}
  951. end;
  952. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  953. begin
  954. { most file defs are unnamed !!! }
  955. if ((sym = nil) or sym^.isusedinstab or use_dbx) and not is_def_stab_written then
  956. begin
  957. if assigned(typed_as) then forcestabto(asmlist,typed_as);
  958. inherited concatstabto(asmlist);
  959. end;
  960. end;
  961. {$endif GDB}
  962. {****************************************************************************
  963. TPOINTERDEF
  964. ****************************************************************************}
  965. constructor tpointerdef.init(def : pdef);
  966. begin
  967. inherited init;
  968. deftype:=pointerdef;
  969. definition:=def;
  970. savesize:=Sizeof(pointer);
  971. end;
  972. constructor tpointerdef.load;
  973. begin
  974. inherited load;
  975. deftype:=pointerdef;
  976. { the real address in memory is calculated later (deref) }
  977. definition:=readdefref;
  978. savesize:=Sizeof(pointer);
  979. end;
  980. procedure tpointerdef.deref;
  981. begin
  982. resolvedef(definition);
  983. end;
  984. procedure tpointerdef.write;
  985. begin
  986. inherited write;
  987. writedefref(definition);
  988. current_ppu^.writeentry(ibpointerdef);
  989. end;
  990. {$ifdef GDB}
  991. function tpointerdef.stabstring : pchar;
  992. begin
  993. stabstring := strpnew('*'+definition^.numberstring);
  994. end;
  995. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  996. var st,nb : string;
  997. sym_line_no : longint;
  998. begin
  999. if ( (sym=nil) or sym^.isusedinstab or use_dbx) and not is_def_stab_written then
  1000. begin
  1001. if assigned(definition) then
  1002. if definition^.deftype in [recorddef,objectdef] then
  1003. begin
  1004. is_def_stab_written := true;
  1005. {to avoid infinite recursion in record with next-like fields }
  1006. nb := definition^.numberstring;
  1007. is_def_stab_written := false;
  1008. if not definition^.is_def_stab_written then
  1009. begin
  1010. if assigned(definition^.sym) then
  1011. begin
  1012. if assigned(sym) then
  1013. begin
  1014. st := sym^.name;
  1015. sym_line_no:=sym^.fileinfo.line;
  1016. end
  1017. else
  1018. begin
  1019. st := ' ';
  1020. sym_line_no:=0;
  1021. end;
  1022. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1023. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1024. if asmlist = debuglist then do_count_dbx := true;
  1025. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1026. end;
  1027. end else inherited concatstabto(asmlist);
  1028. is_def_stab_written := true;
  1029. end else
  1030. begin
  1031. forcestabto(asmlist,definition);
  1032. inherited concatstabto(asmlist);
  1033. end;
  1034. end;
  1035. end;
  1036. {$endif GDB}
  1037. {****************************************************************************
  1038. TCLASSREFDEF
  1039. ****************************************************************************}
  1040. constructor tclassrefdef.init(def : pdef);
  1041. begin
  1042. inherited init(def);
  1043. deftype:=classrefdef;
  1044. definition:=def;
  1045. savesize:=Sizeof(pointer);
  1046. end;
  1047. constructor tclassrefdef.load;
  1048. begin
  1049. inherited load;
  1050. deftype:=classrefdef;
  1051. end;
  1052. procedure tclassrefdef.write;
  1053. begin
  1054. inherited write;
  1055. writedefref(definition);
  1056. current_ppu^.writeentry(ibclassrefdef);
  1057. end;
  1058. {$ifdef GDB}
  1059. function tclassrefdef.stabstring : pchar;
  1060. begin
  1061. stabstring:=strpnew('');
  1062. end;
  1063. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1064. begin
  1065. end;
  1066. {$endif GDB}
  1067. {***************************************************************************
  1068. TSETDEF
  1069. ***************************************************************************}
  1070. constructor tsetdef.init(s : pdef;high : longint);
  1071. begin
  1072. inherited init;
  1073. deftype:=setdef;
  1074. setof:=s;
  1075. if high<32 then
  1076. begin
  1077. settype:=smallset;
  1078. savesize:=Sizeof(longint);
  1079. end
  1080. else
  1081. if high<256 then
  1082. begin
  1083. settype:=normset;
  1084. savesize:=32;
  1085. end
  1086. else
  1087. {$ifdef testvarsets}
  1088. if high<$10000 then
  1089. begin
  1090. settype:=varset;
  1091. savesize:=4*((high+31) div 32);
  1092. end
  1093. else
  1094. {$endif testvarsets}
  1095. Message(sym_e_ill_type_decl_set);
  1096. end;
  1097. constructor tsetdef.load;
  1098. begin
  1099. inherited load;
  1100. deftype:=setdef;
  1101. setof:=readdefref;
  1102. settype:=tsettype(readbyte);
  1103. case settype of
  1104. normset : savesize:=32;
  1105. varset : savesize:=readlong;
  1106. smallset : savesize:=Sizeof(longint);
  1107. end;
  1108. end;
  1109. procedure tsetdef.write;
  1110. begin
  1111. inherited write;
  1112. writedefref(setof);
  1113. writebyte(byte(settype));
  1114. if settype=varset then
  1115. writelong(savesize);
  1116. current_ppu^.writeentry(ibsetdef);
  1117. end;
  1118. {$ifdef GDB}
  1119. function tsetdef.stabstring : pchar;
  1120. begin
  1121. stabstring := strpnew('S'+setof^.numberstring);
  1122. end;
  1123. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1124. begin
  1125. if ( not assigned(sym) or sym^.isusedinstab or use_dbx) and
  1126. not is_def_stab_written then
  1127. begin
  1128. if assigned(setof) then
  1129. forcestabto(asmlist,setof);
  1130. inherited concatstabto(asmlist);
  1131. end;
  1132. end;
  1133. {$endif GDB}
  1134. procedure tsetdef.deref;
  1135. begin
  1136. resolvedef(setof);
  1137. end;
  1138. procedure tsetdef.write_rtti_data;
  1139. begin
  1140. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1141. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1142. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(setof^.get_rtti_label)))));
  1143. end;
  1144. procedure tsetdef.write_child_rtti_data;
  1145. begin
  1146. setof^.get_rtti_label;
  1147. end;
  1148. function tsetdef.is_publishable : boolean;
  1149. begin
  1150. is_publishable:=settype=smallset;
  1151. end;
  1152. {***************************************************************************
  1153. TFORMALDEF
  1154. ***************************************************************************}
  1155. constructor tformaldef.init;
  1156. begin
  1157. inherited init;
  1158. deftype:=formaldef;
  1159. savesize:=Sizeof(pointer);
  1160. end;
  1161. constructor tformaldef.load;
  1162. begin
  1163. inherited load;
  1164. deftype:=formaldef;
  1165. savesize:=Sizeof(pointer);
  1166. end;
  1167. procedure tformaldef.write;
  1168. begin
  1169. inherited write;
  1170. current_ppu^.writeentry(ibformaldef);
  1171. end;
  1172. {$ifdef GDB}
  1173. function tformaldef.stabstring : pchar;
  1174. begin
  1175. stabstring := strpnew('formal'+numberstring+';');
  1176. end;
  1177. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1178. begin
  1179. { formaldef can't be stab'ed !}
  1180. end;
  1181. {$endif GDB}
  1182. {***************************************************************************
  1183. TARRAYDEF
  1184. ***************************************************************************}
  1185. constructor tarraydef.init(l,h : longint;rd : pdef);
  1186. begin
  1187. inherited init;
  1188. deftype:=arraydef;
  1189. lowrange:=l;
  1190. highrange:=h;
  1191. rangedef:=rd;
  1192. rangenr:=0;
  1193. definition:=nil;
  1194. end;
  1195. constructor tarraydef.load;
  1196. begin
  1197. inherited load;
  1198. deftype:=arraydef;
  1199. { the addresses are calculated later }
  1200. definition:=readdefref;
  1201. rangedef:=readdefref;
  1202. lowrange:=readlong;
  1203. highrange:=readlong;
  1204. rangenr:=0;
  1205. end;
  1206. procedure tarraydef.genrangecheck;
  1207. begin
  1208. if rangenr=0 then
  1209. begin
  1210. { generates the data for range checking }
  1211. getlabelnr(rangenr);
  1212. datasegment^.concat(new(pai_symbol,init('R_'+tostr(rangenr))));
  1213. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1214. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1215. end;
  1216. end;
  1217. procedure tarraydef.deref;
  1218. begin
  1219. resolvedef(definition);
  1220. resolvedef(rangedef);
  1221. end;
  1222. procedure tarraydef.write;
  1223. begin
  1224. inherited write;
  1225. writedefref(definition);
  1226. writedefref(rangedef);
  1227. writelong(lowrange);
  1228. writelong(highrange);
  1229. current_ppu^.writeentry(ibarraydef);
  1230. end;
  1231. {$ifdef GDB}
  1232. function tarraydef.stabstring : pchar;
  1233. begin
  1234. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1235. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1236. end;
  1237. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1238. begin
  1239. if (not assigned(sym) or sym^.isusedinstab or use_dbx)
  1240. and not is_def_stab_written then
  1241. begin
  1242. {when array are inserted they have no definition yet !!}
  1243. if assigned(definition) then
  1244. inherited concatstabto(asmlist);
  1245. end;
  1246. end;
  1247. {$endif GDB}
  1248. function tarraydef.elesize : longint;
  1249. begin
  1250. elesize:=definition^.size;
  1251. end;
  1252. function tarraydef.size : longint;
  1253. begin
  1254. size:=(highrange-lowrange+1)*elesize;
  1255. end;
  1256. function tarraydef.needs_inittable : boolean;
  1257. begin
  1258. needs_inittable:=definition^.needs_inittable;
  1259. end;
  1260. procedure tarraydef.write_child_rtti_table;
  1261. begin
  1262. definition^.get_rtti_label;
  1263. end;
  1264. procedure tarraydef.write_rtti_data;
  1265. begin
  1266. rttilist^.concat(new(pai_const,init_8bit(13)));
  1267. writename;
  1268. { size of elements }
  1269. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1270. { count of elements }
  1271. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1272. { element type }
  1273. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(definition^.get_rtti_label)))));
  1274. end;
  1275. {***************************************************************************
  1276. TRECDEF
  1277. ***************************************************************************}
  1278. constructor trecdef.init(p : psymtable);
  1279. begin
  1280. inherited init;
  1281. deftype:=recorddef;
  1282. symtable:=p;
  1283. savesize:=symtable^.datasize;
  1284. symtable^.defowner := @self;
  1285. end;
  1286. constructor trecdef.load;
  1287. var
  1288. oldread_member : boolean;
  1289. begin
  1290. inherited load;
  1291. deftype:=recorddef;
  1292. savesize:=readlong;
  1293. oldread_member:=read_member;
  1294. read_member:=true;
  1295. symtable:=new(psymtable,loadasstruct(recordsymtable));
  1296. read_member:=oldread_member;
  1297. symtable^.defowner := @self;
  1298. end;
  1299. destructor trecdef.done;
  1300. begin
  1301. if assigned(symtable) then dispose(symtable,done);
  1302. inherited done;
  1303. end;
  1304. var
  1305. binittable : boolean;
  1306. procedure check_rec_inittable(s : psym);
  1307. begin
  1308. if (s^.typ=varsym) and (pvarsym(s)^.definition^.needs_inittable) then
  1309. binittable:=true;
  1310. end;
  1311. function trecdef.needs_inittable : boolean;
  1312. var
  1313. oldb : boolean;
  1314. begin
  1315. { there are recursive calls to needs_rtti possible, }
  1316. { so we have to change to old value how else should }
  1317. { we do that ? check_rec_rtti can't be a nested }
  1318. { procedure of needs_rtti ! }
  1319. oldb:=binittable;
  1320. binittable:=false;
  1321. symtable^.foreach(check_rec_inittable);
  1322. needs_inittable:=binittable;
  1323. binittable:=oldb;
  1324. end;
  1325. procedure trecdef.deref;
  1326. var
  1327. hp : pdef;
  1328. oldrecsyms : psymtable;
  1329. begin
  1330. oldrecsyms:=aktrecordsymtable;
  1331. aktrecordsymtable:=symtable;
  1332. { now dereference the definitions }
  1333. hp:=symtable^.rootdef;
  1334. while assigned(hp) do
  1335. begin
  1336. hp^.deref;
  1337. { set owner }
  1338. hp^.owner:=symtable;
  1339. hp:=hp^.next;
  1340. end;
  1341. {$ifdef tp}
  1342. symtable^.foreach(derefsym);
  1343. {$else}
  1344. symtable^.foreach(@derefsym);
  1345. {$endif}
  1346. aktrecordsymtable:=oldrecsyms;
  1347. end;
  1348. procedure trecdef.write;
  1349. var
  1350. oldread_member : boolean;
  1351. begin
  1352. oldread_member:=read_member;
  1353. read_member:=true;
  1354. inherited write;
  1355. writelong(savesize);
  1356. current_ppu^.writeentry(ibrecorddef);
  1357. self.symtable^.writeasstruct;
  1358. read_member:=oldread_member;
  1359. end;
  1360. {$ifdef GDB}
  1361. Const StabRecString : pchar = Nil;
  1362. StabRecSize : longint = 0;
  1363. RecOffset : Longint = 0;
  1364. procedure addname(p : psym);
  1365. var
  1366. news, newrec : pchar;
  1367. begin
  1368. { static variables from objects are like global objects }
  1369. if ((p^.properties and sp_static)<>0) then
  1370. exit;
  1371. If p^.typ = varsym then
  1372. begin
  1373. newrec := strpnew(p^.name+':'+pvarsym(p)^.definition^.numberstring
  1374. +','+tostr(pvarsym(p)^.address*8)+','
  1375. +tostr(pvarsym(p)^.definition^.size*8)+';');
  1376. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1377. begin
  1378. getmem(news,stabrecsize+memsizeinc);
  1379. strcopy(news,stabrecstring);
  1380. freemem(stabrecstring,stabrecsize);
  1381. stabrecsize:=stabrecsize+memsizeinc;
  1382. stabrecstring:=news;
  1383. end;
  1384. strcat(StabRecstring,newrec);
  1385. strdispose(newrec);
  1386. {This should be used for case !!}
  1387. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1388. end;
  1389. end;
  1390. function trecdef.stabstring : pchar;
  1391. Var oldrec : pchar;
  1392. oldsize : longint;
  1393. begin
  1394. oldrec := stabrecstring;
  1395. oldsize:=stabrecsize;
  1396. GetMem(stabrecstring,memsizeinc);
  1397. stabrecsize:=memsizeinc;
  1398. strpcopy(stabRecString,'s'+tostr(savesize));
  1399. RecOffset := 0;
  1400. {$ifdef tp}
  1401. symtable^.foreach(addname);
  1402. {$else}
  1403. symtable^.foreach(@addname);
  1404. {$endif}
  1405. { FPC doesn't want to convert a char to a pchar}
  1406. { is this a bug ? }
  1407. strpcopy(strend(StabRecString),';');
  1408. stabstring := strnew(StabRecString);
  1409. Freemem(stabrecstring,stabrecsize);
  1410. stabrecstring := oldrec;
  1411. stabrecsize:=oldsize;
  1412. end;
  1413. procedure trecdef.concatstabto(asmlist : paasmoutput);
  1414. begin
  1415. if (not assigned(sym) or sym^.isusedinstab or use_dbx) and
  1416. (not is_def_stab_written) then
  1417. inherited concatstabto(asmlist);
  1418. end;
  1419. {$endif GDB}
  1420. var
  1421. count : longint;
  1422. procedure count_inittable_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1423. begin
  1424. if pvarsym(sym)^.definition^.needs_inittable then
  1425. inc(count);
  1426. end;
  1427. procedure count_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1428. begin
  1429. inc(count);
  1430. end;
  1431. procedure write_field_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1432. begin
  1433. if pvarsym(sym)^.definition^.needs_inittable then
  1434. begin
  1435. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(pvarsym(sym)^.definition^.get_inittable_label)))));
  1436. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1437. end;
  1438. end;
  1439. procedure write_field_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1440. begin
  1441. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(pvarsym(sym)^.definition^.get_rtti_label)))));
  1442. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1443. end;
  1444. procedure generate_child_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1445. begin
  1446. if (sym^.typ=varsym) and pvarsym(sym)^.definition^.needs_inittable then
  1447. { force inittable generation }
  1448. pvarsym(sym)^.definition^.get_inittable_label;
  1449. end;
  1450. procedure generate_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1451. begin
  1452. pvarsym(sym)^.definition^.get_rtti_label;
  1453. end;
  1454. procedure trecdef.write_child_rtti_data;
  1455. begin
  1456. symtable^.foreach(generate_child_rtti);
  1457. end;
  1458. procedure trecdef.write_child_init_data;
  1459. begin
  1460. symtable^.foreach(generate_child_inittable);
  1461. end;
  1462. procedure trecdef.write_rtti_data;
  1463. begin
  1464. rttilist^.concat(new(pai_const,init_8bit(14)));
  1465. writename;
  1466. rttilist^.concat(new(pai_const,init_32bit(size)));
  1467. count:=0;
  1468. symtable^.foreach(count_fields);
  1469. rttilist^.concat(new(pai_const,init_32bit(count)));
  1470. symtable^.foreach(write_field_rtti);
  1471. end;
  1472. procedure trecdef.write_init_data;
  1473. begin
  1474. rttilist^.concat(new(pai_const,init_8bit(14)));
  1475. writename;
  1476. rttilist^.concat(new(pai_const,init_32bit(size)));
  1477. count:=0;
  1478. symtable^.foreach(count_inittable_fields);
  1479. rttilist^.concat(new(pai_const,init_32bit(count)));
  1480. symtable^.foreach(write_field_inittable);
  1481. end;
  1482. {***************************************************************************
  1483. TABSTRACTPROCDEF
  1484. ***************************************************************************}
  1485. constructor tabstractprocdef.init;
  1486. begin
  1487. inherited init;
  1488. para1:=nil;
  1489. {$ifdef StoreFPULevel}
  1490. fpu_used:=255;
  1491. {$endif StoreFPULevel}
  1492. options:=0;
  1493. retdef:=voiddef;
  1494. savesize:=Sizeof(pointer);
  1495. end;
  1496. destructor tabstractprocdef.done;
  1497. var
  1498. hp : pdefcoll;
  1499. begin
  1500. hp:=para1;
  1501. while assigned(hp) do
  1502. begin
  1503. para1:=hp^.next;
  1504. dispose(hp);
  1505. hp:=para1;
  1506. end;
  1507. inherited done;
  1508. end;
  1509. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1510. var
  1511. hp : pdefcoll;
  1512. begin
  1513. new(hp);
  1514. hp^.paratyp:=vsp;
  1515. hp^.data:=p;
  1516. hp^.next:=para1;
  1517. para1:=hp;
  1518. end;
  1519. procedure tabstractprocdef.deref;
  1520. var
  1521. hp : pdefcoll;
  1522. begin
  1523. inherited deref;
  1524. resolvedef(retdef);
  1525. hp:=para1;
  1526. while assigned(hp) do
  1527. begin
  1528. resolvedef(hp^.data);
  1529. hp:=hp^.next;
  1530. end;
  1531. end;
  1532. constructor tabstractprocdef.load;
  1533. var
  1534. last,hp : pdefcoll;
  1535. count,i : word;
  1536. begin
  1537. inherited load;
  1538. retdef:=readdefref;
  1539. {$ifdef StoreFPULevel}
  1540. fpu_used:=readbyte;
  1541. {$endif StoreFPULevel}
  1542. options:=readlong;
  1543. count:=readword;
  1544. para1:=nil;
  1545. savesize:=Sizeof(pointer);
  1546. for i:=1 to count do
  1547. begin
  1548. new(hp);
  1549. hp^.paratyp:=tvarspez(readbyte);
  1550. hp^.data:=readdefref;
  1551. hp^.next:=nil;
  1552. if para1=nil then
  1553. para1:=hp
  1554. else
  1555. last^.next:=hp;
  1556. last:=hp;
  1557. end;
  1558. end;
  1559. function tabstractprocdef.para_size : longint;
  1560. var
  1561. pdc : pdefcoll;
  1562. l : longint;
  1563. begin
  1564. l:=0;
  1565. pdc:=para1;
  1566. while assigned(pdc) do
  1567. begin
  1568. case pdc^.paratyp of
  1569. vs_value :
  1570. l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
  1571. vs_var :
  1572. l:=l+sizeof(pointer);
  1573. vs_const :
  1574. if dont_copy_const_param(pdc^.data) then
  1575. l:=l+sizeof(pointer)
  1576. else
  1577. l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
  1578. end;
  1579. pdc:=pdc^.next;
  1580. end;
  1581. para_size:=l;
  1582. end;
  1583. procedure tabstractprocdef.write;
  1584. var
  1585. count : word;
  1586. hp : pdefcoll;
  1587. begin
  1588. inherited write;
  1589. writedefref(retdef);
  1590. {$ifdef StoreFPULevel}
  1591. writebyte(fpu_used);
  1592. {$endif StoreFPULevel}
  1593. writelong(options);
  1594. hp:=para1;
  1595. count:=0;
  1596. while assigned(hp) do
  1597. begin
  1598. inc(count);
  1599. hp:=hp^.next;
  1600. end;
  1601. writeword(count);
  1602. hp:=para1;
  1603. while assigned(hp) do
  1604. begin
  1605. writebyte(byte(hp^.paratyp));
  1606. writedefref(hp^.data);
  1607. hp:=hp^.next;
  1608. end;
  1609. end;
  1610. function tabstractprocdef.demangled_paras : string;
  1611. var s : string;
  1612. p : pdefcoll;
  1613. begin
  1614. s:='';
  1615. p:=para1;
  1616. if assigned(p) then
  1617. begin
  1618. s:=s+'(';
  1619. while assigned(p) do
  1620. begin
  1621. if assigned(p^.data^.sym) then
  1622. s:=s+p^.data^.sym^.name
  1623. else if p^.paratyp=vs_var then
  1624. s:=s+'var'
  1625. else if p^.paratyp=vs_const then
  1626. s:=s+'const';
  1627. p:=p^.next;
  1628. if assigned(p) then
  1629. s:=s+','
  1630. else
  1631. s:=s+')';
  1632. end;
  1633. end;
  1634. demangled_paras:=s;
  1635. end;
  1636. {$ifdef GDB}
  1637. function tabstractprocdef.stabstring : pchar;
  1638. begin
  1639. stabstring := strpnew('abstractproc'+numberstring+';');
  1640. end;
  1641. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  1642. begin
  1643. if (not assigned(sym) or sym^.isusedinstab or use_dbx)
  1644. and not is_def_stab_written then
  1645. begin
  1646. if assigned(retdef) then forcestabto(asmlist,retdef);
  1647. inherited concatstabto(asmlist);
  1648. end;
  1649. end;
  1650. {$endif GDB}
  1651. {***************************************************************************
  1652. TPROCDEF
  1653. ***************************************************************************}
  1654. constructor tprocdef.init;
  1655. begin
  1656. inherited init;
  1657. deftype:=procdef;
  1658. _mangledname:=nil;
  1659. nextoverloaded:=nil;
  1660. extnumber:=-1;
  1661. localst:=new(psymtable,init(localsymtable));
  1662. parast:=new(psymtable,init(parasymtable));
  1663. { this is used by insert
  1664. to check same names in parast and localst }
  1665. localst^.next:=parast;
  1666. {$ifdef UseBrowser}
  1667. defref:=nil;
  1668. lastwritten:=nil;
  1669. refcount:=0;
  1670. if (cs_browser in aktmoduleswitches) and make_ref then
  1671. begin
  1672. defref:=new(pref,init(defref,@tokenpos));
  1673. inc(refcount);
  1674. end;
  1675. lastref:=defref;
  1676. {$endif UseBrowser}
  1677. { first, we assume, that all registers are used }
  1678. {$ifdef i386}
  1679. usedregisters:=$ff;
  1680. {$endif i386}
  1681. {$ifdef m68k}
  1682. usedregisters:=$FFFF;
  1683. {$endif}
  1684. {$ifdef alpha}
  1685. usedregisters_int:=$ffffffff;
  1686. usedregisters_fpu:=$ffffffff;
  1687. {$endif alpha}
  1688. forwarddef:=true;
  1689. _class := nil;
  1690. code:=nil;
  1691. end;
  1692. constructor tprocdef.load;
  1693. var
  1694. s : string;
  1695. begin
  1696. inherited load;
  1697. deftype:=procdef;
  1698. {$ifdef i386}
  1699. usedregisters:=readbyte;
  1700. {$endif i386}
  1701. {$ifdef m68k}
  1702. usedregisters:=readword;
  1703. {$endif}
  1704. {$ifdef alpha}
  1705. usedregisters_int:=readlong;
  1706. usedregisters_fpu:=readlong;
  1707. {$endif alpha}
  1708. s:=readstring;
  1709. setstring(_mangledname,s);
  1710. extnumber:=readlong;
  1711. nextoverloaded:=pprocdef(readdefref);
  1712. _class := pobjectdef(readdefref);
  1713. if (cs_link_deffile in aktglobalswitches) and ((options and poexports)<>0) then
  1714. deffile.AddExport(mangledname);
  1715. parast:=nil;
  1716. localst:=nil;
  1717. forwarddef:=false;
  1718. {$ifdef UseBrowser}
  1719. lastref:=nil;
  1720. lastwritten:=nil;
  1721. defref:=nil;
  1722. refcount:=0;
  1723. {$endif UseBrowser}
  1724. end;
  1725. {$ifdef UseBrowser}
  1726. procedure tprocdef.load_references;
  1727. var
  1728. pos : tfileposinfo;
  1729. begin
  1730. while (not current_ppu^.endofentry) do
  1731. begin
  1732. readposinfo(pos);
  1733. inc(refcount);
  1734. lastref:=new(pref,init(lastref,@pos));
  1735. if refcount=1 then
  1736. defref:=lastref;
  1737. end;
  1738. end;
  1739. procedure tprocdef.write_references;
  1740. var
  1741. ref : pref;
  1742. begin
  1743. if lastwritten=lastref then
  1744. exit;
  1745. { write address of this symbol }
  1746. writedefref(@self);
  1747. { write refs }
  1748. if assigned(lastwritten) then
  1749. ref:=lastwritten
  1750. else
  1751. ref:=defref;
  1752. while assigned(ref) do
  1753. begin
  1754. writeposinfo(ref^.posinfo);
  1755. ref:=ref^.nextref;
  1756. end;
  1757. current_ppu^.writeentry(ibdefref);
  1758. lastwritten:=lastref;
  1759. end;
  1760. procedure tprocdef.add_to_browserlog;
  1761. begin
  1762. if assigned(defref) then
  1763. begin
  1764. Browse.AddLog('***'+mangledname);
  1765. Browse.AddLogRefs(defref);
  1766. if assigned(parast) then
  1767. parast^.writebrowserlog;
  1768. if assigned(localst) then
  1769. localst^.writebrowserlog;
  1770. end;
  1771. end;
  1772. {$endif UseBrowser}
  1773. destructor tprocdef.done;
  1774. begin
  1775. {$ifdef UseBrowser}
  1776. if assigned(defref) then
  1777. dispose(defref,done);
  1778. {$endif UseBrowser}
  1779. if assigned(parast) then
  1780. dispose(parast,done);
  1781. if assigned(localst) then
  1782. dispose(localst,done);
  1783. if
  1784. {$ifdef tp}
  1785. not(use_big) and
  1786. {$endif}
  1787. assigned(_mangledname) then
  1788. strdispose(_mangledname);
  1789. inherited done;
  1790. end;
  1791. procedure tprocdef.write;
  1792. begin
  1793. inherited write;
  1794. {$ifdef i386}
  1795. writebyte(usedregisters);
  1796. {$endif i386}
  1797. {$ifdef m68k}
  1798. writeword(usedregisters);
  1799. {$endif}
  1800. {$ifdef alpha}
  1801. writelong(usedregisters_int);
  1802. writelong(usedregisters_fpu);
  1803. {$endif alpha}
  1804. writestring(mangledname);
  1805. writelong(extnumber);
  1806. if (options and pooperator) = 0 then
  1807. writedefref(nextoverloaded)
  1808. else
  1809. begin
  1810. { only write the overloads from the same unit }
  1811. if nextoverloaded^.owner=owner then
  1812. writedefref(nextoverloaded)
  1813. else
  1814. writedefref(nil);
  1815. end;
  1816. writedefref(_class);
  1817. if (options and poinline) <> 0 then
  1818. begin
  1819. { we need to save
  1820. - the para and the local symtable
  1821. - the code ptree !! PM
  1822. writesymtable(parast);
  1823. writesymtable(localst);
  1824. writeptree(ptree(code));
  1825. }
  1826. end;
  1827. current_ppu^.writeentry(ibprocdef);
  1828. end;
  1829. {$ifdef GDB}
  1830. procedure addparaname(p : psym);
  1831. var vs : char;
  1832. begin
  1833. if pvarsym(p)^.varspez = vs_value then vs := '1'
  1834. else vs := '0';
  1835. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  1836. end;
  1837. function tprocdef.stabstring : pchar;
  1838. var param : pdefcoll;
  1839. i : word;
  1840. vartyp : char;
  1841. oldrec : pchar;
  1842. begin
  1843. oldrec := stabrecstring;
  1844. getmem(StabRecString,1024);
  1845. param := para1;
  1846. i := 0;
  1847. while assigned(param) do
  1848. begin
  1849. inc(i);
  1850. param := param^.next;
  1851. end;
  1852. strpcopy(StabRecString,'f'+retdef^.numberstring);
  1853. if i>0 then
  1854. begin
  1855. strpcopy(strend(StabRecString),','+tostr(i)+';');
  1856. if assigned(parast) then
  1857. {$IfDef TP}
  1858. parast^.foreach(addparaname)
  1859. {$Else}
  1860. parast^.foreach(@addparaname)
  1861. {$EndIf}
  1862. else
  1863. begin
  1864. param := para1;
  1865. i := 0;
  1866. while assigned(param) do
  1867. begin
  1868. inc(i);
  1869. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  1870. {Here we have lost the parameter names !!}
  1871. {using lower case parameters }
  1872. strpcopy(strend(stabrecstring),'p'+tostr(i)
  1873. +':'+param^.data^.numberstring+','+vartyp+';');
  1874. param := param^.next;
  1875. end;
  1876. end;
  1877. {strpcopy(strend(StabRecString),';');}
  1878. end;
  1879. stabstring := strnew(stabrecstring);
  1880. freemem(stabrecstring,1024);
  1881. stabrecstring := oldrec;
  1882. end;
  1883. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  1884. begin
  1885. end;
  1886. {$endif GDB}
  1887. procedure tprocdef.deref;
  1888. begin
  1889. inherited deref;
  1890. resolvedef(pdef(nextoverloaded));
  1891. resolvedef(pdef(_class));
  1892. end;
  1893. function tprocdef.mangledname : string;
  1894. {$ifdef tp}
  1895. var
  1896. oldpos : longint;
  1897. s : string;
  1898. b : byte;
  1899. {$endif tp}
  1900. begin
  1901. {$ifdef tp}
  1902. if use_big then
  1903. begin
  1904. symbolstream.seek(longint(_mangledname));
  1905. symbolstream.read(b,1);
  1906. symbolstream.read(s[1],b);
  1907. s[0]:=chr(b);
  1908. mangledname:=s;
  1909. end
  1910. else
  1911. {$endif}
  1912. mangledname:=strpas(_mangledname);
  1913. end;
  1914. {$IfDef GDB}
  1915. function tprocdef.cplusplusmangledname : string;
  1916. var
  1917. s,s2 : string;
  1918. param : pdefcoll;
  1919. begin
  1920. s := sym^.name;
  1921. if _class <> nil then
  1922. begin
  1923. s2 := _class^.name^;
  1924. s := s+'__'+tostr(length(s2))+s2;
  1925. end else s := s + '_';
  1926. param := para1;
  1927. while assigned(param) do
  1928. begin
  1929. s2 := param^.data^.sym^.name;
  1930. s := s+tostr(length(s2))+s2;
  1931. param := param^.next;
  1932. end;
  1933. cplusplusmangledname:=s;
  1934. end;
  1935. {$EndIf GDB}
  1936. procedure tprocdef.setmangledname(const s : string);
  1937. begin
  1938. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  1939. strdispose(_mangledname);
  1940. setstring(_mangledname,s);
  1941. {$ifdef UseBrowser}
  1942. if assigned(parast) then
  1943. begin
  1944. stringdispose(parast^.name);
  1945. parast^.name:=stringdup('args of '+s);
  1946. end;
  1947. if assigned(localst) then
  1948. begin
  1949. stringdispose(localst^.name);
  1950. localst^.name:=stringdup('locals of '+s);
  1951. end;
  1952. {$endif UseBrowser}
  1953. end;
  1954. {***************************************************************************
  1955. TPROCVARDEF
  1956. ***************************************************************************}
  1957. constructor tprocvardef.init;
  1958. begin
  1959. inherited init;
  1960. deftype:=procvardef;
  1961. end;
  1962. constructor tprocvardef.load;
  1963. begin
  1964. inherited load;
  1965. deftype:=procvardef;
  1966. end;
  1967. procedure tprocvardef.write;
  1968. begin
  1969. { here we cannot get a real good value so just give something }
  1970. { plausible (PM) }
  1971. {$ifdef StoreFPULevel}
  1972. if is_fpu(retdef) then
  1973. fpu_used:=2
  1974. else
  1975. fpu_used:=0;
  1976. {$endif StoreFPULevel}
  1977. inherited write;
  1978. current_ppu^.writeentry(ibprocvardef);
  1979. end;
  1980. function tprocvardef.size : longint;
  1981. begin
  1982. if (options and pomethodpointer)=0 then
  1983. size:=sizeof(pointer)
  1984. else
  1985. size:=2*sizeof(pointer);
  1986. end;
  1987. {$ifdef GDB}
  1988. function tprocvardef.stabstring : pchar;
  1989. var
  1990. nss : pchar;
  1991. i : word;
  1992. vartyp : char;
  1993. pst : pchar;
  1994. param : pdefcoll;
  1995. begin
  1996. i := 0;
  1997. param := para1;
  1998. while assigned(param) do
  1999. begin
  2000. inc(i);
  2001. param := param^.next;
  2002. end;
  2003. getmem(nss,1024);
  2004. strpcopy(nss,'f'+retdef^.numberstring+','+tostr(i)+';');
  2005. param := para1;
  2006. i := 0;
  2007. while assigned(param) do
  2008. begin
  2009. inc(i);
  2010. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2011. {Here we have lost the parameter names !!}
  2012. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2013. strcat(nss,pst);
  2014. strdispose(pst);
  2015. param := param^.next;
  2016. end;
  2017. {strpcopy(strend(nss),';');}
  2018. stabstring := strnew(nss);
  2019. freemem(nss,1024);
  2020. end;
  2021. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2022. begin
  2023. if ( not assigned(sym) or sym^.isusedinstab or use_dbx)
  2024. and not is_def_stab_written then
  2025. inherited concatstabto(asmlist);
  2026. is_def_stab_written:=true;
  2027. end;
  2028. {$endif GDB}
  2029. procedure tprocvardef.write_rtti_data;
  2030. begin
  2031. {!!!!!!!}
  2032. end;
  2033. procedure tprocvardef.write_child_rtti_data;
  2034. begin
  2035. {!!!!!!!!}
  2036. end;
  2037. function tprocvardef.is_publishable : boolean;
  2038. begin
  2039. is_publishable:=(options and pomethodpointer)<>0;
  2040. end;
  2041. {***************************************************************************
  2042. TOBJECTDEF
  2043. ***************************************************************************}
  2044. {$ifdef GDB}
  2045. const
  2046. vtabletype : word = 0;
  2047. vtableassigned : boolean = false;
  2048. {$endif GDB}
  2049. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2050. begin
  2051. tdef.init;
  2052. deftype:=objectdef;
  2053. childof:=c;
  2054. options:=0;
  2055. { some options are inherited !! }
  2056. if assigned(c) then
  2057. options:= c^.options and
  2058. (oo_hasvirtual or oo_hasprivate or
  2059. oo_hasprotected
  2060. {or oo_can_have_published treated in pdecl }
  2061. );
  2062. { privatesyms:=new(psymtable,init(objectsymtable));
  2063. protectedsyms:=new(psymtable,init(objectsymtable)); }
  2064. publicsyms:=new(psymtable,init(objectsymtable));
  2065. publicsyms^.name := stringdup(n);
  2066. { add the data of the anchestor class }
  2067. if assigned(childof) then
  2068. begin
  2069. publicsyms^.datasize:=
  2070. publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  2071. end;
  2072. name:=stringdup(n);
  2073. savesize := publicsyms^.datasize;
  2074. publicsyms^.defowner:=@self;
  2075. end;
  2076. constructor tobjectdef.load;
  2077. var
  2078. oldread_member : boolean;
  2079. begin
  2080. tdef.load;
  2081. deftype:=objectdef;
  2082. savesize:=readlong;
  2083. name:=stringdup(readstring);
  2084. childof:=pobjectdef(readdefref);
  2085. options:=readlong;
  2086. oldread_member:=read_member;
  2087. read_member:=true;
  2088. object_options:=true;
  2089. publicsyms:=new(psymtable,loadasstruct(objectsymtable));
  2090. object_options:=false;
  2091. read_member:=oldread_member;
  2092. publicsyms^.defowner:=@self;
  2093. publicsyms^.datasize:=savesize;
  2094. publicsyms^.name := stringdup(name^);
  2095. { handles the predefined class tobject }
  2096. { the last TOBJECT which is loaded gets }
  2097. { it ! }
  2098. if (name^='TOBJECT') and not(cs_compilesystem in aktmoduleswitches) and
  2099. isclass and (childof=pointer($ffffffff)) then
  2100. class_tobject:=@self;
  2101. end;
  2102. procedure tobjectdef.check_forwards;
  2103. begin
  2104. publicsyms^.check_forwards;
  2105. if (options and oo_isforward)<>0 then
  2106. begin
  2107. { ok, in future, the forward can be resolved }
  2108. Message1(sym_e_class_forward_not_resolved,name^);
  2109. options:=options and not(oo_isforward);
  2110. end;
  2111. end;
  2112. destructor tobjectdef.done;
  2113. begin
  2114. {!!!!
  2115. if assigned(privatesyms) then
  2116. dispose(privatesyms,done);
  2117. if assigned(protectedsyms) then
  2118. dispose(protectedsyms,done); }
  2119. if assigned(publicsyms) then
  2120. dispose(publicsyms,done);
  2121. if (options and oo_isforward)<>0 then
  2122. Message1(sym_e_class_forward_not_resolved,name^);
  2123. stringdispose(name);
  2124. tdef.done;
  2125. end;
  2126. { true, if self inherits from d (or if they are equal) }
  2127. function tobjectdef.isrelated(d : pobjectdef) : boolean;
  2128. var
  2129. hp : pobjectdef;
  2130. begin
  2131. hp:=@self;
  2132. while assigned(hp) do
  2133. begin
  2134. if hp=d then
  2135. begin
  2136. isrelated:=true;
  2137. exit;
  2138. end;
  2139. hp:=hp^.childof;
  2140. end;
  2141. isrelated:=false;
  2142. end;
  2143. function tobjectdef.size : longint;
  2144. begin
  2145. if (options and oois_class)<>0 then
  2146. size:=sizeof(pointer)
  2147. else
  2148. size:=publicsyms^.datasize;
  2149. end;
  2150. procedure tobjectdef.deref;
  2151. var
  2152. hp : pdef;
  2153. oldrecsyms : psymtable;
  2154. begin
  2155. resolvedef(pdef(childof));
  2156. oldrecsyms:=aktrecordsymtable;
  2157. aktrecordsymtable:=publicsyms;
  2158. { nun die Definitionen dereferenzieren }
  2159. hp:=publicsyms^.rootdef;
  2160. while assigned(hp) do
  2161. begin
  2162. hp^.deref;
  2163. { set owner }
  2164. hp^.owner:=publicsyms;
  2165. hp:=hp^.next;
  2166. end;
  2167. {$ifdef tp}
  2168. publicsyms^.foreach(derefsym);
  2169. {$else}
  2170. publicsyms^.foreach(@derefsym);
  2171. {$endif}
  2172. aktrecordsymtable:=oldrecsyms;
  2173. end;
  2174. function tobjectdef.vmt_mangledname : string;
  2175. {DM: I get a nil pointer on the owner name. I don't know if this
  2176. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2177. checks.}
  2178. var
  2179. s1,s2:string;
  2180. begin
  2181. if owner^.name=nil then
  2182. s1:=''
  2183. else
  2184. s1:=owner^.name^;
  2185. if name=nil then
  2186. s2:=''
  2187. else
  2188. s2:=name^;
  2189. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2190. end;
  2191. function tobjectdef.rtti_name : string;
  2192. var
  2193. s1,s2:string;
  2194. begin
  2195. if owner^.name=nil then
  2196. s1:=''
  2197. else
  2198. s1:=owner^.name^;
  2199. if name=nil then
  2200. s2:=''
  2201. else
  2202. s2:=name^;
  2203. rtti_name:='RTTI_'+s1+'$_'+s2;
  2204. end;
  2205. function tobjectdef.isclass : boolean;
  2206. begin
  2207. isclass:=(options and oois_class)<>0;
  2208. end;
  2209. procedure tobjectdef.write;
  2210. var
  2211. oldread_member : boolean;
  2212. begin
  2213. tdef.write;
  2214. writelong(size);
  2215. writestring(name^);
  2216. writedefref(childof);
  2217. writelong(options);
  2218. current_ppu^.writeentry(ibobjectdef);
  2219. oldread_member:=read_member;
  2220. read_member:=true;
  2221. object_options:=true;
  2222. publicsyms^.writeasstruct;
  2223. object_options:=false;
  2224. read_member:=oldread_member;
  2225. end;
  2226. {$ifdef GDB}
  2227. procedure addprocname(p :psym);
  2228. var virtualind,argnames : string;
  2229. news, newrec : pchar;
  2230. pd,ipd : pprocdef;
  2231. lindex : longint;
  2232. para : pdefcoll;
  2233. arglength : byte;
  2234. sp : char;
  2235. begin
  2236. If p^.typ = procsym then
  2237. begin
  2238. pd := pprocsym(p)^.definition;
  2239. { this will be used for full implementation of object stabs
  2240. not yet done }
  2241. ipd := pd;
  2242. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2243. if (pd^.options and povirtualmethod) <> 0 then
  2244. begin
  2245. lindex := pd^.extnumber;
  2246. {doesnt seem to be necessary
  2247. lindex := lindex or $80000000;}
  2248. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2249. end else virtualind := '.';
  2250. { arguments are not listed here }
  2251. {we don't need another definition}
  2252. para := pd^.para1;
  2253. argnames := '';
  2254. while assigned(para) do
  2255. begin
  2256. if para^.data^.deftype = formaldef then
  2257. begin
  2258. if para^.paratyp=vs_var then
  2259. argnames := argnames+'3var'
  2260. else if para^.paratyp=vs_const then
  2261. argnames:=argnames+'5const';
  2262. end
  2263. else
  2264. begin
  2265. { if the arg definition is like (v: ^byte;..
  2266. there is no sym attached to data !!! }
  2267. if assigned(para^.data^.sym) then
  2268. begin
  2269. arglength := length(para^.data^.sym^.name);
  2270. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2271. end
  2272. else
  2273. begin
  2274. argnames:=argnames+'11unnamedtype';
  2275. end;
  2276. end;
  2277. para := para^.next;
  2278. end;
  2279. ipd^.is_def_stab_written := true;
  2280. { here 2A must be changed for private and protected }
  2281. { 0 is private 1 protected and 2 public }
  2282. if (p^.properties and sp_private)<>0 then sp:='0'
  2283. else if (p^.properties and sp_protected)<>0 then sp:='1'
  2284. else sp:='2';
  2285. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2286. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2287. +virtualind+';');
  2288. { get spare place for a string at the end }
  2289. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2290. begin
  2291. getmem(news,stabrecsize+memsizeinc);
  2292. strcopy(news,stabrecstring);
  2293. freemem(stabrecstring,stabrecsize);
  2294. stabrecsize:=stabrecsize+memsizeinc;
  2295. stabrecstring:=news;
  2296. end;
  2297. strcat(StabRecstring,newrec);
  2298. {freemem(newrec,memsizeinc); }
  2299. strdispose(newrec);
  2300. {This should be used for case !!}
  2301. RecOffset := RecOffset + pd^.size;
  2302. end;
  2303. end;
  2304. function tobjectdef.stabstring : pchar;
  2305. var anc : pobjectdef;
  2306. oldrec : pchar;
  2307. oldrecsize : longint;
  2308. str_end : string;
  2309. begin
  2310. oldrec := stabrecstring;
  2311. oldrecsize:=stabrecsize;
  2312. stabrecsize:=memsizeinc;
  2313. GetMem(stabrecstring,stabrecsize);
  2314. strpcopy(stabRecString,'s'+tostr(size));
  2315. if assigned(childof) then
  2316. {only one ancestor not virtual, public, at base offset 0 }
  2317. { !1 , 0 2 0 , }
  2318. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2319. {virtual table to implement yet}
  2320. RecOffset := 0;
  2321. {$ifdef tp}
  2322. publicsyms^.foreach(addname);
  2323. {$else}
  2324. publicsyms^.foreach(@addname);
  2325. {$endif tp}
  2326. if (options and oo_hasvirtual) <> 0 then
  2327. if not assigned(childof) or ((childof^.options and oo_hasvirtual) = 0) then
  2328. begin
  2329. str_end:='$vf'+numberstring+':'+typeglobalnumber('vtblarray')+',0;';
  2330. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')+',0;');
  2331. end;
  2332. {$ifdef tp}
  2333. publicsyms^.foreach(addprocname);
  2334. {$else}
  2335. publicsyms^.foreach(@addprocname);
  2336. {$endif tp }
  2337. if (options and oo_hasvirtual) <> 0 then
  2338. begin
  2339. anc := @self;
  2340. while assigned(anc^.childof) and ((anc^.childof^.options and oo_hasvirtual) <> 0) do
  2341. anc := anc^.childof;
  2342. str_end:=';~%'+anc^.numberstring+';';
  2343. end
  2344. else
  2345. str_end:=';';
  2346. strpcopy(strend(stabrecstring),str_end);
  2347. stabstring := strnew(StabRecString);
  2348. freemem(stabrecstring,stabrecsize);
  2349. stabrecstring := oldrec;
  2350. stabrecsize:=oldrecsize;
  2351. end;
  2352. {$endif GDB}
  2353. procedure tobjectdef.write_child_init_data;
  2354. begin
  2355. end;
  2356. procedure tobjectdef.write_init_data;
  2357. begin
  2358. if isclass then
  2359. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2360. else
  2361. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2362. { generate the name }
  2363. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2364. rttilist^.concat(new(pai_string,init(name^)));
  2365. rttilist^.concat(new(pai_const,init_32bit(size)));
  2366. count:=0;
  2367. publicsyms^.foreach(count_inittable_fields);
  2368. rttilist^.concat(new(pai_const,init_32bit(count)));
  2369. publicsyms^.foreach(write_field_inittable);
  2370. end;
  2371. function tobjectdef.needs_inittable : boolean;
  2372. var
  2373. oldb : boolean;
  2374. begin
  2375. { there are recursive calls to needs_inittable possible, }
  2376. { so we have to change to old value how else should }
  2377. { we do that ? check_rec_rtti can't be a nested }
  2378. { procedure of needs_rtti ! }
  2379. oldb:=binittable;
  2380. binittable:=false;
  2381. publicsyms^.foreach(check_rec_inittable);
  2382. needs_inittable:=binittable;
  2383. binittable:=oldb;
  2384. end;
  2385. procedure count_published_properties(sym : psym);{$ifndef fpc}far;{$endif}
  2386. begin
  2387. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2388. inc(count);
  2389. end;
  2390. procedure write_property_info(sym : psym);{$ifndef fpc}far;{$endif}
  2391. var
  2392. proctypesinfo : byte;
  2393. procedure writeproc(sym : psym;def : pdef;shiftvalue : byte);
  2394. var
  2395. typvalue : byte;
  2396. begin
  2397. if not(assigned(sym)) then
  2398. begin
  2399. rttilist^.concat(new(pai_const,init_32bit(1)));
  2400. typvalue:=3;
  2401. end
  2402. else if sym^.typ=varsym then
  2403. begin
  2404. rttilist^.concat(new(pai_const,init_32bit(
  2405. pvarsym(sym)^.address)));
  2406. typvalue:=0;
  2407. end
  2408. else
  2409. begin
  2410. if (pprocdef(def)^.options and povirtualmethod)=0 then
  2411. begin
  2412. rttilist^.concat(new(pai_const,init_symbol(strpnew(pprocdef(def)^.mangledname))));
  2413. typvalue:=1;
  2414. end
  2415. else
  2416. begin
  2417. { virtual method, write vmt offset }
  2418. rttilist^.concat(new(pai_const,init_32bit(pprocdef(def)^.extnumber*4+12)));
  2419. typvalue:=2;
  2420. end;
  2421. end;
  2422. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  2423. end;
  2424. begin
  2425. proctypesinfo:=0;
  2426. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2427. begin
  2428. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(ppropertysym(sym)^.proptype^.get_rtti_label)))));
  2429. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  2430. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  2431. { isn't it stored ? }
  2432. if (ppropertysym(sym)^.options and ppo_stored)=0 then
  2433. begin
  2434. rttilist^.concat(new(pai_const,init_32bit(1)));
  2435. proctypesinfo:=proctypesinfo or (3 shl 4);
  2436. end
  2437. else
  2438. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  2439. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  2440. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  2441. rttilist^.concat(new(pai_const,init_16bit(count)));
  2442. inc(count);
  2443. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  2444. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  2445. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  2446. end;
  2447. end;
  2448. procedure generate_published_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  2449. begin
  2450. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2451. ppropertysym(sym)^.proptype^.get_rtti_label;
  2452. end;
  2453. procedure tobjectdef.write_child_rtti_data;
  2454. begin
  2455. publicsyms^.foreach(generate_published_child_rtti);
  2456. end;
  2457. procedure tobjectdef.generate_rtti;
  2458. begin
  2459. has_rtti:=true;
  2460. getlabel(rtti_label);
  2461. write_child_rtti_data;
  2462. rttilist^.concat(new(pai_symbol,init_global(rtti_name)));
  2463. rttilist^.concat(new(pai_label,init(rtti_label)));
  2464. write_rtti_data;
  2465. end;
  2466. function tobjectdef.next_free_name_index : longint;
  2467. var
  2468. i : longint;
  2469. begin
  2470. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2471. i:=childof^.next_free_name_index
  2472. else
  2473. i:=0;
  2474. count:=0;
  2475. publicsyms^.foreach(count_published_properties);
  2476. next_free_name_index:=i+count;
  2477. end;
  2478. procedure tobjectdef.write_rtti_data;
  2479. begin
  2480. if isclass then
  2481. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2482. else
  2483. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2484. { generate the name }
  2485. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2486. rttilist^.concat(new(pai_string,init(name^)));
  2487. { write class type }
  2488. rttilist^.concat(new(pai_const,init_symbol(strpnew(vmt_mangledname))));
  2489. { write owner typeinfo }
  2490. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2491. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(childof^.get_rtti_label)))))
  2492. else
  2493. rttilist^.concat(new(pai_const,init_32bit(0)));
  2494. { write published properties count }
  2495. count:=0;
  2496. publicsyms^.foreach(count_published_properties);
  2497. rttilist^.concat(new(pai_const,init_16bit(count)));
  2498. { write unit name }
  2499. if assigned(owner^.name) then
  2500. begin
  2501. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  2502. rttilist^.concat(new(pai_string,init(owner^.name^)));
  2503. end
  2504. else
  2505. rttilist^.concat(new(pai_const,init_8bit(0)));
  2506. { count is used to write nameindex }
  2507. { but we need an offset of the owner }
  2508. { to give each property an own slot }
  2509. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2510. count:=childof^.next_free_name_index
  2511. else
  2512. count:=0;
  2513. publicsyms^.foreach(write_property_info);
  2514. end;
  2515. function tobjectdef.is_publishable : boolean;
  2516. begin
  2517. is_publishable:=isclass;
  2518. end;
  2519. {****************************************************************************
  2520. TERRORDEF
  2521. ****************************************************************************}
  2522. constructor terrordef.init;
  2523. begin
  2524. inherited init;
  2525. deftype:=errordef;
  2526. end;
  2527. {$ifdef GDB}
  2528. function terrordef.stabstring : pchar;
  2529. begin
  2530. stabstring:=strpnew('error'+numberstring);
  2531. end;
  2532. {$endif GDB}
  2533. {
  2534. $Log$
  2535. Revision 1.42 1998-09-17 13:41:20 pierre
  2536. sizeof(TPOINT) problem
  2537. Revision 1.40.2.2 1998/09/17 08:42:33 pierre
  2538. TPOINT sizeof fix
  2539. Revision 1.41 1998/09/15 17:39:30 jonas
  2540. + bugfix from bugfix branch
  2541. Revision 1.40.2.1 1998/09/15 17:35:32 jonas
  2542. * chenged string_typ in tstringdef.wideload from ansistring to widestring
  2543. Revision 1.40 1998/09/09 15:34:00 peter
  2544. * removed warnings
  2545. Revision 1.39 1998/09/08 10:23:44 pierre
  2546. * name field of filedef corrected
  2547. Revision 1.38 1998/09/07 23:10:23 florian
  2548. * a lot of stuff fixed regarding rtti and publishing of properties,
  2549. basics should now work
  2550. Revision 1.37 1998/09/07 19:33:24 florian
  2551. + some stuff for property rtti added:
  2552. - NameIndex of the TPropInfo record is now written correctly
  2553. - the DEFAULT/NODEFAULT keyword is supported now
  2554. - the default value and the storedsym/def are now written to
  2555. the PPU fiel
  2556. Revision 1.36 1998/09/07 17:37:01 florian
  2557. * first fixes for published properties
  2558. Revision 1.35 1998/09/06 22:42:02 florian
  2559. + rtti genreation for properties added
  2560. Revision 1.34 1998/09/04 18:15:02 peter
  2561. * filedef updated
  2562. Revision 1.33 1998/09/03 17:08:49 pierre
  2563. * better lines for stabs
  2564. (no scroll back to if before else part
  2565. no return to case line at jump outside case)
  2566. + source lines also if not in order
  2567. Revision 1.32 1998/09/03 16:03:20 florian
  2568. + rtti generation
  2569. * init table generation changed
  2570. Revision 1.31 1998/09/02 15:14:28 peter
  2571. * enum packing changed from len to max
  2572. Revision 1.30 1998/09/01 17:37:29 peter
  2573. * removed debug writeln :(
  2574. Revision 1.29 1998/09/01 12:53:25 peter
  2575. + aktpackenum
  2576. Revision 1.28 1998/09/01 07:54:22 pierre
  2577. * UseBrowser a little updated (might still be buggy !!)
  2578. * bug in psub.pas in function specifier removed
  2579. * stdcall allowed in interface and in implementation
  2580. (FPC will not yet complain if it is missing in either part
  2581. because stdcall is only a dummy !!)
  2582. Revision 1.27 1998/08/28 12:51:43 florian
  2583. + ansistring to pchar type cast fixed
  2584. Revision 1.26 1998/08/25 12:42:44 pierre
  2585. * CDECL changed to CVAR for variables
  2586. specifications are read in structures also
  2587. + started adding GPC compatibility mode ( option -Sp)
  2588. * names changed to lowercase
  2589. Revision 1.25 1998/08/23 21:04:38 florian
  2590. + rtti generation for classes added
  2591. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  2592. Revision 1.24 1998/08/20 12:53:26 peter
  2593. * object_options are always written for object syms
  2594. Revision 1.23 1998/08/19 00:42:42 peter
  2595. + subrange types for enums
  2596. + checking for bounds type with ranges
  2597. Revision 1.22 1998/08/17 10:10:10 peter
  2598. - removed OLDPPU
  2599. Revision 1.21 1998/08/10 14:50:28 peter
  2600. + localswitches, moduleswitches, globalswitches splitting
  2601. Revision 1.20 1998/07/18 22:54:30 florian
  2602. * some ansi/wide/longstring support fixed:
  2603. o parameter passing
  2604. o returning as result from functions
  2605. Revision 1.19 1998/07/14 14:47:05 peter
  2606. * released NEWINPUT
  2607. Revision 1.18 1998/07/10 10:51:04 peter
  2608. * m68k updates
  2609. Revision 1.16 1998/07/07 11:20:13 peter
  2610. + NEWINPUT for a better inputfile and scanner object
  2611. Revision 1.15 1998/06/24 14:48:37 peter
  2612. * ifdef newppu -> ifndef oldppu
  2613. Revision 1.14 1998/06/16 08:56:31 peter
  2614. + targetcpu
  2615. * cleaner pmodules for newppu
  2616. Revision 1.13 1998/06/15 15:38:09 pierre
  2617. * small bug in systems.pas corrected
  2618. + operators in different units better hanlded
  2619. Revision 1.12 1998/06/15 14:30:12 daniel
  2620. * Reverted my changes.
  2621. Revision 1.10 1998/06/13 00:10:16 peter
  2622. * working browser and newppu
  2623. * some small fixes against crashes which occured in bp7 (but not in
  2624. fpc?!)
  2625. Revision 1.9 1998/06/12 14:10:37 michael
  2626. * Fixed wrong code for ansistring
  2627. Revision 1.8 1998/06/11 10:11:58 peter
  2628. * -gb works again
  2629. Revision 1.7 1998/06/07 15:30:25 florian
  2630. + first working rtti
  2631. + data init/final. for local variables
  2632. Revision 1.6 1998/06/05 14:37:37 pierre
  2633. * fixes for inline for operators
  2634. * inline procedure more correctly restricted
  2635. Revision 1.5 1998/06/04 23:52:01 peter
  2636. * m68k compiles
  2637. + .def file creation moved to gendef.pas so it could also be used
  2638. for win32
  2639. Revision 1.4 1998/06/04 09:55:45 pierre
  2640. * demangled name of procsym reworked to become independant of the mangling
  2641. scheme
  2642. Revision 1.3 1998/06/03 22:49:03 peter
  2643. + wordbool,longbool
  2644. * rename bis,von -> high,low
  2645. * moved some systemunit loading/creating to psystem.pas
  2646. Revision 1.2 1998/05/31 14:13:37 peter
  2647. * fixed call bugs with assembler readers
  2648. + OPR_SYMBOL to hold a symbol in the asm parser
  2649. * fixed staticsymtable vars which were acessed through %ebp instead of
  2650. name
  2651. Revision 1.1 1998/05/27 19:45:09 peter
  2652. * symtable.pas splitted into includefiles
  2653. * symtable adapted for $ifndef OLDPPU
  2654. }