symdef.inc 115 KB

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