globals.pas 48 KB

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