symtable.pas 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl, Pierre Muller
  4. This unit handles the symbol tables
  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. {$ifdef TP}
  19. {$N+,E+,F+}
  20. {$endif}
  21. unit symtable;
  22. interface
  23. uses
  24. {$ifdef TP}
  25. objects,
  26. {$endif}
  27. strings,cobjects,
  28. globtype,globals,tokens,systems,verbose,
  29. aasm
  30. {$ifdef i386}
  31. ,i386base
  32. {$endif}
  33. {$ifdef m68k}
  34. ,m68k
  35. {$endif}
  36. {$ifdef alpha}
  37. ,alpha
  38. {$endif}
  39. {$ifdef GDB}
  40. ,gdb
  41. {$endif}
  42. ;
  43. {************************************************
  44. Some internal constants
  45. ************************************************}
  46. const
  47. hasharraysize = 256;
  48. {$ifdef TP}
  49. indexgrowsize = 256;
  50. {$else}
  51. indexgrowsize = 1024;
  52. {$endif}
  53. {************************************************
  54. Constants
  55. ************************************************}
  56. {$i symconst.inc}
  57. {************************************************
  58. Needed forward pointers
  59. ************************************************}
  60. type
  61. { needed for owner (table) of symbol }
  62. psymtable = ^tsymtable;
  63. punitsymtable = ^tunitsymtable;
  64. { needed for names by the definitions }
  65. ptypesym = ^ttypesym;
  66. penumsym = ^tenumsym;
  67. pref = ^tref;
  68. tref = object
  69. nextref : pref;
  70. posinfo : tfileposinfo;
  71. moduleindex : word;
  72. is_written : boolean;
  73. constructor init(ref:pref;pos:pfileposinfo);
  74. destructor done; virtual;
  75. end;
  76. { Deref entry options }
  77. tdereftype = (derefnil,derefaktrecordindex,derefaktstaticindex,
  78. derefunit,derefrecord,derefindex,
  79. dereflocal,derefpara);
  80. pderef = ^tderef;
  81. tderef = object
  82. dereftype : tdereftype;
  83. index : word;
  84. next : pderef;
  85. constructor init(typ:tdereftype;i:word);
  86. destructor done;
  87. end;
  88. psymtableentry = ^tsymtableentry;
  89. tsymtableentry = object(tnamedindexobject)
  90. owner : psymtable;
  91. end;
  92. {************************************************
  93. TDef
  94. ************************************************}
  95. {$i symdefh.inc}
  96. {************************************************
  97. TSym
  98. ************************************************}
  99. {$i symsymh.inc}
  100. {************************************************
  101. TSymtable
  102. ************************************************}
  103. tsymtabletype = (invalidsymtable,withsymtable,staticsymtable,
  104. globalsymtable,unitsymtable,
  105. objectsymtable,recordsymtable,
  106. macrosymtable,localsymtable,
  107. parasymtable,inlineparasymtable,
  108. inlinelocalsymtable,stt_exceptsymtable,
  109. { only used for PPU reading of static part
  110. of a unit }
  111. staticppusymtable);
  112. tcallback = procedure(p : psym);
  113. tsearchhasharray = array[0..hasharraysize-1] of psym;
  114. psearchhasharray = ^tsearchhasharray;
  115. tsymtable = object
  116. symtabletype : tsymtabletype;
  117. unitid : word; { each symtable gets a number }
  118. name : pstring;
  119. datasize : longint;
  120. symindex,
  121. defindex : pindexarray;
  122. symsearch : pdictionary;
  123. next : psymtable;
  124. defowner : pdef; { for records and objects }
  125. { alignment used in this symtable }
  126. alignment : longint;
  127. { only used for parameter symtable to determine the offset relative }
  128. { to the frame pointer and for local inline }
  129. address_fixup : longint;
  130. { this saves all definition to allow a proper clean up }
  131. { separate lexlevel from symtable type }
  132. symtablelevel : byte;
  133. constructor init(t : tsymtabletype);
  134. destructor done;virtual;
  135. { access }
  136. function getdefnr(l : longint) : pdef;
  137. function getsymnr(l : longint) : psym;
  138. { load/write }
  139. constructor load;
  140. procedure write;
  141. constructor loadas(typ : tsymtabletype);
  142. procedure writeas;
  143. procedure loaddefs;
  144. procedure loadsyms;
  145. procedure writedefs;
  146. procedure writesyms;
  147. procedure deref;
  148. procedure clear;
  149. function rename(const olds,news : stringid):psym;
  150. procedure foreach(proc2call : tnamedindexcallback);
  151. function insert(sym : psym):psym;
  152. function search(const s : stringid) : psym;
  153. function speedsearch(const s : stringid;speedvalue : longint) : psym;
  154. procedure registerdef(p : pdef);
  155. procedure allsymbolsused;
  156. procedure allunitsused;
  157. procedure check_forwards;
  158. procedure checklabels;
  159. { change alignment for args only parasymtable }
  160. procedure set_alignment(_alignment : byte);
  161. { find arg having offset only parasymtable }
  162. function find_at_offset(l : longint) : pvarsym;
  163. {$ifdef CHAINPROCSYMS}
  164. procedure chainprocsyms;
  165. {$endif CHAINPROCSYMS}
  166. procedure load_browser;
  167. procedure write_browser;
  168. {$ifdef BrowserLog}
  169. procedure writebrowserlog;
  170. {$endif BrowserLog}
  171. {$ifdef GDB}
  172. procedure concatstabto(asmlist : paasmoutput);virtual;
  173. {$endif GDB}
  174. function getnewtypecount : word; virtual;
  175. end;
  176. tunitsymtable = object(tsymtable)
  177. unittypecount : word;
  178. unitsym : punitsym;
  179. {$ifdef GDB}
  180. dbx_count : longint;
  181. prev_dbx_counter : plongint;
  182. dbx_count_ok : boolean;
  183. is_stab_written : boolean;
  184. {$endif GDB}
  185. constructor init(t : tsymtabletype;const n : string);
  186. constructor loadasunit;
  187. destructor done;virtual;
  188. procedure writeasunit;
  189. {$ifdef GDB}
  190. procedure concattypestabto(asmlist : paasmoutput);
  191. {$endif GDB}
  192. procedure load_symtable_refs;
  193. function getnewtypecount : word; virtual;
  194. end;
  195. pwithsymtable = ^twithsymtable;
  196. twithsymtable = object(tsymtable)
  197. { used for withsymtable for allowing constructors }
  198. direct_with : boolean;
  199. { in fact it is a ptree }
  200. withnode : pointer;
  201. { ptree to load of direct with var }
  202. { already usable before firstwith
  203. needed for firstpass of function parameters PM }
  204. withrefnode : pointer;
  205. constructor init;
  206. destructor done;virtual;
  207. end;
  208. {****************************************************************************
  209. Var / Consts
  210. ****************************************************************************}
  211. const
  212. systemunit : punitsymtable = nil; { pointer to the system unit }
  213. objpasunit : punitsymtable = nil; { pointer to the objpas unit }
  214. current_object_option : symprop = sp_public;
  215. var
  216. { for STAB debugging }
  217. globaltypecount : word;
  218. pglobaltypecount : pword;
  219. registerdef : boolean; { true, when defs should be registered }
  220. defaultsymtablestack, { symtablestack after default units
  221. have been loaded }
  222. symtablestack : psymtable; { linked list of symtables }
  223. srsym : psym; { result of the last search }
  224. srsymtable : psymtable;
  225. lastsrsym : psym; { last sym found in statement }
  226. lastsrsymtable : psymtable;
  227. lastsymknown : boolean;
  228. forwardsallowed : boolean; { true, wenn forward pointers can be
  229. inserted }
  230. constsymtable : psymtable; { symtable were the constants can be
  231. inserted }
  232. voidpointerdef : ppointerdef; { pointer for Void-Pointerdef }
  233. charpointerdef : ppointerdef; { pointer for Char-Pointerdef }
  234. voidfarpointerdef : ppointerdef;
  235. cformaldef : pformaldef; { unique formal definition }
  236. voiddef : porddef; { Pointer to Void (procedure) }
  237. cchardef : porddef; { Pointer to Char }
  238. booldef : porddef; { pointer to boolean type }
  239. u8bitdef : porddef; { Pointer to 8-Bit unsigned }
  240. u16bitdef : porddef; { Pointer to 16-Bit unsigned }
  241. u32bitdef : porddef; { Pointer to 32-Bit unsigned }
  242. s32bitdef : porddef; { Pointer to 32-Bit signed }
  243. cu64bitdef : porddef; { pointer to 64 bit unsigned def }
  244. cs64bitintdef : porddef; { pointer to 64 bit signed def, }
  245. { calculated by the int unit on i386 }
  246. s32floatdef : pfloatdef; { pointer for realconstn }
  247. s64floatdef : pfloatdef; { pointer for realconstn }
  248. s80floatdef : pfloatdef; { pointer to type of temp. floats }
  249. s32fixeddef : pfloatdef; { pointer to type of temp. fixed }
  250. cshortstringdef : pstringdef; { pointer to type of short string const }
  251. clongstringdef : pstringdef; { pointer to type of long string const }
  252. cansistringdef : pstringdef; { pointer to type of ansi string const }
  253. cwidestringdef : pstringdef; { pointer to type of wide string const }
  254. openshortstringdef : pstringdef; { pointer to type of an open shortstring,
  255. needed for readln() }
  256. openchararraydef : parraydef; { pointer to type of an open array of char,
  257. needed for readln() }
  258. cfiledef : pfiledef; { get the same definition for all file }
  259. { uses for stabs }
  260. firstglobaldef, { linked list of all globals defs }
  261. lastglobaldef : pdef; { used to reset stabs/ranges }
  262. class_tobject : pobjectdef; { pointer to the anchestor of all }
  263. { clases }
  264. aktprocsym : pprocsym; { pointer to the symbol for the
  265. currently be parsed procedure }
  266. aktcallprocsym : pprocsym; { pointer to the symbol for the
  267. currently be called procedure,
  268. only set/unset in firstcall }
  269. aktvarsym : pvarsym; { pointer to the symbol for the
  270. currently read var, only used
  271. for variable directives }
  272. procprefix : string; { eindeutige Namen bei geschachtel- }
  273. { ten Unterprogrammen erzeugen }
  274. lexlevel : longint; { level of code }
  275. { 1 for main procedure }
  276. { 2 for normal function or proc }
  277. { higher for locals }
  278. const
  279. main_program_level = 1;
  280. unit_init_level = 1;
  281. normal_function_level = 2;
  282. in_loading : boolean = false;
  283. {$ifdef i386}
  284. bestrealdef : ^pfloatdef = @s80floatdef;
  285. {$endif}
  286. {$ifdef m68k}
  287. bestrealdef : ^pfloatdef = @s64floatdef;
  288. {$endif}
  289. var
  290. macros : psymtable; { pointer for die Symboltabelle mit }
  291. { Makros }
  292. read_member : boolean; { true, wenn Members aus einer PPU- }
  293. { Datei gelesen werden, d.h. ein }
  294. { varsym seine Adresse einlesen soll }
  295. generrorsym : psym; { Jokersymbol, wenn das richtige }
  296. { Symbol nicht gefunden wird }
  297. generrordef : pdef; { Jokersymbol for eine fehlerhafte }
  298. { Typdefinition }
  299. aktobjectdef : pobjectdef; { used for private functions check !! }
  300. const
  301. { last operator which can be overloaded }
  302. first_overloaded = PLUS;
  303. last_overloaded = ASSIGNMENT;
  304. var
  305. overloaded_operators : array[first_overloaded..last_overloaded] of pprocsym;
  306. { unequal is not equal}
  307. const
  308. overloaded_names : array [first_overloaded..last_overloaded] of string[16] =
  309. ('plus','minus','star','slash','equal',
  310. 'greater','lower','greater_or_equal',
  311. 'lower_or_equal','as','is','in','sym_diff',
  312. 'starstar','assign');
  313. {****************************************************************************
  314. Functions
  315. ****************************************************************************}
  316. {*** Misc ***}
  317. function globaldef(const s : string) : pdef;
  318. procedure duplicatesym(sym:psym);
  319. {*** Search ***}
  320. function search_a_symtable(const symbol:string;symtabletype:tsymtabletype):Psym;
  321. procedure getsym(const s : stringid;notfounderror : boolean);
  322. procedure getsymonlyin(p : psymtable;const s : stringid);
  323. {*** Forwards ***}
  324. procedure save_forward(ppd : ppointerdef;typesym : ptypesym);
  325. procedure resolve_forwards;
  326. {*** PPU Write/Loading ***}
  327. procedure writeunitas(const s : string;unittable : punitsymtable;only_crc : boolean);
  328. procedure closecurrentppu;
  329. procedure numberunits;
  330. procedure load_interface;
  331. {*** GDB ***}
  332. {$ifdef GDB}
  333. function typeglobalnumber(const s : string) : string;
  334. {$endif}
  335. {*** Definition ***}
  336. procedure reset_global_defs;
  337. {*** Object Helpers ***}
  338. function search_class_member(pd : pobjectdef;const n : string) : psym;
  339. function search_default_property(pd : pobjectdef) : ppropertysym;
  340. {*** Macro ***}
  341. procedure def_macro(const s : string);
  342. procedure set_macro(const s : string;value : string);
  343. {*** symtable stack ***}
  344. procedure dellexlevel;
  345. {$ifdef DEBUG}
  346. procedure test_symtablestack;
  347. procedure list_symtablestack;
  348. {$endif DEBUG}
  349. {*** dispose of a pdefcoll (args of a function) ***}
  350. procedure disposepdefcoll(var para1 : pdefcoll);
  351. {*** Init / Done ***}
  352. procedure InitSymtable;
  353. procedure DoneSymtable;
  354. implementation
  355. uses
  356. version,
  357. types,ppu,
  358. gendef,files
  359. ,tree
  360. {$ifdef newcg}
  361. ,cgbase
  362. {$else}
  363. ,hcodegen
  364. {$endif}
  365. {$ifdef BrowserLog}
  366. ,browlog
  367. {$endif BrowserLog}
  368. ;
  369. var
  370. aktrecordsymtable : psymtable; { current record read from ppu symtable }
  371. aktstaticsymtable : psymtable; { current static for local ppu symtable }
  372. {$ifdef GDB}
  373. asmoutput : paasmoutput;
  374. {$endif GDB}
  375. {$ifdef TP}
  376. {$ifndef dpmi}
  377. symbolstream : temsstream; { stream which is used to store some info }
  378. {$else}
  379. symbolstream : tmemorystream;
  380. {$endif}
  381. {$endif}
  382. {to dispose the global symtable of a unit }
  383. const
  384. dispose_global : boolean = false;
  385. memsizeinc = 2048; { for long stabstrings }
  386. tagtypes : Set of tdeftype =
  387. [recorddef,enumdef,
  388. {$IfNDef GDBKnowsStrings}
  389. stringdef,
  390. {$EndIf not GDBKnowsStrings}
  391. {$IfNDef GDBKnowsFiles}
  392. filedef,
  393. {$EndIf not GDBKnowsFiles}
  394. objectdef];
  395. {*****************************************************************************
  396. Helper Routines
  397. *****************************************************************************}
  398. function demangledparas(s : string) : string;
  399. var
  400. r : string;
  401. l : longint;
  402. begin
  403. demangledparas:='';
  404. r:=',';
  405. { delete leading $$'s }
  406. l:=pos('$$',s);
  407. while l<>0 do
  408. begin
  409. delete(s,1,l+1);
  410. l:=pos('$$',s);
  411. end;
  412. l:=pos('$',s);
  413. if l=0 then
  414. exit;
  415. delete(s,1,l);
  416. l:=pos('$',s);
  417. if l=0 then
  418. l:=length(s)+1;
  419. while s<>'' do
  420. begin
  421. r:=r+copy(s,1,l-1)+',';
  422. delete(s,1,l);
  423. end;
  424. delete(r,1,1);
  425. delete(r,length(r),1);
  426. demangledparas:=r;
  427. end;
  428. procedure numberunits;
  429. var
  430. counter : longint;
  431. hp : pused_unit;
  432. begin
  433. counter:=1;
  434. psymtable(current_module^.globalsymtable)^.unitid:=0;
  435. hp:=pused_unit(current_module^.used_units.first);
  436. while assigned(hp) do
  437. begin
  438. psymtable(hp^.u^.globalsymtable)^.unitid:=counter;
  439. inc(counter);
  440. hp:=pused_unit(hp^.next);
  441. end;
  442. end;
  443. procedure setstring(var p : pchar;const s : string);
  444. begin
  445. {$ifdef TP}
  446. if use_big then
  447. begin
  448. p:=pchar(symbolstream.getsize);
  449. symbolstream.seek(longint(p));
  450. symbolstream.writestr(@s);
  451. end
  452. else
  453. {$endif TP}
  454. p:=strpnew(s);
  455. end;
  456. procedure duplicatesym(sym:psym);
  457. begin
  458. Message1(sym_e_duplicate_id,sym^.name);
  459. with sym^.fileinfo do
  460. Message2(sym_h_duplicate_id_where,current_module^.sourcefiles^.get_file_name(fileindex),tostr(line));
  461. end;
  462. {****************************************************************************
  463. TRef
  464. ****************************************************************************}
  465. constructor tref.init(ref :pref;pos : pfileposinfo);
  466. begin
  467. nextref:=nil;
  468. if pos<>nil then
  469. posinfo:=pos^;
  470. if assigned(current_module) then
  471. moduleindex:=current_module^.unit_index;
  472. if assigned(ref) then
  473. ref^.nextref:=@self;
  474. is_written:=false;
  475. end;
  476. destructor tref.done;
  477. var
  478. inputfile : pinputfile;
  479. begin
  480. inputfile:=get_source_file(moduleindex,posinfo.fileindex);
  481. if inputfile<>nil then
  482. dec(inputfile^.ref_count);
  483. if assigned(nextref) then
  484. dispose(nextref,done);
  485. nextref:=nil;
  486. end;
  487. {****************************************************************************
  488. TDeref
  489. ****************************************************************************}
  490. constructor tderef.init(typ:tdereftype;i:word);
  491. begin
  492. dereftype:=typ;
  493. index:=i;
  494. next:=nil;
  495. end;
  496. destructor tderef.done;
  497. begin
  498. end;
  499. {*****************************************************************************
  500. PPU Reading Writing
  501. *****************************************************************************}
  502. {$I symppu.inc}
  503. {*****************************************************************************
  504. Definition Helpers
  505. *****************************************************************************}
  506. function globaldef(const s : string) : pdef;
  507. var st : string;
  508. symt : psymtable;
  509. begin
  510. srsym := nil;
  511. if pos('.',s) > 0 then
  512. begin
  513. st := copy(s,1,pos('.',s)-1);
  514. getsym(st,false);
  515. st := copy(s,pos('.',s)+1,255);
  516. if assigned(srsym) then
  517. begin
  518. if srsym^.typ = unitsym then
  519. begin
  520. symt := punitsym(srsym)^.unitsymtable;
  521. srsym := symt^.search(st);
  522. end else srsym := nil;
  523. end;
  524. end else st := s;
  525. if srsym = nil then getsym(st,false);
  526. if srsym = nil then
  527. getsymonlyin(systemunit,st);
  528. if srsym^.typ<>typesym then
  529. begin
  530. Message(type_e_type_id_expected);
  531. exit;
  532. end;
  533. globaldef := ptypesym(srsym)^.definition;
  534. end;
  535. {*****************************************************************************
  536. Symbol / Definition Resolving
  537. *****************************************************************************}
  538. procedure resolvederef(var p:pderef;var st:psymtable;var idx:word);
  539. var
  540. hp : pderef;
  541. pd : pdef;
  542. begin
  543. st:=nil;
  544. idx:=0;
  545. while assigned(p) do
  546. begin
  547. case p^.dereftype of
  548. derefaktrecordindex :
  549. begin
  550. st:=aktrecordsymtable;
  551. idx:=p^.index;
  552. end;
  553. derefaktstaticindex :
  554. begin
  555. st:=aktstaticsymtable;
  556. idx:=p^.index;
  557. end;
  558. derefunit :
  559. begin
  560. {$ifdef NEWMAP}
  561. st:=psymtable(current_module^.map^[p^.index]^.globalsymtable);
  562. {$else NEWMAP}
  563. st:=psymtable(current_module^.map^[p^.index]);
  564. {$endif NEWMAP}
  565. end;
  566. derefrecord :
  567. begin
  568. pd:=st^.getdefnr(p^.index);
  569. case pd^.deftype of
  570. recorddef :
  571. st:=precdef(pd)^.symtable;
  572. objectdef :
  573. st:=pobjectdef(pd)^.publicsyms;
  574. else
  575. internalerror(556658);
  576. end;
  577. end;
  578. dereflocal :
  579. begin
  580. pd:=st^.getdefnr(p^.index);
  581. case pd^.deftype of
  582. procdef :
  583. st:=pprocdef(pd)^.localst;
  584. else
  585. internalerror(556658);
  586. end;
  587. end;
  588. derefpara :
  589. begin
  590. pd:=st^.getdefnr(p^.index);
  591. case pd^.deftype of
  592. procdef :
  593. st:=pprocdef(pd)^.parast;
  594. else
  595. internalerror(556658);
  596. end;
  597. end;
  598. derefindex :
  599. begin
  600. idx:=p^.index;
  601. end;
  602. else
  603. internalerror(556658);
  604. end;
  605. hp:=p;
  606. p:=p^.next;
  607. dispose(hp,done);
  608. end;
  609. end;
  610. procedure resolvedef(var def:pdef);
  611. var
  612. st : psymtable;
  613. idx : word;
  614. begin
  615. resolvederef(pderef(def),st,idx);
  616. if assigned(st) then
  617. def:=st^.getdefnr(idx)
  618. else
  619. def:=nil;
  620. end;
  621. procedure resolvesym(var sym:psym);
  622. var
  623. st : psymtable;
  624. idx : word;
  625. begin
  626. resolvederef(pderef(sym),st,idx);
  627. if assigned(st) then
  628. sym:=st^.getsymnr(idx)
  629. else
  630. sym:=nil;
  631. end;
  632. {*****************************************************************************
  633. Symbol Call Back Functions
  634. *****************************************************************************}
  635. procedure derefsym(p : pnamedindexobject);
  636. begin
  637. psym(p)^.deref;
  638. end;
  639. procedure derefsymsdelayed(p : pnamedindexobject);
  640. begin
  641. if psym(p)^.typ in [absolutesym,propertysym] then
  642. psym(p)^.deref;
  643. end;
  644. procedure check_procsym_forward(sym : pnamedindexobject);
  645. begin
  646. if psym(sym)^.typ=procsym then
  647. pprocsym(sym)^.check_forward
  648. { check also object method table }
  649. { we needn't to test the def list }
  650. { because each object has to have a type sym }
  651. else
  652. if (psym(sym)^.typ=typesym) and
  653. assigned(ptypesym(sym)^.definition) and
  654. (ptypesym(sym)^.definition^.deftype=objectdef) then
  655. pobjectdef(ptypesym(sym)^.definition)^.check_forwards;
  656. end;
  657. procedure labeldefined(p : pnamedindexobject);
  658. begin
  659. if (psym(p)^.typ=labelsym) and
  660. not(plabelsym(p)^.defined) then
  661. Message1(sym_w_label_not_defined,p^.name);
  662. end;
  663. procedure unitsymbolused(p : pnamedindexobject);
  664. begin
  665. if (psym(p)^.typ=unitsym) and
  666. (punitsym(p)^.refs=0) then
  667. comment(V_info,'Unit '+p^.name+' is not used');
  668. end;
  669. procedure varsymbolused(p : pnamedindexobject);
  670. begin
  671. if (psym(p)^.typ=varsym) and
  672. ((psym(p)^.owner^.symtabletype in [parasymtable,localsymtable,staticsymtable])) then
  673. { unused symbol should be reported only if no }
  674. { error is reported }
  675. { if the symbol is in a register it is used }
  676. { also don't count the value parameters which have local copies }
  677. { also don't claim for high param of open parameters (PM) }
  678. if (pvarsym(p)^.refs=0) and
  679. (Errorcount=0) and
  680. (copy(p^.name,1,3)<>'val') and
  681. (copy(p^.name,1,4)<>'high') then
  682. begin
  683. if (psym(p)^.owner^.symtabletype=parasymtable) or pvarsym(p)^.islocalcopy then
  684. MessagePos1(psym(p)^.fileinfo,sym_h_para_identifier_not_used,p^.name)
  685. else
  686. MessagePos1(psym(p)^.fileinfo,sym_n_local_identifier_not_used,p^.name);
  687. end;
  688. end;
  689. {$ifdef GDB}
  690. procedure concatstab(p : pnamedindexobject);
  691. begin
  692. if psym(p)^.typ <> procsym then
  693. psym(p)^.concatstabto(asmoutput);
  694. end;
  695. procedure concattypestab(p : pnamedindexobject);
  696. begin
  697. if psym(p)^.typ = typesym then
  698. begin
  699. psym(p)^.isstabwritten:=false;
  700. psym(p)^.concatstabto(asmoutput);
  701. end;
  702. end;
  703. procedure forcestabto(asmlist : paasmoutput; pd : pdef);
  704. begin
  705. if not pd^.is_def_stab_written then
  706. begin
  707. if assigned(pd^.sym) then
  708. pd^.sym^.isusedinstab := true;
  709. pd^.concatstabto(asmlist);
  710. end;
  711. end;
  712. {$endif}
  713. {$ifdef CHAINPROCSYMS}
  714. procedure chainprocsym(p : psym);
  715. var
  716. storesymtablestack : psymtable;
  717. begin
  718. if p^.typ=procsym then
  719. begin
  720. storesymtablestack:=symtablestack;
  721. symtablestack:=p^.owner^.next;
  722. while assigned(symtablestack) do
  723. begin
  724. { search for same procsym in other units }
  725. getsym(p^.name,false);
  726. if assigned(srsym) and (srsym^.typ=procsym) then
  727. begin
  728. pprocsym(p)^.nextprocsym:=pprocsym(srsym);
  729. symtablestack:=storesymtablestack;
  730. exit;
  731. end
  732. else if srsym=nil then
  733. symtablestack:=nil
  734. else
  735. symtablestack:=srsymtable^.next;
  736. end;
  737. symtablestack:=storesymtablestack;
  738. end;
  739. end;
  740. {$endif}
  741. procedure write_refs(sym : pnamedindexobject);
  742. begin
  743. psym(sym)^.write_references;
  744. end;
  745. {$ifdef BrowserLog}
  746. procedure add_to_browserlog(p : psym);
  747. begin
  748. p^.add_to_browserlog;
  749. end;
  750. {$endif UseBrowser}
  751. {****************************************************************************
  752. Forward Resolving
  753. ****************************************************************************}
  754. type
  755. presolvelist = ^tresolvelist;
  756. tresolvelist = record
  757. p : ppointerdef;
  758. typ : ptypesym;
  759. next : presolvelist;
  760. end;
  761. var
  762. sroot : presolvelist;
  763. procedure save_forward(ppd : ppointerdef;typesym : ptypesym);
  764. var
  765. p : presolvelist;
  766. begin
  767. new(p);
  768. p^.next:=sroot;
  769. p^.p:=ppd;
  770. ppd^.defsym := typesym;
  771. p^.typ:=typesym;
  772. sroot:=p;
  773. end;
  774. procedure resolve_forwards;
  775. var
  776. p : presolvelist;
  777. begin
  778. p:=sroot;
  779. while p<>nil do
  780. begin
  781. sroot:=sroot^.next;
  782. p^.p^.definition:=p^.typ^.definition;
  783. dispose(p);
  784. p:=sroot;
  785. end;
  786. end;
  787. {*****************************************************************************
  788. Search Symtables for Syms
  789. *****************************************************************************}
  790. procedure getsym(const s : stringid;notfounderror : boolean);
  791. var
  792. speedvalue : longint;
  793. begin
  794. speedvalue:=getspeedvalue(s);
  795. lastsrsym:=nil;
  796. srsymtable:=symtablestack;
  797. while assigned(srsymtable) do
  798. begin
  799. srsym:=srsymtable^.speedsearch(s,speedvalue);
  800. if assigned(srsym) then
  801. exit
  802. else
  803. srsymtable:=srsymtable^.next;
  804. end;
  805. if forwardsallowed then
  806. begin
  807. srsymtable:=symtablestack;
  808. while (srsymtable^.symtabletype in [objectsymtable,recordsymtable]) do
  809. srsymtable:=srsymtable^.next;
  810. srsym:=new(ptypesym,init(s,nil));
  811. srsym^.properties:=sp_forwarddef;
  812. srsymtable^.insert(srsym);
  813. end
  814. else if notfounderror then
  815. begin
  816. Message1(sym_e_id_not_found,s);
  817. srsym:=generrorsym;
  818. end
  819. else srsym:=nil;
  820. end;
  821. procedure getsymonlyin(p : psymtable;const s : stringid);
  822. begin
  823. { the caller have to take care if srsym=nil (FK) }
  824. srsym:=nil;
  825. if assigned(p) then
  826. begin
  827. srsymtable:=p;
  828. srsym:=srsymtable^.search(s);
  829. if assigned(srsym) then
  830. exit
  831. else
  832. begin
  833. if (punitsymtable(srsymtable)=punitsymtable(current_module^.globalsymtable)) then
  834. begin
  835. getsymonlyin(psymtable(current_module^.localsymtable),s);
  836. if assigned(srsym) then
  837. srsymtable:=psymtable(current_module^.localsymtable)
  838. else
  839. Message1(sym_e_id_not_found,s);
  840. end
  841. else
  842. Message1(sym_e_id_not_found,s);
  843. end;
  844. end;
  845. end;
  846. function search_a_symtable(const symbol:string;symtabletype:tsymtabletype):Psym;
  847. {Search for a symbol in a specified symbol table. Returns nil if
  848. the symtable is not found, and also if the symbol cannot be found
  849. in the desired symtable }
  850. var hsymtab:Psymtable;
  851. res:Psym;
  852. begin
  853. res:=nil;
  854. hsymtab:=symtablestack;
  855. while (hsymtab<>nil) and (hsymtab^.symtabletype<>symtabletype) do
  856. hsymtab:=hsymtab^.next;
  857. if hsymtab<>nil then
  858. {We found the desired symtable. Now check if the symbol we
  859. search for is defined in it }
  860. res:=hsymtab^.search(symbol);
  861. search_a_symtable:=res;
  862. end;
  863. {****************************************************************************
  864. TSYMTABLE
  865. ****************************************************************************}
  866. constructor tsymtable.init(t : tsymtabletype);
  867. begin
  868. symtabletype:=t;
  869. symtablelevel:=0;
  870. defowner:=nil;
  871. unitid:=0;
  872. next:=nil;
  873. name:=nil;
  874. address_fixup:=0;
  875. datasize:=0;
  876. new(symindex,init(indexgrowsize));
  877. new(defindex,init(indexgrowsize));
  878. if symtabletype<>withsymtable then
  879. begin
  880. new(symsearch,init);
  881. symsearch^.noclear:=true;
  882. end
  883. else
  884. symsearch:=nil;
  885. alignment:=def_alignment;
  886. end;
  887. destructor tsymtable.done;
  888. begin
  889. stringdispose(name);
  890. dispose(symindex,done);
  891. dispose(defindex,done);
  892. { symsearch can already be disposed or set to nil for withsymtable }
  893. if assigned(symsearch) then
  894. begin
  895. dispose(symsearch,done);
  896. symsearch:=nil;
  897. end;
  898. end;
  899. constructor twithsymtable.init;
  900. begin
  901. inherited init(withsymtable);
  902. direct_with:=false;
  903. withnode:=nil;
  904. withrefnode:=nil;
  905. end;
  906. destructor twithsymtable.done;
  907. begin
  908. symsearch:=nil;
  909. inherited done;
  910. end;
  911. {***********************************************
  912. Helpers
  913. ***********************************************}
  914. function tsymtable.getnewtypecount : word;
  915. begin
  916. getnewtypecount:=pglobaltypecount^;
  917. inc(pglobaltypecount^);
  918. end;
  919. procedure tsymtable.registerdef(p : pdef);
  920. begin
  921. defindex^.insert(p);
  922. { set def owner and indexnb }
  923. p^.owner:=@self;
  924. end;
  925. procedure tsymtable.foreach(proc2call : tnamedindexcallback);
  926. begin
  927. symindex^.foreach(proc2call);
  928. end;
  929. {***********************************************
  930. LOAD / WRITE SYMTABLE FROM PPU
  931. ***********************************************}
  932. procedure tsymtable.loaddefs;
  933. var
  934. hp : pdef;
  935. b : byte;
  936. begin
  937. { load start of definition section, which holds the amount of defs }
  938. if current_ppu^.readentry<>ibstartdefs then
  939. Message(unit_f_ppu_read_error);
  940. current_ppu^.getlongint;
  941. { read definitions }
  942. repeat
  943. b:=current_ppu^.readentry;
  944. case b of
  945. ibpointerdef : hp:=new(ppointerdef,load);
  946. ibarraydef : hp:=new(parraydef,load);
  947. iborddef : hp:=new(porddef,load);
  948. ibfloatdef : hp:=new(pfloatdef,load);
  949. ibprocdef : hp:=new(pprocdef,load);
  950. ibshortstringdef : hp:=new(pstringdef,shortload);
  951. iblongstringdef : hp:=new(pstringdef,longload);
  952. ibansistringdef : hp:=new(pstringdef,ansiload);
  953. ibwidestringdef : hp:=new(pstringdef,wideload);
  954. ibrecorddef : hp:=new(precdef,load);
  955. ibobjectdef : hp:=new(pobjectdef,load);
  956. ibenumdef : hp:=new(penumdef,load);
  957. ibsetdef : hp:=new(psetdef,load);
  958. ibprocvardef : hp:=new(pprocvardef,load);
  959. ibfiledef : hp:=new(pfiledef,load);
  960. ibclassrefdef : hp:=new(pclassrefdef,load);
  961. ibformaldef : hp:=new(pformaldef,load);
  962. ibenddefs : break;
  963. ibend : Message(unit_f_ppu_read_error);
  964. else
  965. Message1(unit_f_ppu_invalid_entry,tostr(b));
  966. end;
  967. hp^.owner:=@self;
  968. defindex^.insert(hp);
  969. until false;
  970. end;
  971. procedure tsymtable.loadsyms;
  972. var
  973. b : byte;
  974. sym : psym;
  975. begin
  976. { load start of definition section, which holds the amount of defs }
  977. if current_ppu^.readentry<>ibstartsyms then
  978. Message(unit_f_ppu_read_error);
  979. { skip amount of symbols, not used currently }
  980. current_ppu^.getlongint;
  981. { load datasize of this symboltable }
  982. datasize:=current_ppu^.getlongint;
  983. { now read the symbols }
  984. repeat
  985. b:=current_ppu^.readentry;
  986. case b of
  987. ibtypesym : sym:=new(ptypesym,load);
  988. ibprocsym : sym:=new(pprocsym,load);
  989. ibconstsym : sym:=new(pconstsym,load);
  990. ibvarsym : sym:=new(pvarsym,load);
  991. ibfuncretsym : sym:=new(pfuncretsym,load);
  992. ibabsolutesym : sym:=new(pabsolutesym,load);
  993. ibenumsym : sym:=new(penumsym,load);
  994. ibtypedconstsym : sym:=new(ptypedconstsym,load);
  995. ibpropertysym : sym:=new(ppropertysym,load);
  996. ibunitsym : sym:=new(punitsym,load);
  997. iblabelsym : sym:=new(plabelsym,load);
  998. ibsyssym : sym:=new(psyssym,load);
  999. ibendsyms : break;
  1000. ibend : Message(unit_f_ppu_read_error);
  1001. else
  1002. Message1(unit_f_ppu_invalid_entry,tostr(b));
  1003. end;
  1004. sym^.owner:=@self;
  1005. symindex^.insert(sym);
  1006. symsearch^.insert(sym);
  1007. until false;
  1008. end;
  1009. procedure tsymtable.writedefs;
  1010. var
  1011. pd : pdef;
  1012. begin
  1013. { each definition get a number, write then the amount of defs to the
  1014. ibstartdef entry }
  1015. current_ppu^.putlongint(defindex^.count);
  1016. current_ppu^.writeentry(ibstartdefs);
  1017. { now write the definition }
  1018. pd:=pdef(defindex^.first);
  1019. while assigned(pd) do
  1020. begin
  1021. pd^.write;
  1022. pd:=pdef(pd^.next);
  1023. end;
  1024. { write end of definitions }
  1025. current_ppu^.writeentry(ibenddefs);
  1026. end;
  1027. procedure tsymtable.writesyms;
  1028. var
  1029. pd : psym;
  1030. begin
  1031. { each definition get a number, write then the amount of syms and the
  1032. datasize to the ibsymdef entry }
  1033. current_ppu^.putlongint(symindex^.count);
  1034. current_ppu^.putlongint(datasize);
  1035. current_ppu^.writeentry(ibstartsyms);
  1036. { foreach is used to write all symbols }
  1037. pd:=psym(symindex^.first);
  1038. while assigned(pd) do
  1039. begin
  1040. pd^.write;
  1041. pd:=psym(pd^.next);
  1042. end;
  1043. { end of symbols }
  1044. current_ppu^.writeentry(ibendsyms);
  1045. end;
  1046. procedure tsymtable.deref;
  1047. var
  1048. hp : pdef;
  1049. hs : psym;
  1050. begin
  1051. hp:=pdef(defindex^.first);
  1052. while assigned(hp) do
  1053. begin
  1054. hp^.deref;
  1055. hp^.symderef;
  1056. hp:=pdef(hp^.next);
  1057. end;
  1058. hs:=psym(symindex^.first);
  1059. while assigned(hs) do
  1060. begin
  1061. hs^.deref;
  1062. hs:=psym(hs^.next);
  1063. end;
  1064. end;
  1065. constructor tsymtable.load;
  1066. var
  1067. st_loading : boolean;
  1068. begin
  1069. st_loading:=in_loading;
  1070. in_loading:=true;
  1071. {$ifndef NEWMAP}
  1072. current_module^.map^[0]:=@self;
  1073. {$else NEWMAP}
  1074. current_module^.globalsymtable:=@self;
  1075. {$endif NEWMAP}
  1076. symtabletype:=unitsymtable;
  1077. symtablelevel:=0;
  1078. { unused for units }
  1079. address_fixup:=0;
  1080. datasize:=0;
  1081. defowner:=nil;
  1082. name:=nil;
  1083. unitid:=0;
  1084. defowner:=nil;
  1085. new(symindex,init(indexgrowsize));
  1086. new(defindex,init(indexgrowsize));
  1087. new(symsearch,init);
  1088. symsearch^.usehash;
  1089. symsearch^.noclear:=true;
  1090. alignment:=def_alignment;
  1091. { load definitions }
  1092. loaddefs;
  1093. { load symbols }
  1094. loadsyms;
  1095. { Now we can deref the symbols and definitions }
  1096. if not(symtabletype in [objectsymtable,recordsymtable]) then
  1097. deref;
  1098. {$ifdef NEWMAP}
  1099. { necessary for dependencies }
  1100. current_module^.globalsymtable:=nil;
  1101. {$endif NEWMAP}
  1102. in_loading:=st_loading;
  1103. end;
  1104. procedure tsymtable.write;
  1105. begin
  1106. { write definitions }
  1107. writedefs;
  1108. { write symbols }
  1109. writesyms;
  1110. end;
  1111. constructor tsymtable.loadas(typ : tsymtabletype);
  1112. var
  1113. storesymtable : psymtable;
  1114. st_loading : boolean;
  1115. begin
  1116. st_loading:=in_loading;
  1117. in_loading:=true;
  1118. symtabletype:=typ;
  1119. new(symindex,init(indexgrowsize));
  1120. new(defindex,init(indexgrowsize));
  1121. new(symsearch,init);
  1122. symsearch^.noclear:=true;
  1123. defowner:=nil;
  1124. storesymtable:=aktrecordsymtable;
  1125. if typ in [recordsymtable,objectsymtable,
  1126. parasymtable,localsymtable] then
  1127. aktrecordsymtable:=@self;
  1128. { used for local browser }
  1129. if typ=staticppusymtable then
  1130. begin
  1131. aktstaticsymtable:=@self;
  1132. symsearch^.usehash;
  1133. end;
  1134. name:=nil;
  1135. alignment:=def_alignment;
  1136. { isn't used there }
  1137. datasize:=0;
  1138. address_fixup:= 0;
  1139. { also unused }
  1140. unitid:=0;
  1141. { load definitions }
  1142. { we need the correct symtable for registering }
  1143. if not (typ in [recordsymtable,objectsymtable]) then
  1144. begin
  1145. next:=symtablestack;
  1146. symtablestack:=@self;
  1147. end;
  1148. { load definitions }
  1149. loaddefs;
  1150. { load symbols }
  1151. loadsyms;
  1152. { now we can deref the syms and defs }
  1153. if not (typ in [recordsymtable,objectsymtable]) then
  1154. deref;
  1155. aktrecordsymtable:=storesymtable;
  1156. if not (typ in [recordsymtable,objectsymtable]) then
  1157. begin
  1158. symtablestack:=next;
  1159. end;
  1160. in_loading:=st_loading;
  1161. end;
  1162. procedure tsymtable.writeas;
  1163. var
  1164. oldtyp : byte;
  1165. storesymtable : psymtable;
  1166. begin
  1167. oldtyp:=current_ppu^.entrytyp;
  1168. storesymtable:=aktrecordsymtable;
  1169. if symtabletype in [recordsymtable,objectsymtable,
  1170. parasymtable,localsymtable] then
  1171. aktrecordsymtable:=@self;
  1172. if (symtabletype in [recordsymtable,objectsymtable]) then
  1173. current_ppu^.entrytyp:=subentryid;
  1174. { write definitions }
  1175. writedefs;
  1176. { write symbols }
  1177. writesyms;
  1178. current_ppu^.entrytyp:=oldtyp;
  1179. aktrecordsymtable:=storesymtable;
  1180. end;
  1181. {***********************************************
  1182. Get Symbol / Def by Number
  1183. ***********************************************}
  1184. function tsymtable.getsymnr(l : longint) : psym;
  1185. var
  1186. hp : psym;
  1187. begin
  1188. hp:=psym(symindex^.search(l));
  1189. if hp=nil then
  1190. internalerror(10999);
  1191. getsymnr:=hp;
  1192. end;
  1193. function tsymtable.getdefnr(l : longint) : pdef;
  1194. var
  1195. hp : pdef;
  1196. begin
  1197. hp:=pdef(defindex^.search(l));
  1198. if hp=nil then
  1199. internalerror(10998);
  1200. getdefnr:=hp;
  1201. end;
  1202. {***********************************************
  1203. Table Access
  1204. ***********************************************}
  1205. procedure tsymtable.clear;
  1206. begin
  1207. { remove no entry from a withsymtable as it is only a pointer to the
  1208. recorddef or objectdef symtable }
  1209. if symtabletype=withsymtable then
  1210. exit;
  1211. symindex^.clear;
  1212. defindex^.clear;
  1213. end;
  1214. function tsymtable.insert(sym:psym):psym;
  1215. var
  1216. hp : psymtable;
  1217. hsym : psym;
  1218. begin
  1219. { set owner and sym indexnb }
  1220. sym^.owner:=@self;
  1221. {$ifdef CHAINPROCSYMS}
  1222. { set the nextprocsym field }
  1223. if sym^.typ=procsym then
  1224. chainprocsym(sym);
  1225. {$endif CHAINPROCSYMS}
  1226. { writes the symbol in data segment if required }
  1227. { also sets the datasize of owner }
  1228. if not in_loading then
  1229. sym^.insert_in_data;
  1230. if (symtabletype in [staticsymtable,globalsymtable]) then
  1231. begin
  1232. hp:=symtablestack;
  1233. while assigned(hp) do
  1234. begin
  1235. if hp^.symtabletype in [staticsymtable,globalsymtable] then
  1236. begin
  1237. hsym:=hp^.search(sym^.name);
  1238. if (assigned(hsym)) and
  1239. (hsym^.properties and sp_forwarddef=0) then
  1240. DuplicateSym(hsym);
  1241. end;
  1242. hp:=hp^.next;
  1243. end;
  1244. end;
  1245. { check for duplicate id in local and parsymtable symtable }
  1246. if (symtabletype=localsymtable) then
  1247. { to be on the sure side: }
  1248. begin
  1249. if assigned(next) and
  1250. (next^.symtabletype=parasymtable) then
  1251. begin
  1252. hsym:=next^.search(sym^.name);
  1253. if assigned(hsym) then
  1254. DuplicateSym(hsym);
  1255. end
  1256. else if (current_module^.flags and uf_local_browser)=0 then
  1257. internalerror(43789);
  1258. end;
  1259. { check for duplicate id in local symtable of methods }
  1260. if (symtabletype=localsymtable) and
  1261. assigned(next) and
  1262. assigned(next^.next) and
  1263. { funcretsym is allowed !! }
  1264. (sym^.typ <> funcretsym) and
  1265. (next^.next^.symtabletype=objectsymtable) then
  1266. begin
  1267. hsym:=search_class_member(pobjectdef(next^.next^.defowner),sym^.name);
  1268. { but private ids can be reused }
  1269. if assigned(hsym) and
  1270. ((hsym^.properties<>sp_private) or
  1271. (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
  1272. DuplicateSym(hsym);
  1273. end;
  1274. { check for duplicate field id in inherited classes }
  1275. if (sym^.typ=varsym) and
  1276. (symtabletype=objectsymtable) and
  1277. assigned(defowner) then
  1278. begin
  1279. hsym:=search_class_member(pobjectdef(defowner),sym^.name);
  1280. { but private ids can be reused }
  1281. if assigned(hsym) and
  1282. ((hsym^.properties<>sp_private) or
  1283. (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
  1284. DuplicateSym(hsym);
  1285. end;
  1286. if sym^.typ = typesym then
  1287. if assigned(ptypesym(sym)^.definition) then
  1288. begin
  1289. if not assigned(ptypesym(sym)^.definition^.owner) and
  1290. (ptypesym(sym)^.definition^.deftype<>errordef) then
  1291. registerdef(ptypesym(sym)^.definition);
  1292. {$ifdef GDB}
  1293. if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist)
  1294. and (symtabletype in [globalsymtable,staticsymtable]) then
  1295. begin
  1296. ptypesym(sym)^.isusedinstab := true;
  1297. sym^.concatstabto(debuglist);
  1298. end;
  1299. {$endif GDB}
  1300. end;
  1301. { insert in index and search hash }
  1302. symindex^.insert(sym);
  1303. symsearch^.insert(sym);
  1304. insert:=sym;
  1305. end;
  1306. function tsymtable.search(const s : stringid) : psym;
  1307. begin
  1308. search:=psym(symsearch^.search(s));
  1309. end;
  1310. function tsymtable.speedsearch(const s : stringid;speedvalue : longint) : psym;
  1311. var
  1312. hp : psym;
  1313. begin
  1314. hp:=psym(symsearch^.speedsearch(s,speedvalue));
  1315. if assigned(hp) then
  1316. begin
  1317. { reject non static members in static procedures,
  1318. be carefull aktprocsym^.definition is not allways
  1319. loaded already (PFV) }
  1320. if (symtabletype=objectsymtable) and
  1321. ((hp^.properties and sp_static)=0) and
  1322. allow_only_static
  1323. {assigned(aktprocsym) and
  1324. assigned(aktprocsym^.definition) and
  1325. ((aktprocsym^.definition^.options and postaticmethod)<>0)} then
  1326. Message(sym_e_only_static_in_static);
  1327. if (symtabletype=unitsymtable) and
  1328. assigned(punitsymtable(@self)^.unitsym) then
  1329. inc(punitsymtable(@self)^.unitsym^.refs);
  1330. { unitsym are only loaded for browsing PM }
  1331. { this was buggy anyway because we could use }
  1332. { unitsyms from other units in _USES !! }
  1333. if (symtabletype=unitsymtable) and (hp^.typ=unitsym) and
  1334. assigned(current_module) and (current_module^.globalsymtable<>@self) then
  1335. hp:=nil;
  1336. if assigned(hp) and
  1337. (cs_browser in aktmoduleswitches) and make_ref then
  1338. begin
  1339. hp^.lastref:=new(pref,init(hp^.lastref,@tokenpos));
  1340. { for symbols that are in tables without
  1341. browser info or syssyms (PM) }
  1342. if hp^.refcount=0 then
  1343. hp^.defref:=hp^.lastref;
  1344. inc(hp^.refcount);
  1345. end;
  1346. end;
  1347. speedsearch:=hp;
  1348. end;
  1349. function tsymtable.rename(const olds,news : stringid):psym;
  1350. begin
  1351. rename:=psym(symsearch^.rename(olds,news));
  1352. end;
  1353. {***********************************************
  1354. Browser
  1355. ***********************************************}
  1356. procedure tsymtable.load_browser;
  1357. var
  1358. b : byte;
  1359. sym : psym;
  1360. prdef : pdef;
  1361. oldrecsyms : psymtable;
  1362. begin
  1363. if symtabletype in [recordsymtable,objectsymtable,
  1364. parasymtable,localsymtable] then
  1365. begin
  1366. oldrecsyms:=aktrecordsymtable;
  1367. aktrecordsymtable:=@self;
  1368. end;
  1369. if symtabletype=staticppusymtable then
  1370. aktstaticsymtable:=@self;
  1371. b:=current_ppu^.readentry;
  1372. if b <> ibbeginsymtablebrowser then
  1373. Message1(unit_f_ppu_invalid_entry,tostr(b));
  1374. repeat
  1375. b:=current_ppu^.readentry;
  1376. case b of
  1377. ibsymref : begin
  1378. sym:=readsymref;
  1379. resolvesym(sym);
  1380. if assigned(sym) then
  1381. sym^.load_references;
  1382. end;
  1383. ibdefref : begin
  1384. prdef:=readdefref;
  1385. resolvedef(prdef);
  1386. if assigned(prdef) then
  1387. begin
  1388. if prdef^.deftype<>procdef then
  1389. Message(unit_f_ppu_read_error);
  1390. pprocdef(prdef)^.load_references;
  1391. end;
  1392. end;
  1393. ibendsymtablebrowser : break;
  1394. else
  1395. Message1(unit_f_ppu_invalid_entry,tostr(b));
  1396. end;
  1397. until false;
  1398. if symtabletype in [recordsymtable,objectsymtable,
  1399. parasymtable,localsymtable] then
  1400. aktrecordsymtable:=oldrecsyms;
  1401. end;
  1402. procedure tsymtable.write_browser;
  1403. var
  1404. oldrecsyms : psymtable;
  1405. begin
  1406. { symbol numbering for references
  1407. should have been done in write PM
  1408. number_symbols;
  1409. number_defs; }
  1410. if symtabletype in [recordsymtable,objectsymtable,
  1411. parasymtable,localsymtable] then
  1412. begin
  1413. oldrecsyms:=aktrecordsymtable;
  1414. aktrecordsymtable:=@self;
  1415. end;
  1416. current_ppu^.writeentry(ibbeginsymtablebrowser);
  1417. foreach({$ifndef TP}@{$endif}write_refs);
  1418. current_ppu^.writeentry(ibendsymtablebrowser);
  1419. if symtabletype in [recordsymtable,objectsymtable,
  1420. parasymtable,localsymtable] then
  1421. aktrecordsymtable:=oldrecsyms;
  1422. end;
  1423. {$ifdef BrowserLog}
  1424. procedure tsymtable.writebrowserlog;
  1425. begin
  1426. if cs_browser in aktmoduleswitches then
  1427. begin
  1428. if assigned(name) then
  1429. Browserlog.AddLog('---Symtable '+name^)
  1430. else
  1431. begin
  1432. if (symtabletype=recordsymtable) and
  1433. assigned(defowner^.sym) then
  1434. Browserlog.AddLog('---Symtable '+defowner^.sym^.name)
  1435. else
  1436. Browserlog.AddLog('---Symtable with no name');
  1437. end;
  1438. Browserlog.Ident;
  1439. foreach({$ifndef TP}@{$endif}add_to_browserlog);
  1440. browserlog.Unident;
  1441. end;
  1442. end;
  1443. {$endif BrowserLog}
  1444. {***********************************************
  1445. Process all entries
  1446. ***********************************************}
  1447. { checks, if all procsyms and methods are defined }
  1448. procedure tsymtable.check_forwards;
  1449. begin
  1450. foreach({$ifndef TP}@{$endif}check_procsym_forward);
  1451. end;
  1452. procedure tsymtable.checklabels;
  1453. begin
  1454. foreach({$ifndef TP}@{$endif}labeldefined);
  1455. end;
  1456. procedure tsymtable.set_alignment(_alignment : byte);
  1457. var
  1458. sym : pvarsym;
  1459. l : longint;
  1460. begin
  1461. { this can not be done if there is an
  1462. hasharray ! }
  1463. alignment:=_alignment;
  1464. if (symtabletype<>parasymtable) then
  1465. internalerror(1111);
  1466. sym:=pvarsym(symindex^.first);
  1467. datasize:=0;
  1468. { there can be only varsyms }
  1469. while assigned(sym) do
  1470. begin
  1471. l:=sym^.getpushsize;
  1472. sym^.address:=datasize;
  1473. datasize:=align(datasize+l,alignment);
  1474. sym:=pvarsym(sym^.next);
  1475. end;
  1476. end;
  1477. function tsymtable.find_at_offset(l : longint) : pvarsym;
  1478. var
  1479. sym : pvarsym;
  1480. begin
  1481. find_at_offset:=nil;
  1482. { this can not be done if there is an
  1483. hasharray ! }
  1484. if (symtabletype<>parasymtable) then
  1485. internalerror(1111);
  1486. sym:=pvarsym(symindex^.first);
  1487. while assigned(sym) do
  1488. begin
  1489. if sym^.address+address_fixup=l then
  1490. begin
  1491. find_at_offset:=sym;
  1492. exit;
  1493. end;
  1494. sym:=pvarsym(sym^.next);
  1495. end;
  1496. end;
  1497. procedure tsymtable.allunitsused;
  1498. begin
  1499. foreach({$ifndef TP}@{$endif}unitsymbolused);
  1500. end;
  1501. procedure tsymtable.allsymbolsused;
  1502. begin
  1503. foreach({$ifndef TP}@{$endif}varsymbolused);
  1504. end;
  1505. {$ifdef CHAINPROCSYMS}
  1506. procedure tsymtable.chainprocsyms;
  1507. begin
  1508. foreach({$ifndef TP}@{$endif}chainprocsym);
  1509. end;
  1510. {$endif CHAINPROCSYMS}
  1511. {$ifdef GDB}
  1512. procedure tsymtable.concatstabto(asmlist : paasmoutput);
  1513. begin
  1514. asmoutput:=asmlist;
  1515. foreach({$ifndef TP}@{$endif}concatstab);
  1516. end;
  1517. {$endif}
  1518. {****************************************************************************
  1519. TUNITSYMTABLE
  1520. ****************************************************************************}
  1521. constructor tunitsymtable.init(t : tsymtabletype; const n : string);
  1522. begin
  1523. inherited init(t);
  1524. name:=stringdup(upper(n));
  1525. unitid:=0;
  1526. unitsym:=nil;
  1527. symsearch^.usehash;
  1528. { reset GDB things }
  1529. {$ifdef GDB}
  1530. if t = globalsymtable then
  1531. begin
  1532. prev_dbx_counter := dbx_counter;
  1533. dbx_counter := @dbx_count;
  1534. end;
  1535. is_stab_written:=false;
  1536. if cs_gdb_dbx in aktglobalswitches then
  1537. begin
  1538. dbx_count := 0;
  1539. if (symtabletype=globalsymtable) then
  1540. pglobaltypecount := @unittypecount;
  1541. debuglist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0'))));
  1542. unitid:=current_module^.unitcount;
  1543. inc(current_module^.unitcount);
  1544. debuglist^.concat(new(pai_asm_comment,init(strpnew('Global '+name^+' has index '+tostr(unitid)))));
  1545. end;
  1546. {$endif GDB}
  1547. end;
  1548. constructor tunitsymtable.loadasunit;
  1549. var
  1550. storeGlobalTypeCount : pword;
  1551. b : byte;
  1552. begin
  1553. unitsym:=nil;
  1554. unitid:=0;
  1555. if (current_module^.flags and uf_has_dbx)<>0 then
  1556. begin
  1557. storeGlobalTypeCount:=PGlobalTypeCount;
  1558. PglobalTypeCount:=@UnitTypeCount;
  1559. end;
  1560. { load symtables }
  1561. inherited load;
  1562. { set the name after because it is set to nil in tsymtable.load !! }
  1563. name:=stringdup(current_module^.modulename^);
  1564. { dbx count }
  1565. {$ifdef GDB}
  1566. if (current_module^.flags and uf_has_dbx)<>0 then
  1567. begin
  1568. b := current_ppu^.readentry;
  1569. if b <> ibdbxcount then
  1570. Message(unit_f_ppu_dbx_count_problem)
  1571. else
  1572. dbx_count := readlong;
  1573. dbx_count_ok := true;
  1574. PGlobalTypeCount:=storeGlobalTypeCount;
  1575. end
  1576. else
  1577. dbx_count := 0;
  1578. is_stab_written:=false;
  1579. {$endif GDB}
  1580. b:=current_ppu^.readentry;
  1581. if b<>ibendimplementation then
  1582. Message1(unit_f_ppu_invalid_entry,tostr(b));
  1583. end;
  1584. destructor tunitsymtable.done;
  1585. var
  1586. pus : punitsym;
  1587. begin
  1588. pus:=unitsym;
  1589. while assigned(pus) do
  1590. begin
  1591. unitsym:=pus^.prevsym;
  1592. pus^.prevsym:=nil;
  1593. pus^.unitsymtable:=nil;
  1594. pus:=unitsym;
  1595. end;
  1596. inherited done;
  1597. end;
  1598. procedure tunitsymtable.load_symtable_refs;
  1599. var
  1600. b : byte;
  1601. unitindex : word;
  1602. begin
  1603. if ((current_module^.flags and uf_local_browser)<>0) then
  1604. begin
  1605. current_module^.localsymtable:=new(punitsymtable,loadas(staticppusymtable));
  1606. psymtable(current_module^.localsymtable)^.name:=
  1607. stringdup('implementation of '+psymtable(current_module^.globalsymtable)^.name^);
  1608. end;
  1609. { load browser }
  1610. if (current_module^.flags and uf_has_browser)<>0 then
  1611. begin
  1612. {if not (cs_browser in aktmoduleswitches) then
  1613. current_ppu^.skipuntilentry(ibendbrowser)
  1614. else }
  1615. begin
  1616. load_browser;
  1617. unitindex:=1;
  1618. while assigned(current_module^.map^[unitindex]) do
  1619. begin
  1620. {each unit wrote one browser entry }
  1621. load_browser;
  1622. inc(unitindex);
  1623. end;
  1624. b:=current_ppu^.readentry;
  1625. if b<>ibendbrowser then
  1626. Message1(unit_f_ppu_invalid_entry,tostr(b));
  1627. end;
  1628. end;
  1629. if ((current_module^.flags and uf_local_browser)<>0) then
  1630. psymtable(current_module^.localsymtable)^.load_browser;
  1631. end;
  1632. procedure tunitsymtable.writeasunit;
  1633. var
  1634. pu : pused_unit;
  1635. begin
  1636. { first the unitname }
  1637. current_ppu^.putstring(name^);
  1638. current_ppu^.writeentry(ibmodulename);
  1639. writesourcefiles;
  1640. writeusedunit;
  1641. { write the objectfiles and libraries that come for this unit,
  1642. preserve the containers becuase they are still needed to load
  1643. the link.res. All doesn't depend on the crc! It doesn't matter
  1644. if a unit is in a .o or .a file }
  1645. current_ppu^.do_crc:=false;
  1646. writecontainer(current_module^.linkunitfiles,iblinkunitfiles,true,true);
  1647. writecontainer(current_module^.linkofiles,iblinkofiles,true,false);
  1648. writecontainer(current_module^.linksharedlibs,iblinksharedlibs,true,true);
  1649. writecontainer(current_module^.linkstaticlibs,iblinkstaticlibs,true,true);
  1650. current_ppu^.do_crc:=true;
  1651. current_ppu^.writeentry(ibendinterface);
  1652. { write the symtable entries }
  1653. inherited write;
  1654. { write dbx count }
  1655. {$ifdef GDB}
  1656. if cs_gdb_dbx in aktglobalswitches then
  1657. begin
  1658. {$IfDef EXTDEBUG}
  1659. writeln('Writing dbx_count ',dbx_count,' in unit ',name^,'.ppu');
  1660. {$ENDIF EXTDEBUG}
  1661. current_ppu^.putlongint(dbx_count);
  1662. current_ppu^.writeentry(ibdbxcount);
  1663. end;
  1664. {$endif GDB}
  1665. current_ppu^.writeentry(ibendimplementation);
  1666. { write static symtable
  1667. needed for local debugging of unit functions }
  1668. if (current_module^.flags and uf_local_browser)<>0 then
  1669. psymtable(current_module^.localsymtable)^.write;
  1670. { write all browser section }
  1671. if (current_module^.flags and uf_has_browser)<>0 then
  1672. begin
  1673. current_ppu^.do_crc:=false; { doesn't affect crc }
  1674. write_browser;
  1675. pu:=pused_unit(current_module^.used_units.first);
  1676. while assigned(pu) do
  1677. begin
  1678. psymtable(pu^.u^.globalsymtable)^.write_browser;
  1679. pu:=pused_unit(pu^.next);
  1680. end;
  1681. current_ppu^.writeentry(ibendbrowser);
  1682. current_ppu^.do_crc:=true;
  1683. end;
  1684. if (current_module^.flags and uf_local_browser)<>0 then
  1685. psymtable(current_module^.localsymtable)^.write_browser;
  1686. { the last entry ibend is written automaticly }
  1687. end;
  1688. function tunitsymtable.getnewtypecount : word;
  1689. begin
  1690. {$ifdef GDB}
  1691. if not (cs_gdb_dbx in aktglobalswitches) then
  1692. getnewtypecount:=tsymtable.getnewtypecount
  1693. else
  1694. {$endif GDB}
  1695. if symtabletype = staticsymtable then
  1696. getnewtypecount:=tsymtable.getnewtypecount
  1697. else
  1698. begin
  1699. getnewtypecount:=unittypecount;
  1700. inc(unittypecount);
  1701. end;
  1702. end;
  1703. {$ifdef GDB}
  1704. procedure tunitsymtable.concattypestabto(asmlist : paasmoutput);
  1705. var prev_dbx_count : plongint;
  1706. begin
  1707. if is_stab_written then exit;
  1708. if not assigned(name) then name := stringdup('Main_program');
  1709. if symtabletype = unitsymtable then
  1710. begin
  1711. unitid:=current_module^.unitcount;
  1712. inc(current_module^.unitcount);
  1713. end;
  1714. asmlist^.concat(new(pai_asm_comment,init(strpnew('Begin unit '+name^
  1715. +' has index '+tostr(unitid)))));
  1716. if cs_gdb_dbx in aktglobalswitches then
  1717. begin
  1718. if dbx_count_ok then
  1719. begin
  1720. asmlist^.insert(new(pai_asm_comment,init(strpnew('"repeated" unit '+name^
  1721. +' has index '+tostr(unitid)))));
  1722. do_count_dbx:=true;
  1723. asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
  1724. +tostr(N_EXCL)+',0,0,'+tostr(dbx_count)))));
  1725. exit;
  1726. end;
  1727. prev_dbx_count := dbx_counter;
  1728. dbx_counter := nil;
  1729. if symtabletype = unitsymtable then
  1730. asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
  1731. +tostr(N_BINCL)+',0,0,0'))));
  1732. dbx_counter := @dbx_count;
  1733. end;
  1734. asmoutput:=asmlist;
  1735. foreach({$ifndef TP}@{$endif}concattypestab);
  1736. if cs_gdb_dbx in aktglobalswitches then
  1737. begin
  1738. dbx_counter := prev_dbx_count;
  1739. do_count_dbx:=true;
  1740. asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
  1741. +tostr(N_EINCL)+',0,0,0'))));
  1742. dbx_count_ok := true;
  1743. end;
  1744. asmlist^.concat(new(pai_asm_comment,init(strpnew('End unit '+name^
  1745. +' has index '+tostr(unitid)))));
  1746. is_stab_written:=true;
  1747. end;
  1748. {$endif}
  1749. {****************************************************************************
  1750. Definitions
  1751. ****************************************************************************}
  1752. {$I symdef.inc}
  1753. {****************************************************************************
  1754. Symbols
  1755. ****************************************************************************}
  1756. {$I symsym.inc}
  1757. {****************************************************************************
  1758. GDB Helpers
  1759. ****************************************************************************}
  1760. {$ifdef GDB}
  1761. function typeglobalnumber(const s : string) : string;
  1762. var st : string;
  1763. symt : psymtable;
  1764. old_make_ref : boolean;
  1765. begin
  1766. old_make_ref:=make_ref;
  1767. make_ref:=false;
  1768. typeglobalnumber := '0';
  1769. srsym := nil;
  1770. if pos('.',s) > 0 then
  1771. begin
  1772. st := copy(s,1,pos('.',s)-1);
  1773. getsym(st,false);
  1774. st := copy(s,pos('.',s)+1,255);
  1775. if assigned(srsym) then
  1776. begin
  1777. if srsym^.typ = unitsym then
  1778. begin
  1779. symt := punitsym(srsym)^.unitsymtable;
  1780. srsym := symt^.search(st);
  1781. end else srsym := nil;
  1782. end;
  1783. end else st := s;
  1784. if srsym = nil then getsym(st,true);
  1785. if srsym^.typ<>typesym then
  1786. begin
  1787. Message(type_e_type_id_expected);
  1788. exit;
  1789. end;
  1790. typeglobalnumber := ptypesym(srsym)^.definition^.numberstring;
  1791. make_ref:=old_make_ref;
  1792. end;
  1793. {$endif GDB}
  1794. {****************************************************************************
  1795. Definition Helpers
  1796. ****************************************************************************}
  1797. procedure reset_global_defs;
  1798. var
  1799. def : pdef;
  1800. {$ifdef debug}
  1801. prevdef : pdef;
  1802. {$endif debug}
  1803. begin
  1804. {$ifdef debug}
  1805. prevdef:=nil;
  1806. {$endif debug}
  1807. {$ifdef GDB}
  1808. pglobaltypecount:=@globaltypecount;
  1809. {$endif GDB}
  1810. def:=firstglobaldef;
  1811. while assigned(def) do
  1812. begin
  1813. {$ifdef GDB}
  1814. if assigned(def^.sym) then
  1815. def^.sym^.isusedinstab:=false;
  1816. def^.is_def_stab_written:=false;
  1817. {$endif GDB}
  1818. {if not current_module^.in_implementation then}
  1819. begin
  1820. { reset rangenr's }
  1821. case def^.deftype of
  1822. orddef : porddef(def)^.rangenr:=0;
  1823. enumdef : penumdef(def)^.rangenr:=0;
  1824. arraydef : parraydef(def)^.rangenr:=0;
  1825. end;
  1826. if def^.deftype<>objectdef then
  1827. def^.has_rtti:=false;
  1828. def^.has_inittable:=false;
  1829. end;
  1830. {$ifdef debug}
  1831. prevdef:=def;
  1832. {$endif debug}
  1833. def:=def^.nextglobal;
  1834. end;
  1835. end;
  1836. {****************************************************************************
  1837. Object Helpers
  1838. ****************************************************************************}
  1839. function search_class_member(pd : pobjectdef;const n : string) : psym;
  1840. { searches n in symtable of pd and all anchestors }
  1841. var
  1842. sym : psym;
  1843. begin
  1844. sym:=nil;
  1845. while assigned(pd) do
  1846. begin
  1847. sym:=pd^.publicsyms^.search(n);
  1848. if assigned(sym) then
  1849. break;
  1850. pd:=pd^.childof;
  1851. end;
  1852. { this is needed for static methods in do_member_read pexpr unit PM
  1853. caused bug0214 }
  1854. if assigned(sym) then
  1855. begin
  1856. srsymtable:=pd^.publicsyms;
  1857. end;
  1858. search_class_member:=sym;
  1859. end;
  1860. var
  1861. _defaultprop : ppropertysym;
  1862. procedure testfordefaultproperty(p : pnamedindexobject);
  1863. begin
  1864. if (psym(p)^.typ=propertysym) and ((ppropertysym(p)^.options and ppo_defaultproperty)<>0) then
  1865. _defaultprop:=ppropertysym(p);
  1866. end;
  1867. function search_default_property(pd : pobjectdef) : ppropertysym;
  1868. { returns the default property of a class, searches also anchestors }
  1869. begin
  1870. _defaultprop:=nil;
  1871. while assigned(pd) do
  1872. begin
  1873. pd^.publicsyms^.foreach({$ifndef TP}@{$endif}testfordefaultproperty);
  1874. if assigned(_defaultprop) then
  1875. break;
  1876. pd:=pd^.childof;
  1877. end;
  1878. search_default_property:=_defaultprop;
  1879. end;
  1880. {****************************************************************************
  1881. Macro's
  1882. ****************************************************************************}
  1883. procedure def_macro(const s : string);
  1884. var
  1885. mac : pmacrosym;
  1886. begin
  1887. mac:=pmacrosym(macros^.search(s));
  1888. if mac=nil then
  1889. begin
  1890. mac:=new(pmacrosym,init(s));
  1891. Message1(parser_m_macro_defined,mac^.name);
  1892. macros^.insert(mac);
  1893. end;
  1894. mac^.defined:=true;
  1895. end;
  1896. procedure set_macro(const s : string;value : string);
  1897. var
  1898. mac : pmacrosym;
  1899. begin
  1900. mac:=pmacrosym(macros^.search(s));
  1901. if mac=nil then
  1902. begin
  1903. mac:=new(pmacrosym,init(s));
  1904. macros^.insert(mac);
  1905. end
  1906. else
  1907. begin
  1908. if assigned(mac^.buftext) then
  1909. freemem(mac^.buftext,mac^.buflen);
  1910. end;
  1911. Message2(parser_m_macro_set_to,mac^.name,value);
  1912. mac^.buflen:=length(value);
  1913. getmem(mac^.buftext,mac^.buflen);
  1914. move(value[1],mac^.buftext^,mac^.buflen);
  1915. mac^.defined:=true;
  1916. end;
  1917. {****************************************************************************
  1918. Symtable Stack
  1919. ****************************************************************************}
  1920. procedure dellexlevel;
  1921. var
  1922. p : psymtable;
  1923. begin
  1924. p:=symtablestack;
  1925. symtablestack:=p^.next;
  1926. { symbol tables of unit interfaces are never disposed }
  1927. { this is handle by the unit unitm }
  1928. if not(p^.symtabletype in [unitsymtable,globalsymtable,stt_exceptsymtable]) or dispose_global then
  1929. dispose(p,done);
  1930. end;
  1931. {$ifdef DEBUG}
  1932. procedure test_symtablestack;
  1933. var
  1934. p : psymtable;
  1935. i : longint;
  1936. begin
  1937. p:=symtablestack;
  1938. i:=0;
  1939. while assigned(p) do
  1940. begin
  1941. inc(i);
  1942. p:=p^.next;
  1943. if i>500 then
  1944. Message(sym_f_internal_error_in_symtablestack);
  1945. end;
  1946. end;
  1947. procedure list_symtablestack;
  1948. var
  1949. p : psymtable;
  1950. i : longint;
  1951. begin
  1952. p:=symtablestack;
  1953. i:=0;
  1954. while assigned(p) do
  1955. begin
  1956. inc(i);
  1957. writeln(i,' ',p^.name^);
  1958. p:=p^.next;
  1959. if i>500 then
  1960. Message(sym_f_internal_error_in_symtablestack);
  1961. end;
  1962. end;
  1963. {$endif DEBUG}
  1964. {****************************************************************************
  1965. Init/Done Symtable
  1966. ****************************************************************************}
  1967. {$ifdef tp}
  1968. procedure do_streamerror;
  1969. begin
  1970. if symbolstream.status=-2 then
  1971. WriteLn('Error: Not enough EMS memory')
  1972. else
  1973. WriteLn('Error: EMS Error ',symbolstream.status);
  1974. halt(1);
  1975. end;
  1976. {$endif TP}
  1977. procedure InitSymtable;
  1978. begin
  1979. {$ifdef TP}
  1980. { Allocate stream }
  1981. if use_big then
  1982. begin
  1983. streamerror:=@do_streamerror;
  1984. { symbolstream.init('TMPFILE',stcreate,16000); }
  1985. {$ifndef dpmi}
  1986. symbolstream.init(10000,4000000); {using ems streams}
  1987. {$else}
  1988. symbolstream.init(1000000,16000); {using memory streams}
  1989. {$endif}
  1990. if symbolstream.errorinfo=stiniterror then
  1991. do_streamerror;
  1992. { write something, because pos 0 means nil pointer }
  1993. symbolstream.writestr(@inputfile);
  1994. end;
  1995. {$endif tp}
  1996. { Reset symbolstack }
  1997. registerdef:=false;
  1998. read_member:=false;
  1999. symtablestack:=nil;
  2000. systemunit:=nil;
  2001. objpasunit:=nil;
  2002. sroot:=nil;
  2003. {$ifdef GDB}
  2004. firstglobaldef:=nil;
  2005. lastglobaldef:=nil;
  2006. {$endif GDB}
  2007. globaltypecount:=1;
  2008. pglobaltypecount:=@globaltypecount;
  2009. { create error syms and def }
  2010. generrorsym:=new(perrorsym,init);
  2011. generrordef:=new(perrordef,init);
  2012. end;
  2013. procedure DoneSymtable;
  2014. begin
  2015. dispose(generrorsym,done);
  2016. dispose(generrordef,done);
  2017. { unload all symtables
  2018. done with loaded_units
  2019. dispose_global:=true;
  2020. while assigned(symtablestack) do
  2021. dellexlevel; }
  2022. {$ifdef TP}
  2023. { close the stream }
  2024. if use_big then
  2025. symbolstream.done;
  2026. {$endif}
  2027. end;
  2028. end.
  2029. {
  2030. $Log$
  2031. Revision 1.22 1999-06-22 16:24:49 pierre
  2032. * local browser stuff corrected
  2033. Revision 1.21 1999/06/08 22:23:50 pierre
  2034. * staticppusymtable was loaded a tsymtable instead of tunitsymtable
  2035. Revision 1.20 1999/06/02 22:44:23 pierre
  2036. * previous wrong log corrected
  2037. Revision 1.19 1999/06/02 22:25:53 pierre
  2038. * changed $ifdef FPC @ into $ifndef TP
  2039. Revision 1.18 1999/06/01 14:45:58 peter
  2040. * @procvar is now always needed for FPC
  2041. Revision 1.17 1999/05/27 19:45:08 peter
  2042. * removed oldasm
  2043. * plabel -> pasmlabel
  2044. * -a switches to source writing automaticly
  2045. * assembler readers OOPed
  2046. * asmsymbol automaticly external
  2047. * jumptables and other label fixes for asm readers
  2048. Revision 1.16 1999/05/23 18:42:16 florian
  2049. * better error recovering in typed constants
  2050. * some problems with arrays of const fixed, some problems
  2051. due my previous
  2052. - the location type of array constructor is now LOC_MEM
  2053. - the pushing of high fixed
  2054. - parameter copying fixed
  2055. - zero temp. allocation removed
  2056. * small problem in the assembler writers fixed:
  2057. ref to nil wasn't written correctly
  2058. Revision 1.15 1999/05/17 23:51:41 peter
  2059. * with temp vars now use a reference with a persistant temp instead
  2060. of setting datasize
  2061. Revision 1.14 1999/05/14 17:52:29 peter
  2062. * new deref code
  2063. Revision 1.13 1999/05/13 21:59:48 peter
  2064. * removed oldppu code
  2065. * warning if objpas is loaded from uses
  2066. * first things for new deref writing
  2067. Revision 1.12 1999/05/10 22:34:59 pierre
  2068. * one more unitsym problem fix
  2069. Revision 1.11 1999/05/10 15:02:51 pierre
  2070. unitsym finally problem fixed
  2071. Revision 1.10 1999/05/09 12:46:26 peter
  2072. + hint where a duplicate sym is already defined
  2073. Revision 1.9 1999/05/08 19:52:40 peter
  2074. + MessagePos() which is enhanced Message() function but also gets the
  2075. position info
  2076. * Removed comp warnings
  2077. Revision 1.8 1999/05/06 21:38:38 peter
  2078. * don't register errordef
  2079. Revision 1.7 1999/05/06 09:05:31 peter
  2080. * generic write_float and str_float
  2081. * fixed constant float conversions
  2082. Revision 1.6 1999/05/05 09:19:16 florian
  2083. * more fixes to get it with delphi running
  2084. Revision 1.5 1999/05/01 13:24:43 peter
  2085. * merged nasm compiler
  2086. * old asm moved to oldasm/
  2087. Revision 1.4 1999/04/29 17:25:37 peter
  2088. * small fix for deref
  2089. Revision 1.3 1999/04/26 18:30:03 peter
  2090. * farpointerdef moved into pointerdef.is_far
  2091. Revision 1.151 1999/04/26 13:31:54 peter
  2092. * release storenumber,double_checksum
  2093. Revision 1.150 1999/04/25 17:36:13 peter
  2094. * typo fix for storenumber
  2095. Revision 1.149 1999/04/21 22:05:28 pierre
  2096. + tsymtable.find_at_offset function
  2097. used by ra386att to give arg name from ebp offset with -vz option
  2098. Revision 1.148 1999/04/21 16:31:44 pierre
  2099. ra386att.pas : commit problem !
  2100. Revision 1.147 1999/04/21 09:43:57 peter
  2101. * storenumber works
  2102. * fixed some typos in double_checksum
  2103. + incompatible types type1 and type2 message (with storenumber)
  2104. Revision 1.146 1999/04/19 09:33:14 pierre
  2105. + added tsymtable.set_alignment(longint) function
  2106. to change the offsets of all function args
  2107. if declared as cdecl or stdcall
  2108. (this must be done after because the cdecl is parsed after
  2109. insertion of the function parameterss into parast symboltable)
  2110. Revision 1.145 1999/04/17 13:16:24 peter
  2111. * fixes for storenumber
  2112. Revision 1.144 1999/04/15 10:01:45 peter
  2113. * small update for storenumber
  2114. Revision 1.143 1999/04/14 09:15:04 peter
  2115. * first things to store the symbol/def number in the ppu
  2116. Revision 1.142 1999/04/08 14:54:10 pierre
  2117. * suppression of val para unused warnings
  2118. Revision 1.141 1999/04/07 15:31:09 pierre
  2119. * all formaldefs are now a sinlge definition
  2120. cformaldef (this was necessary for double_checksum)
  2121. + small part of double_checksum code
  2122. Revision 1.140 1999/03/31 13:55:24 peter
  2123. * assembler inlining working for ag386bin
  2124. Revision 1.139 1999/03/24 23:17:30 peter
  2125. * fixed bugs 212,222,225,227,229,231,233
  2126. Revision 1.138 1999/03/21 22:49:11 florian
  2127. * private ids of objects can be reused in child classes
  2128. if they are in another unit
  2129. Revision 1.137 1999/03/17 22:23:20 florian
  2130. * a FPC compiled compiler checks now also in debug mode in assigned
  2131. if a pointer points to the heap
  2132. * when a symtable is loaded, there is no need to check for duplicate
  2133. symbols. This leads to crashes because defowner isn't assigned
  2134. in this case
  2135. Revision 1.136 1999/03/01 13:45:07 pierre
  2136. + added staticppusymtable symtable type for local browsing
  2137. Revision 1.135 1999/02/23 18:29:28 pierre
  2138. * win32 compilation error fix
  2139. + some work for local browser (not cl=omplete yet)
  2140. Revision 1.134 1999/02/22 15:09:42 florian
  2141. * behaviaor of PROTECTED and PRIVATE fixed, works now like TP/Delphi
  2142. Revision 1.133 1999/02/22 13:07:12 pierre
  2143. + -b and -bl options work !
  2144. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  2145. is not enabled when quitting global section
  2146. * local vars and procedures are not yet stored into PPU
  2147. Revision 1.132 1999/02/22 02:15:40 peter
  2148. * updates for ag386bin
  2149. Revision 1.131 1999/02/16 00:44:34 peter
  2150. * tp7 fix, assigned() can only be used on vars, not on functions
  2151. Revision 1.130 1999/02/15 13:13:16 pierre
  2152. * fix for bug0216
  2153. Revision 1.129 1999/02/11 09:46:29 pierre
  2154. * fix for normal method calls inside static methods :
  2155. WARNING there were both parser and codegen errors !!
  2156. added static_call boolean to calln tree
  2157. Revision 1.128 1999/02/09 23:03:05 florian
  2158. * check for duplicate field names in inherited classes/objects
  2159. * bug with self from the mailing list solved (the problem
  2160. was that classes were sometimes pushed wrong)
  2161. Revision 1.127 1999/02/08 11:29:06 pierre
  2162. * fix for bug0214
  2163. several problems where combined
  2164. search_class_member did not set srsymtable
  2165. => in do_member_read the call node got a wrong symtable
  2166. in cg386cal the vmt was pushed twice without chacking if it exists
  2167. now %esi is set to zero and pushed if not vmt
  2168. (not very efficient but should work !)
  2169. Revision 1.126 1999/02/05 08:54:31 pierre
  2170. + linkofiles splitted inot linkofiles and linkunitfiles
  2171. because linkofiles must be stored with directory
  2172. to enabled linking of different objects with same name
  2173. in a different directory
  2174. Revision 1.125 1999/02/03 09:44:33 pierre
  2175. * symbol nubering begins with 1 in number_symbols
  2176. * program tmodule has globalsymtable for its staticsymtable
  2177. (to get it displayed in IDE globals list)
  2178. + list of symbol (browcol) greatly improved for IDE
  2179. Revision 1.124 1999/01/27 12:58:33 pierre
  2180. * unused var warning suppressed for high of open arrays
  2181. Revision 1.123 1999/01/21 16:41:03 pierre
  2182. * fix for constructor inside with statements
  2183. Revision 1.122 1999/01/20 10:16:44 peter
  2184. * don't update crc when writing objs,libs and sources
  2185. Revision 1.121 1999/01/14 21:50:00 peter
  2186. * fixed forwardpointer problem with multiple forwards for the same
  2187. typesym. It now uses a linkedlist instead of a single pointer
  2188. Revision 1.120 1999/01/13 14:29:22 daniel
  2189. * nonextfield repaired
  2190. Revision 1.119 1999/01/12 14:25:38 peter
  2191. + BrowserLog for browser.log generation
  2192. + BrowserCol for browser info in TCollections
  2193. * released all other UseBrowser
  2194. Revision 1.118 1999/01/05 08:20:10 florian
  2195. * mainly problem with invalid case ranges fixed (reported by Jonas)
  2196. Revision 1.117 1998/12/30 22:15:57 peter
  2197. + farpointer type
  2198. * absolutesym now also stores if its far
  2199. Revision 1.116 1998/12/30 13:41:16 peter
  2200. * released valuepara
  2201. Revision 1.115 1998/12/11 00:03:48 peter
  2202. + globtype,tokens,version unit splitted from globals
  2203. Revision 1.114 1998/12/10 09:47:29 florian
  2204. + basic operations with int64/qord (compiler with -dint64)
  2205. + rtti of enumerations extended: names are now written
  2206. Revision 1.113 1998/12/08 10:18:17 peter
  2207. + -gh for heaptrc unit
  2208. Revision 1.112 1998/12/04 10:18:10 florian
  2209. * some stuff for procedures of object added
  2210. * bug with overridden virtual constructors fixed (reported by Italo Gomes)
  2211. Revision 1.111 1998/11/30 16:34:46 pierre
  2212. * corrected problems with rangecheck
  2213. + added needed code for no rangecheck in CRC32 functions in ppu unit
  2214. * enumdef lso need its rangenr reset to zero
  2215. when calling reset_global_defs
  2216. Revision 1.110 1998/11/28 16:20:58 peter
  2217. + support for dll variables
  2218. Revision 1.109 1998/11/27 14:50:49 peter
  2219. + open strings, $P switch support
  2220. Revision 1.108 1998/11/24 23:00:32 peter
  2221. * small crash prevention
  2222. Revision 1.107 1998/11/20 15:36:01 florian
  2223. * problems with rtti fixed, hope it works
  2224. Revision 1.106 1998/11/18 15:44:20 peter
  2225. * VALUEPARA for tp7 compatible value parameters
  2226. Revision 1.105 1998/11/17 10:39:18 peter
  2227. * has_rtti,has_inittable reset
  2228. Revision 1.104 1998/11/16 10:13:52 peter
  2229. * label defines are checked at the end of the proc
  2230. Revision 1.103 1998/11/13 15:40:32 pierre
  2231. + added -Se in Makefile cvstest target
  2232. + lexlevel cleanup
  2233. normal_function_level main_program_level and unit_init_level defined
  2234. * tins_cache grown to A_EMMS (gave range check error in asm readers)
  2235. (test added in code !)
  2236. * -Un option was wrong
  2237. * _FAIL and _SELF only keyword inside
  2238. constructors and methods respectively
  2239. Revision 1.102 1998/11/12 16:43:34 florian
  2240. * functions with ansi strings as result didn't work, solved
  2241. Revision 1.101 1998/11/12 12:55:18 pierre
  2242. * fix for bug0176 and bug0177
  2243. Revision 1.100 1998/11/10 10:09:15 peter
  2244. * va_list -> array of const
  2245. Revision 1.99 1998/11/09 11:44:38 peter
  2246. + va_list for printf support
  2247. Revision 1.98 1998/11/05 23:33:35 peter
  2248. * symtable.done sets vars to nil
  2249. Revision 1.97 1998/11/05 12:03:00 peter
  2250. * released useansistring
  2251. * removed -Sv, its now available in fpc modes
  2252. Revision 1.96 1998/10/28 18:26:19 pierre
  2253. * removed some erros after other errors (introduced by useexcept)
  2254. * stabs works again correctly (for how long !)
  2255. Revision 1.95 1998/10/21 08:40:01 florian
  2256. + ansistring operator +
  2257. + $h and string[n] for n>255 added
  2258. * small problem with TP fixed
  2259. Revision 1.94 1998/10/20 08:07:03 pierre
  2260. * several memory corruptions due to double freemem solved
  2261. => never use p^.loc.location:=p^.left^.loc.location;
  2262. + finally I added now by default
  2263. that ra386dir translates global and unit symbols
  2264. + added a first field in tsymtable and
  2265. a nextsym field in tsym
  2266. (this allows to obtain ordered type info for
  2267. records and objects in gdb !)
  2268. Revision 1.93 1998/10/19 08:55:08 pierre
  2269. * wrong stabs info corrected once again !!
  2270. + variable vmt offset with vmt field only if required
  2271. implemented now !!!
  2272. Revision 1.92 1998/10/16 13:12:56 pierre
  2273. * added vmt_offsets in destructors code also !!!
  2274. * vmt_offset code for m68k
  2275. Revision 1.91 1998/10/16 08:48:38 peter
  2276. * fixed some misplaced $endif GDB
  2277. Revision 1.90 1998/10/15 15:13:32 pierre
  2278. + added oo_hasconstructor and oo_hasdestructor
  2279. for objects options
  2280. Revision 1.89 1998/10/14 13:38:25 peter
  2281. * fixed path with staticlib/objects in ppufiles
  2282. Revision 1.88 1998/10/09 16:36:07 pierre
  2283. * some memory leaks specific to usebrowser define fixed
  2284. * removed tmodule.implsymtable (was like tmodule.localsymtable)
  2285. Revision 1.87 1998/10/09 11:47:57 pierre
  2286. * still more memory leaks fixes !!
  2287. Revision 1.86 1998/10/08 17:17:35 pierre
  2288. * current_module old scanner tagged as invalid if unit is recompiled
  2289. + added ppheap for better info on tracegetmem of heaptrc
  2290. (adds line column and file index)
  2291. * several memory leaks removed ith help of heaptrc !!
  2292. Revision 1.85 1998/10/08 13:48:51 peter
  2293. * fixed memory leaks for do nothing source
  2294. * fixed unit interdependency
  2295. Revision 1.84 1998/10/06 17:16:58 pierre
  2296. * some memory leaks fixed (thanks to Peter for heaptrc !)
  2297. Revision 1.83 1998/09/26 17:45:45 peter
  2298. + idtoken and only one token table
  2299. Revision 1.82 1998/09/25 09:52:57 peter
  2300. + store also datasize and # of symbols in ppu
  2301. * # of defs is now also stored in structs
  2302. Revision 1.81 1998/09/24 23:49:21 peter
  2303. + aktmodeswitches
  2304. Revision 1.80 1998/09/23 12:20:51 pierre
  2305. * main program tmodule had no symtable (crashed browser)
  2306. * unit symbols problem fixed !!
  2307. Revision 1.79 1998/09/23 12:03:57 peter
  2308. * overloading fix for array of const
  2309. Revision 1.78 1998/09/22 17:13:54 pierre
  2310. + browsing updated and developed
  2311. records and objects fields are also stored
  2312. Revision 1.77 1998/09/22 15:37:24 peter
  2313. + array of const start
  2314. Revision 1.76 1998/09/21 10:00:08 peter
  2315. * store number of defs in ppu file
  2316. Revision 1.75 1998/09/21 08:58:31 peter
  2317. + speedsearch, which also needs speedvalue as parameter
  2318. Revision 1.74 1998/09/21 08:45:25 pierre
  2319. + added vmt_offset in tobjectdef.write for fututre use
  2320. (first steps to have objects without vmt if no virtual !!)
  2321. + added fpu_used field for tabstractprocdef :
  2322. sets this level to 2 if the functions return with value in FPU
  2323. (is then set to correct value at parsing of implementation)
  2324. THIS MIGHT refuse some code with FPU expression too complex
  2325. that were accepted before and even in some cases
  2326. that don't overflow in fact
  2327. ( like if f : float; is a forward that finally in implementation
  2328. only uses one fpu register !!)
  2329. Nevertheless I think that it will improve security on
  2330. FPU operations !!
  2331. * most other changes only for UseBrowser code
  2332. (added symtable references for record and objects)
  2333. local switch for refs to args and local of each function
  2334. (static symtable still missing)
  2335. UseBrowser still not stable and probably broken by
  2336. the definition hash array !!
  2337. Revision 1.73 1998/09/20 09:38:47 florian
  2338. * hasharray for defs fixed
  2339. * ansistring code generation corrected (init/final, assignement)
  2340. Revision 1.72 1998/09/19 22:56:18 florian
  2341. + hash table for getdefnr added
  2342. Revision 1.71 1998/09/18 08:01:40 pierre
  2343. + improvement on the usebrowser part
  2344. (does not work correctly for now)
  2345. Revision 1.70 1998/09/09 11:50:57 pierre
  2346. * forward def are not put in record or objects
  2347. + added check for forwards also in record and objects
  2348. * dummy parasymtable for unit initialization removed from
  2349. symtable stack
  2350. Revision 1.69 1998/09/07 23:10:25 florian
  2351. * a lot of stuff fixed regarding rtti and publishing of properties,
  2352. basics should now work
  2353. Revision 1.68 1998/09/07 19:33:26 florian
  2354. + some stuff for property rtti added:
  2355. - NameIndex of the TPropInfo record is now written correctly
  2356. - the DEFAULT/NODEFAULT keyword is supported now
  2357. - the default value and the storedsym/def are now written to
  2358. the PPU fiel
  2359. Revision 1.67 1998/09/07 18:46:14 peter
  2360. * update smartlinking, uses getdatalabel
  2361. * renamed ptree.value vars to value_str,value_real,value_set
  2362. Revision 1.66 1998/09/07 17:37:05 florian
  2363. * first fixes for published properties
  2364. Revision 1.65 1998/09/06 22:42:03 florian
  2365. + rtti genreation for properties added
  2366. Revision 1.64 1998/09/05 22:11:04 florian
  2367. + switch -vb
  2368. * while/repeat loops accept now also word/longbool conditions
  2369. * makebooltojump did an invalid ungetregister32, fixed
  2370. Revision 1.63 1998/09/04 17:34:23 pierre
  2371. * bug with datalabel corrected
  2372. + assembler errors better commented
  2373. * one nested record crash removed
  2374. Revision 1.62 1998/09/04 08:42:10 peter
  2375. * updated some error messages
  2376. Revision 1.61 1998/09/03 16:03:21 florian
  2377. + rtti generation
  2378. * init table generation changed
  2379. Revision 1.60 1998/09/01 17:39:52 peter
  2380. + internal constant functions
  2381. Revision 1.59 1998/09/01 12:53:27 peter
  2382. + aktpackenum
  2383. Revision 1.58 1998/09/01 07:54:26 pierre
  2384. * UseBrowser a little updated (might still be buggy !!)
  2385. * bug in psub.pas in function specifier removed
  2386. * stdcall allowed in interface and in implementation
  2387. (FPC will not yet complain if it is missing in either part
  2388. because stdcall is only a dummy !!)
  2389. Revision 1.57 1998/08/31 12:26:33 peter
  2390. * m68k and palmos updates from surebugfixes
  2391. Revision 1.56 1998/08/21 14:08:55 pierre
  2392. + TEST_FUNCRET now default (old code removed)
  2393. works also for m68k (at least compiles)
  2394. Revision 1.55 1998/08/21 08:43:32 pierre
  2395. * pocdecl and poclearstack are now different
  2396. external must but written as last specification
  2397. Revision 1.54 1998/08/20 09:26:48 pierre
  2398. + funcret setting in underproc testing
  2399. compile with _dTEST_FUNCRET
  2400. Revision 1.53 1998/08/19 18:04:56 peter
  2401. * fixed current_module^.in_implementation flag
  2402. Revision 1.51 1998/08/18 14:17:12 pierre
  2403. * bug about assigning the return value of a function to
  2404. a procvar fixed : warning
  2405. assigning a proc to a procvar need @ in FPC mode !!
  2406. * missing file/line info restored
  2407. Revision 1.50 1998/08/17 10:10:13 peter
  2408. - removed OLDPPU
  2409. Revision 1.49 1998/08/12 19:39:31 peter
  2410. * fixed some crashes
  2411. Revision 1.48 1998/08/10 14:50:32 peter
  2412. + localswitches, moduleswitches, globalswitches splitting
  2413. Revision 1.47 1998/08/10 10:00:19 peter
  2414. * Moved symbolstream to symtable.pas
  2415. Revision 1.46 1998/08/08 10:19:19 florian
  2416. * small fixes to write the extended type correct
  2417. Revision 1.45 1998/08/02 16:42:00 florian
  2418. * on o : tobject do should also work now, the exceptsymtable shouldn't be
  2419. disposed by dellexlevel
  2420. Revision 1.44 1998/07/30 11:18:21 florian
  2421. + first implementation of try ... except on .. do end;
  2422. * limitiation of 65535 bytes parameters for cdecl removed
  2423. Revision 1.43 1998/07/28 21:52:56 florian
  2424. + implementation of raise and try..finally
  2425. + some misc. exception stuff
  2426. Revision 1.42 1998/07/20 10:23:03 florian
  2427. * better ansi string assignement
  2428. Revision 1.41 1998/07/18 22:54:31 florian
  2429. * some ansi/wide/longstring support fixed:
  2430. o parameter passing
  2431. o returning as result from functions
  2432. Revision 1.40 1998/07/14 14:47:09 peter
  2433. * released NEWINPUT
  2434. Revision 1.39 1998/07/10 00:00:06 peter
  2435. * fixed ttypesym bug finally
  2436. * fileinfo in the symtable and better using for unused vars
  2437. Revision 1.38 1998/07/07 11:20:17 peter
  2438. + NEWINPUT for a better inputfile and scanner object
  2439. Revision 1.37 1998/06/24 14:48:42 peter
  2440. * ifdef newppu -> ifndef oldppu
  2441. Revision 1.36 1998/06/17 14:10:19 peter
  2442. * small os2 fixes
  2443. * fixed interdependent units with newppu (remake3 under linux works now)
  2444. Revision 1.35 1998/06/16 08:56:35 peter
  2445. + targetcpu
  2446. * cleaner pmodules for newppu
  2447. Revision 1.34 1998/06/15 15:38:12 pierre
  2448. * small bug in systems.pas corrected
  2449. + operators in different units better hanlded
  2450. Revision 1.33 1998/06/15 14:10:53 daniel
  2451. * File was ruined, fixed.
  2452. Revision 1.31 1998/06/13 00:10:20 peter
  2453. * working browser and newppu
  2454. * some small fixes against crashes which occured in bp7 (but not in
  2455. fpc?!)
  2456. Revision 1.30 1998/06/09 16:01:53 pierre
  2457. + added procedure directive parsing for procvars
  2458. (accepted are popstack cdecl and pascal)
  2459. + added C vars with the following syntax
  2460. var C calias 'true_c_name';(can be followed by external)
  2461. reason is that you must add the Cprefix
  2462. which is target dependent
  2463. Revision 1.29 1998/06/07 15:30:26 florian
  2464. + first working rtti
  2465. + data init/final. for local variables
  2466. Revision 1.28 1998/06/06 09:27:39 peter
  2467. * new depend file generated
  2468. Revision 1.27 1998/06/05 14:37:38 pierre
  2469. * fixes for inline for operators
  2470. * inline procedure more correctly restricted
  2471. Revision 1.26 1998/06/04 23:52:03 peter
  2472. * m68k compiles
  2473. + .def file creation moved to gendef.pas so it could also be used
  2474. for win32
  2475. Revision 1.25 1998/06/04 09:55:48 pierre
  2476. * demangled name of procsym reworked to become independant of the
  2477. mangling scheme
  2478. Revision 1.24 1998/06/03 22:49:04 peter
  2479. + wordbool,longbool
  2480. * rename bis,von -> high,low
  2481. * moved some systemunit loading/creating to psystem.pas
  2482. Revision 1.23 1998/05/28 14:40:30 peter
  2483. * fixes for newppu, remake3 works now with it
  2484. Revision 1.22 1998/05/27 19:45:09 peter
  2485. * symtable.pas splitted into includefiles
  2486. * symtable adapted for $ifndef OLDPPU
  2487. Revision 1.21 1998/05/23 01:21:31 peter
  2488. + aktasmmode, aktoptprocessor, aktoutputformat
  2489. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  2490. + $LIBNAME to set the library name where the unit will be put in
  2491. * splitted cgi386 a bit (codeseg to large for bp7)
  2492. * nasm, tasm works again. nasm moved to ag386nsm.pas
  2493. Revision 1.20 1998/05/21 19:33:37 peter
  2494. + better procedure directive handling and only one table
  2495. Revision 1.19 1998/05/20 09:42:37 pierre
  2496. + UseTokenInfo now default
  2497. * unit in interface uses and implementation uses gives error now
  2498. * only one error for unknown symbol (uses lastsymknown boolean)
  2499. the problem came from the label code !
  2500. + first inlined procedures and function work
  2501. (warning there might be allowed cases were the result is still wrong !!)
  2502. * UseBrower updated gives a global list of all position of all used symbols
  2503. with switch -gb
  2504. Revision 1.18 1998/05/11 13:07:57 peter
  2505. + $ifndef OLDPPU for the new ppuformat
  2506. + $define GDB not longer required
  2507. * removed all warnings and stripped some log comments
  2508. * no findfirst/findnext anymore to remove smartlink *.o files
  2509. Revision 1.17 1998/05/06 08:38:48 pierre
  2510. * better position info with UseTokenInfo
  2511. UseTokenInfo greatly simplified
  2512. + added check for changed tree after first time firstpass
  2513. (if we could remove all the cases were it happen
  2514. we could skip all firstpass if firstpasscount > 1)
  2515. Only with ExtDebug
  2516. Revision 1.16 1998/05/05 15:24:20 michael
  2517. * Fix to save units with classes.
  2518. Revision 1.15 1998/05/04 17:54:29 peter
  2519. + smartlinking works (only case jumptable left todo)
  2520. * redesign of systems.pas to support assemblers and linkers
  2521. + Unitname is now also in the PPU-file, increased version to 14
  2522. Revision 1.14 1998/05/01 16:38:46 florian
  2523. * handling of private and protected fixed
  2524. + change_keywords_to_tp implemented to remove
  2525. keywords which aren't supported by tp
  2526. * break and continue are now symbols of the system unit
  2527. + widestring, longstring and ansistring type released
  2528. Revision 1.13 1998/05/01 09:01:25 florian
  2529. + correct semantics of private and protected
  2530. * small fix in variable scope:
  2531. a id can be used in a parameter list of a method, even it is used in
  2532. an anchestor class as field id
  2533. Revision 1.12 1998/05/01 07:43:57 florian
  2534. + basics for rtti implemented
  2535. + switch $m (generate rtti for published sections)
  2536. Revision 1.11 1998/04/30 15:59:42 pierre
  2537. * GDB works again better :
  2538. correct type info in one pass
  2539. + UseTokenInfo for better source position
  2540. * fixed one remaining bug in scanner for line counts
  2541. * several little fixes
  2542. Revision 1.10 1998/04/29 10:34:05 pierre
  2543. + added some code for ansistring (not complete nor working yet)
  2544. * corrected operator overloading
  2545. * corrected nasm output
  2546. + started inline procedures
  2547. + added starstarn : use ** for exponentiation (^ gave problems)
  2548. + started UseTokenInfo cond to get accurate positions
  2549. Revision 1.9 1998/04/27 23:10:29 peter
  2550. + new scanner
  2551. * $makelib -> if smartlink
  2552. * small filename fixes pmodule.setfilename
  2553. * moved import from files.pas -> import.pas
  2554. Revision 1.8 1998/04/21 10:16:48 peter
  2555. * patches from strasbourg
  2556. * objects is not used anymore in the fpc compiled version
  2557. Revision 1.7 1998/04/13 22:20:36 florian
  2558. + stricter checking for duplicate id, solves also bug0097
  2559. Revision 1.6 1998/04/13 17:20:43 florian
  2560. * tdef.done much faster implemented
  2561. Revision 1.5 1998/04/10 21:36:56 florian
  2562. + some stuff to support method pointers (procedure of object) added
  2563. (declaration, parameter handling)
  2564. Revision 1.4 1998/04/08 16:58:08 pierre
  2565. * several bugfixes
  2566. ADD ADC and AND are also sign extended
  2567. nasm output OK (program still crashes at end
  2568. and creates wrong assembler files !!)
  2569. procsym types sym in tdef removed !!
  2570. Revision 1.3 1998/04/07 13:19:52 pierre
  2571. * bugfixes for reset_gdb_info
  2572. in MEM parsing for go32v2
  2573. better external symbol creation
  2574. support for rhgdb.exe (lowercase file names)
  2575. Revision 1.2 1998/04/06 13:09:04 daniel
  2576. * Emergency solution for bug in reset_gdb_info.
  2577. }