globals.pas 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 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. unit globals;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. {$ifdef win32}
  23. windows,
  24. {$endif}
  25. {$ifdef unix}
  26. {$ifdef ver1_0}
  27. linux,
  28. {$else}
  29. unix,
  30. {$endif}
  31. {$endif}
  32. {$ifdef os2}
  33. doscalls,
  34. {$endif}
  35. {$ifdef Delphi}
  36. SysUtils,
  37. dmisc,
  38. {$else}
  39. strings,
  40. dos,
  41. {$endif}
  42. cutils,cclasses,
  43. globtype,version,systems;
  44. const
  45. {$ifdef Splitheap}
  46. testsplit : boolean = false;
  47. {$endif Splitheap}
  48. delphimodeswitches : tmodeswitches=
  49. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  50. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  51. m_out,m_default_para,m_hintdirective,m_duplicate_names];
  52. fpcmodeswitches : tmodeswitches=
  53. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  54. m_cvar_support,m_initfinal,m_add_pointer];
  55. objfpcmodeswitches : tmodeswitches=
  56. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  57. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para];
  58. tpmodeswitches : tmodeswitches=
  59. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  60. gpcmodeswitches : tmodeswitches=
  61. [m_gpc,m_all];
  62. type
  63. pfileposinfo = ^tfileposinfo;
  64. tfileposinfo = record
  65. line : longint;
  66. column : word;
  67. fileindex : word;
  68. { moduleindex : word; }
  69. end;
  70. TSearchPathList = class(TStringList)
  71. procedure AddPath(s:string;addfirst:boolean);
  72. procedure AddList(list:TSearchPathList;addfirst:boolean);
  73. function FindFile(const f : string;var foundfile:string):boolean;
  74. end;
  75. { the ordinal type used when evaluating constant integer expressions }
  76. TConstExprInt = int64;
  77. { ... the same unsigned }
  78. TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
  79. var
  80. { specified inputfile }
  81. inputdir : dirstr;
  82. inputfile : namestr;
  83. inputextension : extstr;
  84. { specified outputfile with -o parameter }
  85. outputfile : namestr;
  86. { specified with -FE or -FU }
  87. outputexedir : dirstr;
  88. outputunitdir : dirstr;
  89. { things specified with parameters }
  90. paralinkoptions,
  91. paradynamiclinker : string;
  92. parapreprocess : boolean;
  93. { directory where the utils can be found (options -FD) }
  94. utilsdirectory : dirstr;
  95. { some flags for global compiler switches }
  96. do_build,
  97. do_release,
  98. do_make : boolean;
  99. not_unit_proc : boolean;
  100. { path for searching units, different paths can be seperated by ; }
  101. exepath : dirstr; { Path to ppc }
  102. librarysearchpath,
  103. unitsearchpath,
  104. objectsearchpath,
  105. includesearchpath : TSearchPathList;
  106. { deffile }
  107. usewindowapi : boolean;
  108. description : string;
  109. dllversion : string;
  110. dllmajor,dllminor,dllrevision : word; { revision only for netware }
  111. akttokenpos, { position of the last token }
  112. aktfilepos : tfileposinfo; { current position }
  113. { ad 18.05.2001: Screen and Threadname for Netware }
  114. nwscreenname : string;
  115. nwthreadname : string;
  116. nwcopyright : string;
  117. block_type : tblock_type; { type of currently parsed block }
  118. in_args : boolean; { arguments must be checked especially }
  119. parsing_para_level : integer; { parameter level, used to convert
  120. proc calls to proc loads in firstcalln }
  121. compile_level : word;
  122. make_ref : boolean;
  123. resolving_forward : boolean; { used to add forward reference as second ref }
  124. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  125. inlining_procedure : boolean; { are we inlining a procedure }
  126. statement_level : integer;
  127. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  128. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  129. have_local_threadvars : boolean; { set if a table of local threadvars-tables is present and has to be initialized }
  130. { commandline values }
  131. initdefines : tstringlist;
  132. initglobalswitches : tglobalswitches;
  133. initmoduleswitches : tmoduleswitches;
  134. initlocalswitches : tlocalswitches;
  135. initmodeswitches : tmodeswitches;
  136. {$IFDEF testvarsets}
  137. Initsetalloc, {0=fixed, 1 =var}
  138. {$ENDIF}
  139. initpackenum : longint;
  140. initalignment : talignmentinfo;
  141. initoptprocessor,
  142. initspecificoptprocessor : tprocessors;
  143. initasmmode : tasmmode;
  144. initinterfacetype : tinterfacetypes;
  145. initoutputformat : tasm;
  146. initdefproccall : tproccalloption;
  147. { current state values }
  148. aktglobalswitches : tglobalswitches;
  149. aktmoduleswitches : tmoduleswitches;
  150. aktlocalswitches : tlocalswitches;
  151. nextaktlocalswitches : tlocalswitches;
  152. localswitcheschanged : boolean;
  153. aktmodeswitches : tmodeswitches;
  154. {$IFDEF testvarsets}
  155. aktsetalloc,
  156. {$ENDIF}
  157. aktpackenum : longint;
  158. aktmaxfpuregisters : longint;
  159. aktalignment : talignmentinfo;
  160. aktoptprocessor,
  161. aktspecificoptprocessor : tprocessors;
  162. aktasmmode : tasmmode;
  163. aktinterfacetype : tinterfacetypes;
  164. aktoutputformat : tasm;
  165. aktdefproccall : tproccalloption;
  166. { Memory sizes }
  167. heapsize,
  168. maxheapsize,
  169. stacksize : longint;
  170. {$Ifdef EXTDEBUG}
  171. total_of_firstpass,
  172. firstpass_several : longint;
  173. {$ifdef FPC}
  174. EntryMemUsed : longint;
  175. {$endif FPC}
  176. { parameter switches }
  177. debugstop : boolean;
  178. {$EndIf EXTDEBUG}
  179. { windows / OS/2 application type }
  180. apptype : tapptype;
  181. const
  182. RelocSection : boolean = true;
  183. RelocSectionSetExplicitly : boolean = false;
  184. LinkTypeSetExplicitly : boolean = false;
  185. DLLsource : boolean = false;
  186. DLLImageBase : pstring = nil;
  187. UseDeffileForExport : boolean = true;
  188. ForceDeffileForExport : boolean = false;
  189. { used to set all registers used for each global function
  190. this should dramatically decrease the number of
  191. recompilations needed PM }
  192. simplify_ppu : boolean = true;
  193. { should we allow non static members ? }
  194. allow_only_static : boolean = false;
  195. Inside_asm_statement : boolean = false;
  196. global_unit_count : word = 0;
  197. { for error info in pp.pas }
  198. parser_current_file : string = '';
  199. {$ifdef m68k}
  200. { PalmOS resources }
  201. palmos_applicationname : string = 'FPC Application';
  202. palmos_applicationid : string[4] = 'FPCA';
  203. {$endif m68k}
  204. procedure abstract;
  205. function bstoslash(const s : string) : string;
  206. function getdatestr:string;
  207. function gettimestr:string;
  208. function filetimestring( t : longint) : string;
  209. procedure DefaultReplacements(var s:string);
  210. function GetCurrentDir:string;
  211. function path_absolute(const s : string) : boolean;
  212. Function PathExists ( F : String) : Boolean;
  213. Function FileExists ( Const F : String) : Boolean;
  214. Function RemoveFile(const f:string):boolean;
  215. Function RemoveDir(d:string):boolean;
  216. Function GetFileTime ( Var F : File) : Longint;
  217. Function GetNamedFileTime ( Const F : String) : Longint;
  218. Function SplitPath(const s:string):string;
  219. Function SplitFileName(const s:string):string;
  220. Function SplitName(const s:string):string;
  221. Function SplitExtension(Const HStr:String):String;
  222. Function AddExtension(Const HStr,ext:String):String;
  223. Function ForceExtension(Const HStr,ext:String):String;
  224. Function FixPath(s:string;allowdot:boolean):string;
  225. function FixFileName(const s:string):string;
  226. function TargetFixPath(s:string;allowdot:boolean):string;
  227. function TargetFixFileName(const s:string):string;
  228. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  229. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  230. function FindExe(const bin:string;var foundfile:string):boolean;
  231. function GetShortName(const n:string):string;
  232. Procedure Shell(const command:string);
  233. function GetEnvPChar(const envname:string):pchar;
  234. procedure FreeEnvPChar(p:pchar);
  235. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  236. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  237. procedure InitGlobals;
  238. procedure DoneGlobals;
  239. function string2guid(const s: string; var GUID: TGUID): boolean;
  240. function guid2string(const GUID: TGUID): string;
  241. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  242. implementation
  243. uses
  244. comphook;
  245. procedure abstract;
  246. begin
  247. do_internalerror(255);
  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. bstoslash[0]:=s[0];
  262. end;
  263. {****************************************************************************
  264. Time Handling
  265. ****************************************************************************}
  266. Function L0(l:longint):string;
  267. {
  268. return the string of value l, if l<10 then insert a zero, so
  269. the string is always at least 2 chars '01','02',etc
  270. }
  271. var
  272. s : string;
  273. begin
  274. Str(l,s);
  275. if l<10 then
  276. s:='0'+s;
  277. L0:=s;
  278. end;
  279. function gettimestr:string;
  280. {
  281. get the current time in a string HH:MM:SS
  282. }
  283. var
  284. hour,min,sec,hsec : word;
  285. begin
  286. {$ifdef delphi}
  287. dmisc.gettime(hour,min,sec,hsec);
  288. {$else delphi}
  289. dos.gettime(hour,min,sec,hsec);
  290. {$endif delphi}
  291. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  292. end;
  293. function getdatestr:string;
  294. {
  295. get the current date in a string YY/MM/DD
  296. }
  297. var
  298. Year,Month,Day,Wday : Word;
  299. begin
  300. {$ifdef delphi}
  301. dmisc.getdate(year,month,day,wday);
  302. {$else}
  303. dos.getdate(year,month,day,wday);
  304. {$endif}
  305. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  306. end;
  307. function filetimestring( t : longint) : string;
  308. {
  309. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  310. }
  311. var
  312. DT : DateTime;
  313. begin
  314. if t=-1 then
  315. begin
  316. FileTimeString:='Not Found';
  317. exit;
  318. end;
  319. unpacktime(t,DT);
  320. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  321. end;
  322. {****************************************************************************
  323. Default Macro Handling
  324. ****************************************************************************}
  325. procedure DefaultReplacements(var s:string);
  326. begin
  327. { Replace some macro's }
  328. Replace(s,'$FPCVER',version_string);
  329. Replace(s,'$VERSION',version_string);
  330. Replace(s,'$FULLVERSION',full_version_string);
  331. Replace(s,'$FPCDATE',date_string);
  332. Replace(s,'$FPCTARGET',target_cpu_string);
  333. Replace(s,'$FPCCPU',target_cpu_string);
  334. Replace(s,'$TARGET',target_path);
  335. Replace(s,'$FPCOS',target_path);
  336. end;
  337. {****************************************************************************
  338. File Handling
  339. ****************************************************************************}
  340. function GetCurrentDir:string;
  341. var
  342. CurrentDir : string;
  343. begin
  344. GetDir(0,CurrentDir);
  345. GetCurrentDir:=FixPath(CurrentDir,false);
  346. end;
  347. function path_absolute(const s : string) : boolean;
  348. {
  349. is path s an absolute path?
  350. }
  351. begin
  352. path_absolute:=false;
  353. {$ifdef unix}
  354. if (length(s)>0) and (s[1]='/') then
  355. path_absolute:=true;
  356. {$else unix}
  357. {$ifdef amiga}
  358. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  359. path_absolute:=true;
  360. {$else}
  361. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  362. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  363. path_absolute:=true;
  364. {$endif amiga}
  365. {$endif unix}
  366. end;
  367. {$ifndef FPC}
  368. Procedure FindClose(var Info : SearchRec);
  369. Begin
  370. End;
  371. {$endif not FPC}
  372. Function FileExists ( Const F : String) : Boolean;
  373. {$ifndef delphi}
  374. Var
  375. Info : SearchRec;
  376. {$endif}
  377. begin
  378. {$ifdef delphi}
  379. FileExists:=sysutils.FileExists(f);
  380. {$else}
  381. findfirst(F,readonly+archive+hidden,info);
  382. FileExists:=(doserror=0);
  383. findclose(Info);
  384. {$endif delphi}
  385. end;
  386. Function PathExists ( F : String) : Boolean;
  387. Var
  388. Info : SearchRec;
  389. {$ifdef i386}
  390. disk : byte;
  391. {$endif i386}
  392. begin
  393. {$ifdef i386}
  394. if (Length(f)=3) and (F[2]=':') and (F[3] in ['/','\']) then
  395. begin
  396. if F[1] in ['A'..'Z'] then
  397. disk:=ord(F[1])-ord('A')+1
  398. else if F[1] in ['a'..'z'] then
  399. disk:=ord(F[1])-ord('a')+1
  400. else
  401. disk:=255;
  402. if disk=255 then
  403. PathExists:=false
  404. else
  405. PathExists:=(DiskSize(disk)<>-1);
  406. exit;
  407. end;
  408. {$endif i386}
  409. if F[Length(f)] in ['/','\'] then
  410. Delete(f,length(f),1);
  411. findfirst(F,readonly+archive+hidden+directory,info);
  412. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  413. findclose(Info);
  414. end;
  415. Function RemoveFile(const f:string):boolean;
  416. var
  417. g : file;
  418. begin
  419. assign(g,f);
  420. {$I-}
  421. erase(g);
  422. {$I+}
  423. RemoveFile:=(ioresult=0);
  424. end;
  425. Function RemoveDir(d:string):boolean;
  426. begin
  427. if d[length(d)]=source_info.DirSep then
  428. Delete(d,length(d),1);
  429. {$I-}
  430. rmdir(d);
  431. {$I+}
  432. RemoveDir:=(ioresult=0);
  433. end;
  434. Function SplitPath(const s:string):string;
  435. var
  436. i : longint;
  437. begin
  438. i:=Length(s);
  439. while (i>0) and not(s[i] in ['/','\']) do
  440. dec(i);
  441. SplitPath:=Copy(s,1,i);
  442. end;
  443. Function SplitFileName(const s:string):string;
  444. var
  445. p : dirstr;
  446. n : namestr;
  447. e : extstr;
  448. begin
  449. FSplit(s,p,n,e);
  450. SplitFileName:=n+e;
  451. end;
  452. Function SplitName(const s:string):string;
  453. var
  454. i,j : longint;
  455. begin
  456. i:=Length(s);
  457. j:=Length(s);
  458. while (i>0) and not(s[i] in ['/','\']) do
  459. dec(i);
  460. while (j>0) and (s[j]<>'.') do
  461. dec(j);
  462. if j<=i then
  463. j:=255;
  464. SplitName:=Copy(s,i+1,j-(i+1));
  465. end;
  466. Function SplitExtension(Const HStr:String):String;
  467. var
  468. j : longint;
  469. begin
  470. j:=length(Hstr);
  471. while (j>0) and (Hstr[j]<>'.') do
  472. begin
  473. if hstr[j]=source_info.DirSep then
  474. j:=0
  475. else
  476. dec(j);
  477. end;
  478. if j=0 then
  479. j:=254;
  480. SplitExtension:=Copy(Hstr,j,255);
  481. end;
  482. Function AddExtension(Const HStr,ext:String):String;
  483. begin
  484. if (Ext<>'') and (SplitExtension(HStr)='') then
  485. AddExtension:=Hstr+Ext
  486. else
  487. AddExtension:=Hstr;
  488. end;
  489. Function ForceExtension(Const HStr,ext:String):String;
  490. var
  491. j : longint;
  492. begin
  493. j:=length(Hstr);
  494. while (j>0) and (Hstr[j]<>'.') do
  495. dec(j);
  496. if j=0 then
  497. j:=255;
  498. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  499. end;
  500. Function FixPath(s:string;allowdot:boolean):string;
  501. var
  502. i : longint;
  503. begin
  504. { Fix separator }
  505. for i:=1 to length(s) do
  506. if s[i] in ['/','\'] then
  507. s[i]:=source_info.DirSep;
  508. { Fix ending / }
  509. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  510. (s[length(s)]<>':') then
  511. s:=s+source_info.DirSep;
  512. { Remove ./ }
  513. if (not allowdot) and (s='.'+source_info.DirSep) then
  514. s:='';
  515. { return }
  516. if source_info.files_case_relevent then
  517. FixPath:=s
  518. else
  519. FixPath:=Lower(s);
  520. end;
  521. function FixFileName(const s:string):string;
  522. var
  523. i : longint;
  524. begin
  525. if source_info.files_case_relevent then
  526. begin
  527. for i:=1 to length(s) do
  528. begin
  529. case s[i] of
  530. '/','\' :
  531. FixFileName[i]:=source_info.dirsep;
  532. else
  533. FixFileName[i]:=s[i];
  534. end;
  535. end;
  536. end
  537. else
  538. begin
  539. for i:=1 to length(s) do
  540. begin
  541. case s[i] of
  542. '/','\' :
  543. FixFileName[i]:=source_info.dirsep;
  544. 'A'..'Z' :
  545. FixFileName[i]:=char(byte(s[i])+32);
  546. else
  547. FixFileName[i]:=s[i];
  548. end;
  549. end;
  550. end;
  551. FixFileName[0]:=s[0];
  552. end;
  553. Function TargetFixPath(s:string;allowdot:boolean):string;
  554. var
  555. i : longint;
  556. begin
  557. { Fix separator }
  558. for i:=1 to length(s) do
  559. if s[i] in ['/','\'] then
  560. s[i]:=target_info.DirSep;
  561. { Fix ending / }
  562. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  563. (s[length(s)]<>':') then
  564. s:=s+target_info.DirSep;
  565. { Remove ./ }
  566. if (not allowdot) and (s='.'+target_info.DirSep) then
  567. s:='';
  568. { return }
  569. if target_info.files_case_relevent then
  570. TargetFixPath:=s
  571. else
  572. TargetFixPath:=Lower(s);
  573. end;
  574. function TargetFixFileName(const s:string):string;
  575. var
  576. i : longint;
  577. begin
  578. if target_info.files_case_relevent then
  579. begin
  580. for i:=1 to length(s) do
  581. begin
  582. case s[i] of
  583. '/','\' :
  584. TargetFixFileName[i]:=target_info.dirsep;
  585. else
  586. TargetFixFileName[i]:=s[i];
  587. end;
  588. end;
  589. end
  590. else
  591. begin
  592. for i:=1 to length(s) do
  593. begin
  594. case s[i] of
  595. '/','\' :
  596. TargetFixFileName[i]:=target_info.dirsep;
  597. 'A'..'Z' :
  598. TargetFixFileName[i]:=char(byte(s[i])+32);
  599. else
  600. TargetFixFileName[i]:=s[i];
  601. end;
  602. end;
  603. end;
  604. TargetFixFileName[0]:=s[0];
  605. end;
  606. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  607. var
  608. i : longint;
  609. begin
  610. i:=pos(' ',s);
  611. if i>0 then
  612. begin
  613. bstr:=Copy(s,1,i-1);
  614. cstr:=Copy(s,i+1,length(s)-i);
  615. end
  616. else
  617. begin
  618. bstr:=s;
  619. cstr:='';
  620. end;
  621. end;
  622. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  623. var
  624. j : longint;
  625. hs,hsd,
  626. CurrentDir,
  627. CurrPath : string;
  628. dir : searchrec;
  629. hp : TStringListItem;
  630. procedure addcurrpath;
  631. begin
  632. if addfirst then
  633. begin
  634. Remove(currPath);
  635. Insert(currPath);
  636. end
  637. else
  638. begin
  639. { Check if already in path, then we don't add it }
  640. hp:=Find(currPath);
  641. if not assigned(hp) then
  642. Concat(currPath);
  643. end;
  644. end;
  645. begin
  646. if s='' then
  647. exit;
  648. { Support default macro's }
  649. DefaultReplacements(s);
  650. { get current dir }
  651. CurrentDir:=GetCurrentDir;
  652. repeat
  653. { get currpath }
  654. if addfirst then
  655. begin
  656. j:=length(s);
  657. while (j>0) and (s[j]<>';') do
  658. dec(j);
  659. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  660. if j=0 then
  661. s:=''
  662. else
  663. System.Delete(s,j,length(s)-j+1);
  664. end
  665. else
  666. begin
  667. j:=Pos(';',s);
  668. if j=0 then
  669. j:=255;
  670. CurrPath:=FixPath(Copy(s,1,j-1),false);
  671. System.Delete(s,1,j);
  672. end;
  673. { fix pathname }
  674. if CurrPath='' then
  675. CurrPath:='.'+source_info.DirSep
  676. else
  677. begin
  678. CurrPath:=FixPath(FExpand(CurrPath),false);
  679. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  680. CurrPath:='.'+source_info.DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  681. end;
  682. { wildcard adding ? }
  683. if pos('*',currpath)>0 then
  684. begin
  685. if currpath[length(currpath)]=source_info.dirsep then
  686. hs:=Copy(currpath,1,length(CurrPath)-1)
  687. else
  688. hs:=currpath;
  689. hsd:=SplitPath(hs);
  690. findfirst(hs,directory,dir);
  691. while doserror=0 do
  692. begin
  693. if (dir.name<>'.') and
  694. (dir.name<>'..') and
  695. ((dir.attr and directory)<>0) then
  696. begin
  697. currpath:=hsd+dir.name+source_info.dirsep;
  698. hp:=Find(currPath);
  699. if not assigned(hp) then
  700. AddCurrPath;
  701. end;
  702. findnext(dir);
  703. end;
  704. FindClose(dir);
  705. end
  706. else
  707. begin
  708. if PathExists(currpath) then
  709. addcurrpath;
  710. end;
  711. until (s='');
  712. end;
  713. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  714. var
  715. s : string;
  716. hl : TSearchPathList;
  717. hp,hp2 : TStringListItem;
  718. begin
  719. if list.empty then
  720. exit;
  721. { create temp and reverse the list }
  722. if addfirst then
  723. begin
  724. hl:=TSearchPathList.Create;
  725. hp:=TStringListItem(list.first);
  726. while assigned(hp) do
  727. begin
  728. hl.insert(hp.Str);
  729. hp:=TStringListItem(hp.next);
  730. end;
  731. while not hl.empty do
  732. begin
  733. s:=hl.GetFirst;
  734. Remove(s);
  735. Insert(s);
  736. end;
  737. hl.Free;
  738. end
  739. else
  740. begin
  741. hp:=TStringListItem(list.first);
  742. while assigned(hp) do
  743. begin
  744. hp2:=Find(hp.Str);
  745. { Check if already in path, then we don't add it }
  746. if not assigned(hp2) then
  747. Concat(hp.Str);
  748. hp:=TStringListItem(hp.next);
  749. end;
  750. end;
  751. end;
  752. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  753. Var
  754. p : TStringListItem;
  755. begin
  756. FindFile:=false;
  757. p:=TStringListItem(first);
  758. while assigned(p) do
  759. begin
  760. {
  761. Search order for case sensitive systems:
  762. 1. lowercase
  763. 2. NormalCase
  764. 3. UPPERCASE
  765. None case sensitive only lowercase
  766. }
  767. FoundFile:=p.Str+Lower(f);
  768. If FileExists(FoundFile) then
  769. begin
  770. FindFile:=true;
  771. exit;
  772. end;
  773. {$ifdef UNIX}
  774. FoundFile:=p.Str+f;
  775. If FileExists(FoundFile) then
  776. begin
  777. FindFile:=true;
  778. exit;
  779. end;
  780. FoundFile:=p.Str+Upper(f);
  781. If FileExists(FoundFile) then
  782. begin
  783. FindFile:=true;
  784. exit;
  785. end;
  786. {$endif UNIX}
  787. p:=TStringListItem(p.next);
  788. end;
  789. { Return original filename if not found }
  790. FoundFile:=f;
  791. end;
  792. Function GetFileTime ( Var F : File) : Longint;
  793. Var
  794. {$ifdef unix}
  795. Info : Stat;
  796. {$endif}
  797. L : longint;
  798. begin
  799. {$ifdef unix}
  800. FStat (F,Info);
  801. L:=Info.Mtime;
  802. {$else}
  803. GetFTime(f,l);
  804. {$endif}
  805. GetFileTime:=L;
  806. end;
  807. Function GetNamedFileTime (Const F : String) : Longint;
  808. begin
  809. GetNamedFileTime:=do_getnamedfiletime(F);
  810. end;
  811. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  812. Var
  813. singlepathstring : string;
  814. i : longint;
  815. begin
  816. {$ifdef Unix}
  817. for i:=1 to length(path) do
  818. if path[i]=':' then
  819. path[i]:=';';
  820. {$endif Unix}
  821. FindFile:=false;
  822. repeat
  823. i:=pos(';',path);
  824. if i=0 then
  825. i:=256;
  826. singlepathstring:=FixPath(copy(path,1,i-1),false);
  827. delete(path,1,i);
  828. {
  829. Search order for case sensitive systems:
  830. 1. lowercase
  831. 2. NormalCase
  832. 3. UPPERCASE
  833. None case sensitive only lowercase
  834. }
  835. FoundFile:=singlepathstring+Lower(f);
  836. If FileExists(FoundFile) then
  837. begin
  838. FindFile:=true;
  839. exit;
  840. end;
  841. {$ifdef UNIX}
  842. FoundFile:=singlepathstring+f;
  843. If FileExists(FoundFile) then
  844. begin
  845. FindFile:=true;
  846. exit;
  847. end;
  848. FoundFile:=singlepathstring+Upper(f);
  849. If FileExists(FoundFile) then
  850. begin
  851. FindFile:=true;
  852. exit;
  853. end;
  854. {$endif UNIX}
  855. until path='';
  856. FoundFile:=f;
  857. end;
  858. function FindExe(const bin:string;var foundfile:string):boolean;
  859. begin
  860. {$ifdef delphi}
  861. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
  862. {$else delphi}
  863. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
  864. {$endif delphi}
  865. end;
  866. function GetShortName(const n:string):string;
  867. {$ifdef win32}
  868. var
  869. hs,hs2 : string;
  870. i : longint;
  871. {$endif}
  872. {$ifdef go32v2}
  873. var
  874. hs : string;
  875. {$endif}
  876. begin
  877. GetShortName:=n;
  878. {$ifdef win32}
  879. hs:=n+#0;
  880. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  881. if (i>0) and (i<=high(hs2)) then
  882. begin
  883. hs2[0]:=chr(strlen(@hs2[1]));
  884. GetShortName:=hs2;
  885. end;
  886. {$endif}
  887. {$ifdef go32v2}
  888. hs:=n;
  889. if Dos.GetShortName(hs) then
  890. GetShortName:=hs;
  891. {$endif}
  892. end;
  893. {****************************************************************************
  894. OS Dependent things
  895. ****************************************************************************}
  896. function GetEnvPChar(const envname:string):pchar;
  897. {$ifdef win32}
  898. var
  899. s : string;
  900. i,len : longint;
  901. hp,p,p2 : pchar;
  902. {$endif}
  903. {$ifdef os2}
  904. var
  905. P1, P2: PChar;
  906. {$endif}
  907. begin
  908. {$ifdef unix}
  909. GetEnvPchar:={$ifdef ver1_0}Linux{$else}Unix{$endif}.Getenv(envname);
  910. {$define GETENVOK}
  911. {$endif}
  912. {$ifdef win32}
  913. GetEnvPchar:=nil;
  914. p:=GetEnvironmentStrings;
  915. hp:=p;
  916. while hp^<>#0 do
  917. begin
  918. s:=strpas(hp);
  919. i:=pos('=',s);
  920. len:=strlen(hp);
  921. if upper(copy(s,1,i-1))=upper(envname) then
  922. begin
  923. GetMem(p2,len-length(envname));
  924. Move(hp[i],p2^,len-length(envname));
  925. GetEnvPchar:=p2;
  926. break;
  927. end;
  928. { next string entry}
  929. hp:=hp+len+1;
  930. end;
  931. FreeEnvironmentStrings(p);
  932. {$define GETENVOK}
  933. {$endif}
  934. {$ifdef os2}
  935. P1 := StrPNew (EnvName);
  936. if Assigned (P1) then
  937. begin
  938. if DosCalls.DosScanEnv (P1, P2) = 0 then
  939. GetEnvPChar := P2
  940. else
  941. GetEnvPChar := nil;
  942. StrDispose (P1);
  943. end else GetEnvPChar := nil;
  944. {$define GETENVOK}
  945. {$endif}
  946. {$ifdef GETENVOK}
  947. {$undef GETENVOK}
  948. {$else}
  949. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  950. {$endif}
  951. end;
  952. procedure FreeEnvPChar(p:pchar);
  953. begin
  954. {$ifndef unix}
  955. {$ifndef os2}
  956. StrDispose(p);
  957. {$endif}
  958. {$endif}
  959. end;
  960. Procedure Shell(const command:string);
  961. { This is already defined in the linux.ppu for linux, need for the *
  962. expansion under linux }
  963. {$ifdef unix}
  964. begin
  965. {$ifdef ver1_0}Linux{$else}Unix{$endif}.Shell(command);
  966. end;
  967. {$else}
  968. var
  969. comspec : string;
  970. begin
  971. comspec:=getenv('COMSPEC');
  972. Exec(comspec,' /C '+command);
  973. end;
  974. {$endif}
  975. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  976. var
  977. b : boolean;
  978. begin
  979. b:=true;
  980. if s='DEFAULT' then
  981. aktmodeswitches:=initmodeswitches
  982. else
  983. if s='DELPHI' then
  984. aktmodeswitches:=delphimodeswitches
  985. else
  986. if s='TP' then
  987. aktmodeswitches:=tpmodeswitches
  988. else
  989. if s='FPC' then
  990. aktmodeswitches:=fpcmodeswitches
  991. else
  992. if s='OBJFPC' then
  993. aktmodeswitches:=objfpcmodeswitches
  994. else
  995. if s='GPC' then
  996. aktmodeswitches:=gpcmodeswitches
  997. else
  998. b:=false;
  999. if b and changeInit then
  1000. initmodeswitches := aktmodeswitches;
  1001. if b then
  1002. begin
  1003. { turn ansistrings on by default ? }
  1004. if (m_delphi in aktmodeswitches) then
  1005. begin
  1006. include(aktlocalswitches,cs_ansistrings);
  1007. if changeinit then
  1008. include(initlocalswitches,cs_ansistrings);
  1009. end
  1010. else
  1011. begin
  1012. exclude(aktlocalswitches,cs_ansistrings);
  1013. if changeinit then
  1014. exclude(initlocalswitches,cs_ansistrings);
  1015. end;
  1016. { enum packing }
  1017. if (m_tp7 in aktmodeswitches) then
  1018. aktpackenum:=1
  1019. else
  1020. aktpackenum:=4;
  1021. if changeinit then
  1022. initpackenum:=aktpackenum;
  1023. end;
  1024. SetCompileMode:=b;
  1025. end;
  1026. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1027. const
  1028. DefProcCallName : array[tproccalloption] of string[12] = ('',
  1029. 'CDECL',
  1030. 'CPPDECL',
  1031. '', { compilerproc }
  1032. 'FAR16',
  1033. 'FPCCALL',
  1034. 'INLINE',
  1035. '', { internconst }
  1036. '', { internproc }
  1037. '', { palmossyscall }
  1038. 'PASCAL',
  1039. 'REGISTER',
  1040. 'SAFECALL',
  1041. 'STDCALL',
  1042. 'SYSTEM'
  1043. );
  1044. var
  1045. t : tproccalloption;
  1046. begin
  1047. SetAktProcCall:=false;
  1048. for t:=low(tproccalloption) to high(tproccalloption) do
  1049. if DefProcCallName[t]=s then
  1050. begin
  1051. AktDefProcCall:=t;
  1052. SetAktProcCall:=true;
  1053. break;
  1054. end;
  1055. if changeinit then
  1056. InitDefProcCall:=AktDefProcCall;
  1057. end;
  1058. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1059. function string2guid(const s: string; var GUID: TGUID): boolean;
  1060. function ishexstr(const hs: string): boolean;
  1061. var
  1062. i: integer;
  1063. begin
  1064. ishexstr:=false;
  1065. for i:=1 to Length(hs) do begin
  1066. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1067. exit;
  1068. end;
  1069. ishexstr:=true;
  1070. end;
  1071. function hexstr2longint(const hexs: string): longint;
  1072. var
  1073. i: integer;
  1074. rl: longint;
  1075. begin
  1076. rl:=0;
  1077. for i:=1 to length(hexs) do begin
  1078. rl:=rl shl 4;
  1079. case hexs[i] of
  1080. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1081. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1082. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1083. end
  1084. end;
  1085. hexstr2longint:=rl;
  1086. end;
  1087. var
  1088. i: integer;
  1089. begin
  1090. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1091. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1092. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1093. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1094. ishexstr(copy(s,26,12)) then begin
  1095. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1096. GUID.D2:=hexstr2longint(copy(s,11,4));
  1097. GUID.D3:=hexstr2longint(copy(s,16,4));
  1098. for i:=0 to 1 do
  1099. GUID.D4[i]:=hexstr2longint(copy(s,21+i*2,2));
  1100. for i:=2 to 7 do
  1101. GUID.D4[i]:=hexstr2longint(copy(s,22+i*2,2));
  1102. string2guid:=true;
  1103. end
  1104. else
  1105. string2guid:=false;
  1106. end;
  1107. function guid2string(const GUID: TGUID): string;
  1108. function long2hex(l, len: longint): string;
  1109. const
  1110. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1111. var
  1112. rs: string;
  1113. i: integer;
  1114. begin
  1115. rs[0]:=chr(len);
  1116. for i:=len downto 1 do begin
  1117. rs[i]:=hextbl[l and $F];
  1118. l:=l shr 4;
  1119. end;
  1120. long2hex:=rs;
  1121. end;
  1122. begin
  1123. guid2string:=
  1124. '{'+long2hex(GUID.D1,8)+
  1125. '-'+long2hex(GUID.D2,4)+
  1126. '-'+long2hex(GUID.D3,4)+
  1127. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1128. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1129. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1130. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1131. '}';
  1132. end;
  1133. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1134. var
  1135. tok : string;
  1136. vstr : string;
  1137. l : longint;
  1138. code : integer;
  1139. b : talignmentinfo;
  1140. begin
  1141. UpdateAlignmentStr:=true;
  1142. uppervar(s);
  1143. fillchar(b,sizeof(b),0);
  1144. repeat
  1145. tok:=GetToken(s,'=');
  1146. if tok='' then
  1147. break;
  1148. vstr:=GetToken(s,',');
  1149. val(vstr,l,code);
  1150. if tok='PROC' then
  1151. b.procalign:=l
  1152. else if tok='JUMP' then
  1153. b.jumpalign:=l
  1154. else if tok='LOOP' then
  1155. b.loopalign:=l
  1156. else if tok='CONSTMIN' then
  1157. b.constalignmin:=l
  1158. else if tok='CONSTMAX' then
  1159. b.constalignmax:=l
  1160. else if tok='VARMIN' then
  1161. b.varalignmin:=l
  1162. else if tok='VARMAX' then
  1163. b.varalignmax:=l
  1164. else if tok='LOCALMIN' then
  1165. b.localalignmin:=l
  1166. else if tok='LOCALMAX' then
  1167. b.localalignmax:=l
  1168. else if tok='RECORDMIN' then
  1169. b.recordalignmin:=l
  1170. else if tok='RECORDMAX' then
  1171. b.recordalignmax:=l
  1172. else if tok='PARAALIGN' then
  1173. b.paraalign:=l
  1174. else { Error }
  1175. UpdateAlignmentStr:=false;
  1176. until false;
  1177. UpdateAlignment(a,b);
  1178. end;
  1179. {****************************************************************************
  1180. Init
  1181. ****************************************************************************}
  1182. {$ifdef unix}
  1183. {$define need_path_search}
  1184. {$endif unix}
  1185. {$ifdef os2}
  1186. {$define need_path_search}
  1187. {$endif os2}
  1188. procedure get_exepath;
  1189. var
  1190. hs1 : namestr;
  1191. hs2 : extstr;
  1192. begin
  1193. {$ifdef delphi}
  1194. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1195. {$else delphi}
  1196. exepath:=dos.getenv('PPC_EXEC_PATH');
  1197. {$endif delphi}
  1198. if exepath='' then
  1199. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1200. {$ifdef need_path_search}
  1201. if exepath='' then
  1202. begin
  1203. if pos(source_info.exeext,hs1) <>
  1204. (length(hs1) - length(source_info.exeext)+1) then
  1205. hs1 := hs1 + source_info.exeext;
  1206. {$ifdef delphi}
  1207. findfile(hs1,dmisc.getenv('PATH'),exepath);
  1208. {$else delphi}
  1209. findfile(hs1,dos.getenv('PATH'),exepath);
  1210. {$endif delphi}
  1211. exepath:=SplitPath(exepath);
  1212. end;
  1213. {$endif need_path_search}
  1214. exepath:=FixPath(exepath,false);
  1215. end;
  1216. procedure DoneGlobals;
  1217. begin
  1218. initdefines.free;
  1219. if assigned(DLLImageBase) then
  1220. StringDispose(DLLImageBase);
  1221. RelocSection:=true;
  1222. RelocSectionSetExplicitly:=false;
  1223. UseDeffileForExport:=true;
  1224. librarysearchpath.Free;
  1225. unitsearchpath.Free;
  1226. objectsearchpath.Free;
  1227. includesearchpath.Free;
  1228. end;
  1229. procedure InitGlobals;
  1230. begin
  1231. get_exepath;
  1232. { reset globals }
  1233. do_build:=false;
  1234. do_release:=false;
  1235. do_make:=true;
  1236. compile_level:=0;
  1237. DLLsource:=false;
  1238. inlining_procedure:=false;
  1239. resolving_forward:=false;
  1240. in_args:=false;
  1241. make_ref:=false;
  1242. { Output }
  1243. OutputFile:='';
  1244. OutputExeDir:='';
  1245. OutputUnitDir:='';
  1246. { Utils directory }
  1247. utilsdirectory:='';
  1248. { Search Paths }
  1249. librarysearchpath:=TSearchPathList.Create;
  1250. unitsearchpath:=TSearchPathList.Create;
  1251. includesearchpath:=TSearchPathList.Create;
  1252. objectsearchpath:=TSearchPathList.Create;
  1253. { Def file }
  1254. usewindowapi:=false;
  1255. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1256. dllversion:='';
  1257. nwscreenname := '';
  1258. nwthreadname := '';
  1259. nwcopyright := '';
  1260. { Init values }
  1261. initmodeswitches:=fpcmodeswitches;
  1262. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1263. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1264. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1265. initoutputformat:=target_asm.id;
  1266. fillchar(initalignment,sizeof(talignmentinfo),0);
  1267. {$ifdef i386}
  1268. initoptprocessor:=Class386;
  1269. initspecificoptprocessor:=Class386;
  1270. initpackenum:=4;
  1271. {$IFDEF testvarsets}
  1272. initsetalloc:=0;
  1273. {$ENDIF}
  1274. initasmmode:=asmmode_i386_att;
  1275. {$else not i386}
  1276. {$ifdef m68k}
  1277. initoptprocessor:=MC68000;
  1278. include(initmoduleswitches,cs_fp_emulation);
  1279. initpackenum:=4;
  1280. {$IFDEF testvarsets}
  1281. initsetalloc:=0;
  1282. {$ENDIF}
  1283. initasmmode:=asmmode_m68k_mot;
  1284. {$endif m68k}
  1285. {$endif i386}
  1286. initinterfacetype:=it_interfacecom;
  1287. initdefproccall:=pocall_none;
  1288. initdefines:=TStringList.Create;
  1289. { memory sizes, will be overriden by parameter or default for target
  1290. in options or init_parser }
  1291. stacksize:=0;
  1292. heapsize:=0;
  1293. maxheapsize:=0;
  1294. { compile state }
  1295. in_args:=false;
  1296. { must_be_valid:=true; obsolete PM }
  1297. not_unit_proc:=true;
  1298. apptype:=app_cui;
  1299. have_local_threadvars := false;
  1300. end;
  1301. {$ifdef EXTDEBUG}
  1302. begin
  1303. {$ifdef FPC}
  1304. EntryMemUsed:=system.HeapSize-MemAvail;
  1305. {$endif FPC}
  1306. {$endif}
  1307. end.
  1308. {
  1309. $Log$
  1310. Revision 1.54 2002-04-07 13:24:30 carl
  1311. + moved constant from cpuinfo, these are NOT cpu specific
  1312. constant, but more related to compiler functionality.
  1313. Revision 1.53 2002/04/02 17:11:28 peter
  1314. * tlocation,treference update
  1315. * LOC_CONSTANT added for better constant handling
  1316. * secondadd splitted in multiple routines
  1317. * location_force_reg added for loading a location to a register
  1318. of a specified size
  1319. * secondassignment parses now first the right and then the left node
  1320. (this is compatible with Kylix). This saves a lot of push/pop especially
  1321. with string operations
  1322. * adapted some routines to use the new cg methods
  1323. Revision 1.52 2002/03/28 16:07:52 armin
  1324. + initialize threadvars defined local in units
  1325. Revision 1.51 2002/01/24 18:25:48 peter
  1326. * implicit result variable generation for assembler routines
  1327. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1328. Revision 1.50 2001/12/06 17:57:33 florian
  1329. + parasym to tparaitem added
  1330. Revision 1.49 2001/10/25 21:22:32 peter
  1331. * calling convention rewrite
  1332. Revision 1.48 2001/10/23 21:49:42 peter
  1333. * $calling directive and -Cc commandline patch added
  1334. from Pavel Ozerski
  1335. Revision 1.47 2001/10/21 12:33:05 peter
  1336. * array access for properties added
  1337. Revision 1.46 2001/10/20 20:30:20 peter
  1338. * read only typed const support, switch $J-
  1339. Revision 1.45 2001/10/16 15:10:34 jonas
  1340. * fixed goto/label/try bugs
  1341. Revision 1.44 2001/10/12 16:06:17 peter
  1342. * pathexists fix (merged)
  1343. Revision 1.43 2001/09/18 11:30:47 michael
  1344. * Fixes win32 linking problems with import libraries
  1345. * LINKLIB Libraries are now looked for using C file extensions
  1346. * get_exepath fix
  1347. Revision 1.42 2001/09/17 21:29:11 peter
  1348. * merged netbsd, fpu-overflow from fixes branch
  1349. Revision 1.41 2001/08/19 11:22:22 peter
  1350. * palmos support from v10 merged
  1351. Revision 1.40 2001/08/04 10:23:54 peter
  1352. * updates so it works with the ide
  1353. Revision 1.39 2001/07/01 20:16:15 peter
  1354. * alignmentinfo record added
  1355. * -Oa argument supports more alignment settings that can be specified
  1356. per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
  1357. RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
  1358. required alignment and the maximum usefull alignment. The final
  1359. alignment will be choosen per variable size dependent on these
  1360. settings
  1361. Revision 1.38 2001/06/18 20:36:24 peter
  1362. * -Ur switch (merged)
  1363. * masm fixes (merged)
  1364. * quoted filenames for go32v2 and win32
  1365. Revision 1.37 2001/06/03 21:57:35 peter
  1366. + hint directive parsing support
  1367. Revision 1.36 2001/06/03 20:21:08 peter
  1368. * Kylix fixes, mostly case names of units
  1369. Revision 1.35 2001/05/30 21:35:48 peter
  1370. * netware patches for copyright, screenname, threadname directives
  1371. Revision 1.34 2001/05/12 12:11:31 peter
  1372. * simplify_ppu is now the default, a recompile of the compiler now
  1373. only compiles pp.pas
  1374. Revision 1.33 2001/05/06 14:49:17 peter
  1375. * ppu object to class rewrite
  1376. * move ppu read and write stuff to fppu
  1377. Revision 1.32 2001/04/18 22:01:53 peter
  1378. * registration of targets and assemblers
  1379. Revision 1.31 2001/04/15 09:48:29 peter
  1380. * fixed crash in labelnode
  1381. * easier detection of goto and label in try blocks
  1382. Revision 1.30 2001/04/13 01:22:07 peter
  1383. * symtable change to classes
  1384. * range check generation and errors fixed, make cycle DEBUG=1 works
  1385. * memory leaks fixed
  1386. Revision 1.29 2001/04/04 21:30:42 florian
  1387. * applied several fixes to get the DD8 Delphi Unit compiled
  1388. e.g. "forward"-interfaces are working now
  1389. Revision 1.28 2001/02/20 21:41:16 peter
  1390. * new fixfilename, findfile for unix. Look first for lowercase, then
  1391. NormalCase and last for UPPERCASE names.
  1392. Revision 1.27 2001/02/09 23:05:45 peter
  1393. * default packenum=1 for tp7 mode
  1394. Revision 1.26 2001/02/05 20:47:00 peter
  1395. * support linux unit for ver1_0 compilers
  1396. Revision 1.25 2001/01/21 20:32:45 marco
  1397. * Renamefest. Compiler part. Not that hard.
  1398. Revision 1.24 2001/01/20 18:32:52 hajny
  1399. + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
  1400. Revision 1.23 2001/01/13 00:03:41 peter
  1401. * fixed findexe to also support already extension in name
  1402. Revision 1.22 2000/12/26 15:57:25 peter
  1403. * use system.paramstr()
  1404. Revision 1.21 2000/12/25 00:07:26 peter
  1405. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1406. tlinkedlist objects)
  1407. Revision 1.20 2000/11/13 15:26:12 marco
  1408. * Renamefest
  1409. Revision 1.19 2000/11/12 22:20:37 peter
  1410. * create generic toutputsection for binary writers
  1411. Revision 1.18 2000/11/04 14:25:19 florian
  1412. + merged Attila's changes for interfaces, not tested yet
  1413. Revision 1.17 2000/10/31 22:02:46 peter
  1414. * symtable splitted, no real code changes
  1415. Revision 1.16 2000/10/04 14:51:08 pierre
  1416. * IsExe restored
  1417. Revision 1.15 2000/09/27 21:20:56 peter
  1418. * also set initlocalswitches in setcompilemode (merged)
  1419. Revision 1.14 2000/09/26 10:50:41 jonas
  1420. * initmodeswitches is changed is you change the compiler mode from the
  1421. command line (the -S<x> switches didn't work anymore for changing the
  1422. compiler mode) (merged from fixes branch)
  1423. Revision 1.13 2000/09/24 21:33:46 peter
  1424. * message updates merges
  1425. Revision 1.12 2000/09/24 21:19:50 peter
  1426. * delphi compile fixes
  1427. Revision 1.11 2000/09/24 15:12:40 peter
  1428. * fixed typo
  1429. Revision 1.10 2000/09/24 15:06:16 peter
  1430. * use defines.inc
  1431. Revision 1.9 2000/09/24 10:33:07 peter
  1432. * searching of exe in path also for OS/2
  1433. * fixed searching of exe in path.
  1434. Revision 1.8 2000/09/11 17:00:22 florian
  1435. + first implementation of Netware Module support, thanks to
  1436. Armin Diehl ([email protected]) for providing the patches
  1437. Revision 1.7 2000/08/27 16:11:51 peter
  1438. * moved some util functions from globals,cobjects to cutils
  1439. * splitted files into finput,fmodule
  1440. Revision 1.6 2000/08/12 19:14:58 peter
  1441. * ELF writer works now also with -g
  1442. * ELF writer is default again for linux
  1443. Revision 1.5 2000/08/12 15:30:44 peter
  1444. * IDE patch for stream reading (merged)
  1445. Revision 1.4 2000/08/02 19:49:59 peter
  1446. * first things for default parameters
  1447. Revision 1.3 2000/07/13 12:08:25 michael
  1448. + patched to 1.1.0 with former 1.09patch from peter
  1449. Revision 1.2 2000/07/13 11:32:41 michael
  1450. + removed logs
  1451. }