cobjects.pas 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 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. var
  1251. s1,s2:^string;
  1252. begin
  1253. if currnode=nil then
  1254. begin
  1255. currnode:=newnode;
  1256. insertnode:=currnode;
  1257. end
  1258. { first check speedvalue, to allow a fast insert }
  1259. else
  1260. if currnode^.speedvalue>newnode^.speedvalue then
  1261. insertnode:=insertnode(newnode,currnode^.right)
  1262. else
  1263. if currnode^.speedvalue<newnode^.speedvalue then
  1264. insertnode:=insertnode(newnode,currnode^.left)
  1265. else
  1266. begin
  1267. new(s1);
  1268. new(s2);
  1269. s1^:=currnode^._name^;
  1270. s2^:=newnode^._name^;
  1271. if s1^>s2^ then
  1272. begin
  1273. dispose(s2);
  1274. dispose(s1);
  1275. insertnode:=insertnode(newnode,currnode^.right);
  1276. end
  1277. else
  1278. if s1^<s2^ then
  1279. begin
  1280. dispose(s2);
  1281. dispose(s1);
  1282. insertnode:=insertnode(newnode,currnode^.left);
  1283. end
  1284. else
  1285. begin
  1286. dispose(s2);
  1287. dispose(s1);
  1288. if replace_existing and
  1289. assigned(currnode) then
  1290. begin
  1291. newnode^.left:=currnode^.left;
  1292. newnode^.right:=currnode^.right;
  1293. currnode:=newnode;
  1294. insertnode:=newnode;
  1295. end
  1296. else
  1297. insertnode:=currnode;
  1298. end;
  1299. end;
  1300. end;
  1301. procedure tdictionary.inserttree(currtree,currroot:Pnamedindexobject);
  1302. begin
  1303. if assigned(currtree) then
  1304. begin
  1305. inserttree(currtree^.left,currroot);
  1306. inserttree(currtree^.right,currroot);
  1307. currtree^.right:=nil;
  1308. currtree^.left:=nil;
  1309. insertnode(currtree,currroot);
  1310. end;
  1311. end;
  1312. function tdictionary.rename(const olds,news : string):Pnamedindexobject;
  1313. var
  1314. spdval : longint;
  1315. lasthp,
  1316. hp,hp2,hp3 : Pnamedindexobject;
  1317. begin
  1318. spdval:=getspeedvalue(olds);
  1319. if assigned(hasharray) then
  1320. hp:=hasharray^[spdval mod hasharraysize]
  1321. else
  1322. hp:=root;
  1323. lasthp:=nil;
  1324. while assigned(hp) do
  1325. begin
  1326. if spdval>hp^.speedvalue then
  1327. begin
  1328. lasthp:=hp;
  1329. hp:=hp^.left
  1330. end
  1331. else
  1332. if spdval<hp^.speedvalue then
  1333. begin
  1334. lasthp:=hp;
  1335. hp:=hp^.right
  1336. end
  1337. else
  1338. begin
  1339. if (hp^.name=olds) then
  1340. begin
  1341. { get in hp2 the replacer for the root or hasharr }
  1342. hp2:=hp^.left;
  1343. hp3:=hp^.right;
  1344. if not assigned(hp2) then
  1345. begin
  1346. hp2:=hp^.right;
  1347. hp3:=hp^.left;
  1348. end;
  1349. { remove entry from the tree }
  1350. if assigned(lasthp) then
  1351. begin
  1352. if lasthp^.left=hp then
  1353. lasthp^.left:=hp2
  1354. else
  1355. lasthp^.right:=hp2;
  1356. end
  1357. else
  1358. begin
  1359. if assigned(hasharray) then
  1360. hasharray^[spdval mod hasharraysize]:=hp2
  1361. else
  1362. root:=hp2;
  1363. end;
  1364. { reinsert the hp3 in the tree from hp2 }
  1365. inserttree(hp3,hp2);
  1366. { reset node with new values }
  1367. stringdispose(hp^._name);
  1368. hp^._name:=stringdup(news);
  1369. hp^.speedvalue:=getspeedvalue(news);
  1370. hp^.left:=nil;
  1371. hp^.right:=nil;
  1372. { reinsert }
  1373. if assigned(hasharray) then
  1374. rename:=insertnode(hp,hasharray^[hp^.speedvalue mod hasharraysize])
  1375. else
  1376. rename:=insertnode(hp,root);
  1377. exit;
  1378. end
  1379. else
  1380. if olds>hp^.name then
  1381. begin
  1382. lasthp:=hp;
  1383. hp:=hp^.left
  1384. end
  1385. else
  1386. begin
  1387. lasthp:=hp;
  1388. hp:=hp^.right;
  1389. end;
  1390. end;
  1391. end;
  1392. end;
  1393. function Tdictionary.search(const s:string):Pnamedindexobject;
  1394. begin
  1395. search:=speedsearch(s,getspeedvalue(s));
  1396. end;
  1397. function Tdictionary.speedsearch(const s:string;speedvalue:longint):Pnamedindexobject;
  1398. var
  1399. newnode:Pnamedindexobject;
  1400. begin
  1401. if assigned(hasharray) then
  1402. newnode:=hasharray^[speedvalue mod hasharraysize]
  1403. else
  1404. newnode:=root;
  1405. while assigned(newnode) do
  1406. begin
  1407. if speedvalue>newnode^.speedvalue then
  1408. newnode:=newnode^.left
  1409. else
  1410. if speedvalue<newnode^.speedvalue then
  1411. newnode:=newnode^.right
  1412. else
  1413. begin
  1414. if (newnode^._name^=s) then
  1415. begin
  1416. speedsearch:=newnode;
  1417. exit;
  1418. end
  1419. else
  1420. if s>newnode^._name^ then
  1421. newnode:=newnode^.left
  1422. else
  1423. newnode:=newnode^.right;
  1424. end;
  1425. end;
  1426. speedsearch:=nil;
  1427. end;
  1428. {****************************************************************************
  1429. tdynamicarray
  1430. ****************************************************************************}
  1431. constructor tdynamicarray.init(Aelemlen,Agrow:longint);
  1432. begin
  1433. posn:=0;
  1434. count:=0;
  1435. limit:=0;
  1436. data:=nil;
  1437. elemlen:=Aelemlen;
  1438. growcount:=Agrow;
  1439. grow;
  1440. end;
  1441. function tdynamicarray.size:longint;
  1442. begin
  1443. size:=limit*elemlen;
  1444. end;
  1445. function tdynamicarray.usedsize:longint;
  1446. begin
  1447. usedsize:=count*elemlen;
  1448. end;
  1449. procedure tdynamicarray.grow;
  1450. var
  1451. osize : longint;
  1452. odata : pchar;
  1453. begin
  1454. osize:=size;
  1455. odata:=data;
  1456. inc(limit,growcount);
  1457. getmem(data,size);
  1458. if assigned(odata) then
  1459. begin
  1460. move(odata^,data^,osize);
  1461. freemem(odata,osize);
  1462. end;
  1463. fillchar(data[osize],growcount*elemlen,0);
  1464. end;
  1465. procedure tdynamicarray.align(i:longint);
  1466. var
  1467. j : longint;
  1468. begin
  1469. j:=(posn*elemlen mod i);
  1470. if j<>0 then
  1471. begin
  1472. j:=i-j;
  1473. while limit<(posn+j) do
  1474. grow;
  1475. inc(posn,j);
  1476. if (posn>count) then
  1477. count:=posn;
  1478. end;
  1479. end;
  1480. procedure tdynamicarray.seek(i:longint);
  1481. begin
  1482. while limit<i do
  1483. grow;
  1484. posn:=i;
  1485. if (posn>count) then
  1486. count:=posn;
  1487. end;
  1488. procedure tdynamicarray.write(var d;len:longint);
  1489. begin
  1490. while limit<(posn+len) do
  1491. grow;
  1492. move(d,data[posn*elemlen],len*elemlen);
  1493. inc(posn,len);
  1494. if (posn>count) then
  1495. count:=posn;
  1496. end;
  1497. procedure tdynamicarray.read(var d;len:longint);
  1498. begin
  1499. move(data[posn*elemlen],d,len*elemlen);
  1500. inc(posn,len);
  1501. if (posn>count) then
  1502. count:=posn;
  1503. end;
  1504. procedure tdynamicarray.writepos(pos:longint;var d;len:longint);
  1505. begin
  1506. while limit<(pos+len) do
  1507. grow;
  1508. move(d,data[pos*elemlen],len*elemlen);
  1509. posn:=pos+len;
  1510. if (posn>count) then
  1511. count:=posn;
  1512. end;
  1513. procedure tdynamicarray.readpos(pos:longint;var d;len:longint);
  1514. begin
  1515. while limit<(pos+len) do
  1516. grow;
  1517. move(data[pos*elemlen],d,len*elemlen);
  1518. posn:=pos+len;
  1519. if (posn>count) then
  1520. count:=posn;
  1521. end;
  1522. destructor tdynamicarray.done;
  1523. begin
  1524. if assigned(data) then
  1525. freemem(data,size);
  1526. end;
  1527. {****************************************************************************
  1528. tindexarray
  1529. ****************************************************************************}
  1530. constructor tindexarray.init(Agrowsize:longint);
  1531. begin
  1532. growsize:=Agrowsize;
  1533. size:=0;
  1534. count:=0;
  1535. data:=nil;
  1536. first:=nil;
  1537. end;
  1538. destructor tindexarray.done;
  1539. begin
  1540. if assigned(data) then
  1541. begin
  1542. clear;
  1543. freemem(data,size*4);
  1544. data:=nil;
  1545. end;
  1546. end;
  1547. function tindexarray.search(nr:longint):Pnamedindexobject;
  1548. begin
  1549. if nr<=count then
  1550. search:=data^[nr]
  1551. else
  1552. search:=nil;
  1553. end;
  1554. procedure tindexarray.clear;
  1555. var
  1556. i : longint;
  1557. begin
  1558. for i:=1 to count do
  1559. if assigned(data^[i]) then
  1560. begin
  1561. dispose(data^[i],done);
  1562. data^[i]:=nil;
  1563. end;
  1564. count:=0;
  1565. first:=nil;
  1566. end;
  1567. procedure tindexarray.foreach(proc2call : Tnamedindexcallback);
  1568. var
  1569. i : longint;
  1570. begin
  1571. for i:=1 to count do
  1572. if assigned(data^[i]) then
  1573. proc2call(data^[i]);
  1574. end;
  1575. procedure tindexarray.grow(gsize:longint);
  1576. var
  1577. osize : longint;
  1578. odata : Pnamedindexobjectarray;
  1579. begin
  1580. osize:=size;
  1581. odata:=data;
  1582. inc(size,gsize);
  1583. getmem(data,size*4);
  1584. if assigned(odata) then
  1585. begin
  1586. move(odata^,data^,osize*4);
  1587. freemem(odata,osize*4);
  1588. end;
  1589. fillchar(data^[osize+1],gsize*4,0);
  1590. end;
  1591. procedure tindexarray.deleteindex(p:Pnamedindexobject);
  1592. var
  1593. i : longint;
  1594. begin
  1595. i:=p^.indexnr;
  1596. { update counter }
  1597. if i=count then
  1598. dec(count);
  1599. { update linked list }
  1600. while (i>0) do
  1601. begin
  1602. dec(i);
  1603. if (i>0) and assigned(data^[i]) then
  1604. begin
  1605. data^[i]^.next:=data^[p^.indexnr]^.next;
  1606. break;
  1607. end;
  1608. end;
  1609. if i=0 then
  1610. first:=p^.next;
  1611. data^[p^.indexnr]:=nil;
  1612. { clear entry }
  1613. p^.indexnr:=-1;
  1614. p^.next:=nil;
  1615. end;
  1616. procedure tindexarray.delete(p:Pnamedindexobject);
  1617. begin
  1618. deleteindex(p);
  1619. dispose(p,done);
  1620. p:=nil;
  1621. end;
  1622. procedure tindexarray.insert(p:Pnamedindexobject);
  1623. var
  1624. i : longint;
  1625. begin
  1626. if p^.indexnr=-1 then
  1627. begin
  1628. inc(count);
  1629. p^.indexnr:=count;
  1630. end;
  1631. if p^.indexnr>count then
  1632. count:=p^.indexnr;
  1633. if count>size then
  1634. grow(((count div growsize)+1)*growsize);
  1635. data^[p^.indexnr]:=p;
  1636. { update linked list backward }
  1637. i:=p^.indexnr;
  1638. while (i>0) do
  1639. begin
  1640. dec(i);
  1641. if (i>0) and assigned(data^[i]) then
  1642. begin
  1643. data^[i]^.next:=p;
  1644. break;
  1645. end;
  1646. end;
  1647. if i=0 then
  1648. first:=p;
  1649. { update linked list forward }
  1650. i:=p^.indexnr;
  1651. while (i<=count) do
  1652. begin
  1653. inc(i);
  1654. if (i<=count) and assigned(data^[i]) then
  1655. begin
  1656. p^.next:=data^[i];
  1657. exit;
  1658. end;
  1659. end;
  1660. if i>count then
  1661. p^.next:=nil;
  1662. end;
  1663. {$ifdef BUFFEREDFILE}
  1664. {****************************************************************************
  1665. TBUFFEREDFILE
  1666. ****************************************************************************}
  1667. Const
  1668. crcseed = $ffffffff;
  1669. crctable : array[0..255] of longint = (
  1670. $00000000,$77073096,$ee0e612c,$990951ba,$076dc419,$706af48f,
  1671. $e963a535,$9e6495a3,$0edb8832,$79dcb8a4,$e0d5e91e,$97d2d988,
  1672. $09b64c2b,$7eb17cbd,$e7b82d07,$90bf1d91,$1db71064,$6ab020f2,
  1673. $f3b97148,$84be41de,$1adad47d,$6ddde4eb,$f4d4b551,$83d385c7,
  1674. $136c9856,$646ba8c0,$fd62f97a,$8a65c9ec,$14015c4f,$63066cd9,
  1675. $fa0f3d63,$8d080df5,$3b6e20c8,$4c69105e,$d56041e4,$a2677172,
  1676. $3c03e4d1,$4b04d447,$d20d85fd,$a50ab56b,$35b5a8fa,$42b2986c,
  1677. $dbbbc9d6,$acbcf940,$32d86ce3,$45df5c75,$dcd60dcf,$abd13d59,
  1678. $26d930ac,$51de003a,$c8d75180,$bfd06116,$21b4f4b5,$56b3c423,
  1679. $cfba9599,$b8bda50f,$2802b89e,$5f058808,$c60cd9b2,$b10be924,
  1680. $2f6f7c87,$58684c11,$c1611dab,$b6662d3d,$76dc4190,$01db7106,
  1681. $98d220bc,$efd5102a,$71b18589,$06b6b51f,$9fbfe4a5,$e8b8d433,
  1682. $7807c9a2,$0f00f934,$9609a88e,$e10e9818,$7f6a0dbb,$086d3d2d,
  1683. $91646c97,$e6635c01,$6b6b51f4,$1c6c6162,$856530d8,$f262004e,
  1684. $6c0695ed,$1b01a57b,$8208f4c1,$f50fc457,$65b0d9c6,$12b7e950,
  1685. $8bbeb8ea,$fcb9887c,$62dd1ddf,$15da2d49,$8cd37cf3,$fbd44c65,
  1686. $4db26158,$3ab551ce,$a3bc0074,$d4bb30e2,$4adfa541,$3dd895d7,
  1687. $a4d1c46d,$d3d6f4fb,$4369e96a,$346ed9fc,$ad678846,$da60b8d0,
  1688. $44042d73,$33031de5,$aa0a4c5f,$dd0d7cc9,$5005713c,$270241aa,
  1689. $be0b1010,$c90c2086,$5768b525,$206f85b3,$b966d409,$ce61e49f,
  1690. $5edef90e,$29d9c998,$b0d09822,$c7d7a8b4,$59b33d17,$2eb40d81,
  1691. $b7bd5c3b,$c0ba6cad,$edb88320,$9abfb3b6,$03b6e20c,$74b1d29a,
  1692. $ead54739,$9dd277af,$04db2615,$73dc1683,$e3630b12,$94643b84,
  1693. $0d6d6a3e,$7a6a5aa8,$e40ecf0b,$9309ff9d,$0a00ae27,$7d079eb1,
  1694. $f00f9344,$8708a3d2,$1e01f268,$6906c2fe,$f762575d,$806567cb,
  1695. $196c3671,$6e6b06e7,$fed41b76,$89d32be0,$10da7a5a,$67dd4acc,
  1696. $f9b9df6f,$8ebeeff9,$17b7be43,$60b08ed5,$d6d6a3e8,$a1d1937e,
  1697. $38d8c2c4,$4fdff252,$d1bb67f1,$a6bc5767,$3fb506dd,$48b2364b,
  1698. $d80d2bda,$af0a1b4c,$36034af6,$41047a60,$df60efc3,$a867df55,
  1699. $316e8eef,$4669be79,$cb61b38c,$bc66831a,$256fd2a0,$5268e236,
  1700. $cc0c7795,$bb0b4703,$220216b9,$5505262f,$c5ba3bbe,$b2bd0b28,
  1701. $2bb45a92,$5cb36a04,$c2d7ffa7,$b5d0cf31,$2cd99e8b,$5bdeae1d,
  1702. $9b64c2b0,$ec63f226,$756aa39c,$026d930a,$9c0906a9,$eb0e363f,
  1703. $72076785,$05005713,$95bf4a82,$e2b87a14,$7bb12bae,$0cb61b38,
  1704. $92d28e9b,$e5d5be0d,$7cdcefb7,$0bdbdf21,$86d3d2d4,$f1d4e242,
  1705. $68ddb3f8,$1fda836e,$81be16cd,$f6b9265b,$6fb077e1,$18b74777,
  1706. $88085ae6,$ff0f6a70,$66063bca,$11010b5c,$8f659eff,$f862ae69,
  1707. $616bffd3,$166ccf45,$a00ae278,$d70dd2ee,$4e048354,$3903b3c2,
  1708. $a7672661,$d06016f7,$4969474d,$3e6e77db,$aed16a4a,$d9d65adc,
  1709. $40df0b66,$37d83bf0,$a9bcae53,$debb9ec5,$47b2cf7f,$30b5ffe9,
  1710. $bdbdf21c,$cabac28a,$53b39330,$24b4a3a6,$bad03605,$cdd70693,
  1711. $54de5729,$23d967bf,$b3667a2e,$c4614ab8,$5d681b02,$2a6f2b94,
  1712. $b40bbe37,$c30c8ea1,$5a05df1b,$2d02ef8d);
  1713. constructor tbufferedfile.init(const filename : string;_bufsize : longint);
  1714. begin
  1715. assign(f,filename);
  1716. bufsize:=_bufsize;
  1717. bufpos:=0;
  1718. buflast:=0;
  1719. do_crc:=false;
  1720. iomode:=0;
  1721. tempclosed:=false;
  1722. change_endian:=false;
  1723. clear_crc;
  1724. end;
  1725. destructor tbufferedfile.done;
  1726. begin
  1727. close;
  1728. end;
  1729. procedure tbufferedfile.clear_crc;
  1730. begin
  1731. crc:=crcseed;
  1732. end;
  1733. procedure tbufferedfile.setbuf(p : pchar;s : longint);
  1734. begin
  1735. flush;
  1736. freemem(buf,bufsize);
  1737. bufsize:=s;
  1738. buf:=p;
  1739. end;
  1740. function tbufferedfile.reset:boolean;
  1741. var
  1742. ofm : byte;
  1743. begin
  1744. ofm:=filemode;
  1745. iomode:=1;
  1746. getmem(buf,bufsize);
  1747. filemode:=0;
  1748. {$I-}
  1749. system.reset(f,1);
  1750. {$I+}
  1751. reset:=(ioresult=0);
  1752. filemode:=ofm;
  1753. end;
  1754. procedure tbufferedfile.rewrite;
  1755. begin
  1756. iomode:=2;
  1757. getmem(buf,bufsize);
  1758. system.rewrite(f,1);
  1759. end;
  1760. procedure tbufferedfile.flush;
  1761. var
  1762. {$ifdef FPC}
  1763. count : longint;
  1764. {$else}
  1765. count : integer;
  1766. {$endif}
  1767. begin
  1768. if iomode=2 then
  1769. begin
  1770. if bufpos=0 then
  1771. exit;
  1772. blockwrite(f,buf^,bufpos)
  1773. end
  1774. else if iomode=1 then
  1775. if buflast=bufpos then
  1776. begin
  1777. blockread(f,buf^,bufsize,count);
  1778. buflast:=count;
  1779. end;
  1780. bufpos:=0;
  1781. end;
  1782. function tbufferedfile.getftime : longint;
  1783. var
  1784. l : longint;
  1785. {$ifdef linux}
  1786. Info : Stat;
  1787. {$endif}
  1788. begin
  1789. {$ifndef linux}
  1790. { this only works if the file is open !! }
  1791. dos.getftime(f,l);
  1792. {$else}
  1793. Fstat(f,Info);
  1794. l:=info.mtime;
  1795. {$endif}
  1796. getftime:=l;
  1797. end;
  1798. function tbufferedfile.getsize : longint;
  1799. begin
  1800. getsize:=filesize(f);
  1801. end;
  1802. procedure tbufferedfile.seek(l : longint);
  1803. begin
  1804. if iomode=2 then
  1805. begin
  1806. flush;
  1807. system.seek(f,l);
  1808. end
  1809. else if iomode=1 then
  1810. begin
  1811. { forces a reload }
  1812. bufpos:=buflast;
  1813. system.seek(f,l);
  1814. flush;
  1815. end;
  1816. end;
  1817. type
  1818. {$ifdef tp}
  1819. bytearray1 = array [1..65535] of byte;
  1820. {$else}
  1821. bytearray1 = array [1..10000000] of byte;
  1822. {$endif}
  1823. procedure tbufferedfile.read_data(var data;bytes : longint;var count : longint);
  1824. var
  1825. p : pchar;
  1826. c,i : longint;
  1827. begin
  1828. p:=pchar(@data);
  1829. count:=0;
  1830. while bytes-count>0 do
  1831. begin
  1832. if bytes-count>buflast-bufpos then
  1833. begin
  1834. move((buf+bufpos)^,(p+count)^,buflast-bufpos);
  1835. inc(count,buflast-bufpos);
  1836. bufpos:=buflast;
  1837. flush;
  1838. { can't we read anything ? }
  1839. if bufpos=buflast then
  1840. break;
  1841. end
  1842. else
  1843. begin
  1844. move((buf+bufpos)^,(p+count)^,bytes-count);
  1845. inc(bufpos,bytes-count);
  1846. count:=bytes;
  1847. break;
  1848. end;
  1849. end;
  1850. if do_crc then
  1851. begin
  1852. c:=crc;
  1853. for i:=1 to bytes do
  1854. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1855. crc:=c;
  1856. end;
  1857. end;
  1858. procedure tbufferedfile.write_data(var data;count : longint);
  1859. var
  1860. c,i : longint;
  1861. begin
  1862. if bufpos+count>bufsize then
  1863. flush;
  1864. move(data,(buf+bufpos)^,count);
  1865. inc(bufpos,count);
  1866. if do_crc then
  1867. begin
  1868. c:=crc;
  1869. for i:=1 to count do
  1870. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1871. crc:=c;
  1872. end;
  1873. end;
  1874. function tbufferedfile.getcrc : longint;
  1875. begin
  1876. getcrc:=crc xor crcseed;
  1877. end;
  1878. procedure tbufferedfile.write_string(const s : string);
  1879. begin
  1880. if bufpos+length(s)>bufsize then
  1881. flush;
  1882. { why is there not CRC here ??? }
  1883. move(s[1],(buf+bufpos)^,length(s));
  1884. inc(bufpos,length(s));
  1885. { should be
  1886. write_data(s[1],length(s)); }
  1887. end;
  1888. procedure tbufferedfile.write_pchar(p : pchar);
  1889. var
  1890. l : longint;
  1891. begin
  1892. l:=strlen(p);
  1893. if l>=bufsize then
  1894. do_internalerror(222);
  1895. { why is there not CRC here ???}
  1896. if bufpos+l>bufsize then
  1897. flush;
  1898. move(p^,(buf+bufpos)^,l);
  1899. inc(bufpos,l);
  1900. { should be
  1901. write_data(p^,l); }
  1902. end;
  1903. procedure tbufferedfile.write_byte(b : byte);
  1904. begin
  1905. write_data(b,sizeof(byte));
  1906. end;
  1907. procedure tbufferedfile.write_long(l : longint);
  1908. var
  1909. w1,w2 : word;
  1910. begin
  1911. if change_endian then
  1912. begin
  1913. w1:=l and $ffff;
  1914. w2:=l shr 16;
  1915. l:=swap(w2)+(longint(swap(w1)) shl 16);
  1916. end;
  1917. write_data(l,sizeof(longint));
  1918. end;
  1919. procedure tbufferedfile.write_word(w : word);
  1920. begin
  1921. if change_endian then
  1922. begin
  1923. w:=swap(w);
  1924. end;
  1925. write_data(w,sizeof(word));
  1926. end;
  1927. procedure tbufferedfile.write_double(d : double);
  1928. begin
  1929. write_data(d,sizeof(double));
  1930. end;
  1931. function tbufferedfile.getpath : string;
  1932. begin
  1933. {$ifdef dummy}
  1934. getpath:=strpas(filerec(f).name);
  1935. {$endif}
  1936. getpath:='';
  1937. end;
  1938. procedure tbufferedfile.close;
  1939. begin
  1940. if iomode<>0 then
  1941. begin
  1942. flush;
  1943. system.close(f);
  1944. freemem(buf,bufsize);
  1945. buf:=nil;
  1946. iomode:=0;
  1947. end;
  1948. end;
  1949. procedure tbufferedfile.tempclose;
  1950. begin
  1951. if iomode<>0 then
  1952. begin
  1953. temppos:=system.filepos(f);
  1954. tempmode:=iomode;
  1955. tempclosed:=true;
  1956. system.close(f);
  1957. iomode:=0;
  1958. end
  1959. else
  1960. tempclosed:=false;
  1961. end;
  1962. procedure tbufferedfile.tempreopen;
  1963. var
  1964. ofm : byte;
  1965. begin
  1966. if tempclosed then
  1967. begin
  1968. case tempmode of
  1969. 1 : begin
  1970. ofm:=filemode;
  1971. iomode:=1;
  1972. filemode:=0;
  1973. system.reset(f,1);
  1974. filemode:=ofm;
  1975. end;
  1976. 2 : begin
  1977. iomode:=2;
  1978. system.rewrite(f,1);
  1979. end;
  1980. end;
  1981. system.seek(f,temppos);
  1982. tempclosed:=false;
  1983. end;
  1984. end;
  1985. {$endif BUFFEREDFILE}
  1986. end.
  1987. {
  1988. $Log$
  1989. Revision 1.48 1999-12-06 18:21:03 peter
  1990. * support !ENVVAR for long commandlines
  1991. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1992. finally supported as installdir.
  1993. Revision 1.47 1999/11/15 14:59:55 pierre
  1994. * last was not handled correctly in TStringQueue
  1995. Revision 1.46 1999/11/14 15:56:36 peter
  1996. * fixed stringqueue.delete
  1997. Revision 1.45 1999/11/12 11:03:49 peter
  1998. * searchpaths changed to stringqueue object
  1999. Revision 1.44 1999/11/06 14:34:20 peter
  2000. * truncated log to 20 revs
  2001. Revision 1.43 1999/10/26 12:30:41 peter
  2002. * const parameter is now checked
  2003. * better and generic check if a node can be used for assigning
  2004. * export fixes
  2005. * procvar equal works now (it never had worked at least from 0.99.8)
  2006. * defcoll changed to linkedlist with pparaitem so it can easily be
  2007. walked both directions
  2008. Revision 1.42 1999/09/07 15:08:51 pierre
  2009. * runerror => do_internalerror
  2010. Revision 1.41 1999/08/24 13:13:57 peter
  2011. * MEMDEBUG to see the sizes of asmlist,asmsymbols,symtables
  2012. Revision 1.40 1999/08/12 23:19:05 pierre
  2013. * added inherited init call to tstringcontainer.init_no_double for Peter
  2014. Revision 1.39 1999/08/05 14:58:07 florian
  2015. * some fixes for the floating point registers
  2016. * more things for the new code generator
  2017. Revision 1.38 1999/07/18 10:19:46 florian
  2018. * made it compilable with Dlephi 4 again
  2019. + fixed problem with large stack allocations on win32
  2020. Revision 1.37 1999/07/03 00:29:45 peter
  2021. * new link writing to the ppu, one .ppu is needed for all link types,
  2022. static (.o) is now always created also when smartlinking is used
  2023. Revision 1.36 1999/06/23 11:13:20 peter
  2024. * fixed linebreak
  2025. Revision 1.35 1999/06/23 11:07:23 daniel
  2026. * Tdictionary.delete
  2027. Revision 1.33.2.1 1999/06/15 10:12:22 peter
  2028. * fixed inserttree which didn't reset left,right
  2029. Revision 1.33 1999/05/31 23:33:21 peter
  2030. * fixed tdictionary rename which didn't reset left,right when
  2031. reinserting
  2032. Revision 1.32 1999/05/27 19:44:23 peter
  2033. * removed oldasm
  2034. * plabel -> pasmlabel
  2035. * -a switches to source writing automaticly
  2036. * assembler readers OOPed
  2037. * asmsymbol automaticly external
  2038. * jumptables and other label fixes for asm readers
  2039. Revision 1.31 1999/05/21 13:54:59 peter
  2040. * NEWLAB for label as symbol
  2041. Revision 1.30 1999/05/21 10:38:59 peter
  2042. * fixed deleteindex which didn't reset indexnr and set first wrong
  2043. Revision 1.29 1999/05/08 19:47:27 peter
  2044. * indexarray.delete resets pointer after dispose
  2045. Revision 1.28 1999/05/05 10:05:48 florian
  2046. * a delphi compiled compiler recompiles ppc
  2047. Revision 1.27 1999/05/05 09:19:03 florian
  2048. * more fixes to get it with delphi running
  2049. Revision 1.26 1999/04/21 09:43:31 peter
  2050. * storenumber works
  2051. * fixed some typos in double_checksum
  2052. + incompatible types type1 and type2 message (with storenumber)
  2053. Revision 1.25 1999/04/15 10:01:44 peter
  2054. * small update for storenumber
  2055. Revision 1.24 1999/04/14 09:14:47 peter
  2056. * first things to store the symbol/def number in the ppu
  2057. }