cobjects.pas 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This module provides some basic objects
  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. {$E+,N+,D+,F+}
  20. {$endif}
  21. {$I-}
  22. {$R-}{ necessary for crc calculation }
  23. unit cobjects;
  24. { define OLDSPEEDVALUE}
  25. interface
  26. uses
  27. {$ifdef DELPHI4}
  28. dmisc,
  29. sysutils
  30. {$else DELPHI4}
  31. strings
  32. {$ifndef linux}
  33. ,dos
  34. {$else}
  35. ,linux
  36. {$endif}
  37. {$endif DELPHI4}
  38. ;
  39. const
  40. { the real size will be [-hasharray..hasharray] ! }
  41. {$ifdef TP}
  42. hasharraysize = 127;
  43. {$else}
  44. hasharraysize = 2047;
  45. {$endif}
  46. type
  47. pstring = ^string;
  48. {$ifdef TP}
  49. { redeclare dword only in case of emergency, some small things
  50. of the compiler won't work then correctly (FK)
  51. }
  52. dword = longint;
  53. {$endif TP}
  54. pfileposinfo = ^tfileposinfo;
  55. tfileposinfo = record
  56. line : longint;
  57. column : word;
  58. fileindex : word;
  59. end;
  60. pmemdebug = ^tmemdebug;
  61. tmemdebug = object
  62. constructor init(const s:string);
  63. destructor done;
  64. procedure show;
  65. private
  66. startmem : longint;
  67. infostr : string[40];
  68. end;
  69. plinkedlist_item = ^tlinkedlist_item;
  70. tlinkedlist_item = object
  71. next,previous : plinkedlist_item;
  72. { does nothing }
  73. constructor init;
  74. destructor done;virtual;
  75. function getcopy:plinkedlist_item;virtual;
  76. end;
  77. pstring_item = ^tstring_item;
  78. tstring_item = object(tlinkedlist_item)
  79. str : pstring;
  80. constructor init(const s : string);
  81. destructor done;virtual;
  82. end;
  83. { this implements a double linked list }
  84. plinkedlist = ^tlinkedlist;
  85. tlinkedlist = object
  86. first,last : plinkedlist_item;
  87. constructor init;
  88. destructor done;
  89. { destructors the linkedlist without cleaning the items up }
  90. destructor done_noclear;
  91. { disposes the items of the list }
  92. procedure clear;
  93. { concats a new item at the end }
  94. procedure concat(p : plinkedlist_item);
  95. { inserts a new item at the begin }
  96. procedure insert(p : plinkedlist_item);
  97. { inserts another list at the begin and make this list empty }
  98. procedure insertlist(p : plinkedlist);
  99. { concats another list at the end and make this list empty }
  100. procedure concatlist(p : plinkedlist);
  101. procedure concatlistcopy(p : plinkedlist);
  102. { removes p from the list (p isn't disposed) }
  103. { it's not tested if p is in the list ! }
  104. procedure remove(p : plinkedlist_item);
  105. { is the linkedlist empty ? }
  106. function empty:boolean;
  107. { items in the list }
  108. function count:longint;
  109. end;
  110. { some help data types }
  111. pstringqueueitem = ^tstringqueueitem;
  112. tstringqueueitem = object
  113. data : pstring;
  114. next : pstringqueueitem;
  115. end;
  116. { String Queue}
  117. PStringQueue=^TStringQueue;
  118. TStringQueue=object
  119. first,last : PStringqueueItem;
  120. constructor Init;
  121. destructor Done;
  122. function Empty:boolean;
  123. function Get:string;
  124. function Find(const s:string):PStringqueueItem;
  125. function Delete(const s:string):boolean;
  126. procedure Insert(const s:string);
  127. procedure Concat(const s:string);
  128. procedure Clear;
  129. end;
  130. { containeritem }
  131. pcontaineritem = ^tcontaineritem;
  132. tcontaineritem = object
  133. next : pcontaineritem;
  134. constructor init;
  135. destructor done;virtual;
  136. end;
  137. { container }
  138. pcontainer = ^tcontainer;
  139. tcontainer = object
  140. root,
  141. last : pcontaineritem;
  142. constructor init;
  143. destructor done;
  144. { true when the container is empty }
  145. function empty:boolean;
  146. { inserts a string }
  147. procedure insert(item:pcontaineritem);
  148. { gets a string }
  149. function get:pcontaineritem;
  150. { deletes all items }
  151. procedure clear;
  152. end;
  153. { containeritem }
  154. pstringcontaineritem = ^tstringcontaineritem;
  155. tstringcontaineritem = object(tcontaineritem)
  156. data : pstring;
  157. file_info : tfileposinfo;
  158. constructor init(const s:string);
  159. constructor Init_TokenInfo(const s:string;const pos:tfileposinfo);
  160. destructor done;virtual;
  161. end;
  162. { string container }
  163. pstringcontainer = ^tstringcontainer;
  164. tstringcontainer = object(tcontainer)
  165. doubles : boolean; { if this is set to true, doubles are allowed }
  166. constructor init;
  167. constructor init_no_double;
  168. procedure insert(const s : string);
  169. procedure insert_with_tokeninfo(const s : string;const file_info : tfileposinfo);
  170. { gets a string }
  171. function get : string;
  172. function get_with_tokeninfo(var file_info : tfileposinfo) : string;
  173. { true if string is in the container }
  174. function find(const s:string):boolean;
  175. end;
  176. { namedindexobject for use with dictionary and indexarray }
  177. Pnamedindexobject=^Tnamedindexobject;
  178. Tnamedindexobject=object
  179. indexnr : longint;
  180. _name : Pstring;
  181. next,
  182. left,right : Pnamedindexobject;
  183. speedvalue : longint;
  184. constructor init;
  185. constructor initname(const n:string);
  186. destructor done;virtual;
  187. procedure setname(const n:string);virtual;
  188. function name:string;virtual;
  189. end;
  190. Pdictionaryhasharray=^Tdictionaryhasharray;
  191. Tdictionaryhasharray=array[-hasharraysize..hasharraysize] of Pnamedindexobject;
  192. Tnamedindexcallback = procedure(p:Pnamedindexobject);
  193. Pdictionary=^Tdictionary;
  194. Tdictionary=object
  195. noclear : boolean;
  196. replace_existing : boolean;
  197. constructor init;
  198. destructor done;virtual;
  199. procedure usehash;
  200. procedure clear;
  201. function delete(const s:string):Pnamedindexobject;
  202. function empty:boolean;
  203. procedure foreach(proc2call:Tnamedindexcallback);
  204. function insert(obj:Pnamedindexobject):Pnamedindexobject;
  205. function rename(const olds,news : string):Pnamedindexobject;
  206. function search(const s:string):Pnamedindexobject;
  207. function speedsearch(const s:string;speedvalue:longint):Pnamedindexobject;
  208. private
  209. root : Pnamedindexobject;
  210. hasharray : Pdictionaryhasharray;
  211. procedure cleartree(obj:Pnamedindexobject);
  212. function insertnode(newnode:Pnamedindexobject;var currnode:Pnamedindexobject):Pnamedindexobject;
  213. procedure inserttree(currtree,currroot:Pnamedindexobject);
  214. end;
  215. pdynamicarray = ^tdynamicarray;
  216. tdynamicarray = object
  217. posn,
  218. count,
  219. limit,
  220. elemlen,
  221. growcount : longint;
  222. data : pchar;
  223. constructor init(Aelemlen,Agrow:longint);
  224. destructor done;
  225. function size:longint;
  226. function usedsize:longint;
  227. procedure grow;
  228. procedure align(i:longint);
  229. procedure seek(i:longint);
  230. procedure write(var d;len:longint);
  231. procedure read(var d;len:longint);
  232. procedure writepos(pos:longint;var d;len:longint);
  233. procedure readpos(pos:longint;var d;len:longint);
  234. end;
  235. tindexobjectarray=array[1..16000] of Pnamedindexobject;
  236. Pnamedindexobjectarray=^tindexobjectarray;
  237. pindexarray=^tindexarray;
  238. tindexarray=object
  239. first : Pnamedindexobject;
  240. count : longint;
  241. constructor init(Agrowsize:longint);
  242. destructor done;
  243. procedure clear;
  244. procedure foreach(proc2call : Tnamedindexcallback);
  245. procedure deleteindex(p:Pnamedindexobject);
  246. procedure delete(p:Pnamedindexobject);
  247. procedure insert(p:Pnamedindexobject);
  248. function search(nr:longint):Pnamedindexobject;
  249. private
  250. growsize,
  251. size : longint;
  252. data : Pnamedindexobjectarray;
  253. procedure grow(gsize:longint);
  254. end;
  255. {$ifdef BUFFEREDFILE}
  256. { this is implemented to allow buffered binary I/O }
  257. pbufferedfile = ^tbufferedfile;
  258. tbufferedfile = object
  259. f : file;
  260. buf : pchar;
  261. bufsize,buflast,bufpos : longint;
  262. { 0 closed, 1 input, 2 output }
  263. iomode : byte;
  264. { true, if the compile should change the endian of the output }
  265. change_endian : boolean;
  266. { calcules a crc for the file, }
  267. { but it's assumed, that there no seek while do_crc is true }
  268. do_crc : boolean;
  269. crc : longint;
  270. { temporary closing feature }
  271. tempclosed : boolean;
  272. tempmode : byte;
  273. temppos : longint;
  274. { inits a buffer with the size bufsize which is assigned to }
  275. { the file filename }
  276. constructor init(const filename : string;_bufsize : longint);
  277. { closes the file, if needed, and releases the memory }
  278. destructor done;virtual;
  279. { opens the file for input, other accesses are rejected }
  280. function reset:boolean;
  281. { opens the file for output, other accesses are rejected }
  282. procedure rewrite;
  283. { reads or writes the buffer from or to disk }
  284. procedure flush;
  285. { writes a string to the file }
  286. { the string is written without a length byte }
  287. procedure write_string(const s : string);
  288. { writes a zero terminated string }
  289. procedure write_pchar(p : pchar);
  290. { write specific data types, takes care of }
  291. { byte order }
  292. procedure write_byte(b : byte);
  293. procedure write_word(w : word);
  294. procedure write_long(l : longint);
  295. procedure write_double(d : double);
  296. { writes any data }
  297. procedure write_data(var data;count : longint);
  298. { reads any data }
  299. procedure read_data(var data;bytes : longint;var count : longint);
  300. { closes the file and releases the buffer }
  301. procedure close;
  302. { temporary closing }
  303. procedure tempclose;
  304. procedure tempreopen;
  305. { goto the given position }
  306. procedure seek(l : longint);
  307. { installes an user defined buffer }
  308. { and releases the old one, but be }
  309. { careful, if the old buffer contains }
  310. { data, this data is lost }
  311. procedure setbuf(p : pchar;s : longint);
  312. { reads the file time stamp of the file, }
  313. { the file must be opened }
  314. function getftime : longint;
  315. { returns filesize }
  316. function getsize : longint;
  317. { returns the path }
  318. function getpath : string;
  319. { resets the crc }
  320. procedure clear_crc;
  321. { returns the crc }
  322. function getcrc : longint;
  323. end;
  324. {$endif BUFFEREDFILE}
  325. function getspeedvalue(const s : string) : longint;
  326. { releases the string p and assignes nil to p }
  327. { if p=nil then freemem isn't called }
  328. procedure stringdispose(var p : pstring);
  329. { idem for ansistrings }
  330. procedure ansistringdispose(var p : pchar;length : longint);
  331. { allocates mem for a copy of s, copies s to this mem and returns }
  332. { a pointer to this mem }
  333. function stringdup(const s : string) : pstring;
  334. { allocates memory for s and copies s as zero terminated string
  335. to that mem and returns a pointer to that mem }
  336. function strpnew(const s : string) : pchar;
  337. procedure strdispose(var p : pchar);
  338. { makes a char lowercase, with spanish, french and german char set }
  339. function lowercase(c : char) : char;
  340. { makes zero terminated string to a pascal string }
  341. { the data in p is modified and p is returned }
  342. function pchar2pstring(p : pchar) : pstring;
  343. { ambivalent to pchar2pstring }
  344. function pstring2pchar(p : pstring) : pchar;
  345. implementation
  346. uses
  347. comphook;
  348. {*****************************************************************************
  349. Memory debug
  350. *****************************************************************************}
  351. constructor tmemdebug.init(const s:string);
  352. begin
  353. infostr:=s;
  354. startmem:=memavail;
  355. end;
  356. procedure tmemdebug.show;
  357. var
  358. l : longint;
  359. begin
  360. write('memory [',infostr,'] ');
  361. l:=memavail;
  362. if l>startmem then
  363. writeln(l-startmem,' released')
  364. else
  365. writeln(startmem-l,' allocated');
  366. end;
  367. destructor tmemdebug.done;
  368. begin
  369. show;
  370. end;
  371. {$ifndef OLDSPEEDVALUE}
  372. {*****************************************************************************
  373. Crc 32
  374. *****************************************************************************}
  375. var
  376. {$ifdef Delphi}
  377. Crc32Tbl : array[0..255] of longword;
  378. {$else Delphi}
  379. Crc32Tbl : array[0..255] of longint;
  380. {$endif Delphi}
  381. procedure MakeCRC32Tbl;
  382. var
  383. {$ifdef Delphi}
  384. crc : longword;
  385. {$else Delphi}
  386. crc : longint;
  387. {$endif Delphi}
  388. i,n : byte;
  389. begin
  390. for i:=0 to 255 do
  391. begin
  392. crc:=i;
  393. for n:=1 to 8 do
  394. if odd(crc) then
  395. crc:=(crc shr 1) xor $edb88320
  396. else
  397. crc:=crc shr 1;
  398. Crc32Tbl[i]:=crc;
  399. end;
  400. end;
  401. {$ifopt R+}
  402. {$define Range_check_on}
  403. {$endif opt R+}
  404. {$R- needed here }
  405. {CRC 32}
  406. Function GetSpeedValue(Const s:String):longint;
  407. var
  408. i,InitCrc : longint;
  409. begin
  410. if Crc32Tbl[1]=0 then
  411. MakeCrc32Tbl;
  412. InitCrc:=$ffffffff;
  413. for i:=1to Length(s) do
  414. InitCrc:=Crc32Tbl[byte(InitCrc) xor ord(s[i])] xor (InitCrc shr 8);
  415. GetSpeedValue:=InitCrc;
  416. end;
  417. {$ifdef Range_check_on}
  418. {$R+}
  419. {$undef Range_check_on}
  420. {$endif Range_check_on}
  421. {$else}
  422. {$ifndef TP}
  423. function getspeedvalue(const s : string) : longint;
  424. var
  425. p1,p2:^byte;
  426. i : longint;
  427. begin
  428. p1:=@s;
  429. longint(p2):=longint(p1)+p1^+1;
  430. inc(longint(p1));
  431. i:=0;
  432. while p1<>p2 do
  433. begin
  434. i:=i + ord(p1^);
  435. inc(longint(p1));
  436. end;
  437. getspeedvalue:=i;
  438. end;
  439. {$else}
  440. function getspeedvalue(const s : string) : longint;
  441. type
  442. ptrrec=record
  443. ofs,seg:word;
  444. end;
  445. var
  446. l,w : longint;
  447. p1,p2 : ^byte;
  448. begin
  449. p1:=@s;
  450. ptrrec(p2).seg:=ptrrec(p1).seg;
  451. ptrrec(p2).ofs:=ptrrec(p1).ofs+p1^+1;
  452. inc(p1);
  453. l:=0;
  454. while p1<>p2 do
  455. begin
  456. l:=l + ord(p1^);
  457. inc(p1);
  458. end;
  459. getspeedvalue:=l;
  460. end;
  461. {$endif}
  462. {$endif OLDSPEEDVALUE}
  463. function pchar2pstring(p : pchar) : pstring;
  464. var
  465. w,i : longint;
  466. begin
  467. w:=strlen(p);
  468. for i:=w-1 downto 0 do
  469. p[i+1]:=p[i];
  470. p[0]:=chr(w);
  471. pchar2pstring:=pstring(p);
  472. end;
  473. function pstring2pchar(p : pstring) : pchar;
  474. var
  475. w,i : longint;
  476. begin
  477. w:=length(p^);
  478. for i:=1 to w do
  479. p^[i-1]:=p^[i];
  480. p^[w]:=#0;
  481. pstring2pchar:=pchar(p);
  482. end;
  483. function lowercase(c : char) : char;
  484. begin
  485. case c of
  486. #65..#90 : c := chr(ord (c) + 32);
  487. #154 : c:=#129; { german }
  488. #142 : c:=#132; { german }
  489. #153 : c:=#148; { german }
  490. #144 : c:=#130; { french }
  491. #128 : c:=#135; { french }
  492. #143 : c:=#134; { swedish/norge (?) }
  493. #165 : c:=#164; { spanish }
  494. #228 : c:=#229; { greek }
  495. #226 : c:=#231; { greek }
  496. #232 : c:=#227; { greek }
  497. end;
  498. lowercase := c;
  499. end;
  500. function strpnew(const s : string) : pchar;
  501. var
  502. p : pchar;
  503. begin
  504. getmem(p,length(s)+1);
  505. strpcopy(p,s);
  506. strpnew:=p;
  507. end;
  508. procedure strdispose(var p : pchar);
  509. begin
  510. if assigned(p) then
  511. begin
  512. freemem(p,strlen(p)+1);
  513. p:=nil;
  514. end;
  515. end;
  516. procedure stringdispose(var p : pstring);
  517. begin
  518. if assigned(p) then
  519. freemem(p,length(p^)+1);
  520. p:=nil;
  521. end;
  522. procedure ansistringdispose(var p : pchar;length : longint);
  523. begin
  524. if assigned(p) then
  525. freemem(p,length+1);
  526. p:=nil;
  527. end;
  528. function stringdup(const s : string) : pstring;
  529. var
  530. p : pstring;
  531. begin
  532. getmem(p,length(s)+1);
  533. p^:=s;
  534. stringdup:=p;
  535. end;
  536. {****************************************************************************
  537. TStringQueue
  538. ****************************************************************************}
  539. constructor TStringQueue.Init;
  540. begin
  541. first:=nil;
  542. last:=nil;
  543. end;
  544. function TStringQueue.Empty:boolean;
  545. begin
  546. Empty:=(first=nil);
  547. end;
  548. function TStringQueue.Get:string;
  549. var
  550. newnode : pstringqueueitem;
  551. begin
  552. if first=nil then
  553. begin
  554. Get:='';
  555. exit;
  556. end;
  557. Get:=first^.data^;
  558. stringdispose(first^.data);
  559. newnode:=first;
  560. first:=first^.next;
  561. dispose(newnode);
  562. end;
  563. function TStringQueue.Find(const s:string):PStringqueueItem;
  564. var
  565. p : PStringqueueItem;
  566. begin
  567. p:=first;
  568. while assigned(p) do
  569. begin
  570. if p^.data^=s then
  571. break;
  572. p:=p^.next;
  573. end;
  574. Find:=p;
  575. end;
  576. function TStringQueue.Delete(const s:string):boolean;
  577. var
  578. prev,p : PStringqueueItem;
  579. begin
  580. Delete:=false;
  581. prev:=nil;
  582. p:=first;
  583. while assigned(p) do
  584. begin
  585. if p^.data^=s then
  586. begin
  587. if p=last then
  588. last:=prev;
  589. if assigned(prev) then
  590. prev^.next:=p^.next
  591. else
  592. first:=p^.next;
  593. dispose(p);
  594. Delete:=true;
  595. exit;
  596. end;
  597. prev:=p;
  598. p:=p^.next;
  599. end;
  600. end;
  601. procedure TStringQueue.Insert(const s:string);
  602. var
  603. newnode : pstringqueueitem;
  604. begin
  605. new(newnode);
  606. newnode^.next:=first;
  607. newnode^.data:=stringdup(s);
  608. first:=newnode;
  609. if last=nil then
  610. last:=newnode;
  611. end;
  612. procedure TStringQueue.Concat(const s:string);
  613. var
  614. newnode : pstringqueueitem;
  615. begin
  616. new(newnode);
  617. newnode^.next:=nil;
  618. newnode^.data:=stringdup(s);
  619. if first=nil then
  620. first:=newnode
  621. else
  622. last^.next:=newnode;
  623. last:=newnode;
  624. end;
  625. procedure TStringQueue.Clear;
  626. var
  627. newnode : pstringqueueitem;
  628. begin
  629. while (first<>nil) do
  630. begin
  631. newnode:=first;
  632. stringdispose(first^.data);
  633. first:=first^.next;
  634. dispose(newnode);
  635. end;
  636. last:=nil;
  637. end;
  638. destructor TStringQueue.Done;
  639. begin
  640. Clear;
  641. end;
  642. {****************************************************************************
  643. TContainerItem
  644. ****************************************************************************}
  645. constructor TContainerItem.Init;
  646. begin
  647. end;
  648. destructor TContainerItem.Done;
  649. begin
  650. end;
  651. {****************************************************************************
  652. TStringContainerItem
  653. ****************************************************************************}
  654. constructor TStringContainerItem.Init(const s:string);
  655. begin
  656. inherited Init;
  657. data:=stringdup(s);
  658. file_info.fileindex:=0;
  659. file_info.line:=0;
  660. file_info.column:=0;
  661. end;
  662. constructor TStringContainerItem.Init_TokenInfo(const s:string;const pos:tfileposinfo);
  663. begin
  664. inherited Init;
  665. data:=stringdup(s);
  666. file_info:=pos;
  667. end;
  668. destructor TStringContainerItem.Done;
  669. begin
  670. stringdispose(data);
  671. end;
  672. {****************************************************************************
  673. TCONTAINER
  674. ****************************************************************************}
  675. constructor tcontainer.init;
  676. begin
  677. root:=nil;
  678. last:=nil;
  679. end;
  680. destructor tcontainer.done;
  681. begin
  682. clear;
  683. end;
  684. function tcontainer.empty:boolean;
  685. begin
  686. empty:=(root=nil);
  687. end;
  688. procedure tcontainer.insert(item:pcontaineritem);
  689. begin
  690. item^.next:=nil;
  691. if root=nil then
  692. root:=item
  693. else
  694. last^.next:=item;
  695. last:=item;
  696. end;
  697. procedure tcontainer.clear;
  698. var
  699. newnode : pcontaineritem;
  700. begin
  701. newnode:=root;
  702. while assigned(newnode) do
  703. begin
  704. root:=newnode^.next;
  705. dispose(newnode,done);
  706. newnode:=root;
  707. end;
  708. last:=nil;
  709. root:=nil;
  710. end;
  711. function tcontainer.get:pcontaineritem;
  712. begin
  713. if root=nil then
  714. get:=nil
  715. else
  716. begin
  717. get:=root;
  718. root:=root^.next;
  719. end;
  720. end;
  721. {****************************************************************************
  722. TSTRINGCONTAINER
  723. ****************************************************************************}
  724. constructor tstringcontainer.init;
  725. begin
  726. inherited init;
  727. doubles:=true;
  728. end;
  729. constructor tstringcontainer.init_no_double;
  730. begin
  731. inherited init;
  732. doubles:=false;
  733. end;
  734. procedure tstringcontainer.insert(const s : string);
  735. var
  736. newnode : pstringcontaineritem;
  737. begin
  738. if (s='') or
  739. ((not doubles) and find(s)) then
  740. exit;
  741. new(newnode,init(s));
  742. inherited insert(newnode);
  743. end;
  744. procedure tstringcontainer.insert_with_tokeninfo(const s : string; const file_info : tfileposinfo);
  745. var
  746. newnode : pstringcontaineritem;
  747. begin
  748. if (not doubles) and find(s) then
  749. exit;
  750. new(newnode,init_tokeninfo(s,file_info));
  751. inherited insert(newnode);
  752. end;
  753. function tstringcontainer.get : string;
  754. var
  755. p : pstringcontaineritem;
  756. begin
  757. p:=pstringcontaineritem(inherited get);
  758. if p=nil then
  759. get:=''
  760. else
  761. begin
  762. get:=p^.data^;
  763. dispose(p,done);
  764. end;
  765. end;
  766. function tstringcontainer.get_with_tokeninfo(var file_info : tfileposinfo) : string;
  767. var
  768. p : pstringcontaineritem;
  769. begin
  770. p:=pstringcontaineritem(inherited get);
  771. if p=nil then
  772. begin
  773. get_with_tokeninfo:='';
  774. file_info.fileindex:=0;
  775. file_info.line:=0;
  776. file_info.column:=0;
  777. end
  778. else
  779. begin
  780. get_with_tokeninfo:=p^.data^;
  781. file_info:=p^.file_info;
  782. dispose(p,done);
  783. end;
  784. end;
  785. function tstringcontainer.find(const s:string):boolean;
  786. var
  787. newnode : pstringcontaineritem;
  788. begin
  789. find:=false;
  790. newnode:=pstringcontaineritem(root);
  791. while assigned(newnode) do
  792. begin
  793. if newnode^.data^=s then
  794. begin
  795. find:=true;
  796. exit;
  797. end;
  798. newnode:=pstringcontaineritem(newnode^.next);
  799. end;
  800. end;
  801. {****************************************************************************
  802. TLINKEDLIST_ITEM
  803. ****************************************************************************}
  804. constructor tlinkedlist_item.init;
  805. begin
  806. previous:=nil;
  807. next:=nil;
  808. end;
  809. destructor tlinkedlist_item.done;
  810. begin
  811. end;
  812. function tlinkedlist_item.getcopy:plinkedlist_item;
  813. var
  814. l : longint;
  815. p : plinkedlist_item;
  816. begin
  817. l:=sizeof(self);
  818. getmem(p,l);
  819. move(self,p^,l);
  820. getcopy:=p;
  821. end;
  822. {****************************************************************************
  823. TSTRING_ITEM
  824. ****************************************************************************}
  825. constructor tstring_item.init(const s : string);
  826. begin
  827. str:=stringdup(s);
  828. end;
  829. destructor tstring_item.done;
  830. begin
  831. stringdispose(str);
  832. inherited done;
  833. end;
  834. {****************************************************************************
  835. TLINKEDLIST
  836. ****************************************************************************}
  837. constructor tlinkedlist.init;
  838. begin
  839. first:=nil;
  840. last:=nil;
  841. end;
  842. destructor tlinkedlist.done;
  843. begin
  844. clear;
  845. end;
  846. destructor tlinkedlist.done_noclear;
  847. begin
  848. end;
  849. procedure tlinkedlist.clear;
  850. var
  851. newnode : plinkedlist_item;
  852. begin
  853. newnode:=first;
  854. while assigned(newnode) do
  855. begin
  856. first:=newnode^.next;
  857. dispose(newnode,done);
  858. newnode:=first;
  859. end;
  860. end;
  861. procedure tlinkedlist.insertlist(p : plinkedlist);
  862. begin
  863. { empty list ? }
  864. if not(assigned(p^.first)) then
  865. exit;
  866. p^.last^.next:=first;
  867. { we have a double linked list }
  868. if assigned(first) then
  869. first^.previous:=p^.last;
  870. first:=p^.first;
  871. if not(assigned(last)) then
  872. last:=p^.last;
  873. { p becomes empty }
  874. p^.first:=nil;
  875. p^.last:=nil;
  876. end;
  877. procedure tlinkedlist.concat(p : plinkedlist_item);
  878. begin
  879. if not(assigned(first)) then
  880. begin
  881. first:=p;
  882. p^.previous:=nil;
  883. p^.next:=nil;
  884. end
  885. else
  886. begin
  887. last^.next:=p;
  888. p^.previous:=last;
  889. p^.next:=nil;
  890. end;
  891. last:=p;
  892. end;
  893. procedure tlinkedlist.insert(p : plinkedlist_item);
  894. begin
  895. if not(assigned(first)) then
  896. begin
  897. last:=p;
  898. p^.previous:=nil;
  899. p^.next:=nil;
  900. end
  901. else
  902. begin
  903. first^.previous:=p;
  904. p^.previous:=nil;
  905. p^.next:=first;
  906. end;
  907. first:=p;
  908. end;
  909. procedure tlinkedlist.remove(p : plinkedlist_item);
  910. begin
  911. if not(assigned(p)) then
  912. exit;
  913. if (first=p) and (last=p) then
  914. begin
  915. first:=nil;
  916. last:=nil;
  917. end
  918. else if first=p then
  919. begin
  920. first:=p^.next;
  921. if assigned(first) then
  922. first^.previous:=nil;
  923. end
  924. else if last=p then
  925. begin
  926. last:=last^.previous;
  927. if assigned(last) then
  928. last^.next:=nil;
  929. end
  930. else
  931. begin
  932. p^.previous^.next:=p^.next;
  933. p^.next^.previous:=p^.previous;
  934. end;
  935. p^.next:=nil;
  936. p^.previous:=nil;
  937. end;
  938. procedure tlinkedlist.concatlist(p : plinkedlist);
  939. begin
  940. if not(assigned(p^.first)) then
  941. exit;
  942. if not(assigned(first)) then
  943. first:=p^.first
  944. else
  945. begin
  946. last^.next:=p^.first;
  947. p^.first^.previous:=last;
  948. end;
  949. last:=p^.last;
  950. { make p empty }
  951. p^.last:=nil;
  952. p^.first:=nil;
  953. end;
  954. procedure tlinkedlist.concatlistcopy(p : plinkedlist);
  955. var
  956. newnode,newnode2 : plinkedlist_item;
  957. begin
  958. newnode:=p^.first;
  959. while assigned(newnode) do
  960. begin
  961. newnode2:=newnode^.getcopy;
  962. if assigned(newnode2) then
  963. begin
  964. if not(assigned(first)) then
  965. begin
  966. first:=newnode2;
  967. newnode2^.previous:=nil;
  968. newnode2^.next:=nil;
  969. end
  970. else
  971. begin
  972. last^.next:=newnode2;
  973. newnode2^.previous:=last;
  974. newnode2^.next:=nil;
  975. end;
  976. last:=newnode2;
  977. end;
  978. newnode:=newnode^.next;
  979. end;
  980. end;
  981. function tlinkedlist.empty:boolean;
  982. begin
  983. empty:=(first=nil);
  984. end;
  985. function tlinkedlist.count:longint;
  986. var
  987. i : longint;
  988. hp : plinkedlist_item;
  989. begin
  990. hp:=first;
  991. i:=0;
  992. while assigned(hp) do
  993. begin
  994. inc(i);
  995. hp:=hp^.next;
  996. end;
  997. count:=i;
  998. end;
  999. {****************************************************************************
  1000. Tnamedindexobject
  1001. ****************************************************************************}
  1002. constructor Tnamedindexobject.init;
  1003. begin
  1004. { index }
  1005. indexnr:=-1;
  1006. next:=nil;
  1007. { dictionary }
  1008. left:=nil;
  1009. right:=nil;
  1010. _name:=nil;
  1011. speedvalue:=-1;
  1012. end;
  1013. constructor Tnamedindexobject.initname(const n:string);
  1014. begin
  1015. { index }
  1016. indexnr:=-1;
  1017. next:=nil;
  1018. { dictionary }
  1019. left:=nil;
  1020. right:=nil;
  1021. speedvalue:=-1;
  1022. _name:=stringdup(n);
  1023. end;
  1024. destructor Tnamedindexobject.done;
  1025. begin
  1026. stringdispose(_name);
  1027. end;
  1028. procedure Tnamedindexobject.setname(const n:string);
  1029. begin
  1030. if speedvalue=-1 then
  1031. begin
  1032. if assigned(_name) then
  1033. stringdispose(_name);
  1034. _name:=stringdup(n);
  1035. end;
  1036. end;
  1037. function Tnamedindexobject.name:string;
  1038. begin
  1039. if assigned(_name) then
  1040. name:=_name^
  1041. else
  1042. name:='';
  1043. end;
  1044. {****************************************************************************
  1045. TDICTIONARY
  1046. ****************************************************************************}
  1047. constructor Tdictionary.init;
  1048. begin
  1049. root:=nil;
  1050. hasharray:=nil;
  1051. noclear:=false;
  1052. replace_existing:=false;
  1053. end;
  1054. procedure Tdictionary.usehash;
  1055. begin
  1056. if not(assigned(root)) and
  1057. not(assigned(hasharray)) then
  1058. begin
  1059. new(hasharray);
  1060. fillchar(hasharray^,sizeof(hasharray^),0);
  1061. end;
  1062. end;
  1063. destructor Tdictionary.done;
  1064. begin
  1065. if not noclear then
  1066. clear;
  1067. if assigned(hasharray) then
  1068. dispose(hasharray);
  1069. end;
  1070. procedure Tdictionary.cleartree(obj:Pnamedindexobject);
  1071. begin
  1072. if assigned(obj^.left) then
  1073. cleartree(obj^.left);
  1074. if assigned(obj^.right) then
  1075. cleartree(obj^.right);
  1076. dispose(obj,done);
  1077. obj:=nil;
  1078. end;
  1079. procedure Tdictionary.clear;
  1080. var
  1081. w : longint;
  1082. begin
  1083. if assigned(root) then
  1084. cleartree(root);
  1085. if assigned(hasharray) then
  1086. for w:=-hasharraysize to hasharraysize do
  1087. if assigned(hasharray^[w]) then
  1088. cleartree(hasharray^[w]);
  1089. end;
  1090. function Tdictionary.delete(const s:string):Pnamedindexobject;
  1091. var p,speedvalue:longint;
  1092. n:Pnamedindexobject;
  1093. procedure insert_right_bottom(var root,Atree:Pnamedindexobject);
  1094. begin
  1095. while root^.right<>nil do
  1096. root:=root^.right;
  1097. root^.right:=Atree;
  1098. end;
  1099. function delete_from_tree(root:Pnamedindexobject):Pnamedindexobject;
  1100. type leftright=(left,right);
  1101. var lr:leftright;
  1102. oldroot:Pnamedindexobject;
  1103. begin
  1104. oldroot:=nil;
  1105. while (root<>nil) and (root^.speedvalue<>speedvalue) do
  1106. begin
  1107. oldroot:=root;
  1108. if speedvalue<root^.speedvalue then
  1109. begin
  1110. root:=root^.right;
  1111. lr:=right;
  1112. end
  1113. else
  1114. begin
  1115. root:=root^.left;
  1116. lr:=left;
  1117. end;
  1118. end;
  1119. while (root<>nil) and (root^._name^<>s) do
  1120. begin
  1121. oldroot:=root;
  1122. if s<root^._name^ then
  1123. begin
  1124. root:=root^.right;
  1125. lr:=right;
  1126. end
  1127. else
  1128. begin
  1129. root:=root^.left;
  1130. lr:=left;
  1131. end;
  1132. end;
  1133. if (oldroot=nil) or (root=nil) then
  1134. do_internalerror(218); {Internalerror is not available...}
  1135. if root^.left<>nil then
  1136. begin
  1137. {Now the node pointing to root must point to the left
  1138. subtree of root. The right subtree of root must be
  1139. connected to the right bottom of the left subtree.}
  1140. if lr=left then
  1141. oldroot^.left:=root^.left
  1142. else
  1143. oldroot^.right:=root^.left;
  1144. if root^.right<>nil then
  1145. insert_right_bottom(root^.left,root^.right);
  1146. end
  1147. else
  1148. {There is no left subtree. So we can just replace the node to
  1149. delete with the right subtree.}
  1150. if lr=left then
  1151. oldroot^.left:=root^.right
  1152. else
  1153. oldroot^.right:=root^.right;
  1154. delete_from_tree:=root;
  1155. end;
  1156. begin
  1157. speedvalue:=getspeedvalue(s);
  1158. n:=root;
  1159. if assigned(hasharray) then
  1160. begin
  1161. {First, check if the node to delete directly located under
  1162. the hasharray.}
  1163. p:=speedvalue mod hasharraysize;
  1164. n:=hasharray^[p];
  1165. if (n<>nil) and (n^.speedvalue=speedvalue) and
  1166. (n^._name^=s) then
  1167. begin
  1168. {The node to delete is directly located under the
  1169. hasharray. Make the hasharray point to the left
  1170. subtree of the node and place the right subtree on
  1171. the right-bottom of the left subtree.}
  1172. if n^.left<>nil then
  1173. begin
  1174. hasharray^[p]:=n^.left;
  1175. if n^.right<>nil then
  1176. insert_right_bottom(n^.left,n^.right);
  1177. end
  1178. else
  1179. hasharray^[p]:=n^.right;
  1180. delete:=n;
  1181. exit;
  1182. end;
  1183. end
  1184. else
  1185. begin
  1186. {First check if the node to delete is the root.}
  1187. if (root<>nil) and (n^.speedvalue=speedvalue)
  1188. and (n^._name^=s) then
  1189. begin
  1190. if n^.left<>nil then
  1191. begin
  1192. root:=n^.left;
  1193. if n^.right<>nil then
  1194. insert_right_bottom(n^.left,n^.right);
  1195. end
  1196. else
  1197. root:=n^.right;
  1198. delete:=n;
  1199. exit;
  1200. end;
  1201. end;
  1202. delete:=delete_from_tree(n);
  1203. end;
  1204. function Tdictionary.empty:boolean;
  1205. var
  1206. w : longint;
  1207. begin
  1208. if assigned(hasharray) then
  1209. begin
  1210. empty:=false;
  1211. for w:=-hasharraysize to hasharraysize do
  1212. if assigned(hasharray^[w]) then
  1213. exit;
  1214. empty:=true;
  1215. end
  1216. else
  1217. empty:=(root=nil);
  1218. end;
  1219. procedure Tdictionary.foreach(proc2call:Tnamedindexcallback);
  1220. procedure a(p:Pnamedindexobject);
  1221. begin
  1222. proc2call(p);
  1223. if assigned(p^.left) then
  1224. a(p^.left);
  1225. if assigned(p^.right) then
  1226. a(p^.right);
  1227. end;
  1228. var
  1229. i : longint;
  1230. begin
  1231. if assigned(hasharray) then
  1232. begin
  1233. for i:=-hasharraysize to hasharraysize do
  1234. if assigned(hasharray^[i]) then
  1235. a(hasharray^[i]);
  1236. end
  1237. else
  1238. if assigned(root) then
  1239. a(root);
  1240. end;
  1241. function Tdictionary.insert(obj:Pnamedindexobject):Pnamedindexobject;
  1242. begin
  1243. obj^.speedvalue:=getspeedvalue(obj^._name^);
  1244. if assigned(hasharray) then
  1245. insert:=insertnode(obj,hasharray^[obj^.speedvalue mod hasharraysize])
  1246. else
  1247. insert:=insertnode(obj,root);
  1248. end;
  1249. function tdictionary.insertnode(newnode:Pnamedindexobject;var currnode:Pnamedindexobject):Pnamedindexobject;
  1250. begin
  1251. if currnode=nil then
  1252. begin
  1253. currnode:=newnode;
  1254. insertnode:=newnode;
  1255. end
  1256. { first check speedvalue, to allow a fast insert }
  1257. else
  1258. if currnode^.speedvalue>newnode^.speedvalue then
  1259. insertnode:=insertnode(newnode,currnode^.right)
  1260. else
  1261. if currnode^.speedvalue<newnode^.speedvalue then
  1262. insertnode:=insertnode(newnode,currnode^.left)
  1263. else
  1264. begin
  1265. if currnode^._name^>newnode^._name^ then
  1266. insertnode:=insertnode(newnode,currnode^.right)
  1267. else
  1268. if currnode^._name^<newnode^._name^ then
  1269. insertnode:=insertnode(newnode,currnode^.left)
  1270. else
  1271. begin
  1272. if replace_existing and
  1273. assigned(currnode) then
  1274. begin
  1275. newnode^.left:=currnode^.left;
  1276. newnode^.right:=currnode^.right;
  1277. currnode:=newnode;
  1278. insertnode:=newnode;
  1279. end
  1280. else
  1281. insertnode:=currnode;
  1282. end;
  1283. end;
  1284. end;
  1285. procedure tdictionary.inserttree(currtree,currroot:Pnamedindexobject);
  1286. begin
  1287. if assigned(currtree) then
  1288. begin
  1289. inserttree(currtree^.left,currroot);
  1290. inserttree(currtree^.right,currroot);
  1291. currtree^.right:=nil;
  1292. currtree^.left:=nil;
  1293. insertnode(currtree,currroot);
  1294. end;
  1295. end;
  1296. function tdictionary.rename(const olds,news : string):Pnamedindexobject;
  1297. var
  1298. spdval : longint;
  1299. lasthp,
  1300. hp,hp2,hp3 : Pnamedindexobject;
  1301. begin
  1302. spdval:=getspeedvalue(olds);
  1303. if assigned(hasharray) then
  1304. hp:=hasharray^[spdval mod hasharraysize]
  1305. else
  1306. hp:=root;
  1307. lasthp:=nil;
  1308. while assigned(hp) do
  1309. begin
  1310. if spdval>hp^.speedvalue then
  1311. begin
  1312. lasthp:=hp;
  1313. hp:=hp^.left
  1314. end
  1315. else
  1316. if spdval<hp^.speedvalue then
  1317. begin
  1318. lasthp:=hp;
  1319. hp:=hp^.right
  1320. end
  1321. else
  1322. begin
  1323. if (hp^.name=olds) then
  1324. begin
  1325. { get in hp2 the replacer for the root or hasharr }
  1326. hp2:=hp^.left;
  1327. hp3:=hp^.right;
  1328. if not assigned(hp2) then
  1329. begin
  1330. hp2:=hp^.right;
  1331. hp3:=hp^.left;
  1332. end;
  1333. { remove entry from the tree }
  1334. if assigned(lasthp) then
  1335. begin
  1336. if lasthp^.left=hp then
  1337. lasthp^.left:=hp2
  1338. else
  1339. lasthp^.right:=hp2;
  1340. end
  1341. else
  1342. begin
  1343. if assigned(hasharray) then
  1344. hasharray^[spdval mod hasharraysize]:=hp2
  1345. else
  1346. root:=hp2;
  1347. end;
  1348. { reinsert the hp3 in the tree from hp2 }
  1349. inserttree(hp3,hp2);
  1350. { reset node with new values }
  1351. stringdispose(hp^._name);
  1352. hp^._name:=stringdup(news);
  1353. hp^.speedvalue:=getspeedvalue(news);
  1354. hp^.left:=nil;
  1355. hp^.right:=nil;
  1356. { reinsert }
  1357. if assigned(hasharray) then
  1358. rename:=insertnode(hp,hasharray^[hp^.speedvalue mod hasharraysize])
  1359. else
  1360. rename:=insertnode(hp,root);
  1361. exit;
  1362. end
  1363. else
  1364. if olds>hp^.name then
  1365. begin
  1366. lasthp:=hp;
  1367. hp:=hp^.left
  1368. end
  1369. else
  1370. begin
  1371. lasthp:=hp;
  1372. hp:=hp^.right;
  1373. end;
  1374. end;
  1375. end;
  1376. end;
  1377. function Tdictionary.search(const s:string):Pnamedindexobject;
  1378. begin
  1379. search:=speedsearch(s,getspeedvalue(s));
  1380. end;
  1381. function Tdictionary.speedsearch(const s:string;speedvalue:longint):Pnamedindexobject;
  1382. var
  1383. newnode:Pnamedindexobject;
  1384. begin
  1385. if assigned(hasharray) then
  1386. newnode:=hasharray^[speedvalue mod hasharraysize]
  1387. else
  1388. newnode:=root;
  1389. while assigned(newnode) do
  1390. begin
  1391. if speedvalue>newnode^.speedvalue then
  1392. newnode:=newnode^.left
  1393. else
  1394. if speedvalue<newnode^.speedvalue then
  1395. newnode:=newnode^.right
  1396. else
  1397. begin
  1398. if (newnode^._name^=s) then
  1399. begin
  1400. speedsearch:=newnode;
  1401. exit;
  1402. end
  1403. else
  1404. if s>newnode^._name^ then
  1405. newnode:=newnode^.left
  1406. else
  1407. newnode:=newnode^.right;
  1408. end;
  1409. end;
  1410. speedsearch:=nil;
  1411. end;
  1412. {****************************************************************************
  1413. tdynamicarray
  1414. ****************************************************************************}
  1415. constructor tdynamicarray.init(Aelemlen,Agrow:longint);
  1416. begin
  1417. posn:=0;
  1418. count:=0;
  1419. limit:=0;
  1420. data:=nil;
  1421. elemlen:=Aelemlen;
  1422. growcount:=Agrow;
  1423. grow;
  1424. end;
  1425. function tdynamicarray.size:longint;
  1426. begin
  1427. size:=limit*elemlen;
  1428. end;
  1429. function tdynamicarray.usedsize:longint;
  1430. begin
  1431. usedsize:=count*elemlen;
  1432. end;
  1433. procedure tdynamicarray.grow;
  1434. var
  1435. osize : longint;
  1436. odata : pchar;
  1437. begin
  1438. osize:=size;
  1439. odata:=data;
  1440. inc(limit,growcount);
  1441. getmem(data,size);
  1442. if assigned(odata) then
  1443. begin
  1444. move(odata^,data^,osize);
  1445. freemem(odata,osize);
  1446. end;
  1447. fillchar(data[osize],growcount*elemlen,0);
  1448. end;
  1449. procedure tdynamicarray.align(i:longint);
  1450. var
  1451. j : longint;
  1452. begin
  1453. j:=(posn*elemlen mod i);
  1454. if j<>0 then
  1455. begin
  1456. j:=i-j;
  1457. while limit<(posn+j) do
  1458. grow;
  1459. inc(posn,j);
  1460. if (posn>count) then
  1461. count:=posn;
  1462. end;
  1463. end;
  1464. procedure tdynamicarray.seek(i:longint);
  1465. begin
  1466. while limit<i do
  1467. grow;
  1468. posn:=i;
  1469. if (posn>count) then
  1470. count:=posn;
  1471. end;
  1472. procedure tdynamicarray.write(var d;len:longint);
  1473. begin
  1474. while limit<(posn+len) do
  1475. grow;
  1476. move(d,data[posn*elemlen],len*elemlen);
  1477. inc(posn,len);
  1478. if (posn>count) then
  1479. count:=posn;
  1480. end;
  1481. procedure tdynamicarray.read(var d;len:longint);
  1482. begin
  1483. move(data[posn*elemlen],d,len*elemlen);
  1484. inc(posn,len);
  1485. if (posn>count) then
  1486. count:=posn;
  1487. end;
  1488. procedure tdynamicarray.writepos(pos:longint;var d;len:longint);
  1489. begin
  1490. while limit<(pos+len) do
  1491. grow;
  1492. move(d,data[pos*elemlen],len*elemlen);
  1493. posn:=pos+len;
  1494. if (posn>count) then
  1495. count:=posn;
  1496. end;
  1497. procedure tdynamicarray.readpos(pos:longint;var d;len:longint);
  1498. begin
  1499. while limit<(pos+len) do
  1500. grow;
  1501. move(data[pos*elemlen],d,len*elemlen);
  1502. posn:=pos+len;
  1503. if (posn>count) then
  1504. count:=posn;
  1505. end;
  1506. destructor tdynamicarray.done;
  1507. begin
  1508. if assigned(data) then
  1509. freemem(data,size);
  1510. end;
  1511. {****************************************************************************
  1512. tindexarray
  1513. ****************************************************************************}
  1514. constructor tindexarray.init(Agrowsize:longint);
  1515. begin
  1516. growsize:=Agrowsize;
  1517. size:=0;
  1518. count:=0;
  1519. data:=nil;
  1520. first:=nil;
  1521. end;
  1522. destructor tindexarray.done;
  1523. begin
  1524. if assigned(data) then
  1525. begin
  1526. clear;
  1527. freemem(data,size*4);
  1528. data:=nil;
  1529. end;
  1530. end;
  1531. function tindexarray.search(nr:longint):Pnamedindexobject;
  1532. begin
  1533. if nr<=count then
  1534. search:=data^[nr]
  1535. else
  1536. search:=nil;
  1537. end;
  1538. procedure tindexarray.clear;
  1539. var
  1540. i : longint;
  1541. begin
  1542. for i:=1 to count do
  1543. if assigned(data^[i]) then
  1544. begin
  1545. dispose(data^[i],done);
  1546. data^[i]:=nil;
  1547. end;
  1548. count:=0;
  1549. first:=nil;
  1550. end;
  1551. procedure tindexarray.foreach(proc2call : Tnamedindexcallback);
  1552. var
  1553. i : longint;
  1554. begin
  1555. for i:=1 to count do
  1556. if assigned(data^[i]) then
  1557. proc2call(data^[i]);
  1558. end;
  1559. procedure tindexarray.grow(gsize:longint);
  1560. var
  1561. osize : longint;
  1562. odata : Pnamedindexobjectarray;
  1563. begin
  1564. osize:=size;
  1565. odata:=data;
  1566. inc(size,gsize);
  1567. getmem(data,size*4);
  1568. if assigned(odata) then
  1569. begin
  1570. move(odata^,data^,osize*4);
  1571. freemem(odata,osize*4);
  1572. end;
  1573. fillchar(data^[osize+1],gsize*4,0);
  1574. end;
  1575. procedure tindexarray.deleteindex(p:Pnamedindexobject);
  1576. var
  1577. i : longint;
  1578. begin
  1579. i:=p^.indexnr;
  1580. { update counter }
  1581. if i=count then
  1582. dec(count);
  1583. { update linked list }
  1584. while (i>0) do
  1585. begin
  1586. dec(i);
  1587. if (i>0) and assigned(data^[i]) then
  1588. begin
  1589. data^[i]^.next:=data^[p^.indexnr]^.next;
  1590. break;
  1591. end;
  1592. end;
  1593. if i=0 then
  1594. first:=p^.next;
  1595. data^[p^.indexnr]:=nil;
  1596. { clear entry }
  1597. p^.indexnr:=-1;
  1598. p^.next:=nil;
  1599. end;
  1600. procedure tindexarray.delete(p:Pnamedindexobject);
  1601. begin
  1602. deleteindex(p);
  1603. dispose(p,done);
  1604. p:=nil;
  1605. end;
  1606. procedure tindexarray.insert(p:Pnamedindexobject);
  1607. var
  1608. i : longint;
  1609. begin
  1610. if p^.indexnr=-1 then
  1611. begin
  1612. inc(count);
  1613. p^.indexnr:=count;
  1614. end;
  1615. if p^.indexnr>count then
  1616. count:=p^.indexnr;
  1617. if count>size then
  1618. grow(((count div growsize)+1)*growsize);
  1619. data^[p^.indexnr]:=p;
  1620. { update linked list backward }
  1621. i:=p^.indexnr;
  1622. while (i>0) do
  1623. begin
  1624. dec(i);
  1625. if (i>0) and assigned(data^[i]) then
  1626. begin
  1627. data^[i]^.next:=p;
  1628. break;
  1629. end;
  1630. end;
  1631. if i=0 then
  1632. first:=p;
  1633. { update linked list forward }
  1634. i:=p^.indexnr;
  1635. while (i<=count) do
  1636. begin
  1637. inc(i);
  1638. if (i<=count) and assigned(data^[i]) then
  1639. begin
  1640. p^.next:=data^[i];
  1641. exit;
  1642. end;
  1643. end;
  1644. if i>count then
  1645. p^.next:=nil;
  1646. end;
  1647. {$ifdef BUFFEREDFILE}
  1648. {****************************************************************************
  1649. TBUFFEREDFILE
  1650. ****************************************************************************}
  1651. Const
  1652. crcseed = $ffffffff;
  1653. crctable : array[0..255] of longint = (
  1654. $00000000,$77073096,$ee0e612c,$990951ba,$076dc419,$706af48f,
  1655. $e963a535,$9e6495a3,$0edb8832,$79dcb8a4,$e0d5e91e,$97d2d988,
  1656. $09b64c2b,$7eb17cbd,$e7b82d07,$90bf1d91,$1db71064,$6ab020f2,
  1657. $f3b97148,$84be41de,$1adad47d,$6ddde4eb,$f4d4b551,$83d385c7,
  1658. $136c9856,$646ba8c0,$fd62f97a,$8a65c9ec,$14015c4f,$63066cd9,
  1659. $fa0f3d63,$8d080df5,$3b6e20c8,$4c69105e,$d56041e4,$a2677172,
  1660. $3c03e4d1,$4b04d447,$d20d85fd,$a50ab56b,$35b5a8fa,$42b2986c,
  1661. $dbbbc9d6,$acbcf940,$32d86ce3,$45df5c75,$dcd60dcf,$abd13d59,
  1662. $26d930ac,$51de003a,$c8d75180,$bfd06116,$21b4f4b5,$56b3c423,
  1663. $cfba9599,$b8bda50f,$2802b89e,$5f058808,$c60cd9b2,$b10be924,
  1664. $2f6f7c87,$58684c11,$c1611dab,$b6662d3d,$76dc4190,$01db7106,
  1665. $98d220bc,$efd5102a,$71b18589,$06b6b51f,$9fbfe4a5,$e8b8d433,
  1666. $7807c9a2,$0f00f934,$9609a88e,$e10e9818,$7f6a0dbb,$086d3d2d,
  1667. $91646c97,$e6635c01,$6b6b51f4,$1c6c6162,$856530d8,$f262004e,
  1668. $6c0695ed,$1b01a57b,$8208f4c1,$f50fc457,$65b0d9c6,$12b7e950,
  1669. $8bbeb8ea,$fcb9887c,$62dd1ddf,$15da2d49,$8cd37cf3,$fbd44c65,
  1670. $4db26158,$3ab551ce,$a3bc0074,$d4bb30e2,$4adfa541,$3dd895d7,
  1671. $a4d1c46d,$d3d6f4fb,$4369e96a,$346ed9fc,$ad678846,$da60b8d0,
  1672. $44042d73,$33031de5,$aa0a4c5f,$dd0d7cc9,$5005713c,$270241aa,
  1673. $be0b1010,$c90c2086,$5768b525,$206f85b3,$b966d409,$ce61e49f,
  1674. $5edef90e,$29d9c998,$b0d09822,$c7d7a8b4,$59b33d17,$2eb40d81,
  1675. $b7bd5c3b,$c0ba6cad,$edb88320,$9abfb3b6,$03b6e20c,$74b1d29a,
  1676. $ead54739,$9dd277af,$04db2615,$73dc1683,$e3630b12,$94643b84,
  1677. $0d6d6a3e,$7a6a5aa8,$e40ecf0b,$9309ff9d,$0a00ae27,$7d079eb1,
  1678. $f00f9344,$8708a3d2,$1e01f268,$6906c2fe,$f762575d,$806567cb,
  1679. $196c3671,$6e6b06e7,$fed41b76,$89d32be0,$10da7a5a,$67dd4acc,
  1680. $f9b9df6f,$8ebeeff9,$17b7be43,$60b08ed5,$d6d6a3e8,$a1d1937e,
  1681. $38d8c2c4,$4fdff252,$d1bb67f1,$a6bc5767,$3fb506dd,$48b2364b,
  1682. $d80d2bda,$af0a1b4c,$36034af6,$41047a60,$df60efc3,$a867df55,
  1683. $316e8eef,$4669be79,$cb61b38c,$bc66831a,$256fd2a0,$5268e236,
  1684. $cc0c7795,$bb0b4703,$220216b9,$5505262f,$c5ba3bbe,$b2bd0b28,
  1685. $2bb45a92,$5cb36a04,$c2d7ffa7,$b5d0cf31,$2cd99e8b,$5bdeae1d,
  1686. $9b64c2b0,$ec63f226,$756aa39c,$026d930a,$9c0906a9,$eb0e363f,
  1687. $72076785,$05005713,$95bf4a82,$e2b87a14,$7bb12bae,$0cb61b38,
  1688. $92d28e9b,$e5d5be0d,$7cdcefb7,$0bdbdf21,$86d3d2d4,$f1d4e242,
  1689. $68ddb3f8,$1fda836e,$81be16cd,$f6b9265b,$6fb077e1,$18b74777,
  1690. $88085ae6,$ff0f6a70,$66063bca,$11010b5c,$8f659eff,$f862ae69,
  1691. $616bffd3,$166ccf45,$a00ae278,$d70dd2ee,$4e048354,$3903b3c2,
  1692. $a7672661,$d06016f7,$4969474d,$3e6e77db,$aed16a4a,$d9d65adc,
  1693. $40df0b66,$37d83bf0,$a9bcae53,$debb9ec5,$47b2cf7f,$30b5ffe9,
  1694. $bdbdf21c,$cabac28a,$53b39330,$24b4a3a6,$bad03605,$cdd70693,
  1695. $54de5729,$23d967bf,$b3667a2e,$c4614ab8,$5d681b02,$2a6f2b94,
  1696. $b40bbe37,$c30c8ea1,$5a05df1b,$2d02ef8d);
  1697. constructor tbufferedfile.init(const filename : string;_bufsize : longint);
  1698. begin
  1699. assign(f,filename);
  1700. bufsize:=_bufsize;
  1701. bufpos:=0;
  1702. buflast:=0;
  1703. do_crc:=false;
  1704. iomode:=0;
  1705. tempclosed:=false;
  1706. change_endian:=false;
  1707. clear_crc;
  1708. end;
  1709. destructor tbufferedfile.done;
  1710. begin
  1711. close;
  1712. end;
  1713. procedure tbufferedfile.clear_crc;
  1714. begin
  1715. crc:=crcseed;
  1716. end;
  1717. procedure tbufferedfile.setbuf(p : pchar;s : longint);
  1718. begin
  1719. flush;
  1720. freemem(buf,bufsize);
  1721. bufsize:=s;
  1722. buf:=p;
  1723. end;
  1724. function tbufferedfile.reset:boolean;
  1725. var
  1726. ofm : byte;
  1727. begin
  1728. ofm:=filemode;
  1729. iomode:=1;
  1730. getmem(buf,bufsize);
  1731. filemode:=0;
  1732. {$I-}
  1733. system.reset(f,1);
  1734. {$I+}
  1735. reset:=(ioresult=0);
  1736. filemode:=ofm;
  1737. end;
  1738. procedure tbufferedfile.rewrite;
  1739. begin
  1740. iomode:=2;
  1741. getmem(buf,bufsize);
  1742. system.rewrite(f,1);
  1743. end;
  1744. procedure tbufferedfile.flush;
  1745. var
  1746. {$ifdef FPC}
  1747. count : longint;
  1748. {$else}
  1749. count : integer;
  1750. {$endif}
  1751. begin
  1752. if iomode=2 then
  1753. begin
  1754. if bufpos=0 then
  1755. exit;
  1756. blockwrite(f,buf^,bufpos)
  1757. end
  1758. else if iomode=1 then
  1759. if buflast=bufpos then
  1760. begin
  1761. blockread(f,buf^,bufsize,count);
  1762. buflast:=count;
  1763. end;
  1764. bufpos:=0;
  1765. end;
  1766. function tbufferedfile.getftime : longint;
  1767. var
  1768. l : longint;
  1769. {$ifdef linux}
  1770. Info : Stat;
  1771. {$endif}
  1772. begin
  1773. {$ifndef linux}
  1774. { this only works if the file is open !! }
  1775. dos.getftime(f,l);
  1776. {$else}
  1777. Fstat(f,Info);
  1778. l:=info.mtime;
  1779. {$endif}
  1780. getftime:=l;
  1781. end;
  1782. function tbufferedfile.getsize : longint;
  1783. begin
  1784. getsize:=filesize(f);
  1785. end;
  1786. procedure tbufferedfile.seek(l : longint);
  1787. begin
  1788. if iomode=2 then
  1789. begin
  1790. flush;
  1791. system.seek(f,l);
  1792. end
  1793. else if iomode=1 then
  1794. begin
  1795. { forces a reload }
  1796. bufpos:=buflast;
  1797. system.seek(f,l);
  1798. flush;
  1799. end;
  1800. end;
  1801. type
  1802. {$ifdef tp}
  1803. bytearray1 = array [1..65535] of byte;
  1804. {$else}
  1805. bytearray1 = array [1..10000000] of byte;
  1806. {$endif}
  1807. procedure tbufferedfile.read_data(var data;bytes : longint;var count : longint);
  1808. var
  1809. p : pchar;
  1810. c,i : longint;
  1811. begin
  1812. p:=pchar(@data);
  1813. count:=0;
  1814. while bytes-count>0 do
  1815. begin
  1816. if bytes-count>buflast-bufpos then
  1817. begin
  1818. move((buf+bufpos)^,(p+count)^,buflast-bufpos);
  1819. inc(count,buflast-bufpos);
  1820. bufpos:=buflast;
  1821. flush;
  1822. { can't we read anything ? }
  1823. if bufpos=buflast then
  1824. break;
  1825. end
  1826. else
  1827. begin
  1828. move((buf+bufpos)^,(p+count)^,bytes-count);
  1829. inc(bufpos,bytes-count);
  1830. count:=bytes;
  1831. break;
  1832. end;
  1833. end;
  1834. if do_crc then
  1835. begin
  1836. c:=crc;
  1837. for i:=1 to bytes do
  1838. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1839. crc:=c;
  1840. end;
  1841. end;
  1842. procedure tbufferedfile.write_data(var data;count : longint);
  1843. var
  1844. c,i : longint;
  1845. begin
  1846. if bufpos+count>bufsize then
  1847. flush;
  1848. move(data,(buf+bufpos)^,count);
  1849. inc(bufpos,count);
  1850. if do_crc then
  1851. begin
  1852. c:=crc;
  1853. for i:=1 to count do
  1854. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1855. crc:=c;
  1856. end;
  1857. end;
  1858. function tbufferedfile.getcrc : longint;
  1859. begin
  1860. getcrc:=crc xor crcseed;
  1861. end;
  1862. procedure tbufferedfile.write_string(const s : string);
  1863. begin
  1864. if bufpos+length(s)>bufsize then
  1865. flush;
  1866. { why is there not CRC here ??? }
  1867. move(s[1],(buf+bufpos)^,length(s));
  1868. inc(bufpos,length(s));
  1869. { should be
  1870. write_data(s[1],length(s)); }
  1871. end;
  1872. procedure tbufferedfile.write_pchar(p : pchar);
  1873. var
  1874. l : longint;
  1875. begin
  1876. l:=strlen(p);
  1877. if l>=bufsize then
  1878. do_internalerror(222);
  1879. { why is there not CRC here ???}
  1880. if bufpos+l>bufsize then
  1881. flush;
  1882. move(p^,(buf+bufpos)^,l);
  1883. inc(bufpos,l);
  1884. { should be
  1885. write_data(p^,l); }
  1886. end;
  1887. procedure tbufferedfile.write_byte(b : byte);
  1888. begin
  1889. write_data(b,sizeof(byte));
  1890. end;
  1891. procedure tbufferedfile.write_long(l : longint);
  1892. var
  1893. w1,w2 : word;
  1894. begin
  1895. if change_endian then
  1896. begin
  1897. w1:=l and $ffff;
  1898. w2:=l shr 16;
  1899. l:=swap(w2)+(longint(swap(w1)) shl 16);
  1900. end;
  1901. write_data(l,sizeof(longint));
  1902. end;
  1903. procedure tbufferedfile.write_word(w : word);
  1904. begin
  1905. if change_endian then
  1906. begin
  1907. w:=swap(w);
  1908. end;
  1909. write_data(w,sizeof(word));
  1910. end;
  1911. procedure tbufferedfile.write_double(d : double);
  1912. begin
  1913. write_data(d,sizeof(double));
  1914. end;
  1915. function tbufferedfile.getpath : string;
  1916. begin
  1917. {$ifdef dummy}
  1918. getpath:=strpas(filerec(f).name);
  1919. {$endif}
  1920. getpath:='';
  1921. end;
  1922. procedure tbufferedfile.close;
  1923. begin
  1924. if iomode<>0 then
  1925. begin
  1926. flush;
  1927. system.close(f);
  1928. freemem(buf,bufsize);
  1929. buf:=nil;
  1930. iomode:=0;
  1931. end;
  1932. end;
  1933. procedure tbufferedfile.tempclose;
  1934. begin
  1935. if iomode<>0 then
  1936. begin
  1937. temppos:=system.filepos(f);
  1938. tempmode:=iomode;
  1939. tempclosed:=true;
  1940. system.close(f);
  1941. iomode:=0;
  1942. end
  1943. else
  1944. tempclosed:=false;
  1945. end;
  1946. procedure tbufferedfile.tempreopen;
  1947. var
  1948. ofm : byte;
  1949. begin
  1950. if tempclosed then
  1951. begin
  1952. case tempmode of
  1953. 1 : begin
  1954. ofm:=filemode;
  1955. iomode:=1;
  1956. filemode:=0;
  1957. system.reset(f,1);
  1958. filemode:=ofm;
  1959. end;
  1960. 2 : begin
  1961. iomode:=2;
  1962. system.rewrite(f,1);
  1963. end;
  1964. end;
  1965. system.seek(f,temppos);
  1966. tempclosed:=false;
  1967. end;
  1968. end;
  1969. {$endif BUFFEREDFILE}
  1970. end.
  1971. {
  1972. $Log$
  1973. Revision 1.50 2000-01-07 01:14:23 peter
  1974. * updated copyright to 2000
  1975. Revision 1.49 1999/12/22 01:01:48 peter
  1976. - removed freelabel()
  1977. * added undefined label detection in internal assembler, this prevents
  1978. a lot of ld crashes and wrong .o files
  1979. * .o files aren't written anymore if errors have occured
  1980. * inlining of assembler labels is now correct
  1981. Revision 1.48 1999/12/06 18:21:03 peter
  1982. * support !ENVVAR for long commandlines
  1983. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1984. finally supported as installdir.
  1985. Revision 1.47 1999/11/15 14:59:55 pierre
  1986. * last was not handled correctly in TStringQueue
  1987. Revision 1.46 1999/11/14 15:56:36 peter
  1988. * fixed stringqueue.delete
  1989. Revision 1.45 1999/11/12 11:03:49 peter
  1990. * searchpaths changed to stringqueue object
  1991. Revision 1.44 1999/11/06 14:34:20 peter
  1992. * truncated log to 20 revs
  1993. Revision 1.43 1999/10/26 12:30:41 peter
  1994. * const parameter is now checked
  1995. * better and generic check if a node can be used for assigning
  1996. * export fixes
  1997. * procvar equal works now (it never had worked at least from 0.99.8)
  1998. * defcoll changed to linkedlist with pparaitem so it can easily be
  1999. walked both directions
  2000. Revision 1.42 1999/09/07 15:08:51 pierre
  2001. * runerror => do_internalerror
  2002. Revision 1.41 1999/08/24 13:13:57 peter
  2003. * MEMDEBUG to see the sizes of asmlist,asmsymbols,symtables
  2004. Revision 1.40 1999/08/12 23:19:05 pierre
  2005. * added inherited init call to tstringcontainer.init_no_double for Peter
  2006. Revision 1.39 1999/08/05 14:58:07 florian
  2007. * some fixes for the floating point registers
  2008. * more things for the new code generator
  2009. Revision 1.38 1999/07/18 10:19:46 florian
  2010. * made it compilable with Dlephi 4 again
  2011. + fixed problem with large stack allocations on win32
  2012. Revision 1.37 1999/07/03 00:29:45 peter
  2013. * new link writing to the ppu, one .ppu is needed for all link types,
  2014. static (.o) is now always created also when smartlinking is used
  2015. Revision 1.36 1999/06/23 11:13:20 peter
  2016. * fixed linebreak
  2017. Revision 1.35 1999/06/23 11:07:23 daniel
  2018. * Tdictionary.delete
  2019. Revision 1.33.2.1 1999/06/15 10:12:22 peter
  2020. * fixed inserttree which didn't reset left,right
  2021. Revision 1.33 1999/05/31 23:33:21 peter
  2022. * fixed tdictionary rename which didn't reset left,right when
  2023. reinserting
  2024. Revision 1.32 1999/05/27 19:44:23 peter
  2025. * removed oldasm
  2026. * plabel -> pasmlabel
  2027. * -a switches to source writing automaticly
  2028. * assembler readers OOPed
  2029. * asmsymbol automaticly external
  2030. * jumptables and other label fixes for asm readers
  2031. Revision 1.31 1999/05/21 13:54:59 peter
  2032. * NEWLAB for label as symbol
  2033. Revision 1.30 1999/05/21 10:38:59 peter
  2034. * fixed deleteindex which didn't reset indexnr and set first wrong
  2035. Revision 1.29 1999/05/08 19:47:27 peter
  2036. * indexarray.delete resets pointer after dispose
  2037. Revision 1.28 1999/05/05 10:05:48 florian
  2038. * a delphi compiled compiler recompiles ppc
  2039. Revision 1.27 1999/05/05 09:19:03 florian
  2040. * more fixes to get it with delphi running
  2041. Revision 1.26 1999/04/21 09:43:31 peter
  2042. * storenumber works
  2043. * fixed some typos in double_checksum
  2044. + incompatible types type1 and type2 message (with storenumber)
  2045. Revision 1.25 1999/04/15 10:01:44 peter
  2046. * small update for storenumber
  2047. Revision 1.24 1999/04/14 09:14:47 peter
  2048. * first things to store the symbol/def number in the ppu
  2049. }