symdef.inc 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. Symbol table implementation for the definitions
  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. { and the rtl/[i386,template/rttip.inc files }
  25. tkUnknown = 0;
  26. tkInteger = 1;
  27. tkChar = 2;
  28. tkEnumeration = 3;
  29. tkFloat = 4;
  30. tkSet = 5;
  31. tkMethod = 6;
  32. tkSString = 7;
  33. tkString = tkSString;
  34. tkLString = 8;
  35. tkAString = 9;
  36. tkWString = 10;
  37. tkVariant = 11;
  38. tkArray = 12;
  39. tkRecord = 13;
  40. tkInterface = 14;
  41. tkClass = 15;
  42. tkObject = 16;
  43. tkWChar = 17;
  44. tkBool = 18;
  45. otSByte = 0;
  46. otUByte = 1;
  47. otSWord = 2;
  48. otUWord = 3;
  49. otSLong = 4;
  50. otULong = 5;
  51. ftSingle = 0;
  52. ftDouble = 1;
  53. ftExtended = 2;
  54. ftComp = 3;
  55. ftCurr = 4;
  56. ftFixed16 = 5;
  57. ftFixed32 = 6;
  58. constructor tdef.init;
  59. begin
  60. {$ifdef STORENUMBER}
  61. inherited init;
  62. {$else}
  63. indexnb := 0;
  64. next := nil;
  65. {$endif}
  66. deftype:=abstractdef;
  67. owner := nil;
  68. sym := nil;
  69. savesize := 0;
  70. if registerdef then
  71. symtablestack^.registerdef(@self);
  72. has_rtti:=false;
  73. has_inittable:=false;
  74. {$ifdef GDB}
  75. is_def_stab_written := false;
  76. globalnb := 0;
  77. {$endif GDB}
  78. if assigned(lastglobaldef) then
  79. begin
  80. lastglobaldef^.nextglobal := @self;
  81. previousglobal:=lastglobaldef;
  82. end
  83. else
  84. begin
  85. firstglobaldef := @self;
  86. previousglobal := nil;
  87. end;
  88. lastglobaldef := @self;
  89. nextglobal := nil;
  90. end;
  91. constructor tdef.load;
  92. begin
  93. deftype:=abstractdef;
  94. next := nil;
  95. owner := nil;
  96. has_rtti:=false;
  97. has_inittable:=false;
  98. {$ifdef GDB}
  99. is_def_stab_written := false;
  100. globalnb := 0;
  101. {$endif GDB}
  102. if assigned(lastglobaldef) then
  103. begin
  104. lastglobaldef^.nextglobal := @self;
  105. previousglobal:=lastglobaldef;
  106. end
  107. else
  108. begin
  109. firstglobaldef := @self;
  110. previousglobal:=nil;
  111. end;
  112. lastglobaldef := @self;
  113. nextglobal := nil;
  114. { load }
  115. {$ifdef STORENUMBER}
  116. indexnr:=readlong;
  117. sym:=ptypesym(readsymref);
  118. {$else}
  119. indexnb := 0;
  120. sym:=nil;
  121. {$endif}
  122. end;
  123. destructor tdef.done;
  124. begin
  125. { first element ? }
  126. if not(assigned(previousglobal)) then
  127. begin
  128. firstglobaldef := nextglobal;
  129. if assigned(firstglobaldef) then
  130. firstglobaldef^.previousglobal:=nil;
  131. end
  132. else
  133. begin
  134. { remove reference in the element before }
  135. previousglobal^.nextglobal:=nextglobal;
  136. end;
  137. { last element ? }
  138. if not(assigned(nextglobal)) then
  139. begin
  140. lastglobaldef := previousglobal;
  141. if assigned(lastglobaldef) then
  142. lastglobaldef^.nextglobal:=nil;
  143. end
  144. else
  145. nextglobal^.previousglobal:=previousglobal;
  146. previousglobal:=nil;
  147. nextglobal:=nil;
  148. end;
  149. { used for enumdef because the symbols are
  150. inserted in the owner symtable }
  151. procedure tdef.correct_owner_symtable;
  152. var
  153. st : psymtable;
  154. begin
  155. if assigned(owner) and
  156. (owner^.symtabletype in [recordsymtable,objectsymtable]) then
  157. begin
  158. {$ifdef STORENUMBER}
  159. owner^.defindex^.delete(@self);
  160. {$else}
  161. { no other definition
  162. has been inserted !! (PM) }
  163. owner^.rootdef:=next;
  164. {$endif}
  165. st:=owner;
  166. while (st^.symtabletype in [recordsymtable,objectsymtable]) do
  167. st:=st^.next;
  168. st^.registerdef(@self);
  169. end;
  170. end;
  171. function tdef.typename:string;
  172. begin
  173. if assigned(sym) then
  174. typename:=sym^.name
  175. else
  176. typename:='unknown';
  177. end;
  178. function tdef.is_in_current : boolean;
  179. var
  180. p : psymtable;
  181. begin
  182. p:=owner;
  183. is_in_current:=false;
  184. while assigned(p) do
  185. begin
  186. if (p=current_module^.globalsymtable) or (p=current_module^.localsymtable)
  187. or (p^.symtabletype in [globalsymtable,staticsymtable]) then
  188. begin
  189. is_in_current:=true;
  190. exit;
  191. end
  192. else if p^.symtabletype=objectsymtable then
  193. begin
  194. if assigned(p^.defowner) then
  195. p:=pobjectdef(p^.defowner)^.owner
  196. else
  197. exit;
  198. end
  199. else
  200. exit;
  201. end;
  202. end;
  203. procedure tdef.write;
  204. begin
  205. {$ifdef STORENUMBER}
  206. writelong(indexnr);
  207. writesymref(sym);
  208. {$endif}
  209. {$ifdef GDB}
  210. if globalnb = 0 then
  211. begin
  212. if assigned(owner) then
  213. globalnb := owner^.getnewtypecount
  214. else
  215. begin
  216. globalnb := PGlobalTypeCount^;
  217. Inc(PGlobalTypeCount^);
  218. end;
  219. end;
  220. {$endif GDB}
  221. end;
  222. function tdef.size : longint;
  223. begin
  224. size:=savesize;
  225. end;
  226. {$ifdef GDB}
  227. procedure tdef.set_globalnb;
  228. begin
  229. globalnb :=PGlobalTypeCount^;
  230. inc(PglobalTypeCount^);
  231. end;
  232. function tdef.stabstring : pchar;
  233. begin
  234. stabstring := strpnew('t'+numberstring+';');
  235. end;
  236. function tdef.numberstring : string;
  237. var table : psymtable;
  238. begin
  239. {formal def have no type !}
  240. if deftype = formaldef then
  241. begin
  242. numberstring := voiddef^.numberstring;
  243. exit;
  244. end;
  245. if (not assigned(sym)) or (not sym^.isusedinstab) then
  246. begin
  247. {set even if debuglist is not defined}
  248. if assigned(sym) then
  249. sym^.isusedinstab := true;
  250. if assigned(debuglist) and not is_def_stab_written then
  251. concatstabto(debuglist);
  252. end;
  253. if not (cs_gdb_dbx in aktglobalswitches) then
  254. begin
  255. if globalnb = 0 then
  256. set_globalnb;
  257. numberstring := tostr(globalnb);
  258. end
  259. else
  260. begin
  261. if globalnb = 0 then
  262. begin
  263. if assigned(owner) then
  264. globalnb := owner^.getnewtypecount
  265. else
  266. begin
  267. globalnb := PGlobalTypeCount^;
  268. Inc(PGlobalTypeCount^);
  269. end;
  270. end;
  271. if assigned(sym) then
  272. begin
  273. table := sym^.owner;
  274. if table^.unitid > 0 then
  275. numberstring := '('+tostr(table^.unitid)+','
  276. +tostr(sym^.definition^.globalnb)+')'
  277. else
  278. numberstring := tostr(globalnb);
  279. exit;
  280. end;
  281. numberstring := tostr(globalnb);
  282. end;
  283. end;
  284. function tdef.allstabstring : pchar;
  285. var stabchar : string[2];
  286. ss,st : pchar;
  287. name : string;
  288. sym_line_no : longint;
  289. begin
  290. ss := stabstring;
  291. getmem(st,strlen(ss)+512);
  292. stabchar := 't';
  293. if deftype in tagtypes then
  294. stabchar := 'Tt';
  295. if assigned(sym) then
  296. begin
  297. name := sym^.name;
  298. sym_line_no:=sym^.fileinfo.line;
  299. end
  300. else
  301. begin
  302. name := ' ';
  303. sym_line_no:=0;
  304. end;
  305. strpcopy(st,'"'+name+':'+stabchar+numberstring+'=');
  306. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  307. allstabstring := strnew(st);
  308. freemem(st,strlen(ss)+512);
  309. strdispose(ss);
  310. end;
  311. procedure tdef.concatstabto(asmlist : paasmoutput);
  312. var stab_str : pchar;
  313. begin
  314. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  315. and not is_def_stab_written then
  316. begin
  317. If cs_gdb_dbx in aktglobalswitches then
  318. begin
  319. { otherwise you get two of each def }
  320. If assigned(sym) then
  321. begin
  322. if sym^.typ=typesym then
  323. sym^.isusedinstab:=true;
  324. if (sym^.owner = nil) or
  325. ((sym^.owner^.symtabletype = unitsymtable) and
  326. punitsymtable(sym^.owner)^.dbx_count_ok) then
  327. begin
  328. {with DBX we get the definition from the other objects }
  329. is_def_stab_written := true;
  330. exit;
  331. end;
  332. end;
  333. end;
  334. { to avoid infinite loops }
  335. is_def_stab_written := true;
  336. stab_str := allstabstring;
  337. if asmlist = debuglist then do_count_dbx := true;
  338. { count_dbx(stab_str); moved to GDB.PAS}
  339. asmlist^.concat(new(pai_stabs,init(stab_str)));
  340. end;
  341. end;
  342. {$endif GDB}
  343. procedure tdef.deref;
  344. begin
  345. end;
  346. procedure tdef.symderef;
  347. begin
  348. resolvesym(psym(sym));
  349. end;
  350. { rtti generation }
  351. procedure tdef.generate_rtti;
  352. begin
  353. has_rtti:=true;
  354. getlabel(rtti_label);
  355. write_child_rtti_data;
  356. rttilist^.concat(new(pai_label,init(rtti_label)));
  357. write_rtti_data;
  358. end;
  359. function tdef.get_rtti_label : string;
  360. begin
  361. if not(has_rtti) then
  362. generate_rtti;
  363. get_rtti_label:=lab2str(rtti_label);
  364. end;
  365. { init table handling }
  366. function tdef.needs_inittable : boolean;
  367. begin
  368. needs_inittable:=false;
  369. end;
  370. procedure tdef.generate_inittable;
  371. begin
  372. has_inittable:=true;
  373. getlabel(inittable_label);
  374. write_child_init_data;
  375. rttilist^.concat(new(pai_label,init(inittable_label)));
  376. write_init_data;
  377. end;
  378. procedure tdef.write_init_data;
  379. begin
  380. write_rtti_data;
  381. end;
  382. procedure tdef.write_child_init_data;
  383. begin
  384. write_child_rtti_data;
  385. end;
  386. function tdef.get_inittable_label : plabel;
  387. begin
  388. if not(has_inittable) then
  389. generate_inittable;
  390. get_inittable_label:=inittable_label;
  391. end;
  392. procedure tdef.write_rtti_name;
  393. var
  394. str : string;
  395. begin
  396. { name }
  397. if assigned(sym) then
  398. begin
  399. str:=sym^.name;
  400. rttilist^.concat(new(pai_string,init(chr(length(str))+str)));
  401. end
  402. else
  403. rttilist^.concat(new(pai_string,init(#0)))
  404. end;
  405. { returns true, if the definition can be published }
  406. function tdef.is_publishable : boolean;
  407. begin
  408. is_publishable:=false;
  409. end;
  410. procedure tdef.write_rtti_data;
  411. begin
  412. end;
  413. procedure tdef.write_child_rtti_data;
  414. begin
  415. end;
  416. {****************************************************************************
  417. TSTRINGDEF
  418. ****************************************************************************}
  419. constructor tstringdef.shortinit(l : byte);
  420. begin
  421. tdef.init;
  422. string_typ:=st_shortstring;
  423. deftype:=stringdef;
  424. len:=l;
  425. savesize:=len+1;
  426. end;
  427. constructor tstringdef.shortload;
  428. begin
  429. tdef.load;
  430. string_typ:=st_shortstring;
  431. deftype:=stringdef;
  432. len:=readbyte;
  433. savesize:=len+1;
  434. end;
  435. constructor tstringdef.longinit(l : longint);
  436. begin
  437. tdef.init;
  438. string_typ:=st_longstring;
  439. deftype:=stringdef;
  440. len:=l;
  441. savesize:=target_os.size_of_pointer;
  442. end;
  443. constructor tstringdef.longload;
  444. begin
  445. tdef.load;
  446. deftype:=stringdef;
  447. string_typ:=st_longstring;
  448. len:=readlong;
  449. savesize:=target_os.size_of_pointer;
  450. end;
  451. constructor tstringdef.ansiinit(l : longint);
  452. begin
  453. tdef.init;
  454. string_typ:=st_ansistring;
  455. deftype:=stringdef;
  456. len:=l;
  457. savesize:=target_os.size_of_pointer;
  458. end;
  459. constructor tstringdef.ansiload;
  460. begin
  461. tdef.load;
  462. deftype:=stringdef;
  463. string_typ:=st_ansistring;
  464. len:=readlong;
  465. savesize:=target_os.size_of_pointer;
  466. end;
  467. constructor tstringdef.wideinit(l : longint);
  468. begin
  469. tdef.init;
  470. string_typ:=st_widestring;
  471. deftype:=stringdef;
  472. len:=l;
  473. savesize:=target_os.size_of_pointer;
  474. end;
  475. constructor tstringdef.wideload;
  476. begin
  477. tdef.load;
  478. deftype:=stringdef;
  479. string_typ:=st_widestring;
  480. len:=readlong;
  481. savesize:=target_os.size_of_pointer;
  482. end;
  483. function tstringdef.stringtypname:string;
  484. const
  485. typname:array[tstringtype] of string[8]=(
  486. 'SHORTSTR','LONGSTR','ANSISTR','WIDESTR'
  487. );
  488. begin
  489. stringtypname:=typname[string_typ];
  490. end;
  491. function tstringdef.size : longint;
  492. begin
  493. size:=savesize;
  494. end;
  495. procedure tstringdef.write;
  496. begin
  497. tdef.write;
  498. if string_typ=st_shortstring then
  499. writebyte(len)
  500. else
  501. writelong(len);
  502. case string_typ of
  503. st_shortstring : current_ppu^.writeentry(ibstringdef);
  504. st_longstring : current_ppu^.writeentry(iblongstringdef);
  505. st_ansistring : current_ppu^.writeentry(ibansistringdef);
  506. st_widestring : current_ppu^.writeentry(ibwidestringdef);
  507. end;
  508. end;
  509. {$ifdef GDB}
  510. function tstringdef.stabstring : pchar;
  511. var
  512. bytest,charst,longst : string;
  513. begin
  514. case string_typ of
  515. st_shortstring:
  516. begin
  517. charst := typeglobalnumber('char');
  518. { this is what I found in stabs.texinfo but
  519. gdb 4.12 for go32 doesn't understand that !! }
  520. {$IfDef GDBknowsstrings}
  521. stabstring := strpnew('n'+charst+';'+tostr(len));
  522. {$else}
  523. bytest := typeglobalnumber('byte');
  524. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  525. +',0,8;st:ar'+bytest
  526. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  527. {$EndIf}
  528. end;
  529. st_longstring:
  530. begin
  531. charst := typeglobalnumber('char');
  532. { this is what I found in stabs.texinfo but
  533. gdb 4.12 for go32 doesn't understand that !! }
  534. {$IfDef GDBknowsstrings}
  535. stabstring := strpnew('n'+charst+';'+tostr(len));
  536. {$else}
  537. bytest := typeglobalnumber('byte');
  538. longst := typeglobalnumber('longint');
  539. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  540. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  541. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  542. {$EndIf}
  543. end;
  544. st_ansistring:
  545. begin
  546. { an ansi string looks like a pchar easy !! }
  547. stabstring:=strpnew('*'+typeglobalnumber('char'));
  548. end;
  549. st_widestring:
  550. begin
  551. { an ansi string looks like a pchar easy !! }
  552. stabstring:=strpnew('*'+typeglobalnumber('char'));
  553. end;
  554. end;
  555. end;
  556. procedure tstringdef.concatstabto(asmlist : paasmoutput);
  557. begin
  558. inherited concatstabto(asmlist);
  559. end;
  560. {$endif GDB}
  561. function tstringdef.needs_inittable : boolean;
  562. begin
  563. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  564. end;
  565. procedure tstringdef.write_rtti_data;
  566. begin
  567. case string_typ of
  568. st_ansistring:
  569. begin
  570. rttilist^.concat(new(pai_const,init_8bit(tkAString)));
  571. end;
  572. st_widestring:
  573. begin
  574. rttilist^.concat(new(pai_const,init_8bit(tkWString)));
  575. end;
  576. st_longstring:
  577. begin
  578. rttilist^.concat(new(pai_const,init_8bit(tkLString)));
  579. end;
  580. st_shortstring:
  581. begin
  582. rttilist^.concat(new(pai_const,init_8bit(tkSString)));
  583. rttilist^.concat(new(pai_const,init_8bit(len)));
  584. end;
  585. end;
  586. end;
  587. function tstringdef.is_publishable : boolean;
  588. begin
  589. is_publishable:=true;
  590. end;
  591. {****************************************************************************
  592. TENUMDEF
  593. ****************************************************************************}
  594. constructor tenumdef.init;
  595. begin
  596. tdef.init;
  597. deftype:=enumdef;
  598. minval:=0;
  599. maxval:=0;
  600. calcsavesize;
  601. has_jumps:=false;
  602. basedef:=nil;
  603. rangenr:=0;
  604. firstenum:=nil;
  605. correct_owner_symtable;
  606. end;
  607. constructor tenumdef.init_subrange(_basedef:penumdef;_min,_max:longint);
  608. begin
  609. tdef.init;
  610. deftype:=enumdef;
  611. minval:=_min;
  612. maxval:=_max;
  613. basedef:=_basedef;
  614. calcsavesize;
  615. has_jumps:=false;
  616. rangenr:=0;
  617. firstenum:=basedef^.firstenum;
  618. while assigned(firstenum) and (penumsym(firstenum)^.value<>minval) do
  619. firstenum:=firstenum^.nextenum;
  620. correct_owner_symtable;
  621. end;
  622. constructor tenumdef.load;
  623. begin
  624. tdef.load;
  625. deftype:=enumdef;
  626. basedef:=penumdef(readdefref);
  627. minval:=readlong;
  628. maxval:=readlong;
  629. savesize:=readlong;
  630. has_jumps:=false;
  631. firstenum:=Nil;
  632. end;
  633. procedure tenumdef.calcsavesize;
  634. begin
  635. if (aktpackenum=4) or (min<0) or (max>65535) then
  636. savesize:=4
  637. else
  638. if (aktpackenum=2) or (min<0) or (max>255) then
  639. savesize:=2
  640. else
  641. savesize:=1;
  642. end;
  643. procedure tenumdef.setmax(_max:longint);
  644. begin
  645. maxval:=_max;
  646. calcsavesize;
  647. end;
  648. procedure tenumdef.setmin(_min:longint);
  649. begin
  650. minval:=_min;
  651. calcsavesize;
  652. end;
  653. function tenumdef.min:longint;
  654. begin
  655. min:=minval;
  656. end;
  657. function tenumdef.max:longint;
  658. begin
  659. max:=maxval;
  660. end;
  661. procedure tenumdef.deref;
  662. begin
  663. resolvedef(pdef(basedef));
  664. end;
  665. destructor tenumdef.done;
  666. begin
  667. inherited done;
  668. end;
  669. procedure tenumdef.write;
  670. begin
  671. tdef.write;
  672. writedefref(basedef);
  673. writelong(min);
  674. writelong(max);
  675. writelong(savesize);
  676. current_ppu^.writeentry(ibenumdef);
  677. end;
  678. function tenumdef.getrangecheckstring : string;
  679. begin
  680. if (cs_smartlink in aktmoduleswitches) then
  681. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  682. else
  683. getrangecheckstring:='R_'+tostr(rangenr);
  684. end;
  685. procedure tenumdef.genrangecheck;
  686. begin
  687. if rangenr=0 then
  688. begin
  689. { generate two constant for bounds }
  690. getlabelnr(rangenr);
  691. if (cs_smartlink in aktmoduleswitches) then
  692. datasegment^.concat(new(pai_symbol,init_global(getrangecheckstring)))
  693. else
  694. datasegment^.concat(new(pai_symbol,init(getrangecheckstring)));
  695. datasegment^.concat(new(pai_const,init_32bit(min)));
  696. datasegment^.concat(new(pai_const,init_32bit(max)));
  697. end;
  698. end;
  699. {$ifdef GDB}
  700. function tenumdef.stabstring : pchar;
  701. var st,st2 : pchar;
  702. p : penumsym;
  703. s : string;
  704. memsize : word;
  705. begin
  706. memsize := memsizeinc;
  707. getmem(st,memsize);
  708. strpcopy(st,'e');
  709. p := firstenum;
  710. while assigned(p) do
  711. begin
  712. s :=p^.name+':'+tostr(p^.value)+',';
  713. { place for the ending ';' also }
  714. if (strlen(st)+length(s)+1<memsize) then
  715. strpcopy(strend(st),s)
  716. else
  717. begin
  718. getmem(st2,memsize+memsizeinc);
  719. strcopy(st2,st);
  720. freemem(st,memsize);
  721. st := st2;
  722. memsize := memsize+memsizeinc;
  723. strpcopy(strend(st),s);
  724. end;
  725. p := p^.nextenum;
  726. end;
  727. strpcopy(strend(st),';');
  728. stabstring := strnew(st);
  729. freemem(st,memsize);
  730. end;
  731. {$endif GDB}
  732. procedure tenumdef.write_child_rtti_data;
  733. begin
  734. if assigned(basedef) then
  735. basedef^.get_rtti_label;
  736. end;
  737. procedure tenumdef.write_rtti_data;
  738. var
  739. hp : penumsym;
  740. begin
  741. rttilist^.concat(new(pai_const,init_8bit(tkEnumeration)));
  742. case savesize of
  743. 1:
  744. rttilist^.concat(new(pai_const,init_8bit(otUByte)));
  745. 2:
  746. rttilist^.concat(new(pai_const,init_8bit(otUWord)));
  747. 4:
  748. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  749. end;
  750. rttilist^.concat(new(pai_const,init_32bit(min)));
  751. rttilist^.concat(new(pai_const,init_32bit(max)));
  752. if assigned(basedef) then
  753. rttilist^.concat(new(pai_const_symbol,init(basedef^.get_rtti_label)))
  754. else
  755. rttilist^.concat(new(pai_const,init_32bit(0)));
  756. hp:=firstenum;
  757. while assigned(hp) do
  758. begin
  759. rttilist^.concat(new(pai_const,init_8bit(length(hp^.name))));
  760. rttilist^.concat(new(pai_string,init(hp^.name)));
  761. hp:=hp^.nextenum;
  762. end;
  763. rttilist^.concat(new(pai_const,init_8bit(0)));
  764. end;
  765. function tenumdef.is_publishable : boolean;
  766. begin
  767. is_publishable:=true;
  768. end;
  769. {****************************************************************************
  770. TORDDEF
  771. ****************************************************************************}
  772. constructor torddef.init(t : tbasetype;v,b : longint);
  773. begin
  774. inherited init;
  775. deftype:=orddef;
  776. low:=v;
  777. high:=b;
  778. typ:=t;
  779. rangenr:=0;
  780. setsize;
  781. end;
  782. constructor torddef.load;
  783. begin
  784. inherited load;
  785. deftype:=orddef;
  786. typ:=tbasetype(readbyte);
  787. low:=readlong;
  788. high:=readlong;
  789. rangenr:=0;
  790. setsize;
  791. end;
  792. procedure torddef.setsize;
  793. begin
  794. if typ=uauto then
  795. begin
  796. { generate a unsigned range if high<0 and low>=0 }
  797. if (low>=0) and (high<0) then
  798. begin
  799. savesize:=4;
  800. typ:=u32bit;
  801. end
  802. else if (low>=0) and (high<=255) then
  803. begin
  804. savesize:=1;
  805. typ:=u8bit;
  806. end
  807. else if (low>=-128) and (high<=127) then
  808. begin
  809. savesize:=1;
  810. typ:=s8bit;
  811. end
  812. else if (low>=0) and (high<=65536) then
  813. begin
  814. savesize:=2;
  815. typ:=u16bit;
  816. end
  817. else if (low>=-32768) and (high<=32767) then
  818. begin
  819. savesize:=2;
  820. typ:=s16bit;
  821. end
  822. else
  823. begin
  824. savesize:=4;
  825. typ:=s32bit;
  826. end;
  827. end
  828. else
  829. begin
  830. case typ of
  831. u8bit,s8bit,
  832. uchar,bool8bit:
  833. savesize:=1;
  834. u16bit,s16bit,
  835. bool16bit:
  836. savesize:=2;
  837. s32bit,u32bit,
  838. bool32bit:
  839. savesize:=4;
  840. u64bit,s64bitint:
  841. savesize:=8;
  842. else
  843. savesize:=0;
  844. end;
  845. end;
  846. { there are no entrys for range checking }
  847. rangenr:=0;
  848. end;
  849. function torddef.getrangecheckstring : string;
  850. begin
  851. if (cs_smartlink in aktmoduleswitches) then
  852. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  853. else
  854. getrangecheckstring:='R_'+tostr(rangenr);
  855. end;
  856. procedure torddef.genrangecheck;
  857. begin
  858. if rangenr=0 then
  859. begin
  860. { generate two constant for bounds }
  861. getlabelnr(rangenr);
  862. if (cs_smartlink in aktmoduleswitches) then
  863. datasegment^.concat(new(pai_symbol,init_global(getrangecheckstring)))
  864. else
  865. datasegment^.concat(new(pai_symbol,init(getrangecheckstring)));
  866. if low<=high then
  867. begin
  868. datasegment^.concat(new(pai_const,init_32bit(low)));
  869. datasegment^.concat(new(pai_const,init_32bit(high)));
  870. end
  871. { for u32bit we need two bounds }
  872. else
  873. begin
  874. datasegment^.concat(new(pai_const,init_32bit(low)));
  875. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  876. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  877. datasegment^.concat(new(pai_const,init_32bit(high)));
  878. end;
  879. end;
  880. end;
  881. procedure torddef.write;
  882. begin
  883. tdef.write;
  884. writebyte(byte(typ));
  885. writelong(low);
  886. writelong(high);
  887. current_ppu^.writeentry(iborddef);
  888. end;
  889. {$ifdef GDB}
  890. function torddef.stabstring : pchar;
  891. begin
  892. case typ of
  893. uvoid : stabstring := strpnew(numberstring+';');
  894. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  895. {$ifdef Use_integer_types_for_boolean}
  896. bool8bit,
  897. bool16bit,
  898. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  899. {$else : not Use_integer_types_for_boolean}
  900. bool8bit : stabstring := strpnew('-21;');
  901. bool16bit : stabstring := strpnew('-22;');
  902. bool32bit : stabstring := strpnew('-23;');
  903. u64bit : stabstring := strpnew('-32;');
  904. s64bitint : stabstring := strpnew('-31;');
  905. {$endif not Use_integer_types_for_boolean}
  906. { u32bit : stabstring := strpnew('r'+
  907. s32bitdef^.numberstring+';0;-1;'); }
  908. else
  909. stabstring := strpnew('r'+s32bitdef^.numberstring+';'+tostr(low)+';'+tostr(high)+';');
  910. end;
  911. end;
  912. {$endif GDB}
  913. procedure torddef.write_rtti_data;
  914. const
  915. trans : array[uchar..bool8bit] of byte =
  916. (otUByte,otUByte,otUWord,otULong,otSByte,otSWord,otSLong,otUByte);
  917. begin
  918. case typ of
  919. bool8bit:
  920. rttilist^.concat(new(pai_const,init_8bit(tkBool)));
  921. uchar:
  922. rttilist^.concat(new(pai_const,init_8bit(tkChar)));
  923. else
  924. rttilist^.concat(new(pai_const,init_8bit(tkInteger)));
  925. end;
  926. rttilist^.concat(new(pai_const,init_8bit(byte(trans[typ]))));
  927. rttilist^.concat(new(pai_const,init_32bit(low)));
  928. rttilist^.concat(new(pai_const,init_32bit(high)));
  929. end;
  930. function torddef.is_publishable : boolean;
  931. begin
  932. is_publishable:=typ in [uchar..bool8bit];
  933. end;
  934. {****************************************************************************
  935. TFLOATDEF
  936. ****************************************************************************}
  937. constructor tfloatdef.init(t : tfloattype);
  938. begin
  939. inherited init;
  940. deftype:=floatdef;
  941. typ:=t;
  942. setsize;
  943. end;
  944. constructor tfloatdef.load;
  945. begin
  946. inherited load;
  947. deftype:=floatdef;
  948. typ:=tfloattype(readbyte);
  949. setsize;
  950. end;
  951. procedure tfloatdef.setsize;
  952. begin
  953. case typ of
  954. f16bit : savesize:=2;
  955. f32bit,
  956. s32real : savesize:=4;
  957. s64real : savesize:=8;
  958. s64bit : savesize:=8;
  959. s80real : savesize:=extended_size;
  960. else
  961. savesize:=0;
  962. end;
  963. end;
  964. procedure tfloatdef.write;
  965. begin
  966. inherited write;
  967. writebyte(byte(typ));
  968. current_ppu^.writeentry(ibfloatdef);
  969. end;
  970. {$ifdef GDB}
  971. function tfloatdef.stabstring : pchar;
  972. begin
  973. case typ of
  974. s32real,
  975. s64real : stabstring := strpnew('r'+
  976. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  977. { for fixed real use longint instead to be able to }
  978. { debug something at least }
  979. f32bit:
  980. stabstring := s32bitdef^.stabstring;
  981. f16bit:
  982. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  983. tostr($ffff)+';');
  984. { found this solution in stabsread.c from GDB v4.16 }
  985. s64bit : stabstring := strpnew('r'+
  986. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  987. {$ifdef i386}
  988. { under dos at least you must give a size of twelve instead of 10 !! }
  989. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  990. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  991. {$endif i386}
  992. else
  993. internalerror(10005);
  994. end;
  995. end;
  996. {$endif GDB}
  997. procedure tfloatdef.write_rtti_data;
  998. const
  999. translate : array[tfloattype] of byte =
  1000. (ftFixed32,ftSingle,ftDouble,ftExtended,ftComp,ftFixed16);
  1001. begin
  1002. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  1003. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  1004. end;
  1005. function tfloatdef.is_publishable : boolean;
  1006. begin
  1007. is_publishable:=true;
  1008. end;
  1009. {****************************************************************************
  1010. TFILEDEF
  1011. ****************************************************************************}
  1012. constructor tfiledef.init(ft : tfiletype;tas : pdef);
  1013. begin
  1014. inherited init;
  1015. deftype:=filedef;
  1016. filetype:=ft;
  1017. typed_as:=tas;
  1018. setsize;
  1019. end;
  1020. constructor tfiledef.load;
  1021. begin
  1022. inherited load;
  1023. deftype:=filedef;
  1024. filetype:=tfiletype(readbyte);
  1025. if filetype=ft_typed then
  1026. typed_as:=readdefref
  1027. else
  1028. typed_as:=nil;
  1029. setsize;
  1030. end;
  1031. procedure tfiledef.deref;
  1032. begin
  1033. if filetype=ft_typed then
  1034. resolvedef(typed_as);
  1035. end;
  1036. procedure tfiledef.setsize;
  1037. begin
  1038. case filetype of
  1039. ft_text : savesize:=572;
  1040. ft_typed,
  1041. ft_untyped : savesize:=316;
  1042. end;
  1043. end;
  1044. procedure tfiledef.write;
  1045. begin
  1046. inherited write;
  1047. writebyte(byte(filetype));
  1048. if filetype=ft_typed then
  1049. writedefref(typed_as);
  1050. current_ppu^.writeentry(ibfiledef);
  1051. end;
  1052. {$ifdef GDB}
  1053. function tfiledef.stabstring : pchar;
  1054. begin
  1055. {$IfDef GDBknowsfiles}
  1056. case filetyp of
  1057. ft_typed : stabstring := strpnew('d'+typed_as^.numberstring{+';'});
  1058. ft_untyped : stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  1059. ft_text : stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  1060. end;
  1061. {$Else}
  1062. {based on
  1063. FileRec = Packed Record
  1064. Handle,
  1065. Mode,
  1066. RecSize : longint;
  1067. _private : array[1..32] of byte;
  1068. UserData : array[1..16] of byte;
  1069. name : array[0..255] of char;
  1070. End; }
  1071. { the buffer part is still missing !! (PM) }
  1072. { but the string could become too long !! }
  1073. stabstring := strpnew('s'+tostr(savesize)+
  1074. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1075. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1076. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1077. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1078. +',96,256;'+
  1079. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1080. +',352,128;'+
  1081. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1082. +',480,2048;;');
  1083. {$EndIf}
  1084. end;
  1085. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  1086. begin
  1087. { most file defs are unnamed !!! }
  1088. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1089. not is_def_stab_written then
  1090. begin
  1091. if assigned(typed_as) then forcestabto(asmlist,typed_as);
  1092. inherited concatstabto(asmlist);
  1093. end;
  1094. end;
  1095. {$endif GDB}
  1096. {****************************************************************************
  1097. TPOINTERDEF
  1098. ****************************************************************************}
  1099. constructor tpointerdef.init(def : pdef);
  1100. begin
  1101. inherited init;
  1102. deftype:=pointerdef;
  1103. definition:=def;
  1104. savesize:=target_os.size_of_pointer;
  1105. end;
  1106. constructor tpointerdef.load;
  1107. begin
  1108. inherited load;
  1109. deftype:=pointerdef;
  1110. { the real address in memory is calculated later (deref) }
  1111. definition:=readdefref;
  1112. savesize:=target_os.size_of_pointer;
  1113. end;
  1114. procedure tpointerdef.deref;
  1115. begin
  1116. resolvedef(definition);
  1117. end;
  1118. procedure tpointerdef.write;
  1119. begin
  1120. inherited write;
  1121. writedefref(definition);
  1122. current_ppu^.writeentry(ibpointerdef);
  1123. end;
  1124. {$ifdef GDB}
  1125. function tpointerdef.stabstring : pchar;
  1126. begin
  1127. stabstring := strpnew('*'+definition^.numberstring);
  1128. end;
  1129. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1130. var st,nb : string;
  1131. sym_line_no : longint;
  1132. begin
  1133. if ( (sym=nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1134. not is_def_stab_written then
  1135. begin
  1136. if assigned(definition) then
  1137. if definition^.deftype in [recorddef,objectdef] then
  1138. begin
  1139. is_def_stab_written := true;
  1140. {to avoid infinite recursion in record with next-like fields }
  1141. nb := definition^.numberstring;
  1142. is_def_stab_written := false;
  1143. if not definition^.is_def_stab_written then
  1144. begin
  1145. if assigned(definition^.sym) then
  1146. begin
  1147. if assigned(sym) then
  1148. begin
  1149. st := sym^.name;
  1150. sym_line_no:=sym^.fileinfo.line;
  1151. end
  1152. else
  1153. begin
  1154. st := ' ';
  1155. sym_line_no:=0;
  1156. end;
  1157. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1158. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1159. if asmlist = debuglist then do_count_dbx := true;
  1160. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1161. end;
  1162. end else inherited concatstabto(asmlist);
  1163. is_def_stab_written := true;
  1164. end else
  1165. begin
  1166. { p =^p1; p1=^p problem }
  1167. is_def_stab_written := true;
  1168. forcestabto(asmlist,definition);
  1169. is_def_stab_written := false;
  1170. inherited concatstabto(asmlist);
  1171. end;
  1172. end;
  1173. end;
  1174. {$endif GDB}
  1175. {****************************************************************************
  1176. TFARPOINTERDEF
  1177. ****************************************************************************}
  1178. constructor tfarpointerdef.init(def : pdef);
  1179. begin
  1180. inherited init(def);
  1181. deftype:=farpointerdef;
  1182. savesize:=target_os.size_of_pointer;
  1183. end;
  1184. constructor tfarpointerdef.load;
  1185. begin
  1186. inherited load;
  1187. deftype:=farpointerdef;
  1188. savesize:=target_os.size_of_pointer;
  1189. end;
  1190. procedure tfarpointerdef.write;
  1191. begin
  1192. tdef.write;
  1193. writedefref(definition);
  1194. current_ppu^.writeentry(ibfarpointerdef);
  1195. end;
  1196. {****************************************************************************
  1197. TCLASSREFDEF
  1198. ****************************************************************************}
  1199. constructor tclassrefdef.init(def : pdef);
  1200. begin
  1201. inherited init(def);
  1202. deftype:=classrefdef;
  1203. definition:=def;
  1204. savesize:=target_os.size_of_pointer;
  1205. end;
  1206. constructor tclassrefdef.load;
  1207. begin
  1208. inherited load;
  1209. deftype:=classrefdef;
  1210. end;
  1211. procedure tclassrefdef.write;
  1212. begin
  1213. { be careful, tclassdefref inherits from tpointerdef }
  1214. tdef.write;
  1215. writedefref(definition);
  1216. current_ppu^.writeentry(ibclassrefdef);
  1217. end;
  1218. {$ifdef GDB}
  1219. function tclassrefdef.stabstring : pchar;
  1220. begin
  1221. stabstring:=strpnew('');
  1222. end;
  1223. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1224. begin
  1225. end;
  1226. {$endif GDB}
  1227. {***************************************************************************
  1228. TSETDEF
  1229. ***************************************************************************}
  1230. { For i386 smallsets work,
  1231. for m68k there are problems
  1232. can be test by compiling with -dusesmallset PM }
  1233. {$ifdef i386}
  1234. {$define usesmallset}
  1235. {$endif i386}
  1236. constructor tsetdef.init(s : pdef;high : longint);
  1237. begin
  1238. inherited init;
  1239. deftype:=setdef;
  1240. setof:=s;
  1241. {$ifdef usesmallset}
  1242. { small sets only working for i386 PM }
  1243. if high<32 then
  1244. begin
  1245. settype:=smallset;
  1246. savesize:=Sizeof(longint);
  1247. end
  1248. else
  1249. {$endif usesmallset}
  1250. if high<256 then
  1251. begin
  1252. settype:=normset;
  1253. savesize:=32;
  1254. end
  1255. else
  1256. {$ifdef testvarsets}
  1257. if high<$10000 then
  1258. begin
  1259. settype:=varset;
  1260. savesize:=4*((high+31) div 32);
  1261. end
  1262. else
  1263. {$endif testvarsets}
  1264. Message(sym_e_ill_type_decl_set);
  1265. end;
  1266. constructor tsetdef.load;
  1267. begin
  1268. inherited load;
  1269. deftype:=setdef;
  1270. setof:=readdefref;
  1271. settype:=tsettype(readbyte);
  1272. case settype of
  1273. normset : savesize:=32;
  1274. varset : savesize:=readlong;
  1275. smallset : savesize:=Sizeof(longint);
  1276. end;
  1277. end;
  1278. procedure tsetdef.write;
  1279. begin
  1280. inherited write;
  1281. writedefref(setof);
  1282. writebyte(byte(settype));
  1283. if settype=varset then
  1284. writelong(savesize);
  1285. current_ppu^.writeentry(ibsetdef);
  1286. end;
  1287. {$ifdef GDB}
  1288. function tsetdef.stabstring : pchar;
  1289. begin
  1290. stabstring := strpnew('S'+setof^.numberstring);
  1291. end;
  1292. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1293. begin
  1294. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1295. not is_def_stab_written then
  1296. begin
  1297. if assigned(setof) then
  1298. forcestabto(asmlist,setof);
  1299. inherited concatstabto(asmlist);
  1300. end;
  1301. end;
  1302. {$endif GDB}
  1303. procedure tsetdef.deref;
  1304. begin
  1305. resolvedef(setof);
  1306. end;
  1307. procedure tsetdef.write_rtti_data;
  1308. begin
  1309. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1310. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1311. rttilist^.concat(new(pai_const_symbol,init(setof^.get_rtti_label)));
  1312. end;
  1313. procedure tsetdef.write_child_rtti_data;
  1314. begin
  1315. setof^.get_rtti_label;
  1316. end;
  1317. function tsetdef.is_publishable : boolean;
  1318. begin
  1319. is_publishable:=settype=smallset;
  1320. end;
  1321. {***************************************************************************
  1322. TFORMALDEF
  1323. ***************************************************************************}
  1324. constructor tformaldef.init;
  1325. var
  1326. stregdef : boolean;
  1327. begin
  1328. stregdef:=registerdef;
  1329. registerdef:=false;
  1330. inherited init;
  1331. deftype:=formaldef;
  1332. registerdef:=stregdef;
  1333. { formaldef must be registered at unit level !! }
  1334. if registerdef and assigned(current_module) then
  1335. if assigned(current_module^.localsymtable) then
  1336. psymtable(current_module^.localsymtable)^.registerdef(@self)
  1337. else if assigned(current_module^.globalsymtable) then
  1338. psymtable(current_module^.globalsymtable)^.registerdef(@self);
  1339. savesize:=target_os.size_of_pointer;
  1340. end;
  1341. constructor tformaldef.load;
  1342. begin
  1343. inherited load;
  1344. deftype:=formaldef;
  1345. savesize:=target_os.size_of_pointer;
  1346. end;
  1347. procedure tformaldef.write;
  1348. begin
  1349. inherited write;
  1350. current_ppu^.writeentry(ibformaldef);
  1351. end;
  1352. {$ifdef GDB}
  1353. function tformaldef.stabstring : pchar;
  1354. begin
  1355. stabstring := strpnew('formal'+numberstring+';');
  1356. end;
  1357. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1358. begin
  1359. { formaldef can't be stab'ed !}
  1360. end;
  1361. {$endif GDB}
  1362. {***************************************************************************
  1363. TARRAYDEF
  1364. ***************************************************************************}
  1365. constructor tarraydef.init(l,h : longint;rd : pdef);
  1366. begin
  1367. inherited init;
  1368. deftype:=arraydef;
  1369. lowrange:=l;
  1370. highrange:=h;
  1371. rangedef:=rd;
  1372. definition:=nil;
  1373. IsVariant:=false;
  1374. IsConstructor:=false;
  1375. IsArrayOfConst:=false;
  1376. rangenr:=0;
  1377. end;
  1378. constructor tarraydef.load;
  1379. begin
  1380. inherited load;
  1381. deftype:=arraydef;
  1382. { the addresses are calculated later }
  1383. definition:=readdefref;
  1384. rangedef:=readdefref;
  1385. lowrange:=readlong;
  1386. highrange:=readlong;
  1387. IsArrayOfConst:=boolean(readbyte);
  1388. IsVariant:=false;
  1389. IsConstructor:=false;
  1390. rangenr:=0;
  1391. end;
  1392. function tarraydef.getrangecheckstring : string;
  1393. begin
  1394. if (cs_smartlink in aktmoduleswitches) then
  1395. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  1396. else
  1397. getrangecheckstring:='R_'+tostr(rangenr);
  1398. end;
  1399. procedure tarraydef.genrangecheck;
  1400. begin
  1401. if rangenr=0 then
  1402. begin
  1403. { generates the data for range checking }
  1404. getlabelnr(rangenr);
  1405. if (cs_smartlink in aktmoduleswitches) then
  1406. datasegment^.concat(new(pai_symbol,init_global(getrangecheckstring)))
  1407. else
  1408. datasegment^.concat(new(pai_symbol,init(getrangecheckstring)));
  1409. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1410. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1411. end;
  1412. end;
  1413. procedure tarraydef.deref;
  1414. begin
  1415. resolvedef(definition);
  1416. resolvedef(rangedef);
  1417. end;
  1418. procedure tarraydef.write;
  1419. begin
  1420. inherited write;
  1421. writedefref(definition);
  1422. writedefref(rangedef);
  1423. writelong(lowrange);
  1424. writelong(highrange);
  1425. writebyte(byte(IsArrayOfConst));
  1426. current_ppu^.writeentry(ibarraydef);
  1427. end;
  1428. {$ifdef GDB}
  1429. function tarraydef.stabstring : pchar;
  1430. begin
  1431. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1432. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1433. end;
  1434. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1435. begin
  1436. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1437. and not is_def_stab_written then
  1438. begin
  1439. {when array are inserted they have no definition yet !!}
  1440. if assigned(definition) then
  1441. inherited concatstabto(asmlist);
  1442. end;
  1443. end;
  1444. {$endif GDB}
  1445. function tarraydef.elesize : longint;
  1446. begin
  1447. elesize:=definition^.size;
  1448. end;
  1449. function tarraydef.size : longint;
  1450. begin
  1451. { dirty hack to overcome an overflow (PFV) }
  1452. if highrange=$7fffffff then
  1453. size:=$7fffffff
  1454. else
  1455. size:=(highrange-lowrange+1)*elesize;
  1456. end;
  1457. function tarraydef.needs_inittable : boolean;
  1458. begin
  1459. needs_inittable:=definition^.needs_inittable;
  1460. end;
  1461. procedure tarraydef.write_child_rtti_data;
  1462. begin
  1463. definition^.get_rtti_label;
  1464. end;
  1465. procedure tarraydef.write_rtti_data;
  1466. begin
  1467. rttilist^.concat(new(pai_const,init_8bit(13)));
  1468. write_rtti_name;
  1469. { size of elements }
  1470. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1471. { count of elements }
  1472. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1473. { element type }
  1474. rttilist^.concat(new(pai_const_symbol,init(definition^.get_rtti_label)));
  1475. end;
  1476. {***************************************************************************
  1477. TRECDEF
  1478. ***************************************************************************}
  1479. constructor trecdef.init(p : psymtable);
  1480. begin
  1481. inherited init;
  1482. deftype:=recorddef;
  1483. symtable:=p;
  1484. savesize:=symtable^.datasize;
  1485. symtable^.defowner := @self;
  1486. end;
  1487. constructor trecdef.load;
  1488. var
  1489. oldread_member : boolean;
  1490. begin
  1491. inherited load;
  1492. deftype:=recorddef;
  1493. savesize:=readlong;
  1494. oldread_member:=read_member;
  1495. read_member:=true;
  1496. symtable:=new(psymtable,loadas(recordsymtable));
  1497. read_member:=oldread_member;
  1498. symtable^.defowner := @self;
  1499. end;
  1500. destructor trecdef.done;
  1501. begin
  1502. if assigned(symtable) then dispose(symtable,done);
  1503. inherited done;
  1504. end;
  1505. var
  1506. binittable : boolean;
  1507. procedure check_rec_inittable(s : psym);
  1508. begin
  1509. if (s^.typ=varsym) and
  1510. ((pvarsym(s)^.definition^.deftype<>objectdef)
  1511. or not(pobjectdef(pvarsym(s)^.definition)^.isclass)) then
  1512. binittable:=pvarsym(s)^.definition^.needs_inittable;
  1513. end;
  1514. function trecdef.needs_inittable : boolean;
  1515. var
  1516. oldb : boolean;
  1517. begin
  1518. { there are recursive calls to needs_rtti possible, }
  1519. { so we have to change to old value how else should }
  1520. { we do that ? check_rec_rtti can't be a nested }
  1521. { procedure of needs_rtti ! }
  1522. oldb:=binittable;
  1523. binittable:=false;
  1524. symtable^.foreach(check_rec_inittable);
  1525. needs_inittable:=binittable;
  1526. binittable:=oldb;
  1527. end;
  1528. procedure trecdef.deref;
  1529. var
  1530. hp : pdef;
  1531. oldrecsyms : psymtable;
  1532. begin
  1533. oldrecsyms:=aktrecordsymtable;
  1534. aktrecordsymtable:=symtable;
  1535. { now dereference the definitions }
  1536. {$ifdef STORENUMBER}
  1537. hp:=pdef(symtable^.defindex^.first);
  1538. {$else}
  1539. hp:=symtable^.rootdef;
  1540. {$endif}
  1541. while assigned(hp) do
  1542. begin
  1543. hp^.deref;
  1544. { set owner }
  1545. hp^.owner:=symtable;
  1546. hp:=pdef(hp^.next);
  1547. end;
  1548. {$ifdef tp}
  1549. symtable^.foreach(derefsym);
  1550. {$else}
  1551. symtable^.foreach(@derefsym);
  1552. {$endif}
  1553. aktrecordsymtable:=oldrecsyms;
  1554. end;
  1555. procedure trecdef.write;
  1556. var
  1557. oldread_member : boolean;
  1558. begin
  1559. oldread_member:=read_member;
  1560. read_member:=true;
  1561. inherited write;
  1562. writelong(savesize);
  1563. current_ppu^.writeentry(ibrecorddef);
  1564. self.symtable^.writeas;
  1565. read_member:=oldread_member;
  1566. end;
  1567. {$ifdef GDB}
  1568. Const StabRecString : pchar = Nil;
  1569. StabRecSize : longint = 0;
  1570. RecOffset : Longint = 0;
  1571. procedure addname(p : psym);
  1572. var
  1573. news, newrec : pchar;
  1574. spec : string[2];
  1575. size : longint;
  1576. begin
  1577. { static variables from objects are like global objects }
  1578. if ((p^.properties and sp_static)<>0) then
  1579. exit;
  1580. if ((p^.properties and sp_protected)<>0) then
  1581. spec:='/1'
  1582. else if ((p^.properties and sp_private)<>0) then
  1583. spec:='/0'
  1584. else
  1585. spec:='';
  1586. If p^.typ = varsym then
  1587. begin
  1588. size:=pvarsym(p)^.definition^.size;
  1589. { open arrays made overflows !! }
  1590. if size>$fffffff then
  1591. size:=$fffffff;
  1592. newrec := strpnew(p^.name+':'+spec+pvarsym(p)^.definition^.numberstring
  1593. +','+tostr(pvarsym(p)^.address*8)+','
  1594. +tostr(size*8)+';');
  1595. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1596. begin
  1597. getmem(news,stabrecsize+memsizeinc);
  1598. strcopy(news,stabrecstring);
  1599. freemem(stabrecstring,stabrecsize);
  1600. stabrecsize:=stabrecsize+memsizeinc;
  1601. stabrecstring:=news;
  1602. end;
  1603. strcat(StabRecstring,newrec);
  1604. strdispose(newrec);
  1605. {This should be used for case !!}
  1606. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1607. end;
  1608. end;
  1609. function trecdef.stabstring : pchar;
  1610. Var oldrec : pchar;
  1611. oldsize : longint;
  1612. cur : psym;
  1613. begin
  1614. oldrec := stabrecstring;
  1615. oldsize:=stabrecsize;
  1616. GetMem(stabrecstring,memsizeinc);
  1617. stabrecsize:=memsizeinc;
  1618. strpcopy(stabRecString,'s'+tostr(savesize));
  1619. RecOffset := 0;
  1620. {$ifdef nonextfield}
  1621. {$ifdef tp}
  1622. symtable^.foreach(addname);
  1623. {$else}
  1624. symtable^.foreach(@addname);
  1625. {$endif}
  1626. {$else nonextfield}
  1627. cur:=symtable^.searchroot;
  1628. while assigned(cur) do
  1629. begin
  1630. addname(cur);
  1631. cur:=cur^.nextsym;
  1632. end;
  1633. {$endif nonextfield}
  1634. { FPC doesn't want to convert a char to a pchar}
  1635. { is this a bug ? }
  1636. strpcopy(strend(StabRecString),';');
  1637. stabstring := strnew(StabRecString);
  1638. Freemem(stabrecstring,stabrecsize);
  1639. stabrecstring := oldrec;
  1640. stabrecsize:=oldsize;
  1641. end;
  1642. procedure trecdef.concatstabto(asmlist : paasmoutput);
  1643. begin
  1644. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1645. (not is_def_stab_written) then
  1646. inherited concatstabto(asmlist);
  1647. end;
  1648. {$endif GDB}
  1649. var
  1650. count : longint;
  1651. procedure count_inittable_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1652. begin
  1653. if (sym^.typ=varsym) and (pvarsym(sym)^.definition^.needs_inittable) then
  1654. inc(count);
  1655. end;
  1656. procedure count_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1657. begin
  1658. inc(count);
  1659. end;
  1660. procedure write_field_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1661. begin
  1662. if (sym^.typ=varsym) and pvarsym(sym)^.definition^.needs_inittable then
  1663. begin
  1664. rttilist^.concat(new(pai_const_symbol,init(lab2str(pvarsym(sym)^.definition^.get_inittable_label))));
  1665. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1666. end;
  1667. end;
  1668. procedure write_field_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1669. begin
  1670. rttilist^.concat(new(pai_const_symbol,init(pvarsym(sym)^.definition^.get_rtti_label)));
  1671. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1672. end;
  1673. procedure generate_child_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1674. begin
  1675. if (sym^.typ=varsym) and pvarsym(sym)^.definition^.needs_inittable then
  1676. { force inittable generation }
  1677. pvarsym(sym)^.definition^.get_inittable_label;
  1678. end;
  1679. procedure generate_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1680. begin
  1681. pvarsym(sym)^.definition^.get_rtti_label;
  1682. end;
  1683. procedure trecdef.write_child_rtti_data;
  1684. begin
  1685. symtable^.foreach(generate_child_rtti);
  1686. end;
  1687. procedure trecdef.write_child_init_data;
  1688. begin
  1689. symtable^.foreach(generate_child_inittable);
  1690. end;
  1691. procedure trecdef.write_rtti_data;
  1692. begin
  1693. rttilist^.concat(new(pai_const,init_8bit(14)));
  1694. write_rtti_name;
  1695. rttilist^.concat(new(pai_const,init_32bit(size)));
  1696. count:=0;
  1697. symtable^.foreach(count_fields);
  1698. rttilist^.concat(new(pai_const,init_32bit(count)));
  1699. symtable^.foreach(write_field_rtti);
  1700. end;
  1701. procedure trecdef.write_init_data;
  1702. begin
  1703. rttilist^.concat(new(pai_const,init_8bit(14)));
  1704. write_rtti_name;
  1705. rttilist^.concat(new(pai_const,init_32bit(size)));
  1706. count:=0;
  1707. symtable^.foreach(count_inittable_fields);
  1708. rttilist^.concat(new(pai_const,init_32bit(count)));
  1709. symtable^.foreach(write_field_inittable);
  1710. end;
  1711. {***************************************************************************
  1712. TABSTRACTPROCDEF
  1713. ***************************************************************************}
  1714. constructor tabstractprocdef.init;
  1715. begin
  1716. inherited init;
  1717. para1:=nil;
  1718. fpu_used:=0;
  1719. options:=0;
  1720. retdef:=voiddef;
  1721. savesize:=target_os.size_of_pointer;
  1722. end;
  1723. procedure disposepdefcoll(var para1 : pdefcoll);
  1724. var
  1725. hp : pdefcoll;
  1726. begin
  1727. hp:=para1;
  1728. while assigned(hp) do
  1729. begin
  1730. para1:=hp^.next;
  1731. dispose(hp);
  1732. hp:=para1;
  1733. end;
  1734. end;
  1735. destructor tabstractprocdef.done;
  1736. begin
  1737. disposepdefcoll(para1);
  1738. inherited done;
  1739. end;
  1740. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1741. var
  1742. hp : pdefcoll;
  1743. begin
  1744. new(hp);
  1745. hp^.paratyp:=vsp;
  1746. hp^.data:=p;
  1747. hp^.next:=para1;
  1748. para1:=hp;
  1749. end;
  1750. { all functions returning in FPU are
  1751. assume to use 2 FPU registers
  1752. until the function implementation
  1753. is processed PM }
  1754. procedure tabstractprocdef.test_if_fpu_result;
  1755. begin
  1756. if assigned(retdef) and is_fpu(retdef) then
  1757. fpu_used:=2;
  1758. end;
  1759. procedure tabstractprocdef.deref;
  1760. var
  1761. hp : pdefcoll;
  1762. begin
  1763. inherited deref;
  1764. resolvedef(retdef);
  1765. hp:=para1;
  1766. while assigned(hp) do
  1767. begin
  1768. resolvedef(hp^.data);
  1769. hp:=hp^.next;
  1770. end;
  1771. end;
  1772. constructor tabstractprocdef.load;
  1773. var
  1774. last,hp : pdefcoll;
  1775. count,i : word;
  1776. begin
  1777. inherited load;
  1778. retdef:=readdefref;
  1779. fpu_used:=readbyte;
  1780. options:=readlong;
  1781. count:=readword;
  1782. para1:=nil;
  1783. savesize:=target_os.size_of_pointer;
  1784. for i:=1 to count do
  1785. begin
  1786. new(hp);
  1787. hp^.paratyp:=tvarspez(readbyte);
  1788. hp^.data:=readdefref;
  1789. hp^.next:=nil;
  1790. if para1=nil then
  1791. para1:=hp
  1792. else
  1793. last^.next:=hp;
  1794. last:=hp;
  1795. end;
  1796. end;
  1797. function tabstractprocdef.para_size : longint;
  1798. var
  1799. pdc : pdefcoll;
  1800. l : longint;
  1801. begin
  1802. l:=0;
  1803. pdc:=para1;
  1804. while assigned(pdc) do
  1805. begin
  1806. case pdc^.paratyp of
  1807. vs_var : inc(l,target_os.size_of_pointer);
  1808. vs_value,
  1809. vs_const : if push_addr_param(pdc^.data) then
  1810. inc(l,target_os.size_of_pointer)
  1811. else
  1812. inc(l,align(pdc^.data^.size,target_os.stackalignment));
  1813. end;
  1814. pdc:=pdc^.next;
  1815. end;
  1816. para_size:=l;
  1817. end;
  1818. procedure tabstractprocdef.write;
  1819. var
  1820. count : word;
  1821. hp : pdefcoll;
  1822. begin
  1823. inherited write;
  1824. writedefref(retdef);
  1825. {$ifdef Double_checksum}
  1826. current_ppu^.do_interface_crc:=false;
  1827. {$endif def Double_checksum}
  1828. writebyte(fpu_used);
  1829. writelong(options);
  1830. {$ifdef Double_checksum}
  1831. current_ppu^.do_interface_crc:=true;
  1832. {$endif def Double_checksum}
  1833. hp:=para1;
  1834. count:=0;
  1835. while assigned(hp) do
  1836. begin
  1837. inc(count);
  1838. hp:=hp^.next;
  1839. end;
  1840. writeword(count);
  1841. hp:=para1;
  1842. while assigned(hp) do
  1843. begin
  1844. writebyte(byte(hp^.paratyp));
  1845. writedefref(hp^.data);
  1846. hp:=hp^.next;
  1847. end;
  1848. end;
  1849. function tabstractprocdef.demangled_paras : string;
  1850. var s : string;
  1851. p : pdefcoll;
  1852. begin
  1853. s:='';
  1854. p:=para1;
  1855. if assigned(p) then
  1856. begin
  1857. s:=s+'(';
  1858. while assigned(p) do
  1859. begin
  1860. if assigned(p^.data^.sym) then
  1861. s:=s+p^.data^.sym^.name
  1862. else if p^.paratyp=vs_var then
  1863. s:=s+'var'
  1864. else if p^.paratyp=vs_const then
  1865. s:=s+'const';
  1866. p:=p^.next;
  1867. if assigned(p) then
  1868. s:=s+','
  1869. else
  1870. s:=s+')';
  1871. end;
  1872. end;
  1873. demangled_paras:=s;
  1874. end;
  1875. {$ifdef GDB}
  1876. function tabstractprocdef.stabstring : pchar;
  1877. begin
  1878. stabstring := strpnew('abstractproc'+numberstring+';');
  1879. end;
  1880. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  1881. begin
  1882. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1883. and not is_def_stab_written then
  1884. begin
  1885. if assigned(retdef) then forcestabto(asmlist,retdef);
  1886. inherited concatstabto(asmlist);
  1887. end;
  1888. end;
  1889. {$endif GDB}
  1890. {***************************************************************************
  1891. TPROCDEF
  1892. ***************************************************************************}
  1893. constructor tprocdef.init;
  1894. begin
  1895. inherited init;
  1896. deftype:=procdef;
  1897. _mangledname:=nil;
  1898. nextoverloaded:=nil;
  1899. extnumber:=-1;
  1900. localst:=new(psymtable,init(localsymtable));
  1901. parast:=new(psymtable,init(parasymtable));
  1902. localst^.defowner:=@self;
  1903. parast^.defowner:=@self;
  1904. { this is used by insert
  1905. to check same names in parast and localst }
  1906. localst^.next:=parast;
  1907. defref:=nil;
  1908. lastwritten:=nil;
  1909. refcount:=0;
  1910. if (cs_browser in aktmoduleswitches) and make_ref then
  1911. begin
  1912. defref:=new(pref,init(defref,@tokenpos));
  1913. inc(refcount);
  1914. end;
  1915. lastref:=defref;
  1916. { first, we assume, that all registers are used }
  1917. {$ifdef i386}
  1918. usedregisters:=$ff;
  1919. {$endif i386}
  1920. {$ifdef m68k}
  1921. usedregisters:=$FFFF;
  1922. {$endif}
  1923. {$ifdef alpha}
  1924. usedregisters_int:=$ffffffff;
  1925. usedregisters_fpu:=$ffffffff;
  1926. {$endif alpha}
  1927. forwarddef:=true;
  1928. _class := nil;
  1929. code:=nil;
  1930. count:=false;
  1931. is_used:=false;
  1932. end;
  1933. constructor tprocdef.load;
  1934. var
  1935. s : string;
  1936. begin
  1937. inherited load;
  1938. deftype:=procdef;
  1939. {$ifdef i386}
  1940. usedregisters:=readbyte;
  1941. {$endif i386}
  1942. {$ifdef m68k}
  1943. usedregisters:=readword;
  1944. {$endif}
  1945. {$ifdef alpha}
  1946. usedregisters_int:=readlong;
  1947. usedregisters_fpu:=readlong;
  1948. {$endif alpha}
  1949. s:=readstring;
  1950. setstring(_mangledname,s);
  1951. extnumber:=readlong;
  1952. nextoverloaded:=pprocdef(readdefref);
  1953. _class := pobjectdef(readdefref);
  1954. if (cs_link_deffile in aktglobalswitches) and ((options and poexports)<>0) then
  1955. deffile.AddExport(mangledname);
  1956. parast:=nil;
  1957. localst:=nil;
  1958. forwarddef:=false;
  1959. lastref:=nil;
  1960. lastwritten:=nil;
  1961. defref:=nil;
  1962. refcount:=0;
  1963. count:=true;
  1964. is_used:=false;
  1965. end;
  1966. Const local_symtable_index : longint = $8001;
  1967. procedure tprocdef.load_references;
  1968. var
  1969. pos : tfileposinfo;
  1970. {$ifndef NOLOCALBROWSER}
  1971. pdo : pobjectdef;
  1972. {$endif ndef NOLOCALBROWSER}
  1973. move_last : boolean;
  1974. begin
  1975. move_last:=lastwritten=lastref;
  1976. while (not current_ppu^.endofentry) do
  1977. begin
  1978. readposinfo(pos);
  1979. inc(refcount);
  1980. lastref:=new(pref,init(lastref,@pos));
  1981. lastref^.is_written:=true;
  1982. if refcount=1 then
  1983. defref:=lastref;
  1984. end;
  1985. if move_last then
  1986. lastwritten:=lastref;
  1987. if ((current_module^.flags and uf_local_browser)<>0)
  1988. and is_in_current then
  1989. begin
  1990. {$ifndef NOLOCALBROWSER}
  1991. pdo:=_class;
  1992. if assigned(pdo) and (owner^.symtabletype<>localsymtable) then
  1993. localsymtablestack:=pdo^.publicsyms;
  1994. if owner^.symtabletype<>localsymtable then
  1995. while assigned(pdo) do
  1996. begin
  1997. if pdo^.publicsyms<>aktrecordsymtable then
  1998. begin
  1999. pdo^.publicsyms^.unitid:=local_symtable_index;
  2000. inc(local_symtable_index);
  2001. end;
  2002. pdo:=pdo^.childof;
  2003. end;
  2004. new(parast,loadas(parasymtable));
  2005. parast^.next:=localsymtablestack;
  2006. localsymtablestack:=parast;
  2007. parast^.unitid:=local_symtable_index;
  2008. inc(local_symtable_index);
  2009. parast^.load_browser;
  2010. new(localst,loadas(localsymtable));
  2011. localst^.next:=localsymtablestack;
  2012. localsymtablestack:=localst;
  2013. localst^.unitid:=local_symtable_index;
  2014. inc(local_symtable_index);
  2015. localst^.load_browser;
  2016. { decrement for }
  2017. local_symtable_index:=local_symtable_index-2;
  2018. localsymtablestack:=localsymtablestack^.next^.next;
  2019. pdo:=_class;
  2020. if (owner^.symtabletype<>localsymtable) then
  2021. localsymtablestack:=nil;
  2022. if (owner^.symtabletype<>localsymtable) then
  2023. while assigned(pdo) do
  2024. begin
  2025. if pdo^.publicsyms<>aktrecordsymtable then
  2026. dec(local_symtable_index);
  2027. pdo:=pdo^.childof;
  2028. end;
  2029. {$endif ndef NOLOCALBROWSER}
  2030. end;
  2031. end;
  2032. function tprocdef.write_references : boolean;
  2033. var
  2034. ref : pref;
  2035. {$ifndef NOLOCALBROWSER}
  2036. pdo : pobjectdef;
  2037. {$endif ndef NOLOCALBROWSER}
  2038. move_last : boolean;
  2039. begin
  2040. move_last:=lastwritten=lastref;
  2041. if move_last and (((current_module^.flags and uf_local_browser)=0)
  2042. or not is_in_current) then
  2043. exit;
  2044. { write address of this symbol }
  2045. writedefref(@self);
  2046. { write refs }
  2047. if assigned(lastwritten) then
  2048. ref:=lastwritten
  2049. else
  2050. ref:=defref;
  2051. while assigned(ref) do
  2052. begin
  2053. if ref^.moduleindex=current_module^.unit_index then
  2054. begin
  2055. writeposinfo(ref^.posinfo);
  2056. ref^.is_written:=true;
  2057. if move_last then
  2058. lastwritten:=ref;
  2059. end
  2060. else if not ref^.is_written then
  2061. move_last:=false
  2062. else if move_last then
  2063. lastwritten:=ref;
  2064. ref:=ref^.nextref;
  2065. end;
  2066. current_ppu^.writeentry(ibdefref);
  2067. write_references:=true;
  2068. if ((current_module^.flags and uf_local_browser)<>0)
  2069. and is_in_current then
  2070. begin
  2071. {$ifndef NOLOCALBROWSER}
  2072. pdo:=_class;
  2073. if (owner^.symtabletype<>localsymtable) then
  2074. while assigned(pdo) do
  2075. begin
  2076. if pdo^.publicsyms<>aktrecordsymtable then
  2077. begin
  2078. pdo^.publicsyms^.unitid:=local_symtable_index;
  2079. inc(local_symtable_index);
  2080. end;
  2081. pdo:=pdo^.childof;
  2082. end;
  2083. { we need TESTLOCALBROWSER para and local symtables
  2084. PPU files are then easier to read PM }
  2085. if not assigned(parast) then
  2086. parast:=new(psymtable,init(parasymtable));
  2087. parast^.writeas;
  2088. parast^.unitid:=local_symtable_index;
  2089. inc(local_symtable_index);
  2090. parast^.write_browser;
  2091. if not assigned(localst) then
  2092. localst:=new(psymtable,init(localsymtable));
  2093. localst^.writeas;
  2094. localst^.unitid:=local_symtable_index;
  2095. inc(local_symtable_index);
  2096. localst^.write_browser;
  2097. { decrement for }
  2098. local_symtable_index:=local_symtable_index-2;
  2099. pdo:=_class;
  2100. if (owner^.symtabletype<>localsymtable) then
  2101. while assigned(pdo) do
  2102. begin
  2103. if pdo^.publicsyms<>aktrecordsymtable then
  2104. dec(local_symtable_index);
  2105. pdo:=pdo^.childof;
  2106. end;
  2107. {$endif ndef NOLOCALBROWSER}
  2108. end;
  2109. end;
  2110. {$ifdef BrowserLog}
  2111. procedure tprocdef.add_to_browserlog;
  2112. begin
  2113. if assigned(defref) then
  2114. begin
  2115. browserlog.AddLog('***'+mangledname);
  2116. browserlog.AddLogRefs(defref);
  2117. if (current_module^.flags and uf_local_browser)<>0 then
  2118. begin
  2119. if assigned(parast) then
  2120. parast^.writebrowserlog;
  2121. if assigned(localst) then
  2122. localst^.writebrowserlog;
  2123. end;
  2124. end;
  2125. end;
  2126. {$endif BrowserLog}
  2127. destructor tprocdef.done;
  2128. begin
  2129. if assigned(defref) then
  2130. dispose(defref,done);
  2131. if assigned(parast) then
  2132. dispose(parast,done);
  2133. if assigned(localst) and (localst^.symtabletype<>staticsymtable) then
  2134. dispose(localst,done);
  2135. if ((options and poinline) <> 0) and assigned(code) then
  2136. disposetree(ptree(code));
  2137. if (options and pomsgstr)<>0 then
  2138. strdispose(messageinf.str);
  2139. if
  2140. {$ifdef tp}
  2141. not(use_big) and
  2142. {$endif}
  2143. assigned(_mangledname) then
  2144. strdispose(_mangledname);
  2145. inherited done;
  2146. end;
  2147. procedure tprocdef.write;
  2148. begin
  2149. inherited write;
  2150. {$ifdef Double_checksum}
  2151. current_ppu^.do_interface_crc:=false;
  2152. {$endif def Double_checksum}
  2153. {$ifdef i386}
  2154. writebyte(usedregisters);
  2155. {$endif i386}
  2156. {$ifdef m68k}
  2157. writeword(usedregisters);
  2158. {$endif}
  2159. {$ifdef alpha}
  2160. writelong(usedregisters_int);
  2161. writelong(usedregisters_fpu);
  2162. {$endif alpha}
  2163. writestring(mangledname);
  2164. writelong(extnumber);
  2165. {$ifdef Double_checksum}
  2166. current_ppu^.do_interface_crc:=true;
  2167. {$endif def Double_checksum}
  2168. if (options and pooperator) = 0 then
  2169. writedefref(nextoverloaded)
  2170. else
  2171. begin
  2172. { only write the overloads from the same unit }
  2173. if assigned(nextoverloaded) and
  2174. (nextoverloaded^.owner=owner) then
  2175. writedefref(nextoverloaded)
  2176. else
  2177. writedefref(nil);
  2178. end;
  2179. writedefref(_class);
  2180. if (options and poinline) <> 0 then
  2181. begin
  2182. { we need to save
  2183. - the para and the local symtable
  2184. - the code ptree !! PM
  2185. writesymtable(parast);
  2186. writesymtable(localst);
  2187. writeptree(ptree(code));
  2188. }
  2189. end;
  2190. current_ppu^.writeentry(ibprocdef);
  2191. end;
  2192. {$ifdef GDB}
  2193. procedure addparaname(p : psym);
  2194. var vs : char;
  2195. begin
  2196. if pvarsym(p)^.varspez = vs_value then vs := '1'
  2197. else vs := '0';
  2198. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  2199. end;
  2200. function tprocdef.stabstring : pchar;
  2201. var param : pdefcoll;
  2202. i : word;
  2203. oldrec : pchar;
  2204. begin
  2205. oldrec := stabrecstring;
  2206. getmem(StabRecString,1024);
  2207. param := para1;
  2208. i := 0;
  2209. while assigned(param) do
  2210. begin
  2211. inc(i);
  2212. param := param^.next;
  2213. end;
  2214. strpcopy(StabRecString,'f'+retdef^.numberstring);
  2215. if i>0 then
  2216. begin
  2217. strpcopy(strend(StabRecString),','+tostr(i)+';');
  2218. (* confuse gdb !! PM
  2219. if assigned(parast) then
  2220. {$IfDef TP}
  2221. parast^.foreach(addparaname)
  2222. {$Else}
  2223. parast^.foreach(@addparaname)
  2224. {$EndIf}
  2225. else
  2226. begin
  2227. param := para1;
  2228. i := 0;
  2229. while assigned(param) do
  2230. begin
  2231. inc(i);
  2232. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2233. {Here we have lost the parameter names !!}
  2234. {using lower case parameters }
  2235. strpcopy(strend(stabrecstring),'p'+tostr(i)
  2236. +':'+param^.data^.numberstring+','+vartyp+';');
  2237. param := param^.next;
  2238. end;
  2239. end; *)
  2240. {strpcopy(strend(StabRecString),';');}
  2241. end;
  2242. stabstring := strnew(stabrecstring);
  2243. freemem(stabrecstring,1024);
  2244. stabrecstring := oldrec;
  2245. end;
  2246. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  2247. begin
  2248. end;
  2249. {$endif GDB}
  2250. procedure tprocdef.deref;
  2251. begin
  2252. inherited deref;
  2253. resolvedef(pdef(nextoverloaded));
  2254. resolvedef(pdef(_class));
  2255. end;
  2256. function tprocdef.mangledname : string;
  2257. {$ifdef tp}
  2258. var
  2259. oldpos : longint;
  2260. s : string;
  2261. b : byte;
  2262. {$endif tp}
  2263. begin
  2264. {$ifdef tp}
  2265. if use_big then
  2266. begin
  2267. symbolstream.seek(longint(_mangledname));
  2268. symbolstream.read(b,1);
  2269. symbolstream.read(s[1],b);
  2270. s[0]:=chr(b);
  2271. mangledname:=s;
  2272. end
  2273. else
  2274. {$endif}
  2275. mangledname:=strpas(_mangledname);
  2276. if count then
  2277. is_used:=true;
  2278. end;
  2279. {$IfDef GDB}
  2280. function tprocdef.cplusplusmangledname : string;
  2281. var
  2282. s,s2 : string;
  2283. param : pdefcoll;
  2284. begin
  2285. s := sym^.name;
  2286. if _class <> nil then
  2287. begin
  2288. s2 := _class^.name^;
  2289. s := s+'__'+tostr(length(s2))+s2;
  2290. end else s := s + '_';
  2291. param := para1;
  2292. while assigned(param) do
  2293. begin
  2294. s2 := param^.data^.sym^.name;
  2295. s := s+tostr(length(s2))+s2;
  2296. param := param^.next;
  2297. end;
  2298. cplusplusmangledname:=s;
  2299. end;
  2300. {$EndIf GDB}
  2301. procedure tprocdef.setmangledname(const s : string);
  2302. begin
  2303. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  2304. strdispose(_mangledname);
  2305. setstring(_mangledname,s);
  2306. if assigned(parast) then
  2307. begin
  2308. stringdispose(parast^.name);
  2309. parast^.name:=stringdup('args of '+s);
  2310. end;
  2311. if assigned(localst) then
  2312. begin
  2313. stringdispose(localst^.name);
  2314. localst^.name:=stringdup('locals of '+s);
  2315. end;
  2316. end;
  2317. {***************************************************************************
  2318. TPROCVARDEF
  2319. ***************************************************************************}
  2320. constructor tprocvardef.init;
  2321. begin
  2322. inherited init;
  2323. deftype:=procvardef;
  2324. end;
  2325. constructor tprocvardef.load;
  2326. begin
  2327. inherited load;
  2328. deftype:=procvardef;
  2329. end;
  2330. procedure tprocvardef.write;
  2331. begin
  2332. { here we cannot get a real good value so just give something }
  2333. { plausible (PM) }
  2334. { a more secure way would be
  2335. to allways store in a temp }
  2336. if is_fpu(retdef) then
  2337. fpu_used:=2
  2338. else
  2339. fpu_used:=0;
  2340. inherited write;
  2341. current_ppu^.writeentry(ibprocvardef);
  2342. end;
  2343. function tprocvardef.size : longint;
  2344. begin
  2345. if (options and pomethodpointer)=0 then
  2346. size:=target_os.size_of_pointer
  2347. else
  2348. size:=2*target_os.size_of_pointer;
  2349. end;
  2350. {$ifdef GDB}
  2351. function tprocvardef.stabstring : pchar;
  2352. var
  2353. nss : pchar;
  2354. i : word;
  2355. param : pdefcoll;
  2356. begin
  2357. i := 0;
  2358. param := para1;
  2359. while assigned(param) do
  2360. begin
  2361. inc(i);
  2362. param := param^.next;
  2363. end;
  2364. getmem(nss,1024);
  2365. { it is not a function but a function pointer !! (PM) }
  2366. strpcopy(nss,'*f'+retdef^.numberstring{+','+tostr(i)}+';');
  2367. param := para1;
  2368. i := 0;
  2369. { this confuses gdb !!
  2370. we should use 'F' instead of 'f' but
  2371. as we use c++ language mode
  2372. it does not like that either
  2373. Please do not remove this part
  2374. might be used once
  2375. gdb for pascal is ready PM }
  2376. (* while assigned(param) do
  2377. begin
  2378. inc(i);
  2379. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2380. {Here we have lost the parameter names !!}
  2381. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2382. strcat(nss,pst);
  2383. strdispose(pst);
  2384. param := param^.next;
  2385. end; *)
  2386. {strpcopy(strend(nss),';');}
  2387. stabstring := strnew(nss);
  2388. freemem(nss,1024);
  2389. end;
  2390. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2391. begin
  2392. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2393. and not is_def_stab_written then
  2394. inherited concatstabto(asmlist);
  2395. is_def_stab_written:=true;
  2396. end;
  2397. {$endif GDB}
  2398. procedure tprocvardef.write_rtti_data;
  2399. begin
  2400. {!!!!!!!}
  2401. end;
  2402. procedure tprocvardef.write_child_rtti_data;
  2403. begin
  2404. {!!!!!!!!}
  2405. end;
  2406. function tprocvardef.is_publishable : boolean;
  2407. begin
  2408. is_publishable:=(options and pomethodpointer)<>0;
  2409. end;
  2410. {***************************************************************************
  2411. TOBJECTDEF
  2412. ***************************************************************************}
  2413. {$ifdef GDB}
  2414. const
  2415. vtabletype : word = 0;
  2416. vtableassigned : boolean = false;
  2417. {$endif GDB}
  2418. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2419. begin
  2420. tdef.init;
  2421. deftype:=objectdef;
  2422. options:=0;
  2423. childof:=nil;
  2424. publicsyms:=new(psymtable,init(objectsymtable));
  2425. publicsyms^.name := stringdup(n);
  2426. { create space for vmt !! }
  2427. {$ifdef OLDVMTSTYLE}
  2428. publicsyms^.datasize:=target_os.size_of_pointer;
  2429. options:=oo_hasvmt;
  2430. vmt_offset:=0;
  2431. {$else }
  2432. options:=0;
  2433. vmt_offset:=0;
  2434. publicsyms^.datasize:=0;
  2435. {$endif }
  2436. publicsyms^.defowner:=@self;
  2437. set_parent(c);
  2438. name:=stringdup(n);
  2439. end;
  2440. procedure tobjectdef.set_parent( c : pobjectdef);
  2441. begin
  2442. { nothing to do if the parent was not forward !}
  2443. if assigned(childof) then
  2444. exit;
  2445. childof:=c;
  2446. { some options are inherited !! }
  2447. if assigned(c) then
  2448. begin
  2449. options:= options or (c^.options and
  2450. (oo_hasvirtual or oo_hasprivate or
  2451. oo_hasprotected or
  2452. oo_hasconstructor or oo_hasdestructor
  2453. ));
  2454. { add the data of the anchestor class }
  2455. publicsyms^.datasize:=publicsyms^.datasize
  2456. +childof^.publicsyms^.datasize;
  2457. if ((options and oo_hasvmt)<>0) and
  2458. ((c^.options and oo_hasvmt)<>0) then
  2459. publicsyms^.datasize:=publicsyms^.datasize-target_os.size_of_pointer;
  2460. { if parent has a vmt field then
  2461. the offset is the same for the child PM }
  2462. if ((c^.options and oo_hasvmt)<>0) or isclass then
  2463. begin
  2464. vmt_offset:=c^.vmt_offset;
  2465. options:=options or oo_hasvmt;
  2466. end;
  2467. end;
  2468. savesize := publicsyms^.datasize;
  2469. end;
  2470. constructor tobjectdef.load;
  2471. var
  2472. oldread_member : boolean;
  2473. begin
  2474. tdef.load;
  2475. deftype:=objectdef;
  2476. savesize:=readlong;
  2477. vmt_offset:=readlong;
  2478. name:=stringdup(readstring);
  2479. childof:=pobjectdef(readdefref);
  2480. options:=readlong;
  2481. oldread_member:=read_member;
  2482. read_member:=true;
  2483. object_options:=true;
  2484. publicsyms:=new(psymtable,loadas(objectsymtable));
  2485. object_options:=false;
  2486. read_member:=oldread_member;
  2487. publicsyms^.defowner:=@self;
  2488. { publicsyms^.datasize:=savesize; }
  2489. publicsyms^.name := stringdup(name^);
  2490. { handles the predefined class tobject }
  2491. { the last TOBJECT which is loaded gets }
  2492. { it ! }
  2493. if (name^='TOBJECT') and not(cs_compilesystem in aktmoduleswitches) and
  2494. isclass and (childof=pointer($ffffffff)) then
  2495. class_tobject:=@self;
  2496. has_rtti:=true;
  2497. end;
  2498. procedure tobjectdef.insertvmt;
  2499. begin
  2500. if (options and oo_hasvmt)<>0 then
  2501. internalerror(12345)
  2502. else
  2503. begin
  2504. { first round up to multiple of 4 }
  2505. if (aktpackrecords=2) then
  2506. begin
  2507. if (publicsyms^.datasize and 1)<>0 then
  2508. inc(publicsyms^.datasize);
  2509. end;
  2510. if (aktpackrecords>=4) then
  2511. begin
  2512. if (publicsyms^.datasize mod 4) <> 0 then
  2513. publicsyms^.datasize:=publicsyms^.datasize+4-(publicsyms^.datasize mod 4);
  2514. end;
  2515. vmt_offset:=publicsyms^.datasize;
  2516. publicsyms^.datasize:=publicsyms^.datasize+target_os.size_of_pointer;
  2517. options:=options or oo_hasvmt;
  2518. end;
  2519. end;
  2520. procedure tobjectdef.check_forwards;
  2521. begin
  2522. publicsyms^.check_forwards;
  2523. if (options and oo_isforward)<>0 then
  2524. begin
  2525. { ok, in future, the forward can be resolved }
  2526. Message1(sym_e_class_forward_not_resolved,name^);
  2527. options:=options and not(oo_isforward);
  2528. end;
  2529. end;
  2530. destructor tobjectdef.done;
  2531. begin
  2532. {!!!!
  2533. if assigned(privatesyms) then
  2534. dispose(privatesyms,done);
  2535. if assigned(protectedsyms) then
  2536. dispose(protectedsyms,done); }
  2537. if assigned(publicsyms) then
  2538. dispose(publicsyms,done);
  2539. if (options and oo_isforward)<>0 then
  2540. Message1(sym_e_class_forward_not_resolved,name^);
  2541. stringdispose(name);
  2542. tdef.done;
  2543. end;
  2544. { true, if self inherits from d (or if they are equal) }
  2545. function tobjectdef.isrelated(d : pobjectdef) : boolean;
  2546. var
  2547. hp : pobjectdef;
  2548. begin
  2549. hp:=@self;
  2550. while assigned(hp) do
  2551. begin
  2552. if hp=d then
  2553. begin
  2554. isrelated:=true;
  2555. exit;
  2556. end;
  2557. hp:=hp^.childof;
  2558. end;
  2559. isrelated:=false;
  2560. end;
  2561. function tobjectdef.size : longint;
  2562. begin
  2563. if (options and oo_is_class)<>0 then
  2564. size:=target_os.size_of_pointer
  2565. else
  2566. size:=publicsyms^.datasize;
  2567. end;
  2568. procedure tobjectdef.deref;
  2569. var
  2570. hp : pdef;
  2571. oldrecsyms : psymtable;
  2572. begin
  2573. resolvedef(pdef(childof));
  2574. oldrecsyms:=aktrecordsymtable;
  2575. aktrecordsymtable:=publicsyms;
  2576. { nun die Definitionen dereferenzieren }
  2577. {$ifdef STORENUMBER}
  2578. hp:=pdef(publicsyms^.defindex^.first);
  2579. {$else}
  2580. hp:=publicsyms^.rootdef;
  2581. {$endif}
  2582. while assigned(hp) do
  2583. begin
  2584. hp^.deref;
  2585. { set owner }
  2586. hp^.owner:=publicsyms;
  2587. hp:=pdef(hp^.next);
  2588. end;
  2589. {$ifdef tp}
  2590. publicsyms^.foreach(derefsym);
  2591. {$else}
  2592. publicsyms^.foreach(@derefsym);
  2593. {$endif}
  2594. aktrecordsymtable:=oldrecsyms;
  2595. end;
  2596. function tobjectdef.vmt_mangledname : string;
  2597. {DM: I get a nil pointer on the owner name. I don't know if this
  2598. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2599. checks.}
  2600. var
  2601. s1,s2:string;
  2602. begin
  2603. if (options and oo_hasvmt)=0 then
  2604. {internalerror(12346);}
  2605. Message1(parser_object_has_no_vmt,name^);
  2606. if owner^.name=nil then
  2607. s1:=''
  2608. else
  2609. s1:=owner^.name^;
  2610. if name=nil then
  2611. s2:=''
  2612. else
  2613. s2:=name^;
  2614. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2615. end;
  2616. function tobjectdef.rtti_name : string;
  2617. var
  2618. s1,s2:string;
  2619. begin
  2620. if owner^.name=nil then
  2621. s1:=''
  2622. else
  2623. s1:=owner^.name^;
  2624. if name=nil then
  2625. s2:=''
  2626. else
  2627. s2:=name^;
  2628. rtti_name:='RTTI_'+s1+'$_'+s2;
  2629. end;
  2630. function tobjectdef.isclass : boolean;
  2631. begin
  2632. isclass:=(options and oo_is_class)<>0;
  2633. end;
  2634. procedure tobjectdef.write;
  2635. var
  2636. oldread_member : boolean;
  2637. begin
  2638. tdef.write;
  2639. writelong(size);
  2640. writelong(vmt_offset);
  2641. writestring(name^);
  2642. writedefref(childof);
  2643. writelong(options);
  2644. current_ppu^.writeentry(ibobjectdef);
  2645. oldread_member:=read_member;
  2646. read_member:=true;
  2647. object_options:=true;
  2648. publicsyms^.writeas;
  2649. object_options:=false;
  2650. read_member:=oldread_member;
  2651. end;
  2652. {$ifdef GDB}
  2653. procedure addprocname(p :psym);
  2654. var virtualind,argnames : string;
  2655. news, newrec : pchar;
  2656. pd,ipd : pprocdef;
  2657. lindex : longint;
  2658. para : pdefcoll;
  2659. arglength : byte;
  2660. sp : char;
  2661. begin
  2662. If p^.typ = procsym then
  2663. begin
  2664. pd := pprocsym(p)^.definition;
  2665. { this will be used for full implementation of object stabs
  2666. not yet done }
  2667. ipd := pd;
  2668. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2669. if (pd^.options and povirtualmethod) <> 0 then
  2670. begin
  2671. lindex := pd^.extnumber;
  2672. {doesnt seem to be necessary
  2673. lindex := lindex or $80000000;}
  2674. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2675. end else virtualind := '.';
  2676. { arguments are not listed here }
  2677. {we don't need another definition}
  2678. para := pd^.para1;
  2679. { used by gdbpas to recognize constructor and destructors }
  2680. if (pd^.options and poconstructor) <> 0 then
  2681. argnames:='__ct__'
  2682. else if (pd^.options and podestructor) <> 0 then
  2683. argnames:='__dt__'
  2684. else
  2685. argnames := '';
  2686. while assigned(para) do
  2687. begin
  2688. if para^.data^.deftype = formaldef then
  2689. begin
  2690. if para^.paratyp=vs_var then
  2691. argnames := argnames+'3var'
  2692. else if para^.paratyp=vs_const then
  2693. argnames:=argnames+'5const';
  2694. end
  2695. else
  2696. begin
  2697. { if the arg definition is like (v: ^byte;..
  2698. there is no sym attached to data !!! }
  2699. if assigned(para^.data^.sym) then
  2700. begin
  2701. arglength := length(para^.data^.sym^.name);
  2702. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2703. end
  2704. else
  2705. begin
  2706. argnames:=argnames+'11unnamedtype';
  2707. end;
  2708. end;
  2709. para := para^.next;
  2710. end;
  2711. ipd^.is_def_stab_written := true;
  2712. { here 2A must be changed for private and protected }
  2713. { 0 is private 1 protected and 2 public }
  2714. if (p^.properties and sp_private)<>0 then sp:='0'
  2715. else if (p^.properties and sp_protected)<>0 then sp:='1'
  2716. else sp:='2';
  2717. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2718. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2719. +virtualind+';');
  2720. { get spare place for a string at the end }
  2721. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2722. begin
  2723. getmem(news,stabrecsize+memsizeinc);
  2724. strcopy(news,stabrecstring);
  2725. freemem(stabrecstring,stabrecsize);
  2726. stabrecsize:=stabrecsize+memsizeinc;
  2727. stabrecstring:=news;
  2728. end;
  2729. strcat(StabRecstring,newrec);
  2730. {freemem(newrec,memsizeinc); }
  2731. strdispose(newrec);
  2732. {This should be used for case !!}
  2733. RecOffset := RecOffset + pd^.size;
  2734. end;
  2735. end;
  2736. function tobjectdef.stabstring : pchar;
  2737. var anc : pobjectdef;
  2738. oldrec : pchar;
  2739. oldrecsize : longint;
  2740. str_end : string;
  2741. {$ifndef nonextfield}
  2742. cur : psym;
  2743. {$endif nonextfield}
  2744. begin
  2745. oldrec := stabrecstring;
  2746. oldrecsize:=stabrecsize;
  2747. stabrecsize:=memsizeinc;
  2748. GetMem(stabrecstring,stabrecsize);
  2749. strpcopy(stabRecString,'s'+tostr(size));
  2750. if assigned(childof) then
  2751. {only one ancestor not virtual, public, at base offset 0 }
  2752. { !1 , 0 2 0 , }
  2753. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2754. {virtual table to implement yet}
  2755. RecOffset := 0;
  2756. {$ifdef nonextfield}
  2757. {$ifdef tp}
  2758. publicsyms^.foreach(addname);
  2759. {$else}
  2760. publicsyms^.foreach(@addname);
  2761. {$endif}
  2762. {$else nonextfield}
  2763. cur:=publicsyms^.searchroot;
  2764. while assigned(cur) do
  2765. begin
  2766. addname(cur);
  2767. cur:=cur^.nextsym;
  2768. end;
  2769. {$endif nonextfield}
  2770. if (options and oo_hasvmt) <> 0 then
  2771. if not assigned(childof) or ((childof^.options and oo_hasvmt) = 0) then
  2772. begin
  2773. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')
  2774. +','+tostr(vmt_offset*8)+';');
  2775. end;
  2776. {$ifdef nonextfield}
  2777. {$ifdef tp}
  2778. publicsyms^.foreach(addprocname);
  2779. {$else}
  2780. publicsyms^.foreach(@addprocname);
  2781. {$endif tp }
  2782. {$else nonextfield}
  2783. cur:=publicsyms^.searchroot;
  2784. while assigned(cur) do
  2785. begin
  2786. addprocname(cur);
  2787. cur:=cur^.nextsym;
  2788. end;
  2789. {$endif nonextfield}
  2790. if (options and oo_hasvmt) <> 0 then
  2791. begin
  2792. anc := @self;
  2793. while assigned(anc^.childof) and ((anc^.childof^.options and oo_hasvmt) <> 0) do
  2794. anc := anc^.childof;
  2795. str_end:=';~%'+anc^.numberstring+';';
  2796. end
  2797. else
  2798. str_end:=';';
  2799. strpcopy(strend(stabrecstring),str_end);
  2800. stabstring := strnew(StabRecString);
  2801. freemem(stabrecstring,stabrecsize);
  2802. stabrecstring := oldrec;
  2803. stabrecsize:=oldrecsize;
  2804. end;
  2805. {$endif GDB}
  2806. procedure tobjectdef.write_child_init_data;
  2807. begin
  2808. end;
  2809. procedure tobjectdef.write_init_data;
  2810. begin
  2811. if isclass then
  2812. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2813. else
  2814. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2815. { generate the name }
  2816. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2817. rttilist^.concat(new(pai_string,init(name^)));
  2818. rttilist^.concat(new(pai_const,init_32bit(size)));
  2819. count:=0;
  2820. publicsyms^.foreach(count_inittable_fields);
  2821. rttilist^.concat(new(pai_const,init_32bit(count)));
  2822. publicsyms^.foreach(write_field_inittable);
  2823. end;
  2824. function tobjectdef.needs_inittable : boolean;
  2825. var
  2826. oldb : boolean;
  2827. begin
  2828. { there are recursive calls to needs_inittable possible, }
  2829. { so we have to change to old value how else should }
  2830. { we do that ? check_rec_rtti can't be a nested }
  2831. { procedure of needs_rtti ! }
  2832. oldb:=binittable;
  2833. binittable:=false;
  2834. publicsyms^.foreach(check_rec_inittable);
  2835. needs_inittable:=binittable;
  2836. binittable:=oldb;
  2837. end;
  2838. procedure count_published_properties(sym : psym);{$ifndef fpc}far;{$endif}
  2839. begin
  2840. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2841. inc(count);
  2842. end;
  2843. procedure write_property_info(sym : psym);{$ifndef fpc}far;{$endif}
  2844. var
  2845. proctypesinfo : byte;
  2846. procedure writeproc(sym : psym;def : pdef;shiftvalue : byte);
  2847. var
  2848. typvalue : byte;
  2849. begin
  2850. if not(assigned(sym)) then
  2851. begin
  2852. rttilist^.concat(new(pai_const,init_32bit(1)));
  2853. typvalue:=3;
  2854. end
  2855. else if sym^.typ=varsym then
  2856. begin
  2857. rttilist^.concat(new(pai_const,init_32bit(
  2858. pvarsym(sym)^.address)));
  2859. typvalue:=0;
  2860. end
  2861. else
  2862. begin
  2863. if (pprocdef(def)^.options and povirtualmethod)=0 then
  2864. begin
  2865. rttilist^.concat(new(pai_const_symbol,init(pprocdef(def)^.mangledname)));
  2866. typvalue:=1;
  2867. end
  2868. else
  2869. begin
  2870. { virtual method, write vmt offset }
  2871. rttilist^.concat(new(pai_const,init_32bit(pprocdef(def)^.extnumber*4+12)));
  2872. typvalue:=2;
  2873. end;
  2874. end;
  2875. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  2876. end;
  2877. begin
  2878. if (ppropertysym(sym)^.options and ppo_indexed)<>0 then
  2879. proctypesinfo:=$40
  2880. else
  2881. proctypesinfo:=0;
  2882. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2883. begin
  2884. rttilist^.concat(new(pai_const_symbol,init(ppropertysym(sym)^.proptype^.get_rtti_label)));
  2885. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  2886. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  2887. { isn't it stored ? }
  2888. if (ppropertysym(sym)^.options and ppo_stored)=0 then
  2889. begin
  2890. rttilist^.concat(new(pai_const,init_32bit(1)));
  2891. proctypesinfo:=proctypesinfo or (3 shl 4);
  2892. end
  2893. else
  2894. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  2895. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  2896. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  2897. rttilist^.concat(new(pai_const,init_16bit(count)));
  2898. inc(count);
  2899. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  2900. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  2901. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  2902. end;
  2903. end;
  2904. procedure generate_published_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  2905. begin
  2906. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2907. ppropertysym(sym)^.proptype^.get_rtti_label;
  2908. end;
  2909. procedure tobjectdef.write_child_rtti_data;
  2910. begin
  2911. publicsyms^.foreach(generate_published_child_rtti);
  2912. end;
  2913. procedure tobjectdef.generate_rtti;
  2914. begin
  2915. has_rtti:=true;
  2916. getlabel(rtti_label);
  2917. write_child_rtti_data;
  2918. rttilist^.concat(new(pai_symbol,init_global(rtti_name)));
  2919. rttilist^.concat(new(pai_label,init(rtti_label)));
  2920. write_rtti_data;
  2921. end;
  2922. function tobjectdef.next_free_name_index : longint;
  2923. var
  2924. i : longint;
  2925. begin
  2926. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2927. i:=childof^.next_free_name_index
  2928. else
  2929. i:=0;
  2930. count:=0;
  2931. publicsyms^.foreach(count_published_properties);
  2932. next_free_name_index:=i+count;
  2933. end;
  2934. procedure tobjectdef.write_rtti_data;
  2935. begin
  2936. if isclass then
  2937. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2938. else
  2939. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2940. { generate the name }
  2941. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2942. rttilist^.concat(new(pai_string,init(name^)));
  2943. { write class type }
  2944. rttilist^.concat(new(pai_const_symbol,init(vmt_mangledname)));
  2945. { write owner typeinfo }
  2946. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2947. rttilist^.concat(new(pai_const_symbol,init(childof^.get_rtti_label)))
  2948. else
  2949. rttilist^.concat(new(pai_const,init_32bit(0)));
  2950. { count total number of properties }
  2951. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2952. count:=childof^.next_free_name_index
  2953. else
  2954. count:=0;
  2955. { write it }
  2956. publicsyms^.foreach(count_published_properties);
  2957. rttilist^.concat(new(pai_const,init_16bit(count)));
  2958. { write unit name }
  2959. if assigned(owner^.name) then
  2960. begin
  2961. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  2962. rttilist^.concat(new(pai_string,init(owner^.name^)));
  2963. end
  2964. else
  2965. rttilist^.concat(new(pai_const,init_8bit(0)));
  2966. { write published properties count }
  2967. count:=0;
  2968. publicsyms^.foreach(count_published_properties);
  2969. rttilist^.concat(new(pai_const,init_16bit(count)));
  2970. { count is used to write nameindex }
  2971. { but we need an offset of the owner }
  2972. { to give each property an own slot }
  2973. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2974. count:=childof^.next_free_name_index
  2975. else
  2976. count:=0;
  2977. publicsyms^.foreach(write_property_info);
  2978. end;
  2979. function tobjectdef.is_publishable : boolean;
  2980. begin
  2981. is_publishable:=isclass;
  2982. end;
  2983. function tobjectdef.get_rtti_label : string;
  2984. begin
  2985. get_rtti_label:=rtti_name;
  2986. end;
  2987. {****************************************************************************
  2988. TERRORDEF
  2989. ****************************************************************************}
  2990. constructor terrordef.init;
  2991. begin
  2992. inherited init;
  2993. deftype:=errordef;
  2994. end;
  2995. {$ifdef GDB}
  2996. function terrordef.stabstring : pchar;
  2997. begin
  2998. stabstring:=strpnew('error'+numberstring);
  2999. end;
  3000. {$endif GDB}
  3001. {
  3002. $Log$
  3003. Revision 1.103 1999-04-19 09:28:20 peter
  3004. * fixed crash when writing overload operator to ppu
  3005. Revision 1.102 1999/04/17 22:01:28 pierre
  3006. * typo error fix in STORENUMBER code
  3007. Revision 1.101 1999/04/14 09:14:58 peter
  3008. * first things to store the symbol/def number in the ppu
  3009. Revision 1.100 1999/04/08 15:57:51 peter
  3010. + subrange checking for readln()
  3011. Revision 1.99 1999/04/07 15:39:32 pierre
  3012. + double_checksum code added
  3013. Revision 1.98 1999/03/06 17:24:16 peter
  3014. * reset savesize in tdef.init
  3015. Revision 1.97 1999/03/01 13:45:04 pierre
  3016. + added staticppusymtable symtable type for local browsing
  3017. Revision 1.96 1999/02/25 21:02:52 peter
  3018. * ag386bin updates
  3019. + coff writer
  3020. Revision 1.95 1999/02/23 18:29:23 pierre
  3021. * win32 compilation error fix
  3022. + some work for local browser (not cl=omplete yet)
  3023. Revision 1.94 1999/02/22 20:13:38 florian
  3024. + first implementation of message keyword
  3025. Revision 1.93 1999/02/22 13:07:07 pierre
  3026. + -b and -bl options work !
  3027. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  3028. is not enabled when quitting global section
  3029. * local vars and procedures are not yet stored into PPU
  3030. Revision 1.92 1999/02/17 10:14:20 peter
  3031. * set the first enumsym also for subrange types
  3032. Revision 1.91 1999/02/08 09:51:21 pierre
  3033. * gdb info for local functions was wrong
  3034. Revision 1.90 1999/01/26 09:57:29 pierre
  3035. * open arrays stabs changed
  3036. Revision 1.89 1999/01/22 17:29:30 pierre
  3037. * overflow in addname for open arrays removed
  3038. Revision 1.88 1999/01/20 14:18:39 pierre
  3039. * bugs related to mangledname solved
  3040. - linux external without name
  3041. -external procs already used
  3042. (added count and is_used boolean fiels in tprocvar)
  3043. Revision 1.87 1999/01/19 10:56:05 pierre
  3044. typeof(object) without vmt generates an error instead of an internalerror
  3045. Revision 1.86 1999/01/12 14:25:32 peter
  3046. + BrowserLog for browser.log generation
  3047. + BrowserCol for browser info in TCollections
  3048. * released all other UseBrowser
  3049. Revision 1.85 1998/12/30 22:15:52 peter
  3050. + farpointer type
  3051. * absolutesym now also stores if its far
  3052. Revision 1.84 1998/12/30 13:41:12 peter
  3053. * released valuepara
  3054. Revision 1.83 1998/12/21 14:03:08 pierre
  3055. * procvar stabs correction
  3056. Revision 1.82 1998/12/19 00:23:52 florian
  3057. * ansistring memory leaks fixed
  3058. Revision 1.81 1998/12/11 08:57:22 pierre
  3059. * internal gdb types for booleans and 64bit integers
  3060. Revision 1.80 1998/12/10 09:47:26 florian
  3061. + basic operations with int64/qord (compiler with -dint64)
  3062. + rtti of enumerations extended: names are now written
  3063. Revision 1.79 1998/12/08 10:18:12 peter
  3064. + -gh for heaptrc unit
  3065. Revision 1.78 1998/12/08 09:06:30 pierre
  3066. + constructor destructor info for gdbpas
  3067. Revision 1.77 1998/12/01 23:37:39 pierre
  3068. * function type problem for gdb fix
  3069. Revision 1.76 1998/11/29 21:45:48 florian
  3070. * problem with arrays with init tables fixed
  3071. Revision 1.75 1998/11/29 12:45:59 peter
  3072. * hack for arraydef.size overflow
  3073. Revision 1.74 1998/11/27 14:50:47 peter
  3074. + open strings, $P switch support
  3075. Revision 1.73 1998/11/26 14:47:00 michael
  3076. + Fixed RTTI constants
  3077. Revision 1.72 1998/11/25 14:35:28 florian
  3078. * writting of rtti for properties fixed
  3079. Revision 1.71 1998/11/20 15:35:59 florian
  3080. * problems with rtti fixed, hope it works
  3081. Revision 1.70 1998/11/18 15:44:16 peter
  3082. * VALUEPARA for tp7 compatible value parameters
  3083. Revision 1.69 1998/11/10 17:54:56 peter
  3084. * removed warning
  3085. Revision 1.68 1998/11/05 23:34:36 peter
  3086. * don't dispose staticsymtable (caused crash under tp7 after a fatal
  3087. error)
  3088. Revision 1.67 1998/11/05 12:02:56 peter
  3089. * released useansistring
  3090. * removed -Sv, its now available in fpc modes
  3091. Revision 1.66 1998/10/26 22:58:22 florian
  3092. * new introduded problem with classes fix, the parent class wasn't set
  3093. correct, if the class was defined forward before
  3094. Revision 1.65 1998/10/26 14:19:28 pierre
  3095. + added options -lS and -lT for source and target os output
  3096. (to have a easier way to test OS_SOURCE abd OS_TARGET in makefiles)
  3097. * several problems with rtti data
  3098. (type of sym was not checked)
  3099. assumed to be varsym when they could be procsym or property syms !!
  3100. Revision 1.64 1998/10/22 17:11:21 pierre
  3101. + terminated the include exclude implementation for i386
  3102. * enums inside records fixed
  3103. Revision 1.63 1998/10/20 09:32:56 peter
  3104. * removed some unused vars
  3105. Revision 1.62 1998/10/20 08:06:58 pierre
  3106. * several memory corruptions due to double freemem solved
  3107. => never use p^.loc.location:=p^.left^.loc.location;
  3108. + finally I added now by default
  3109. that ra386dir translates global and unit symbols
  3110. + added a first field in tsymtable and
  3111. a nextsym field in tsym
  3112. (this allows to obtain ordered type info for
  3113. records and objects in gdb !)
  3114. Revision 1.61 1998/10/19 08:55:05 pierre
  3115. * wrong stabs info corrected once again !!
  3116. + variable vmt offset with vmt field only if required
  3117. implemented now !!!
  3118. Revision 1.60 1998/10/16 13:12:53 pierre
  3119. * added vmt_offsets in destructors code also !!!
  3120. * vmt_offset code for m68k
  3121. Revision 1.59 1998/10/16 08:51:51 peter
  3122. + target_os.stackalignment
  3123. + stack can be aligned at 2 or 4 byte boundaries
  3124. Revision 1.58 1998/10/15 15:13:30 pierre
  3125. + added oo_hasconstructor and oo_hasdestructor
  3126. for objects options
  3127. Revision 1.57 1998/10/14 15:54:20 pierre
  3128. * smallsets are not entirely implemented for
  3129. m68k added a ifdef usesmallset
  3130. that is allways defined for i386
  3131. (enables testing for m68k)
  3132. Revision 1.56 1998/10/09 11:47:56 pierre
  3133. * still more memory leaks fixes !!
  3134. Revision 1.55 1998/10/06 17:16:55 pierre
  3135. * some memory leaks fixed (thanks to Peter for heaptrc !)
  3136. Revision 1.54 1998/10/05 21:33:28 peter
  3137. * fixed 161,165,166,167,168
  3138. Revision 1.53 1998/10/05 12:48:39 pierre
  3139. * wrong handling of range check for arrays fixed
  3140. Revision 1.52 1998/10/02 07:20:38 florian
  3141. * range checking in units doesn't work if the units are smartlinked, fixed
  3142. Revision 1.51 1998/09/25 12:01:41 florian
  3143. * tobjectdef.publicsyms.datasize was set to savesize, this is wrong now
  3144. because the symtable size is read from the ppu file
  3145. Revision 1.50 1998/09/23 15:46:40 florian
  3146. * problem with with and classes fixed
  3147. Revision 1.49 1998/09/23 12:03:55 peter
  3148. * overloading fix for array of const
  3149. Revision 1.48 1998/09/22 15:37:23 peter
  3150. + array of const start
  3151. Revision 1.47 1998/09/21 15:46:01 michael
  3152. Applied florians fix for check_rec_inittable
  3153. Revision 1.46 1998/09/21 08:45:21 pierre
  3154. + added vmt_offset in tobjectdef.write for fututre use
  3155. (first steps to have objects without vmt if no virtual !!)
  3156. + added fpu_used field for tabstractprocdef :
  3157. sets this level to 2 if the functions return with value in FPU
  3158. (is then set to correct value at parsing of implementation)
  3159. THIS MIGHT refuse some code with FPU expression too complex
  3160. that were accepted before and even in some cases
  3161. that don't overflow in fact
  3162. ( like if f : float; is a forward that finally in implementation
  3163. only uses one fpu register !!)
  3164. Nevertheless I think that it will improve security on
  3165. FPU operations !!
  3166. * most other changes only for UseBrowser code
  3167. (added symtable references for record and objects)
  3168. local switch for refs to args and local of each function
  3169. (static symtable still missing)
  3170. UseBrowser still not stable and probably broken by
  3171. the definition hash array !!
  3172. Revision 1.45 1998/09/20 08:31:29 florian
  3173. + bit 6 of tpropinfo.propprocs is set, if the property contains a
  3174. constant index
  3175. Revision 1.44 1998/09/19 15:23:58 florian
  3176. * rtti for ordtypes corrected
  3177. Revision 1.43 1998/09/18 17:12:40 florian
  3178. * problem with writing of class references fixed
  3179. Revision 1.42 1998/09/17 13:41:20 pierre
  3180. sizeof(TPOINT) problem
  3181. Revision 1.40.2.2 1998/09/17 08:42:33 pierre
  3182. TPOINT sizeof fix
  3183. Revision 1.41 1998/09/15 17:39:30 jonas
  3184. + bugfix from bugfix branch
  3185. Revision 1.40.2.1 1998/09/15 17:35:32 jonas
  3186. * chenged string_typ in tstringdef.wideload from ansistring to widestring
  3187. Revision 1.40 1998/09/09 15:34:00 peter
  3188. * removed warnings
  3189. Revision 1.39 1998/09/08 10:23:44 pierre
  3190. * name field of filedef corrected
  3191. Revision 1.38 1998/09/07 23:10:23 florian
  3192. * a lot of stuff fixed regarding rtti and publishing of properties,
  3193. basics should now work
  3194. Revision 1.37 1998/09/07 19:33:24 florian
  3195. + some stuff for property rtti added:
  3196. - NameIndex of the TPropInfo record is now written correctly
  3197. - the DEFAULT/NODEFAULT keyword is supported now
  3198. - the default value and the storedsym/def are now written to
  3199. the PPU fiel
  3200. Revision 1.36 1998/09/07 17:37:01 florian
  3201. * first fixes for published properties
  3202. Revision 1.35 1998/09/06 22:42:02 florian
  3203. + rtti genreation for properties added
  3204. Revision 1.34 1998/09/04 18:15:02 peter
  3205. * filedef updated
  3206. Revision 1.33 1998/09/03 17:08:49 pierre
  3207. * better lines for stabs
  3208. (no scroll back to if before else part
  3209. no return to case line at jump outside case)
  3210. + source lines also if not in order
  3211. Revision 1.32 1998/09/03 16:03:20 florian
  3212. + rtti generation
  3213. * init table generation changed
  3214. Revision 1.31 1998/09/02 15:14:28 peter
  3215. * enum packing changed from len to max
  3216. Revision 1.30 1998/09/01 17:37:29 peter
  3217. * removed debug writeln :(
  3218. Revision 1.29 1998/09/01 12:53:25 peter
  3219. + aktpackenum
  3220. Revision 1.28 1998/09/01 07:54:22 pierre
  3221. * UseBrowser a little updated (might still be buggy !!)
  3222. * bug in psub.pas in function specifier removed
  3223. * stdcall allowed in interface and in implementation
  3224. (FPC will not yet complain if it is missing in either part
  3225. because stdcall is only a dummy !!)
  3226. Revision 1.27 1998/08/28 12:51:43 florian
  3227. + ansistring to pchar type cast fixed
  3228. Revision 1.26 1998/08/25 12:42:44 pierre
  3229. * CDECL changed to CVAR for variables
  3230. specifications are read in structures also
  3231. + started adding GPC compatibility mode ( option -Sp)
  3232. * names changed to lowercase
  3233. Revision 1.25 1998/08/23 21:04:38 florian
  3234. + rtti generation for classes added
  3235. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  3236. Revision 1.24 1998/08/20 12:53:26 peter
  3237. * object_options are always written for object syms
  3238. Revision 1.23 1998/08/19 00:42:42 peter
  3239. + subrange types for enums
  3240. + checking for bounds type with ranges
  3241. Revision 1.22 1998/08/17 10:10:10 peter
  3242. - removed OLDPPU
  3243. Revision 1.21 1998/08/10 14:50:28 peter
  3244. + localswitches, moduleswitches, globalswitches splitting
  3245. Revision 1.20 1998/07/18 22:54:30 florian
  3246. * some ansi/wide/longstring support fixed:
  3247. o parameter passing
  3248. o returning as result from functions
  3249. Revision 1.19 1998/07/14 14:47:05 peter
  3250. * released NEWINPUT
  3251. Revision 1.18 1998/07/10 10:51:04 peter
  3252. * m68k updates
  3253. Revision 1.16 1998/07/07 11:20:13 peter
  3254. + NEWINPUT for a better inputfile and scanner object
  3255. Revision 1.15 1998/06/24 14:48:37 peter
  3256. * ifdef newppu -> ifndef oldppu
  3257. Revision 1.14 1998/06/16 08:56:31 peter
  3258. + targetcpu
  3259. * cleaner pmodules for newppu
  3260. Revision 1.13 1998/06/15 15:38:09 pierre
  3261. * small bug in systems.pas corrected
  3262. + operators in different units better hanlded
  3263. Revision 1.12 1998/06/15 14:30:12 daniel
  3264. * Reverted my changes.
  3265. Revision 1.10 1998/06/13 00:10:16 peter
  3266. * working browser and newppu
  3267. * some small fixes against crashes which occured in bp7 (but not in
  3268. fpc?!)
  3269. Revision 1.9 1998/06/12 14:10:37 michael
  3270. * Fixed wrong code for ansistring
  3271. Revision 1.8 1998/06/11 10:11:58 peter
  3272. * -gb works again
  3273. Revision 1.7 1998/06/07 15:30:25 florian
  3274. + first working rtti
  3275. + data init/final. for local variables
  3276. Revision 1.6 1998/06/05 14:37:37 pierre
  3277. * fixes for inline for operators
  3278. * inline procedure more correctly restricted
  3279. Revision 1.5 1998/06/04 23:52:01 peter
  3280. * m68k compiles
  3281. + .def file creation moved to gendef.pas so it could also be used
  3282. for win32
  3283. Revision 1.4 1998/06/04 09:55:45 pierre
  3284. * demangled name of procsym reworked to become independant of the mangling
  3285. scheme
  3286. Revision 1.3 1998/06/03 22:49:03 peter
  3287. + wordbool,longbool
  3288. * rename bis,von -> high,low
  3289. * moved some systemunit loading/creating to psystem.pas
  3290. Revision 1.2 1998/05/31 14:13:37 peter
  3291. * fixed call bugs with assembler readers
  3292. + OPR_SYMBOL to hold a symbol in the asm parser
  3293. * fixed staticsymtable vars which were acessed through %ebp instead of
  3294. name
  3295. Revision 1.1 1998/05/27 19:45:09 peter
  3296. * symtable.pas splitted into includefiles
  3297. * symtable adapted for $ifndef OLDPPU
  3298. }