globals.pas 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  1. {
  2. $Id$
  3. Copyright (C) 1993-98 by Florian Klaempfl
  4. This unit implements some support functions and global variables
  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+}
  20. {$endif}
  21. unit globals;
  22. interface
  23. uses
  24. {$ifdef TP}
  25. objects,
  26. {$endif}
  27. {$ifdef Delphi4}
  28. dmisc,
  29. sysutils,
  30. {$endif}
  31. {$ifdef linux}
  32. linux,
  33. {$endif}
  34. strings,dos,
  35. globtype,version,tokens,systems,cobjects;
  36. const
  37. {$ifdef linux}
  38. DirSep = '/';
  39. {$else}
  40. {$ifdef amiga}
  41. DirSep = '/';
  42. {$else}
  43. DirSep = '\';
  44. {$endif}
  45. {$endif}
  46. {$ifdef Splitheap}
  47. testsplit : boolean = false;
  48. {$endif Splitheap}
  49. delphimodeswitches : tmodeswitches=
  50. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  51. m_pointer_2_procedure,m_autoderef];
  52. fpcmodeswitches : tmodeswitches=
  53. [m_fpc,m_all,m_class,m_string_pchar,m_nested_comment,m_repeat_forward,
  54. m_cvar_support];
  55. objfpcmodeswitches : tmodeswitches=
  56. [m_fpc,m_all,m_objpas,m_class,m_result,m_string_pchar,m_nested_comment,
  57. m_repeat_forward,m_cvar_support];
  58. tpmodeswitches : tmodeswitches=
  59. [m_tp,m_all,m_tp_procvar];
  60. gpcmodeswitches : tmodeswitches=
  61. [m_gpc,m_all];
  62. var
  63. { specified inputfile }
  64. inputdir : dirstr;
  65. inputfile : namestr;
  66. inputextension : extstr;
  67. { specified outputfile with -o parameter }
  68. outputfile : namestr;
  69. { specified with -FE or -FU }
  70. outputexedir : dirstr;
  71. outputunitdir : dirstr;
  72. { directory where the utils can be found (options -FD) }
  73. utilsdirectory : dirstr;
  74. { some flags for global compiler switches }
  75. do_build,
  76. do_make : boolean;
  77. not_unit_proc : boolean;
  78. { path for searching units, different paths can be seperated by ; }
  79. exepath : dirstr; { Path to ppc }
  80. unitsearchpath,
  81. objectsearchpath,
  82. includesearchpath : string;
  83. { deffile }
  84. usewindowapi : boolean;
  85. description : string;
  86. { current position }
  87. token, { current token being parsed }
  88. idtoken : ttoken; { holds the token if the pattern is a known word }
  89. tokenpos, { last postion of the read token }
  90. aktfilepos : tfileposinfo; { current position }
  91. { type of currently parsed block }
  92. { isn't full implemented (FK) }
  93. block_type : tblock_type;
  94. in_args : boolean; { arguments must be checked especially }
  95. parsing_para_level : longint; { parameter level, used to convert
  96. proc calls to proc loads in firstcalln }
  97. Must_be_valid : boolean; { should the variable already have a value }
  98. compile_level : word;
  99. make_ref : boolean;
  100. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  101. {$ifdef TP}
  102. use_big : boolean;
  103. {$endif}
  104. { commandline values }
  105. initdefines : tlinkedlist;
  106. initglobalswitches : tglobalswitches;
  107. initmoduleswitches : tmoduleswitches;
  108. initlocalswitches : tlocalswitches;
  109. initmodeswitches : tmodeswitches;
  110. initpackenum,
  111. initpackrecords : longint;
  112. initoutputformat : tasm;
  113. initoptprocessor : tprocessors;
  114. initasmmode : tasmmode;
  115. { current state values }
  116. aktglobalswitches : tglobalswitches;
  117. aktmoduleswitches : tmoduleswitches;
  118. aktlocalswitches : tlocalswitches;
  119. aktmodeswitches : tmodeswitches;
  120. aktpackenum,
  121. aktpackrecords : longint;
  122. aktoutputformat : tasm;
  123. aktoptprocessor : tprocessors;
  124. aktasmmode : tasmmode;
  125. { Memory sizes }
  126. heapsize,
  127. maxheapsize,
  128. stacksize : longint;
  129. {$Ifdef EXTDEBUG}
  130. total_of_firstpass,
  131. firstpass_several : longint;
  132. {$EndIf EXTDEBUG}
  133. { parameter switches }
  134. {$Ifdef EXTDEBUG}
  135. debugstop,
  136. only_one_pass : boolean;
  137. {$EndIf EXTDEBUG}
  138. { windows application type }
  139. apptype : tapptype;
  140. const
  141. RelocSection : boolean = false;
  142. DLLsource : boolean = false;
  143. { no binding needed for win32
  144. .edata written directly !! PM }
  145. bind_win32_dll : boolean = false;
  146. { should we allow non static members ? }
  147. allow_only_static : boolean = false;
  148. Inside_asm_statement : boolean = false;
  149. { for error info in pp.pas }
  150. const
  151. parser_current_file : string = '';
  152. function getspeedvalue(const s : string) : longint;
  153. {$ifdef debug}
  154. { if the pointer don't point to the heap then write an error }
  155. function assigned(p : pointer) : boolean;
  156. {$endif}
  157. function min(a,b : longint) : longint;
  158. function max(a,b : longint) : longint;
  159. function align(i,a:longint):longint;
  160. procedure Replace(var s:string;const s1,s2:string);
  161. function upper(const s : string) : string;
  162. function lower(const s : string) : string;
  163. function trimspace(const s:string):string;
  164. procedure uppervar(var s : string);
  165. function tostr(i : longint) : string;
  166. function tostr_with_plus(i : longint) : string;
  167. procedure valint(S : string;var V : longint;var code : integer);
  168. function is_number(const s : string) : boolean;
  169. function ispowerof2(value : longint;var power : longint) : boolean;
  170. { enable ansistring comparison }
  171. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  172. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  173. function bstoslash(const s : string) : string;
  174. procedure abstract;
  175. function getdatestr:string;
  176. function gettimestr:string;
  177. function filetimestring( t : longint) : string;
  178. function path_absolute(const s : string) : boolean;
  179. Function FileExists ( Const F : String) : Boolean;
  180. Function RemoveFile(const f:string):boolean;
  181. Function RemoveDir(d:string):boolean;
  182. Function GetFileTime ( Var F : File) : Longint;
  183. Function GetNamedFileTime ( Const F : String) : Longint;
  184. Function SplitFileName(const s:string):string;
  185. Function SplitName(const s:string):string;
  186. Function SplitExtension(Const HStr:String):String;
  187. Function AddExtension(Const HStr,ext:String):String;
  188. Function ForceExtension(Const HStr,ext:String):String;
  189. Function FixPath(s:string;allowdot:boolean):string;
  190. function FixFileName(const s:string):string;
  191. procedure AddPathToList(var list:string;s:string;first:boolean);
  192. function search(const f : string;path : string;var b : boolean) : string;
  193. procedure SynchronizeFileTime(const fn1,fn2:string);
  194. function FindExe(bin:string;var found:boolean):string;
  195. procedure InitGlobals;
  196. procedure DoneGlobals;
  197. procedure strdispose(var p : pchar);
  198. implementation
  199. procedure strdispose(var p : pchar);
  200. begin
  201. if assigned(p) then
  202. begin
  203. freemem(p,strlen(p)+1);
  204. p:=nil;
  205. end;
  206. end;
  207. {$ifdef FPC}
  208. function getspeedvalue(const s : string) : longint;
  209. var
  210. p1,p2:^byte;
  211. begin
  212. p1:=@s;
  213. longint(p2):=longint(p1)+p1^+1;
  214. inc(longint(p1));
  215. getspeedvalue:=0;
  216. while p1<>p2 do
  217. begin
  218. inc(getspeedvalue,p1^);
  219. inc(longint(p1));
  220. end;
  221. end;
  222. {$else}
  223. function getspeedvalue(const s : string) : longint;
  224. type
  225. ptrrec=record
  226. ofs,seg:word;
  227. end;
  228. var
  229. l,w : longint;
  230. p1,p2 : ^byte;
  231. begin
  232. p1:=@s;
  233. ptrrec(p2).seg:=ptrrec(p1).seg;
  234. ptrrec(p2).ofs:=ptrrec(p1).ofs+p1^+1;
  235. inc(p1);
  236. l:=0;
  237. while p1<>p2 do
  238. begin
  239. l:=l+p1^;
  240. inc(p1);
  241. end;
  242. getspeedvalue:=l;
  243. end;
  244. {$endif}
  245. function ngraphsearchvalue(const s1,s2 : string) : double;
  246. const
  247. n = 3;
  248. var
  249. equals,i,j : longint;
  250. hs : string;
  251. begin
  252. equals:=0;
  253. { is the string long enough ? }
  254. if min(length(s1),length(s2))-n+1<1 then
  255. begin
  256. ngraphsearchvalue:=0.0;
  257. exit;
  258. end;
  259. for i:=1 to length(s1)-n+1 do
  260. begin
  261. hs:=copy(s1,i,n);
  262. for j:=1 to length(s2)-n+1 do
  263. if hs=copy(s2,j,n) then
  264. inc(equals);
  265. end;
  266. {$ifdef fpc}
  267. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  268. {$else}
  269. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  270. {$endif}
  271. end;
  272. function bstoslash(const s : string) : string;
  273. {
  274. return string s with all \ changed into /
  275. }
  276. var
  277. i : longint;
  278. begin
  279. for i:=1to length(s) do
  280. if s[i]='\' then
  281. bstoslash[i]:='/'
  282. else
  283. bstoslash[i]:=s[i];
  284. {$ifndef TP}
  285. {$ifopt H+}
  286. setlength(bstoslash,length(s));
  287. {$else}
  288. bstoslash[0]:=s[0];
  289. {$endif}
  290. {$else}
  291. bstoslash[0]:=s[0];
  292. {$endif}
  293. end;
  294. {$ifdef debug}
  295. function assigned(p : pointer) : boolean;
  296. {$ifndef FPC}
  297. {$ifndef DPMI}
  298. var
  299. lp : longint;
  300. {$endif DPMI}
  301. {$endif FPC}
  302. begin
  303. {$ifdef FPC}
  304. { Assigned is used for procvar and
  305. stack stored temp records !! PM }
  306. (* if (p<>nil) {and
  307. ((p<heaporg) or
  308. (p>heapptr))} then
  309. runerror(230); *)
  310. {$else}
  311. {$ifdef DPMI}
  312. assigned:=(p<>nil);
  313. exit;
  314. {$else DPMI}
  315. if p=nil then
  316. lp:=0
  317. else
  318. lp:=longint(ptrrec(p).seg)*16+longint(ptrrec(p).ofs);
  319. if (lp<>0) and
  320. ((lp<longint(seg(heaporg^))*16+longint(ofs(heaporg^))) or
  321. (lp>longint(seg(heapptr^))*16+longint(ofs(heapptr^)))) then
  322. runerror(230);
  323. {$endif DPMI}
  324. {$endif FPC}
  325. assigned:=(p<>nil);
  326. end;
  327. {$endif}
  328. function min(a,b : longint) : longint;
  329. {
  330. return the minimal of a and b
  331. }
  332. begin
  333. if a>b then
  334. min:=b
  335. else
  336. min:=a;
  337. end;
  338. function max(a,b : longint) : longint;
  339. {
  340. return the maximum of a and b
  341. }
  342. begin
  343. if a<b then
  344. max:=b
  345. else
  346. max:=a;
  347. end;
  348. function align(i,a:longint):longint;
  349. {
  350. return value <i> aligned <a> boundary
  351. }
  352. begin
  353. align:=(i+a-1) and not(a-1);
  354. end;
  355. procedure Replace(var s:string;const s1,s2:string);
  356. {
  357. replace all s1 with s2 in string s
  358. }
  359. var
  360. i : longint;
  361. begin
  362. repeat
  363. i:=pos(s1,s);
  364. if i>0 then
  365. begin
  366. Delete(s,i,length(s1));
  367. Insert(s2,s,i);
  368. end;
  369. until i=0;
  370. end;
  371. function upper(const s : string) : string;
  372. {
  373. return uppercased string of s
  374. }
  375. var
  376. i : longint;
  377. begin
  378. for i:=1 to length(s) do
  379. if s[i] in ['a'..'z'] then
  380. upper[i]:=char(byte(s[i])-32)
  381. else
  382. upper[i]:=s[i];
  383. {$ifdef FPC}
  384. {$ifopt H+}
  385. setlength(upper,length(s));
  386. {$else}
  387. upper[0]:=s[0];
  388. {$endif}
  389. {$else}
  390. upper[0]:=s[0];
  391. {$endif}
  392. end;
  393. function lower(const s : string) : string;
  394. {
  395. return lowercased string of s
  396. }
  397. var
  398. i : longint;
  399. begin
  400. for i:=1 to length(s) do
  401. if s[i] in ['A'..'Z'] then
  402. lower[i]:=char(byte(s[i])+32)
  403. else
  404. lower[i]:=s[i];
  405. {$ifndef TP}
  406. {$ifopt H+}
  407. setlength(lower,length(s));
  408. {$else}
  409. lower[0]:=s[0];
  410. {$endif}
  411. {$else}
  412. lower[0]:=s[0];
  413. {$endif}
  414. end;
  415. procedure uppervar(var s : string);
  416. {
  417. uppercase string s
  418. }
  419. var
  420. i : longint;
  421. begin
  422. for i:=1 to length(s) do
  423. if s[i] in ['a'..'z'] then
  424. s[i]:=char(byte(s[i])-32);
  425. end;
  426. function trimspace(const s:string):string;
  427. {
  428. return s with all leading and ending spaces and tabs removed
  429. }
  430. var
  431. i,j : longint;
  432. begin
  433. i:=length(s);
  434. while (i>0) and (s[i] in [#9,' ']) do
  435. dec(i);
  436. j:=1;
  437. while (j<i) and (s[j] in [#9,' ']) do
  438. inc(j);
  439. trimspace:=Copy(s,j,i-j+1);
  440. end;
  441. function tostr(i : longint) : string;
  442. {
  443. return string of value i
  444. }
  445. var
  446. hs : string;
  447. begin
  448. str(i,hs);
  449. tostr:=hs;
  450. end;
  451. function tostr_with_plus(i : longint) : string;
  452. {
  453. return string of value i, but always include a + when i>=0
  454. }
  455. var
  456. hs : string;
  457. begin
  458. str(i,hs);
  459. if i>=0 then
  460. tostr_with_plus:='+'+hs
  461. else
  462. tostr_with_plus:=hs;
  463. end;
  464. procedure valint(S : string;var V : longint;var code : integer);
  465. {
  466. val() with support for octal, which is not supported under tp7
  467. }
  468. {$ifndef FPC}
  469. var
  470. vs : longint;
  471. c : byte;
  472. begin
  473. if s[1]='%' then
  474. begin
  475. vs:=0;
  476. longint(v):=0;
  477. for c:=2 to length(s) do
  478. begin
  479. if s[c]='0' then
  480. vs:=vs shl 1
  481. else
  482. if s[c]='1' then
  483. vs:=vs shl 1+1
  484. else
  485. begin
  486. code:=c;
  487. exit;
  488. end;
  489. end;
  490. code:=0;
  491. longint(v):=vs;
  492. end
  493. else
  494. system.val(S,V,code);
  495. end;
  496. {$else not FPC}
  497. begin
  498. system.val(S,V,code);
  499. end;
  500. {$endif not FPC}
  501. function is_number(const s : string) : boolean;
  502. {
  503. is string a correct number ?
  504. }
  505. var
  506. w : integer;
  507. l : longint;
  508. begin
  509. valint(s,l,w);
  510. is_number:=(w=0);
  511. end;
  512. function ispowerof2(value : longint;var power : longint) : boolean;
  513. {
  514. return if value is a power of 2. And if correct return the power
  515. }
  516. var
  517. hl : longint;
  518. i : longint;
  519. begin
  520. hl:=1;
  521. ispowerof2:=true;
  522. for i:=0 to 31 do
  523. begin
  524. if hl=value then
  525. begin
  526. power:=i;
  527. exit;
  528. end;
  529. hl:=hl shl 1;
  530. end;
  531. ispowerof2:=false;
  532. end;
  533. { enable ansistring comparison }
  534. { 0 means equal }
  535. { 1 means p1 > p2 }
  536. { -1 means p1 < p2 }
  537. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  538. var
  539. i,j : longint;
  540. begin
  541. compareansistrings:=0;
  542. j:=min(length1,length2);
  543. for i:=1 to j do
  544. begin
  545. if p1[i]>p2[i] then
  546. begin
  547. compareansistrings:=1;
  548. exit;
  549. end
  550. else if p1[i]<p2[i] then
  551. begin
  552. compareansistrings:=-1;
  553. exit;
  554. end;
  555. end;
  556. if length1>length2 then
  557. compareansistrings:=1
  558. else
  559. if length1<length2 then
  560. compareansistrings:=-1;
  561. end;
  562. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  563. var
  564. p : pchar;
  565. begin
  566. getmem(p,length1+length2+1);
  567. move(p1[0],p[0],length1);
  568. move(p2[0],p[length1],length2+1);
  569. concatansistrings:=p;
  570. end;
  571. {****************************************************************************
  572. Time Handling
  573. ****************************************************************************}
  574. Function L0(l:longint):string;
  575. {
  576. return the string of value l, if l<10 then insert a zero, so
  577. the string is always at least 2 chars '01','02',etc
  578. }
  579. var
  580. s : string;
  581. begin
  582. Str(l,s);
  583. if l<10 then
  584. s:='0'+s;
  585. L0:=s;
  586. end;
  587. function gettimestr:string;
  588. {
  589. get the current time in a string HH:MM:SS
  590. }
  591. var
  592. hour,min,sec,hsec : word;
  593. begin
  594. {$ifdef delphi}
  595. dmisc.gettime(hour,min,sec,hsec);
  596. {$else delphi}
  597. dos.gettime(hour,min,sec,hsec);
  598. {$endif delphi}
  599. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  600. end;
  601. function getdatestr:string;
  602. {
  603. get the current date in a string YY/MM/DD
  604. }
  605. var
  606. Year,Month,Day,Wday : Word;
  607. begin
  608. {$ifdef delphi}
  609. dmisc.getdate(year,month,day,wday);
  610. {$else}
  611. dos.getdate(year,month,day,wday);
  612. {$endif}
  613. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  614. end;
  615. function filetimestring( t : longint) : string;
  616. {
  617. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  618. }
  619. var
  620. {$ifndef linux}
  621. DT : DateTime;
  622. {$endif}
  623. Year,Month,Day,Hour,Min,Sec : Word;
  624. begin
  625. if t=-1 then
  626. begin
  627. FileTimeString:='Not Found';
  628. exit;
  629. end;
  630. {$ifndef linux}
  631. unpacktime(t,DT);
  632. Year:=dT.year;month:=dt.month;day:=dt.day;
  633. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  634. {$else}
  635. EpochToLocal (t,year,month,day,hour,min,sec);
  636. {$endif}
  637. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  638. end;
  639. {****************************************************************************
  640. File Handling
  641. ****************************************************************************}
  642. function path_absolute(const s : string) : boolean;
  643. {
  644. is path s an absolute path?
  645. }
  646. begin
  647. path_absolute:=false;
  648. {$ifdef linux}
  649. if (length(s)>0) and (s[1]='/') then
  650. path_absolute:=true;
  651. {$else linux}
  652. {$ifdef amiga}
  653. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  654. path_absolute:=true;
  655. {$else}
  656. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  657. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  658. path_absolute:=true;
  659. {$endif amiga}
  660. {$endif linux}
  661. end;
  662. {$ifndef FPC}
  663. Procedure FindClose(var Info : SearchRec);
  664. Begin
  665. End;
  666. {$endif not FPC}
  667. {$ifdef delphi}
  668. Function FileExists ( Const F : String) : Boolean;
  669. begin
  670. FileExists:=sysutils.FileExists(f);
  671. end;
  672. {$else}
  673. Function FileExists ( Const F : String) : Boolean;
  674. Var
  675. {$ifdef linux}
  676. Info : Stat;
  677. {$else}
  678. Info : SearchRec;
  679. {$endif}
  680. begin
  681. {$ifdef linux}
  682. FileExists:=FStat(F,info);
  683. {$else}
  684. findfirst(F,readonly+archive+hidden,info);
  685. FileExists:=(doserror=0);
  686. findclose(Info);
  687. {$endif}
  688. end;
  689. {$endif}
  690. Function RemoveFile(const f:string):boolean;
  691. var
  692. g : file;
  693. begin
  694. assign(g,f);
  695. {$I-}
  696. erase(g);
  697. {$I+}
  698. RemoveFile:=(ioresult=0);
  699. end;
  700. Function RemoveDir(d:string):boolean;
  701. begin
  702. if d[length(d)]=DirSep then
  703. Delete(d,length(d),1);
  704. {$I-}
  705. rmdir(d);
  706. {$I+}
  707. RemoveDir:=(ioresult=0);
  708. end;
  709. Function SplitFileName(const s:string):string;
  710. var
  711. p : dirstr;
  712. n : namestr;
  713. e : extstr;
  714. begin
  715. FSplit(s,p,n,e);
  716. SplitFileName:=n+e;
  717. end;
  718. Function SplitName(const s:string):string;
  719. var
  720. i,j : longint;
  721. begin
  722. i:=Length(s);
  723. j:=Length(s);
  724. while (i>0) and not(s[i] in ['/','\']) do
  725. dec(i);
  726. while (j>0) and (s[j]<>'.') do
  727. dec(j);
  728. if j<=i then
  729. j:=255;
  730. SplitName:=Copy(s,i+1,j-(i+1));
  731. end;
  732. Function SplitExtension(Const HStr:String):String;
  733. var
  734. j : longint;
  735. begin
  736. j:=length(Hstr);
  737. while (j>0) and (Hstr[j]<>'.') do
  738. begin
  739. if hstr[j]=DirSep then
  740. j:=0
  741. else
  742. dec(j);
  743. end;
  744. if j=0 then
  745. j:=254;
  746. SplitExtension:=Copy(Hstr,j,255);
  747. end;
  748. Function AddExtension(Const HStr,ext:String):String;
  749. begin
  750. if (Ext<>'') and (SplitExtension(HStr)='') then
  751. AddExtension:=Hstr+Ext
  752. else
  753. AddExtension:=Hstr;
  754. end;
  755. Function ForceExtension(Const HStr,ext:String):String;
  756. var
  757. j : longint;
  758. begin
  759. j:=length(Hstr);
  760. while (j>0) and (Hstr[j]<>'.') do
  761. dec(j);
  762. if j=0 then
  763. j:=255;
  764. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  765. end;
  766. Function FixPath(s:string;allowdot:boolean):string;
  767. var
  768. i : longint;
  769. begin
  770. for i:=1 to length(s) do
  771. if s[i] in ['/','\'] then
  772. s[i]:=DirSep;
  773. if (length(s)>0) and (s[length(s)]<>DirSep) and
  774. (s[length(s)]<>':') then
  775. s:=s+DirSep;
  776. if (not allowdot) and (s='.'+DirSep) then
  777. s:='';
  778. FixPath:=s;
  779. end;
  780. function FixFileName(const s:string):string;
  781. var
  782. i : longint;
  783. NoPath : boolean;
  784. begin
  785. NoPath:=true;
  786. for i:=length(s) downto 1 do
  787. begin
  788. case s[i] of
  789. {$ifdef Linux}
  790. '/','\' : begin
  791. FixFileName[i]:='/';
  792. NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
  793. end;
  794. 'A'..'Z' : if NoPath then
  795. FixFileName[i]:=char(byte(s[i])+32)
  796. else
  797. FixFileName[i]:=s[i];
  798. {$else}
  799. '/' : FixFileName[i]:='\';
  800. 'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
  801. {$endif}
  802. else
  803. FixFileName[i]:=s[i];
  804. end;
  805. end;
  806. {$ifndef TP}
  807. {$ifopt H+}
  808. SetLength(FixFileName,length(s));
  809. {$else}
  810. FixFileName[0]:=s[0];
  811. {$endif}
  812. {$else}
  813. FixFileName[0]:=s[0];
  814. {$endif}
  815. end;
  816. procedure AddPathToList(var list:string;s:string;first:boolean);
  817. var
  818. LastAdd,
  819. starti,i,j : longint;
  820. Found : boolean;
  821. CurrentDir,
  822. CurrPath,
  823. AddList : string;
  824. begin
  825. if s='' then
  826. exit;
  827. {Fix List}
  828. if (length(list)>0) and (list[length(list)]<>';') then
  829. list:=list+';';
  830. GetDir(0,CurrentDir);
  831. CurrentDir:=FixPath(CurrentDir,false);
  832. AddList:='';
  833. LastAdd:=1;
  834. repeat
  835. j:=Pos(';',s);
  836. if j=0 then
  837. j:=255;
  838. {Get Pathname}
  839. CurrPath:=FixPath(Copy(s,1,j-1),false);
  840. if CurrPath='' then
  841. CurrPath:='.'+DirSep+';'
  842. else
  843. begin
  844. CurrPath:=FixPath(FExpand(CurrPath),false)+';';
  845. if (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  846. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  847. end;
  848. Delete(s,1,j);
  849. {Check if already in path}
  850. found:=false;
  851. i:=0;
  852. starti:=1;
  853. while (not found) and (i<length(list)) do
  854. begin
  855. inc(i);
  856. if (list[i]=';') then
  857. begin
  858. found:=(CurrPath=Copy(List,starti,i-starti+1));
  859. if Found then
  860. begin
  861. if First then
  862. Delete(List,Starti,i-starti+1); {The new entry is placed first}
  863. end
  864. else
  865. starti:=i+1;
  866. end;
  867. end;
  868. if First then
  869. begin
  870. Insert(CurrPath,List,LastAdd);
  871. inc(LastAdd,Length(CurrPath));
  872. end
  873. else
  874. if not Found then
  875. List:=List+CurrPath
  876. until (s='');
  877. end;
  878. function search(const f : string;path : string;var b : boolean) : string;
  879. Var
  880. singlepathstring : string;
  881. i : longint;
  882. begin
  883. {$ifdef linux}
  884. for i:=1 to length(path) do
  885. if path[i]=':' then
  886. path[i]:=';';
  887. {$endif}
  888. b:=false;
  889. search:='';
  890. repeat
  891. i:=pos(';',path);
  892. if i=0 then
  893. i:=255;
  894. singlepathstring:=FixPath(copy(path,1,i-1),false);
  895. delete(path,1,i);
  896. If FileExists (singlepathstring+f) then
  897. begin
  898. Search:=singlepathstring;
  899. b:=true;
  900. exit;
  901. end;
  902. until path='';
  903. end;
  904. Function GetFileTime ( Var F : File) : Longint;
  905. Var
  906. {$ifdef linux}
  907. Info : Stat;
  908. {$endif}
  909. L : longint;
  910. begin
  911. {$ifdef linux}
  912. FStat (F,Info);
  913. L:=Info.Mtime;
  914. {$else}
  915. GetFTime(f,l);
  916. {$endif}
  917. GetFileTime:=L;
  918. end;
  919. Function GetNamedFileTime (Const F : String) : Longint;
  920. var
  921. L : Longint;
  922. {$ifndef linux}
  923. info : SearchRec;
  924. {$else}
  925. info : stat;
  926. {$endif}
  927. begin
  928. l:=-1;
  929. {$ifdef linux}
  930. if FStat (F,Info) then
  931. L:=info.mtime;
  932. {$else}
  933. {$ifdef delphi}
  934. dmisc.FindFirst (F,archive+readonly+hidden,info);
  935. {$else delphi}
  936. FindFirst (F,archive+readonly+hidden,info);
  937. {$endif delphi}
  938. if DosError=0 then
  939. l:=info.time;
  940. {$ifdef Linux}
  941. FindClose(info);
  942. {$endif}
  943. {$ifdef Win32}
  944. FindClose(info);
  945. {$endif}
  946. {$endif}
  947. GetNamedFileTime:=l;
  948. end;
  949. {Touch Assembler and object time to ppu time is there is a ppufilename}
  950. procedure SynchronizeFileTime(const fn1,fn2:string);
  951. var
  952. f : file;
  953. l : longint;
  954. begin
  955. Assign(f,fn1);
  956. {$I-}
  957. reset(f,1);
  958. {$I+}
  959. if ioresult=0 then
  960. begin
  961. getftime(f,l);
  962. close(f);
  963. assign(f,fn2);
  964. {$I-}
  965. reset(f,1);
  966. {$I+}
  967. if ioresult=0 then
  968. begin
  969. setftime(f,l);
  970. close(f);
  971. end;
  972. end;
  973. end;
  974. function FindExe(bin:string;var found:boolean):string;
  975. begin
  976. bin:=FixFileName(bin)+source_os.exeext;
  977. {$ifdef delphi}
  978. FindExe:=Search(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
  979. {$else delphi}
  980. FindExe:=Search(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
  981. {$endif delphi}
  982. end;
  983. procedure abstract;
  984. begin
  985. runerror(255);
  986. end;
  987. {****************************************************************************
  988. Init
  989. ****************************************************************************}
  990. procedure get_exepath;
  991. var
  992. hs1 : namestr;
  993. hs2 : extstr;
  994. begin
  995. {$ifdef delphi}
  996. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  997. {$else delphi}
  998. exepath:=dos.getenv('PPC_EXEC_PATH');
  999. {$endif delphi}
  1000. if exepath='' then
  1001. fsplit(FixFileName(paramstr(0)),exepath,hs1,hs2);
  1002. {$ifdef linux}
  1003. if exepath='' then
  1004. fsearch(hs1,dos.getenv('PATH'));
  1005. {$endif}
  1006. exepath:=FixPath(exepath,false);
  1007. end;
  1008. procedure DoneGlobals;
  1009. begin
  1010. initdefines.done;
  1011. end;
  1012. procedure InitGlobals;
  1013. begin
  1014. { set global switches }
  1015. do_build:=false;
  1016. do_make:=true;
  1017. {$ifdef tp}
  1018. use_big:=false;
  1019. {$endif tp}
  1020. { Output }
  1021. OutputFile:='';
  1022. OutputExeDir:='';
  1023. OutputUnitDir:='';
  1024. { Utils directory }
  1025. utilsdirectory:='';
  1026. { Def file }
  1027. usewindowapi:=false;
  1028. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1029. { Init values }
  1030. {$ifdef i386}
  1031. initoptprocessor:=Class386;
  1032. initlocalswitches:=[];
  1033. initmoduleswitches:=[cs_extsyntax{$ifndef OLDPPU},cs_browser{$endif}];
  1034. initglobalswitches:=[cs_check_unit_name];
  1035. initmodeswitches:=fpcmodeswitches;
  1036. initpackenum:=4;
  1037. initpackrecords:=2;
  1038. initoutputformat:=target_asm.id;
  1039. initasmmode:=asmmode_i386_att;
  1040. initdefines.init;
  1041. {$else not i386}
  1042. {$ifdef m68k}
  1043. initoptprocessor:=MC68000;
  1044. initlocalswitches:=[];
  1045. initmoduleswitches:=[cs_extsyntax{$ifndef OLDPPU},cs_browser{$endif},cs_fp_emulation];
  1046. initglobalswitches:=[cs_check_unit_name];
  1047. initmodeswitches:=fpcmodeswitches;
  1048. initpackenum:=4;
  1049. initpackrecords:=2;
  1050. initoutputformat:=as_m68k_as;
  1051. initasmmode:=asmmode_m68k_mot;
  1052. initdefines.init;
  1053. {$endif m68k}
  1054. {$endif i386}
  1055. { memory sizes, will be overriden by parameter or default for target
  1056. in options or init_parser }
  1057. stacksize:=0;
  1058. heapsize:=0;
  1059. maxheapsize:=0;
  1060. { compile state }
  1061. in_args:=false;
  1062. must_be_valid:=true;
  1063. not_unit_proc:=true;
  1064. apptype:=at_cui;
  1065. end;
  1066. begin
  1067. get_exepath;
  1068. end.
  1069. {
  1070. $Log$
  1071. Revision 1.6 1999-05-05 10:05:50 florian
  1072. * a delphi compiled compiler recompiles ppc
  1073. Revision 1.5 1999/05/04 21:44:43 florian
  1074. * changes to compile it with Delphi 4.0
  1075. Revision 1.4 1999/04/26 13:31:32 peter
  1076. * release storenumber,double_checksum
  1077. Revision 1.3 1999/04/21 14:12:55 peter
  1078. * default asm changed to att
  1079. Revision 1.2 1999/04/16 09:56:05 pierre
  1080. * unused local var commented
  1081. Revision 1.1 1999/04/08 09:14:46 michael
  1082. + Re-added;
  1083. Revision 1.119 1999/04/07 14:15:53 pierre
  1084. * assigned test for FPC removed, problems with stack variables
  1085. Revision 1.118 1999/03/17 22:23:17 florian
  1086. * a FPC compiled compiler checks now also in debug mode in assigned
  1087. if a pointer points to the heap
  1088. * when a symtable is loaded, there is no need to check for duplicate
  1089. symbols. This leads to crashes because defowner isn't assigned
  1090. in this case
  1091. Revision 1.117 1999/03/04 13:55:42 pierre
  1092. * some m68k fixes (still not compilable !)
  1093. * new(tobj) does not give warning if tobj has no VMT !
  1094. Revision 1.116 1999/03/02 18:20:09 peter
  1095. * fixed compareansistring which gave always -1 or 1 and never 0 :)
  1096. Revision 1.115 1999/03/01 15:43:47 peter
  1097. * synchronize also the objfile for ag386bin
  1098. Revision 1.114 1999/02/25 21:02:36 peter
  1099. * ag386bin updates
  1100. + coff writer
  1101. Revision 1.113 1999/02/22 13:06:50 pierre
  1102. + -b and -bl options work !
  1103. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1104. is not enabled when quitting global section
  1105. * local vars and procedures are not yet stored into PPU
  1106. Revision 1.111 1999/02/11 09:46:22 pierre
  1107. * fix for normal method calls inside static methods :
  1108. WARNING there were both parser and codegen errors !!
  1109. added static_call boolean to calln tree
  1110. Revision 1.110 1999/01/27 13:05:42 pierre
  1111. * give include file name on error
  1112. Revision 1.109 1999/01/22 16:56:50 pierre
  1113. * findclose problem fixed
  1114. Revision 1.108 1999/01/22 10:08:19 daniel
  1115. * Findclose is removed for go32v1 and go32v2 platforms, because this is
  1116. TP incompatible. It is now only called for Linux and Win32.
  1117. Revision 1.107 1999/01/12 14:25:27 peter
  1118. + BrowserLog for browser.log generation
  1119. + BrowserCol for browser info in TCollections
  1120. * released all other UseBrowser
  1121. Revision 1.106 1999/01/05 08:19:57 florian
  1122. * mainly problem with invalid case ranges fixed (reported by Jonas)
  1123. Revision 1.105 1998/12/28 23:26:16 peter
  1124. + resource file handling ($R directive) for Win32
  1125. Revision 1.104 1998/12/23 22:49:42 peter
  1126. * forgot one conflict :(
  1127. Revision 1.103 1998/12/23 22:48:41 peter
  1128. * fixed findclose problem
  1129. Revision 1.102 1998/12/23 14:26:30 jonas
  1130. * patch from Peter: remove FindClose call in FileExists (caused error under Dos
  1131. when opening the ppc386.cfg file)
  1132. Revision 1.101 1998/12/23 14:02:00 peter
  1133. * daniels patches against the latest versions
  1134. Revision 1.99 1998/12/19 00:23:47 florian
  1135. * ansistring memory leaks fixed
  1136. Revision 1.98 1998/12/15 10:23:24 peter
  1137. + -iSO, -iSP, -iTO, -iTP
  1138. Revision 1.97 1998/12/11 00:03:17 peter
  1139. + globtype,tokens,version unit splitted from globals
  1140. Revision 1.96 1998/12/08 10:18:06 peter
  1141. + -gh for heaptrc unit
  1142. Revision 1.95 1998/12/03 10:17:30 peter
  1143. * target_os.use_bound_instruction boolean
  1144. Revision 1.94 1998/11/30 13:26:22 pierre
  1145. * the code for ordering the exported procs/vars was buggy
  1146. + added -WB to force binding (Ozerski way of creating DLL)
  1147. this is off by default as direct writing of .edata section seems
  1148. OK
  1149. Revision 1.93 1998/11/30 09:43:10 pierre
  1150. * some range check bugs fixed (still not working !)
  1151. + added DLL writing support for win32 (also accepts variables)
  1152. + TempAnsi for code that could be used for Temporary ansi strings
  1153. handling
  1154. Revision 1.92 1998/11/27 14:50:37 peter
  1155. + open strings, $P switch support
  1156. Revision 1.91 1998/11/26 21:33:08 peter
  1157. * rangecheck updates
  1158. Revision 1.90 1998/11/24 17:03:23 peter
  1159. * removed obsolete version.inc
  1160. Revision 1.89 1998/11/16 15:41:41 peter
  1161. * tp7 didn't like my ifopt H+ :(
  1162. Revision 1.88 1998/11/16 10:17:07 peter
  1163. * fixed for H+ compilation
  1164. Revision 1.87 1998/11/15 16:32:36 florian
  1165. * some stuff of Pavel implement (win32 dll creation)
  1166. * bug with ansistring function results fixed
  1167. Revision 1.86 1998/11/05 12:02:43 peter
  1168. * released useansistring
  1169. * removed -Sv, its now available in fpc modes
  1170. Revision 1.85 1998/10/26 22:23:30 peter
  1171. + fixpath() has an extra option to allow a ./ as path
  1172. Revision 1.84 1998/10/25 23:30:15 peter
  1173. * valint fix for tp7 to overcome overflow
  1174. Revision 1.83 1998/10/22 17:54:02 florian
  1175. + switch $APPTYPE for win32 added
  1176. Revision 1.82 1998/10/22 11:56:44 pierre
  1177. * FixPath handling of c: corrected
  1178. Revision 1.81 1998/10/19 15:41:00 peter
  1179. * better splitname to support glib-1.1.dll alike names
  1180. Revision 1.80 1998/10/16 13:37:17 florian
  1181. + switch -FD added to specify the path for utilities
  1182. Revision 1.79 1998/10/16 08:51:46 peter
  1183. + target_os.stackalignment
  1184. + stack can be aligned at 2 or 4 byte boundaries
  1185. Revision 1.78 1998/10/14 13:38:21 peter
  1186. * fixed path with staticlib/objects in ppufiles
  1187. Revision 1.77 1998/10/13 14:01:09 peter
  1188. * fixed -al
  1189. Revision 1.76 1998/10/13 13:10:15 peter
  1190. * new style for m68k/i386 infos and enums
  1191. Revision 1.75 1998/10/13 08:19:32 pierre
  1192. + source_os is now set correctly for cross-processor compilers
  1193. (tos contains all target_infos and
  1194. we use CPU86 and CPU68 conditionnals to
  1195. get the source operating system
  1196. this only works if you do not undefine
  1197. the source target !!)
  1198. * several cg68k memory leaks fixed
  1199. + started to change the code so that it should be possible to have
  1200. a complete compiler (both for m68k and i386 !!)
  1201. Revision 1.74 1998/10/12 10:28:29 florian
  1202. + auto dereferencing of pointers to structured types in delphi mode
  1203. Revision 1.73 1998/10/12 09:49:56 florian
  1204. + support of <procedure var type>:=<pointer> in delphi mode added
  1205. Revision 1.72 1998/10/06 17:16:48 pierre
  1206. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1207. Revision 1.71 1998/09/30 19:53:54 michael
  1208. + Upgraded to version 0.99.9
  1209. Revision 1.70 1998/09/29 15:23:03 peter
  1210. * remove also the end files for smartlinking
  1211. Revision 1.69 1998/09/26 17:45:28 peter
  1212. + idtoken and only one token table
  1213. Revision 1.68 1998/09/24 23:49:04 peter
  1214. + aktmodeswitches
  1215. Revision 1.67 1998/09/22 17:13:46 pierre
  1216. + browsing updated and developed
  1217. records and objects fields are also stored
  1218. Revision 1.66 1998/09/22 15:40:54 peter
  1219. * some extra ifdef GDB
  1220. Revision 1.65 1998/09/18 16:03:38 florian
  1221. * some changes to compile with Delphi
  1222. Revision 1.64 1998/09/10 15:25:29 daniel
  1223. + Added maxheapsize.
  1224. * Corrected semi-bug in calling the assembler and the linker
  1225. Revision 1.63 1998/09/09 18:17:13 florian
  1226. * version number changed to 0.99.8
  1227. Revision 1.62 1998/09/07 17:36:59 florian
  1228. * first fixes for published properties
  1229. Revision 1.61 1998/09/03 11:21:52 peter
  1230. * -al sets cs_asm_source
  1231. Revision 1.60 1998/09/01 12:53:20 peter
  1232. + aktpackenum
  1233. Revision 1.59 1998/09/01 07:54:18 pierre
  1234. * UseBrowser a little updated (might still be buggy !!)
  1235. * bug in psub.pas in function specifier removed
  1236. * stdcall allowed in interface and in implementation
  1237. (FPC will not yet complain if it is missing in either part
  1238. because stdcall is only a dummy !!)
  1239. Revision 1.58 1998/08/31 12:26:25 peter
  1240. * m68k and palmos updates from surebugfixes
  1241. Revision 1.57 1998/08/29 13:51:09 peter
  1242. * moved get_exepath to globals
  1243. + date_string const with the current date for 0.99.7+
  1244. Revision 1.56 1998/08/26 15:35:31 peter
  1245. * fixed scannerfiles for macros
  1246. + $I %<environment>%
  1247. Revision 1.55 1998/08/25 12:42:35 pierre
  1248. * CDECL changed to CVAR for variables
  1249. specifications are read in structures also
  1250. + started adding GPC compatibility mode ( option -Sp)
  1251. * names changed to lowercase
  1252. Revision 1.54 1998/08/19 18:04:53 peter
  1253. * fixed current_module^.in_implementation flag
  1254. Revision 1.53 1998/08/19 16:07:45 jonas
  1255. * changed optimizer switches + cleanup of DestroyRefs in daopt386.pas
  1256. Revision 1.52 1998/08/19 10:06:13 peter
  1257. * fixed filenames and removedir which supports slash at the end
  1258. Revision 1.51 1998/08/17 09:17:46 peter
  1259. * static/shared linking updates
  1260. Revision 1.50 1998/08/14 21:56:33 peter
  1261. * setting the outputfile using -o works now to create static libs
  1262. Revision 1.49 1998/08/13 10:57:31 peter
  1263. * constant sets are now written correctly to the ppufile
  1264. Revision 1.48 1998/08/11 15:31:37 peter
  1265. * write extended to ppu file
  1266. * new version 0.99.7
  1267. Revision 1.47 1998/08/10 14:49:59 peter
  1268. + localswitches, moduleswitches, globalswitches splitting
  1269. Revision 1.46 1998/08/10 10:18:25 peter
  1270. + Compiler,Comphook unit which are the new interface units to the
  1271. compiler
  1272. Revision 1.45 1998/07/24 22:16:56 florian
  1273. * internal error 10 together with array access fixed. I hope
  1274. that's the final fix.
  1275. Revision 1.44 1998/07/18 17:11:08 florian
  1276. + ansi string constants fixed
  1277. + switch $H partial implemented
  1278. Revision 1.43 1998/07/14 21:46:42 peter
  1279. * updated messages file
  1280. Revision 1.42 1998/07/08 14:28:35 daniel
  1281. * Fixed small TP incompatibility: Fsplit requires use of dirstr, namestr and
  1282. extstr
  1283. Revision 1.41 1998/07/07 11:19:56 peter
  1284. + NEWINPUT for a better inputfile and scanner object
  1285. Revision 1.40 1998/06/25 08:48:13 florian
  1286. * first version of rtti support
  1287. Revision 1.39 1998/06/17 14:10:12 peter
  1288. * small os2 fixes
  1289. * fixed interdependent units with newppu (remake3 under linux works now)
  1290. Revision 1.38 1998/06/16 08:56:21 peter
  1291. + targetcpu
  1292. * cleaner pmodules for newppu
  1293. Revision 1.37 1998/06/13 00:10:06 peter
  1294. * working browser and newppu
  1295. * some small fixes against crashes which occured in bp7 (but not in
  1296. fpc?!)
  1297. Revision 1.36 1998/06/12 16:15:31 pierre
  1298. * external name 'C_var';
  1299. export name 'intern_C_var';
  1300. cdecl;
  1301. cdecl;external;
  1302. are now supported only with -Sv switch
  1303. Revision 1.34 1998/06/04 23:51:39 peter
  1304. * m68k compiles
  1305. + .def file creation moved to gendef.pas so it could also be used
  1306. for win32
  1307. Revision 1.33 1998/06/03 22:48:54 peter
  1308. + wordbool,longbool
  1309. * rename bis,von -> high,low
  1310. * moved some systemunit loading/creating to psystem.pas
  1311. Revision 1.32 1998/05/30 14:31:04 peter
  1312. + $ASMMODE
  1313. Revision 1.31 1998/05/28 14:40:24 peter
  1314. * fixes for newppu, remake3 works now with it
  1315. Revision 1.30 1998/05/27 19:45:03 peter
  1316. * symtable.pas splitted into includefiles
  1317. * symtable adapted for $ifdef NEWPPU
  1318. Revision 1.29 1998/05/25 17:11:39 pierre
  1319. * firstpasscount bug fixed
  1320. now all is already set correctly the first time
  1321. under EXTDEBUG try -gp to skip all other firstpasses
  1322. it works !!
  1323. * small bug fixes
  1324. - for smallsets with -dTESTSMALLSET
  1325. - some warnings removed (by correcting code !)
  1326. Revision 1.28 1998/05/23 01:21:07 peter
  1327. + aktasmmode, aktoptprocessor, aktoutputformat
  1328. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1329. + $LIBNAME to set the library name where the unit will be put in
  1330. * splitted cgi386 a bit (codeseg to large for bp7)
  1331. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1332. Revision 1.27 1998/05/20 09:42:33 pierre
  1333. + UseTokenInfo now default
  1334. * unit in interface uses and implementation uses gives error now
  1335. * only one error for unknown symbol (uses lastsymknown boolean)
  1336. the problem came from the label code !
  1337. + first inlined procedures and function work
  1338. (warning there might be allowed cases were the result is still wrong !!)
  1339. * UseBrower updated gives a global list of all position of all used symbols
  1340. with switch -gb
  1341. Revision 1.26 1998/05/12 10:46:59 peter
  1342. * moved printstatus to verb_def
  1343. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1344. prefix like error: warning: and is included in V_Default
  1345. * fixed some messages
  1346. * first time parameter scan is only for -v and -T
  1347. - removed old style messages
  1348. Revision 1.25 1998/05/11 13:07:54 peter
  1349. + $ifdef NEWPPU for the new ppuformat
  1350. + $define GDB not longer required
  1351. * removed all warnings and stripped some log comments
  1352. * no findfirst/findnext anymore to remove smartlink *.o files
  1353. Revision 1.24 1998/05/08 09:21:20 michael
  1354. * Added missing -Fl message to messages file.
  1355. * Corrected mangling of file names when doing Linklib
  1356. * -Fl now actually WORKS.
  1357. * Librarysearchpath is now a field in linker object.
  1358. Revision 1.23 1998/05/06 15:04:20 pierre
  1359. + when trying to find source files of a ppufile
  1360. check the includepathlist for included files
  1361. the main file must still be in the same directory
  1362. Revision 1.22 1998/05/06 08:38:39 pierre
  1363. * better position info with UseTokenInfo
  1364. UseTokenInfo greatly simplified
  1365. + added check for changed tree after first time firstpass
  1366. (if we could remove all the cases were it happen
  1367. we could skip all firstpass if firstpasscount > 1)
  1368. Only with ExtDebug
  1369. Revision 1.21 1998/05/04 17:54:25 peter
  1370. + smartlinking works (only case jumptable left todo)
  1371. * redesign of systems.pas to support assemblers and linkers
  1372. + Unitname is now also in the PPU-file, increased version to 14
  1373. Revision 1.20 1998/05/01 07:43:53 florian
  1374. + basics for rtti implemented
  1375. + switch $m (generate rtti for published sections)
  1376. Revision 1.19 1998/04/30 15:59:40 pierre
  1377. * GDB works again better :
  1378. correct type info in one pass
  1379. + UseTokenInfo for better source position
  1380. * fixed one remaining bug in scanner for line counts
  1381. * several little fixes
  1382. Revision 1.18 1998/04/29 10:33:52 pierre
  1383. + added some code for ansistring (not complete nor working yet)
  1384. * corrected operator overloading
  1385. * corrected nasm output
  1386. + started inline procedures
  1387. + added starstarn : use ** for exponentiation (^ gave problems)
  1388. + started UseTokenInfo cond to get accurate positions
  1389. Revision 1.17 1998/04/27 23:10:28 peter
  1390. + new scanner
  1391. * $makelib -> if smartlink
  1392. * small filename fixes pmodule.setfilename
  1393. * moved import from files.pas -> import.pas
  1394. Revision 1.16 1998/04/27 15:45:20 peter
  1395. + -Xl for smartlink
  1396. + target_info.arext = .a
  1397. Revision 1.15 1998/04/22 21:06:50 florian
  1398. * last fixes before the release:
  1399. - veryyyy slow firstcall fixed
  1400. Revision 1.14 1998/04/21 13:48:09 michael
  1401. + Updated patch number
  1402. Revision 1.13 1998/04/21 10:16:47 peter
  1403. * patches from strasbourg
  1404. * objects is not used anymore in the fpc compiled version
  1405. Revision 1.12 1998/04/09 14:28:06 jonas
  1406. + basic k6 and 6x86 optimizing support (-O7 and -O8)
  1407. Revision 1.11 1998/04/08 16:58:02 pierre
  1408. * several bugfixes
  1409. ADD ADC and AND are also sign extended
  1410. nasm output OK (program still crashes at end
  1411. and creates wrong assembler files !!)
  1412. procsym types sym in tdef removed !!
  1413. Revision 1.10 1998/04/08 11:34:22 peter
  1414. * nasm works (linux only tested)
  1415. Revision 1.9 1998/04/07 21:37:30 peter
  1416. * fixed fixpath to also change / and \ slashes and better addpathtolist
  1417. Revision 1.8 1998/04/07 13:19:44 pierre
  1418. * bugfixes for reset_gdb_info
  1419. in MEM parsing for go32v2
  1420. better external symbol creation
  1421. support for rhgdb.exe (lowercase file names)
  1422. Revision 1.7 1998/04/06 16:19:46 peter
  1423. * fixed the -Up.. bug
  1424. }