symtable.pas 95 KB

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