symdef.inc 110 KB

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