globals.pas 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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 fpcdefs.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. stacksize : longint;
  169. {$Ifdef EXTDEBUG}
  170. total_of_firstpass,
  171. firstpass_several : longint;
  172. {$ifdef FPC}
  173. EntryMemUsed : longint;
  174. {$endif FPC}
  175. { parameter switches }
  176. debugstop : boolean;
  177. {$EndIf EXTDEBUG}
  178. { windows / OS/2 application type }
  179. apptype : tapptype;
  180. const
  181. RelocSection : boolean = true;
  182. RelocSectionSetExplicitly : boolean = false;
  183. LinkTypeSetExplicitly : boolean = false;
  184. DLLsource : boolean = false;
  185. DLLImageBase : pstring = nil;
  186. UseDeffileForExport : boolean = true;
  187. ForceDeffileForExport : boolean = false;
  188. { used to set all registers used for each global function
  189. this should dramatically decrease the number of
  190. recompilations needed PM }
  191. simplify_ppu : boolean = true;
  192. { should we allow non static members ? }
  193. allow_only_static : boolean = false;
  194. Inside_asm_statement : boolean = false;
  195. global_unit_count : word = 0;
  196. { for error info in pp.pas }
  197. parser_current_file : string = '';
  198. {$ifdef m68k}
  199. { PalmOS resources }
  200. palmos_applicationname : string = 'FPC Application';
  201. palmos_applicationid : string[4] = 'FPCA';
  202. {$endif m68k}
  203. procedure abstract;
  204. function bstoslash(const s : string) : string;
  205. function getdatestr:string;
  206. function gettimestr:string;
  207. function filetimestring( t : longint) : string;
  208. procedure DefaultReplacements(var s:string);
  209. function GetCurrentDir:string;
  210. function path_absolute(const s : string) : boolean;
  211. Function PathExists ( F : String) : Boolean;
  212. Function FileExists ( Const F : String) : Boolean;
  213. Function RemoveFile(const f:string):boolean;
  214. Function RemoveDir(d:string):boolean;
  215. Function GetFileTime ( Var F : File) : Longint;
  216. Function GetNamedFileTime ( Const F : String) : Longint;
  217. Function SplitPath(const s:string):string;
  218. Function SplitFileName(const s:string):string;
  219. Function SplitName(const s:string):string;
  220. Function SplitExtension(Const HStr:String):String;
  221. Function AddExtension(Const HStr,ext:String):String;
  222. Function ForceExtension(Const HStr,ext:String):String;
  223. Function FixPath(s:string;allowdot:boolean):string;
  224. function FixFileName(const s:string):string;
  225. function TargetFixPath(s:string;allowdot:boolean):string;
  226. function TargetFixFileName(const s:string):string;
  227. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  228. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  229. function FindExe(const bin:string;var foundfile:string):boolean;
  230. function GetShortName(const n:string):string;
  231. Procedure Shell(const command:string);
  232. function GetEnvPChar(const envname:string):pchar;
  233. procedure FreeEnvPChar(p:pchar);
  234. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  235. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  236. procedure InitGlobals;
  237. procedure DoneGlobals;
  238. function string2guid(const s: string; var GUID: TGUID): boolean;
  239. function guid2string(const GUID: TGUID): string;
  240. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  241. implementation
  242. uses
  243. comphook;
  244. procedure abstract;
  245. begin
  246. do_internalerror(255);
  247. end;
  248. function bstoslash(const s : string) : string;
  249. {
  250. return string s with all \ changed into /
  251. }
  252. var
  253. i : longint;
  254. begin
  255. for i:=1to length(s) do
  256. if s[i]='\' then
  257. bstoslash[i]:='/'
  258. else
  259. bstoslash[i]:=s[i];
  260. bstoslash[0]:=s[0];
  261. end;
  262. {****************************************************************************
  263. Time Handling
  264. ****************************************************************************}
  265. Function L0(l:longint):string;
  266. {
  267. return the string of value l, if l<10 then insert a zero, so
  268. the string is always at least 2 chars '01','02',etc
  269. }
  270. var
  271. s : string;
  272. begin
  273. Str(l,s);
  274. if l<10 then
  275. s:='0'+s;
  276. L0:=s;
  277. end;
  278. function gettimestr:string;
  279. {
  280. get the current time in a string HH:MM:SS
  281. }
  282. var
  283. hour,min,sec,hsec : word;
  284. begin
  285. {$ifdef delphi}
  286. dmisc.gettime(hour,min,sec,hsec);
  287. {$else delphi}
  288. dos.gettime(hour,min,sec,hsec);
  289. {$endif delphi}
  290. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  291. end;
  292. function getdatestr:string;
  293. {
  294. get the current date in a string YY/MM/DD
  295. }
  296. var
  297. Year,Month,Day,Wday : Word;
  298. begin
  299. {$ifdef delphi}
  300. dmisc.getdate(year,month,day,wday);
  301. {$else}
  302. dos.getdate(year,month,day,wday);
  303. {$endif}
  304. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  305. end;
  306. function filetimestring( t : longint) : string;
  307. {
  308. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  309. }
  310. var
  311. DT : DateTime;
  312. begin
  313. if t=-1 then
  314. begin
  315. FileTimeString:='Not Found';
  316. exit;
  317. end;
  318. unpacktime(t,DT);
  319. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  320. end;
  321. {****************************************************************************
  322. Default Macro Handling
  323. ****************************************************************************}
  324. procedure DefaultReplacements(var s:string);
  325. begin
  326. { Replace some macro's }
  327. Replace(s,'$FPCVER',version_string);
  328. Replace(s,'$VERSION',version_string);
  329. Replace(s,'$FULLVERSION',full_version_string);
  330. Replace(s,'$FPCDATE',date_string);
  331. Replace(s,'$FPCTARGET',target_cpu_string);
  332. Replace(s,'$FPCCPU',target_cpu_string);
  333. Replace(s,'$TARGET',target_path);
  334. Replace(s,'$FPCOS',target_path);
  335. end;
  336. {****************************************************************************
  337. File Handling
  338. ****************************************************************************}
  339. function GetCurrentDir:string;
  340. var
  341. CurrentDir : string;
  342. begin
  343. GetDir(0,CurrentDir);
  344. GetCurrentDir:=FixPath(CurrentDir,false);
  345. end;
  346. function path_absolute(const s : string) : boolean;
  347. {
  348. is path s an absolute path?
  349. }
  350. begin
  351. path_absolute:=false;
  352. {$ifdef unix}
  353. if (length(s)>0) and (s[1]='/') then
  354. path_absolute:=true;
  355. {$else unix}
  356. {$ifdef amiga}
  357. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  358. path_absolute:=true;
  359. {$else}
  360. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  361. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  362. path_absolute:=true;
  363. {$endif amiga}
  364. {$endif unix}
  365. end;
  366. {$ifndef FPC}
  367. Procedure FindClose(var Info : SearchRec);
  368. Begin
  369. End;
  370. {$endif not FPC}
  371. Function FileExists ( Const F : String) : Boolean;
  372. {$ifndef delphi}
  373. Var
  374. Info : SearchRec;
  375. {$endif}
  376. begin
  377. {$ifdef delphi}
  378. FileExists:=sysutils.FileExists(f);
  379. {$else}
  380. findfirst(F,readonly+archive+hidden,info);
  381. FileExists:=(doserror=0);
  382. findclose(Info);
  383. {$endif delphi}
  384. end;
  385. Function PathExists ( F : String) : Boolean;
  386. Var
  387. Info : SearchRec;
  388. {$ifdef i386}
  389. disk : byte;
  390. {$endif i386}
  391. begin
  392. {$ifdef i386}
  393. if (Length(f)=3) and (F[2]=':') and (F[3] in ['/','\']) then
  394. begin
  395. if F[1] in ['A'..'Z'] then
  396. disk:=ord(F[1])-ord('A')+1
  397. else if F[1] in ['a'..'z'] then
  398. disk:=ord(F[1])-ord('a')+1
  399. else
  400. disk:=255;
  401. if disk=255 then
  402. PathExists:=false
  403. else
  404. PathExists:=(DiskSize(disk)<>-1);
  405. exit;
  406. end;
  407. {$endif i386}
  408. if F[Length(f)] in ['/','\'] then
  409. Delete(f,length(f),1);
  410. findfirst(F,readonly+archive+hidden+directory,info);
  411. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  412. findclose(Info);
  413. end;
  414. Function RemoveFile(const f:string):boolean;
  415. var
  416. g : file;
  417. begin
  418. assign(g,f);
  419. {$I-}
  420. erase(g);
  421. {$I+}
  422. RemoveFile:=(ioresult=0);
  423. end;
  424. Function RemoveDir(d:string):boolean;
  425. begin
  426. if d[length(d)]=source_info.DirSep then
  427. Delete(d,length(d),1);
  428. {$I-}
  429. rmdir(d);
  430. {$I+}
  431. RemoveDir:=(ioresult=0);
  432. end;
  433. Function SplitPath(const s:string):string;
  434. var
  435. i : longint;
  436. begin
  437. i:=Length(s);
  438. while (i>0) and not(s[i] in ['/','\']) do
  439. dec(i);
  440. SplitPath:=Copy(s,1,i);
  441. end;
  442. Function SplitFileName(const s:string):string;
  443. var
  444. p : dirstr;
  445. n : namestr;
  446. e : extstr;
  447. begin
  448. FSplit(s,p,n,e);
  449. SplitFileName:=n+e;
  450. end;
  451. Function SplitName(const s:string):string;
  452. var
  453. i,j : longint;
  454. begin
  455. i:=Length(s);
  456. j:=Length(s);
  457. while (i>0) and not(s[i] in ['/','\']) do
  458. dec(i);
  459. while (j>0) and (s[j]<>'.') do
  460. dec(j);
  461. if j<=i then
  462. j:=255;
  463. SplitName:=Copy(s,i+1,j-(i+1));
  464. end;
  465. Function SplitExtension(Const HStr:String):String;
  466. var
  467. j : longint;
  468. begin
  469. j:=length(Hstr);
  470. while (j>0) and (Hstr[j]<>'.') do
  471. begin
  472. if hstr[j]=source_info.DirSep then
  473. j:=0
  474. else
  475. dec(j);
  476. end;
  477. if j=0 then
  478. j:=254;
  479. SplitExtension:=Copy(Hstr,j,255);
  480. end;
  481. Function AddExtension(Const HStr,ext:String):String;
  482. begin
  483. if (Ext<>'') and (SplitExtension(HStr)='') then
  484. AddExtension:=Hstr+Ext
  485. else
  486. AddExtension:=Hstr;
  487. end;
  488. Function ForceExtension(Const HStr,ext:String):String;
  489. var
  490. j : longint;
  491. begin
  492. j:=length(Hstr);
  493. while (j>0) and (Hstr[j]<>'.') do
  494. dec(j);
  495. if j=0 then
  496. j:=255;
  497. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  498. end;
  499. Function FixPath(s:string;allowdot:boolean):string;
  500. var
  501. i : longint;
  502. begin
  503. { Fix separator }
  504. for i:=1 to length(s) do
  505. if s[i] in ['/','\'] then
  506. s[i]:=source_info.DirSep;
  507. { Fix ending / }
  508. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  509. (s[length(s)]<>':') then
  510. s:=s+source_info.DirSep;
  511. { Remove ./ }
  512. if (not allowdot) and (s='.'+source_info.DirSep) then
  513. s:='';
  514. { return }
  515. if source_info.files_case_relevent then
  516. FixPath:=s
  517. else
  518. FixPath:=Lower(s);
  519. end;
  520. function FixFileName(const s:string):string;
  521. var
  522. i : longint;
  523. begin
  524. if source_info.files_case_relevent then
  525. begin
  526. for i:=1 to length(s) do
  527. begin
  528. case s[i] of
  529. '/','\' :
  530. FixFileName[i]:=source_info.dirsep;
  531. else
  532. FixFileName[i]:=s[i];
  533. end;
  534. end;
  535. end
  536. else
  537. begin
  538. for i:=1 to length(s) do
  539. begin
  540. case s[i] of
  541. '/','\' :
  542. FixFileName[i]:=source_info.dirsep;
  543. 'A'..'Z' :
  544. FixFileName[i]:=char(byte(s[i])+32);
  545. else
  546. FixFileName[i]:=s[i];
  547. end;
  548. end;
  549. end;
  550. FixFileName[0]:=s[0];
  551. end;
  552. Function TargetFixPath(s:string;allowdot:boolean):string;
  553. var
  554. i : longint;
  555. begin
  556. { Fix separator }
  557. for i:=1 to length(s) do
  558. if s[i] in ['/','\'] then
  559. s[i]:=target_info.DirSep;
  560. { Fix ending / }
  561. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  562. (s[length(s)]<>':') then
  563. s:=s+target_info.DirSep;
  564. { Remove ./ }
  565. if (not allowdot) and (s='.'+target_info.DirSep) then
  566. s:='';
  567. { return }
  568. if target_info.files_case_relevent then
  569. TargetFixPath:=s
  570. else
  571. TargetFixPath:=Lower(s);
  572. end;
  573. function TargetFixFileName(const s:string):string;
  574. var
  575. i : longint;
  576. begin
  577. if target_info.files_case_relevent then
  578. begin
  579. for i:=1 to length(s) do
  580. begin
  581. case s[i] of
  582. '/','\' :
  583. TargetFixFileName[i]:=target_info.dirsep;
  584. else
  585. TargetFixFileName[i]:=s[i];
  586. end;
  587. end;
  588. end
  589. else
  590. begin
  591. for i:=1 to length(s) do
  592. begin
  593. case s[i] of
  594. '/','\' :
  595. TargetFixFileName[i]:=target_info.dirsep;
  596. 'A'..'Z' :
  597. TargetFixFileName[i]:=char(byte(s[i])+32);
  598. else
  599. TargetFixFileName[i]:=s[i];
  600. end;
  601. end;
  602. end;
  603. TargetFixFileName[0]:=s[0];
  604. end;
  605. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  606. var
  607. i : longint;
  608. begin
  609. i:=pos(' ',s);
  610. if i>0 then
  611. begin
  612. bstr:=Copy(s,1,i-1);
  613. cstr:=Copy(s,i+1,length(s)-i);
  614. end
  615. else
  616. begin
  617. bstr:=s;
  618. cstr:='';
  619. end;
  620. end;
  621. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  622. var
  623. j : longint;
  624. hs,hsd,
  625. CurrentDir,
  626. CurrPath : string;
  627. dir : searchrec;
  628. hp : TStringListItem;
  629. procedure addcurrpath;
  630. begin
  631. if addfirst then
  632. begin
  633. Remove(currPath);
  634. Insert(currPath);
  635. end
  636. else
  637. begin
  638. { Check if already in path, then we don't add it }
  639. hp:=Find(currPath);
  640. if not assigned(hp) then
  641. Concat(currPath);
  642. end;
  643. end;
  644. begin
  645. if s='' then
  646. exit;
  647. { Support default macro's }
  648. DefaultReplacements(s);
  649. { get current dir }
  650. CurrentDir:=GetCurrentDir;
  651. repeat
  652. { get currpath }
  653. if addfirst then
  654. begin
  655. j:=length(s);
  656. while (j>0) and (s[j]<>';') do
  657. dec(j);
  658. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  659. if j=0 then
  660. s:=''
  661. else
  662. System.Delete(s,j,length(s)-j+1);
  663. end
  664. else
  665. begin
  666. j:=Pos(';',s);
  667. if j=0 then
  668. j:=255;
  669. CurrPath:=FixPath(Copy(s,1,j-1),false);
  670. System.Delete(s,1,j);
  671. end;
  672. { fix pathname }
  673. if CurrPath='' then
  674. CurrPath:='.'+source_info.DirSep
  675. else
  676. begin
  677. CurrPath:=FixPath(FExpand(CurrPath),false);
  678. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  679. CurrPath:='.'+source_info.DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  680. end;
  681. { wildcard adding ? }
  682. if pos('*',currpath)>0 then
  683. begin
  684. if currpath[length(currpath)]=source_info.dirsep then
  685. hs:=Copy(currpath,1,length(CurrPath)-1)
  686. else
  687. hs:=currpath;
  688. hsd:=SplitPath(hs);
  689. findfirst(hs,directory,dir);
  690. while doserror=0 do
  691. begin
  692. if (dir.name<>'.') and
  693. (dir.name<>'..') and
  694. ((dir.attr and directory)<>0) then
  695. begin
  696. currpath:=hsd+dir.name+source_info.dirsep;
  697. hp:=Find(currPath);
  698. if not assigned(hp) then
  699. AddCurrPath;
  700. end;
  701. findnext(dir);
  702. end;
  703. FindClose(dir);
  704. end
  705. else
  706. begin
  707. if PathExists(currpath) then
  708. addcurrpath;
  709. end;
  710. until (s='');
  711. end;
  712. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  713. var
  714. s : string;
  715. hl : TSearchPathList;
  716. hp,hp2 : TStringListItem;
  717. begin
  718. if list.empty then
  719. exit;
  720. { create temp and reverse the list }
  721. if addfirst then
  722. begin
  723. hl:=TSearchPathList.Create;
  724. hp:=TStringListItem(list.first);
  725. while assigned(hp) do
  726. begin
  727. hl.insert(hp.Str);
  728. hp:=TStringListItem(hp.next);
  729. end;
  730. while not hl.empty do
  731. begin
  732. s:=hl.GetFirst;
  733. Remove(s);
  734. Insert(s);
  735. end;
  736. hl.Free;
  737. end
  738. else
  739. begin
  740. hp:=TStringListItem(list.first);
  741. while assigned(hp) do
  742. begin
  743. hp2:=Find(hp.Str);
  744. { Check if already in path, then we don't add it }
  745. if not assigned(hp2) then
  746. Concat(hp.Str);
  747. hp:=TStringListItem(hp.next);
  748. end;
  749. end;
  750. end;
  751. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  752. Var
  753. p : TStringListItem;
  754. begin
  755. FindFile:=false;
  756. p:=TStringListItem(first);
  757. while assigned(p) do
  758. begin
  759. {
  760. Search order for case sensitive systems:
  761. 1. lowercase
  762. 2. NormalCase
  763. 3. UPPERCASE
  764. None case sensitive only lowercase
  765. }
  766. FoundFile:=p.Str+Lower(f);
  767. If FileExists(FoundFile) then
  768. begin
  769. FindFile:=true;
  770. exit;
  771. end;
  772. {$ifdef UNIX}
  773. FoundFile:=p.Str+f;
  774. If FileExists(FoundFile) then
  775. begin
  776. FindFile:=true;
  777. exit;
  778. end;
  779. FoundFile:=p.Str+Upper(f);
  780. If FileExists(FoundFile) then
  781. begin
  782. FindFile:=true;
  783. exit;
  784. end;
  785. {$endif UNIX}
  786. p:=TStringListItem(p.next);
  787. end;
  788. { Return original filename if not found }
  789. FoundFile:=f;
  790. end;
  791. Function GetFileTime ( Var F : File) : Longint;
  792. Var
  793. {$ifdef unix}
  794. Info : Stat;
  795. {$endif}
  796. L : longint;
  797. begin
  798. {$ifdef unix}
  799. FStat (F,Info);
  800. L:=Info.Mtime;
  801. {$else}
  802. GetFTime(f,l);
  803. {$endif}
  804. GetFileTime:=L;
  805. end;
  806. Function GetNamedFileTime (Const F : String) : Longint;
  807. begin
  808. GetNamedFileTime:=do_getnamedfiletime(F);
  809. end;
  810. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  811. Var
  812. singlepathstring : string;
  813. i : longint;
  814. begin
  815. {$ifdef Unix}
  816. for i:=1 to length(path) do
  817. if path[i]=':' then
  818. path[i]:=';';
  819. {$endif Unix}
  820. FindFile:=false;
  821. repeat
  822. i:=pos(';',path);
  823. if i=0 then
  824. i:=256;
  825. singlepathstring:=FixPath(copy(path,1,i-1),false);
  826. delete(path,1,i);
  827. {
  828. Search order for case sensitive systems:
  829. 1. lowercase
  830. 2. NormalCase
  831. 3. UPPERCASE
  832. None case sensitive only lowercase
  833. }
  834. FoundFile:=singlepathstring+Lower(f);
  835. If FileExists(FoundFile) then
  836. begin
  837. FindFile:=true;
  838. exit;
  839. end;
  840. {$ifdef UNIX}
  841. FoundFile:=singlepathstring+f;
  842. If FileExists(FoundFile) then
  843. begin
  844. FindFile:=true;
  845. exit;
  846. end;
  847. FoundFile:=singlepathstring+Upper(f);
  848. If FileExists(FoundFile) then
  849. begin
  850. FindFile:=true;
  851. exit;
  852. end;
  853. {$endif UNIX}
  854. until path='';
  855. FoundFile:=f;
  856. end;
  857. function FindExe(const bin:string;var foundfile:string):boolean;
  858. begin
  859. {$ifdef delphi}
  860. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
  861. {$else delphi}
  862. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
  863. {$endif delphi}
  864. end;
  865. function GetShortName(const n:string):string;
  866. {$ifdef win32}
  867. var
  868. hs,hs2 : string;
  869. i : longint;
  870. {$endif}
  871. {$ifdef go32v2}
  872. var
  873. hs : string;
  874. {$endif}
  875. begin
  876. GetShortName:=n;
  877. {$ifdef win32}
  878. hs:=n+#0;
  879. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  880. if (i>0) and (i<=high(hs2)) then
  881. begin
  882. hs2[0]:=chr(strlen(@hs2[1]));
  883. GetShortName:=hs2;
  884. end;
  885. {$endif}
  886. {$ifdef go32v2}
  887. hs:=n;
  888. if Dos.GetShortName(hs) then
  889. GetShortName:=hs;
  890. {$endif}
  891. end;
  892. {****************************************************************************
  893. OS Dependent things
  894. ****************************************************************************}
  895. function GetEnvPChar(const envname:string):pchar;
  896. {$ifdef win32}
  897. var
  898. s : string;
  899. i,len : longint;
  900. hp,p,p2 : pchar;
  901. {$endif}
  902. {$ifdef os2}
  903. var
  904. P1, P2: PChar;
  905. {$endif}
  906. begin
  907. {$ifdef unix}
  908. GetEnvPchar:={$ifdef ver1_0}Linux{$else}Unix{$endif}.Getenv(envname);
  909. {$define GETENVOK}
  910. {$endif}
  911. {$ifdef win32}
  912. GetEnvPchar:=nil;
  913. p:=GetEnvironmentStrings;
  914. hp:=p;
  915. while hp^<>#0 do
  916. begin
  917. s:=strpas(hp);
  918. i:=pos('=',s);
  919. len:=strlen(hp);
  920. if upper(copy(s,1,i-1))=upper(envname) then
  921. begin
  922. GetMem(p2,len-length(envname));
  923. Move(hp[i],p2^,len-length(envname));
  924. GetEnvPchar:=p2;
  925. break;
  926. end;
  927. { next string entry}
  928. hp:=hp+len+1;
  929. end;
  930. FreeEnvironmentStrings(p);
  931. {$define GETENVOK}
  932. {$endif}
  933. {$ifdef os2}
  934. P1 := StrPNew (EnvName);
  935. if Assigned (P1) then
  936. begin
  937. if DosCalls.DosScanEnv (P1, P2) = 0 then
  938. GetEnvPChar := P2
  939. else
  940. GetEnvPChar := nil;
  941. StrDispose (P1);
  942. end else GetEnvPChar := nil;
  943. {$define GETENVOK}
  944. {$endif}
  945. {$ifdef GETENVOK}
  946. {$undef GETENVOK}
  947. {$else}
  948. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  949. {$endif}
  950. end;
  951. procedure FreeEnvPChar(p:pchar);
  952. begin
  953. {$ifndef unix}
  954. {$ifndef os2}
  955. StrDispose(p);
  956. {$endif}
  957. {$endif}
  958. end;
  959. Procedure Shell(const command:string);
  960. { This is already defined in the linux.ppu for linux, need for the *
  961. expansion under linux }
  962. {$ifdef unix}
  963. begin
  964. {$ifdef ver1_0}Linux{$else}Unix{$endif}.Shell(command);
  965. end;
  966. {$else}
  967. var
  968. comspec : string;
  969. begin
  970. comspec:=getenv('COMSPEC');
  971. Exec(comspec,' /C '+command);
  972. end;
  973. {$endif}
  974. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  975. var
  976. b : boolean;
  977. begin
  978. b:=true;
  979. if s='DEFAULT' then
  980. aktmodeswitches:=initmodeswitches
  981. else
  982. if s='DELPHI' then
  983. aktmodeswitches:=delphimodeswitches
  984. else
  985. if s='TP' then
  986. aktmodeswitches:=tpmodeswitches
  987. else
  988. if s='FPC' then
  989. aktmodeswitches:=fpcmodeswitches
  990. else
  991. if s='OBJFPC' then
  992. aktmodeswitches:=objfpcmodeswitches
  993. else
  994. if s='GPC' then
  995. aktmodeswitches:=gpcmodeswitches
  996. else
  997. b:=false;
  998. if b and changeInit then
  999. initmodeswitches := aktmodeswitches;
  1000. if b then
  1001. begin
  1002. { turn ansistrings on by default ? }
  1003. if (m_delphi in aktmodeswitches) then
  1004. begin
  1005. include(aktlocalswitches,cs_ansistrings);
  1006. if changeinit then
  1007. include(initlocalswitches,cs_ansistrings);
  1008. end
  1009. else
  1010. begin
  1011. exclude(aktlocalswitches,cs_ansistrings);
  1012. if changeinit then
  1013. exclude(initlocalswitches,cs_ansistrings);
  1014. end;
  1015. { enum packing }
  1016. if (m_tp7 in aktmodeswitches) then
  1017. aktpackenum:=1
  1018. else
  1019. aktpackenum:=4;
  1020. if changeinit then
  1021. initpackenum:=aktpackenum;
  1022. end;
  1023. SetCompileMode:=b;
  1024. end;
  1025. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1026. const
  1027. DefProcCallName : array[tproccalloption] of string[12] = ('',
  1028. 'CDECL',
  1029. 'CPPDECL',
  1030. '', { compilerproc }
  1031. 'FAR16',
  1032. 'FPCCALL',
  1033. 'INLINE',
  1034. '', { internconst }
  1035. '', { internproc }
  1036. '', { palmossyscall }
  1037. 'PASCAL',
  1038. 'REGISTER',
  1039. 'SAFECALL',
  1040. 'STDCALL',
  1041. 'SYSTEM'
  1042. );
  1043. var
  1044. t : tproccalloption;
  1045. begin
  1046. SetAktProcCall:=false;
  1047. for t:=low(tproccalloption) to high(tproccalloption) do
  1048. if DefProcCallName[t]=s then
  1049. begin
  1050. AktDefProcCall:=t;
  1051. SetAktProcCall:=true;
  1052. break;
  1053. end;
  1054. if changeinit then
  1055. InitDefProcCall:=AktDefProcCall;
  1056. end;
  1057. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1058. function string2guid(const s: string; var GUID: TGUID): boolean;
  1059. function ishexstr(const hs: string): boolean;
  1060. var
  1061. i: integer;
  1062. begin
  1063. ishexstr:=false;
  1064. for i:=1 to Length(hs) do begin
  1065. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1066. exit;
  1067. end;
  1068. ishexstr:=true;
  1069. end;
  1070. function hexstr2longint(const hexs: string): longint;
  1071. var
  1072. i: integer;
  1073. rl: longint;
  1074. begin
  1075. rl:=0;
  1076. for i:=1 to length(hexs) do begin
  1077. rl:=rl shl 4;
  1078. case hexs[i] of
  1079. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1080. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1081. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1082. end
  1083. end;
  1084. hexstr2longint:=rl;
  1085. end;
  1086. var
  1087. i: integer;
  1088. begin
  1089. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1090. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1091. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1092. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1093. ishexstr(copy(s,26,12)) then begin
  1094. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1095. GUID.D2:=hexstr2longint(copy(s,11,4));
  1096. GUID.D3:=hexstr2longint(copy(s,16,4));
  1097. for i:=0 to 1 do
  1098. GUID.D4[i]:=hexstr2longint(copy(s,21+i*2,2));
  1099. for i:=2 to 7 do
  1100. GUID.D4[i]:=hexstr2longint(copy(s,22+i*2,2));
  1101. string2guid:=true;
  1102. end
  1103. else
  1104. string2guid:=false;
  1105. end;
  1106. function guid2string(const GUID: TGUID): string;
  1107. function long2hex(l, len: longint): string;
  1108. const
  1109. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1110. var
  1111. rs: string;
  1112. i: integer;
  1113. begin
  1114. rs[0]:=chr(len);
  1115. for i:=len downto 1 do begin
  1116. rs[i]:=hextbl[l and $F];
  1117. l:=l shr 4;
  1118. end;
  1119. long2hex:=rs;
  1120. end;
  1121. begin
  1122. guid2string:=
  1123. '{'+long2hex(GUID.D1,8)+
  1124. '-'+long2hex(GUID.D2,4)+
  1125. '-'+long2hex(GUID.D3,4)+
  1126. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1127. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1128. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1129. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1130. '}';
  1131. end;
  1132. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1133. var
  1134. tok : string;
  1135. vstr : string;
  1136. l : longint;
  1137. code : integer;
  1138. b : talignmentinfo;
  1139. begin
  1140. UpdateAlignmentStr:=true;
  1141. uppervar(s);
  1142. fillchar(b,sizeof(b),0);
  1143. repeat
  1144. tok:=GetToken(s,'=');
  1145. if tok='' then
  1146. break;
  1147. vstr:=GetToken(s,',');
  1148. val(vstr,l,code);
  1149. if tok='PROC' then
  1150. b.procalign:=l
  1151. else if tok='JUMP' then
  1152. b.jumpalign:=l
  1153. else if tok='LOOP' then
  1154. b.loopalign:=l
  1155. else if tok='CONSTMIN' then
  1156. b.constalignmin:=l
  1157. else if tok='CONSTMAX' then
  1158. b.constalignmax:=l
  1159. else if tok='VARMIN' then
  1160. b.varalignmin:=l
  1161. else if tok='VARMAX' then
  1162. b.varalignmax:=l
  1163. else if tok='LOCALMIN' then
  1164. b.localalignmin:=l
  1165. else if tok='LOCALMAX' then
  1166. b.localalignmax:=l
  1167. else if tok='RECORDMIN' then
  1168. b.recordalignmin:=l
  1169. else if tok='RECORDMAX' then
  1170. b.recordalignmax:=l
  1171. else if tok='PARAALIGN' then
  1172. b.paraalign:=l
  1173. else { Error }
  1174. UpdateAlignmentStr:=false;
  1175. until false;
  1176. UpdateAlignment(a,b);
  1177. end;
  1178. {****************************************************************************
  1179. Init
  1180. ****************************************************************************}
  1181. {$ifdef unix}
  1182. {$define need_path_search}
  1183. {$endif unix}
  1184. {$ifdef os2}
  1185. {$define need_path_search}
  1186. {$endif os2}
  1187. procedure get_exepath;
  1188. var
  1189. hs1 : namestr;
  1190. hs2 : extstr;
  1191. begin
  1192. {$ifdef delphi}
  1193. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1194. {$else delphi}
  1195. exepath:=dos.getenv('PPC_EXEC_PATH');
  1196. {$endif delphi}
  1197. if exepath='' then
  1198. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1199. {$ifdef need_path_search}
  1200. if exepath='' then
  1201. begin
  1202. if pos(source_info.exeext,hs1) <>
  1203. (length(hs1) - length(source_info.exeext)+1) then
  1204. hs1 := hs1 + source_info.exeext;
  1205. {$ifdef delphi}
  1206. findfile(hs1,dmisc.getenv('PATH'),exepath);
  1207. {$else delphi}
  1208. findfile(hs1,dos.getenv('PATH'),exepath);
  1209. {$endif delphi}
  1210. exepath:=SplitPath(exepath);
  1211. end;
  1212. {$endif need_path_search}
  1213. exepath:=FixPath(exepath,false);
  1214. end;
  1215. procedure DoneGlobals;
  1216. begin
  1217. initdefines.free;
  1218. if assigned(DLLImageBase) then
  1219. StringDispose(DLLImageBase);
  1220. RelocSection:=true;
  1221. RelocSectionSetExplicitly:=false;
  1222. UseDeffileForExport:=true;
  1223. librarysearchpath.Free;
  1224. unitsearchpath.Free;
  1225. objectsearchpath.Free;
  1226. includesearchpath.Free;
  1227. end;
  1228. procedure InitGlobals;
  1229. begin
  1230. get_exepath;
  1231. { reset globals }
  1232. do_build:=false;
  1233. do_release:=false;
  1234. do_make:=true;
  1235. compile_level:=0;
  1236. DLLsource:=false;
  1237. inlining_procedure:=false;
  1238. resolving_forward:=false;
  1239. in_args:=false;
  1240. make_ref:=false;
  1241. { Output }
  1242. OutputFile:='';
  1243. OutputExeDir:='';
  1244. OutputUnitDir:='';
  1245. { Utils directory }
  1246. utilsdirectory:='';
  1247. { Search Paths }
  1248. librarysearchpath:=TSearchPathList.Create;
  1249. unitsearchpath:=TSearchPathList.Create;
  1250. includesearchpath:=TSearchPathList.Create;
  1251. objectsearchpath:=TSearchPathList.Create;
  1252. { Def file }
  1253. usewindowapi:=false;
  1254. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1255. dllversion:='';
  1256. nwscreenname := '';
  1257. nwthreadname := '';
  1258. nwcopyright := '';
  1259. { Init values }
  1260. initmodeswitches:=fpcmodeswitches;
  1261. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1262. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1263. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1264. initoutputformat:=target_asm.id;
  1265. fillchar(initalignment,sizeof(talignmentinfo),0);
  1266. {$ifdef i386}
  1267. initoptprocessor:=Class386;
  1268. initspecificoptprocessor:=Class386;
  1269. initpackenum:=4;
  1270. {$IFDEF testvarsets}
  1271. initsetalloc:=0;
  1272. {$ENDIF}
  1273. initasmmode:=asmmode_i386_att;
  1274. {$else not i386}
  1275. {$ifdef m68k}
  1276. initoptprocessor:=MC68000;
  1277. include(initmoduleswitches,cs_fp_emulation);
  1278. initpackenum:=4;
  1279. {$IFDEF testvarsets}
  1280. initsetalloc:=0;
  1281. {$ENDIF}
  1282. initasmmode:=asmmode_m68k_mot;
  1283. {$endif m68k}
  1284. {$endif i386}
  1285. initinterfacetype:=it_interfacecom;
  1286. initdefproccall:=pocall_none;
  1287. initdefines:=TStringList.Create;
  1288. { memory sizes, will be overriden by parameter or default for target
  1289. in options or init_parser }
  1290. stacksize:=0;
  1291. heapsize:=0;
  1292. { compile state }
  1293. in_args:=false;
  1294. { must_be_valid:=true; obsolete PM }
  1295. not_unit_proc:=true;
  1296. apptype:=app_cui;
  1297. have_local_threadvars := false;
  1298. end;
  1299. {$ifdef EXTDEBUG}
  1300. begin
  1301. {$ifdef FPC}
  1302. EntryMemUsed:=system.HeapSize-MemAvail;
  1303. {$endif FPC}
  1304. {$endif}
  1305. end.
  1306. {
  1307. $Log$
  1308. Revision 1.58 2002-05-18 13:34:08 peter
  1309. * readded missing revisions
  1310. Revision 1.57 2002/05/16 19:46:36 carl
  1311. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1312. + try to fix temp allocation (still in ifdef)
  1313. + generic constructor calls
  1314. + start of tassembler / tmodulebase class cleanup
  1315. Revision 1.55 2002/04/20 21:32:23 carl
  1316. + generic FPC_CHECKPOINTER
  1317. + first parameter offset in stack now portable
  1318. * rename some constants
  1319. + move some cpu stuff to other units
  1320. - remove unused constents
  1321. * fix stacksize for some targets
  1322. * fix generic size problems which depend now on EXTEND_SIZE constant
  1323. Revision 1.54 2002/04/07 13:24:30 carl
  1324. + moved constant from cpuinfo, these are NOT cpu specific
  1325. constant, but more related to compiler functionality.
  1326. Revision 1.53 2002/04/02 17:11:28 peter
  1327. * tlocation,treference update
  1328. * LOC_CONSTANT added for better constant handling
  1329. * secondadd splitted in multiple routines
  1330. * location_force_reg added for loading a location to a register
  1331. of a specified size
  1332. * secondassignment parses now first the right and then the left node
  1333. (this is compatible with Kylix). This saves a lot of push/pop especially
  1334. with string operations
  1335. * adapted some routines to use the new cg methods
  1336. Revision 1.52 2002/03/28 16:07:52 armin
  1337. + initialize threadvars defined local in units
  1338. Revision 1.51 2002/01/24 18:25:48 peter
  1339. * implicit result variable generation for assembler routines
  1340. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1341. }