globals.pas 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672
  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 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.57 2002-05-16 19:46:36 carl
  1309. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1310. + try to fix temp allocation (still in ifdef)
  1311. + generic constructor calls
  1312. + start of tassembler / tmodulebase class cleanup
  1313. Revision 1.55 2002/04/20 21:32:23 carl
  1314. + generic FPC_CHECKPOINTER
  1315. + first parameter offset in stack now portable
  1316. * rename some constants
  1317. + move some cpu stuff to other units
  1318. - remove unused constents
  1319. * fix stacksize for some targets
  1320. * fix generic size problems which depend now on EXTEND_SIZE constant
  1321. Revision 1.54 2002/04/07 13:24:30 carl
  1322. + moved constant from cpuinfo, these are NOT cpu specific
  1323. constant, but more related to compiler functionality.
  1324. Revision 1.53 2002/04/02 17:11:28 peter
  1325. * tlocation,treference update
  1326. * LOC_CONSTANT added for better constant handling
  1327. * secondadd splitted in multiple routines
  1328. * location_force_reg added for loading a location to a register
  1329. of a specified size
  1330. * secondassignment parses now first the right and then the left node
  1331. (this is compatible with Kylix). This saves a lot of push/pop especially
  1332. with string operations
  1333. * adapted some routines to use the new cg methods
  1334. Revision 1.52 2002/03/28 16:07:52 armin
  1335. + initialize threadvars defined local in units
  1336. Revision 1.51 2002/01/24 18:25:48 peter
  1337. * implicit result variable generation for assembler routines
  1338. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1339. Revision 1.50 2001/12/06 17:57:33 florian
  1340. + parasym to tparaitem added
  1341. Revision 1.49 2001/10/25 21:22:32 peter
  1342. * calling convention rewrite
  1343. Revision 1.48 2001/10/23 21:49:42 peter
  1344. * $calling directive and -Cc commandline patch added
  1345. from Pavel Ozerski
  1346. Revision 1.47 2001/10/21 12:33:05 peter
  1347. * array access for properties added
  1348. Revision 1.46 2001/10/20 20:30:20 peter
  1349. * read only typed const support, switch $J-
  1350. Revision 1.45 2001/10/16 15:10:34 jonas
  1351. * fixed goto/label/try bugs
  1352. Revision 1.44 2001/10/12 16:06:17 peter
  1353. * pathexists fix (merged)
  1354. Revision 1.43 2001/09/18 11:30:47 michael
  1355. * Fixes win32 linking problems with import libraries
  1356. * LINKLIB Libraries are now looked for using C file extensions
  1357. * get_exepath fix
  1358. Revision 1.42 2001/09/17 21:29:11 peter
  1359. * merged netbsd, fpu-overflow from fixes branch
  1360. Revision 1.41 2001/08/19 11:22:22 peter
  1361. * palmos support from v10 merged
  1362. Revision 1.40 2001/08/04 10:23:54 peter
  1363. * updates so it works with the ide
  1364. Revision 1.39 2001/07/01 20:16:15 peter
  1365. * alignmentinfo record added
  1366. * -Oa argument supports more alignment settings that can be specified
  1367. per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
  1368. RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
  1369. required alignment and the maximum usefull alignment. The final
  1370. alignment will be choosen per variable size dependent on these
  1371. settings
  1372. Revision 1.38 2001/06/18 20:36:24 peter
  1373. * -Ur switch (merged)
  1374. * masm fixes (merged)
  1375. * quoted filenames for go32v2 and win32
  1376. Revision 1.37 2001/06/03 21:57:35 peter
  1377. + hint directive parsing support
  1378. Revision 1.36 2001/06/03 20:21:08 peter
  1379. * Kylix fixes, mostly case names of units
  1380. Revision 1.35 2001/05/30 21:35:48 peter
  1381. * netware patches for copyright, screenname, threadname directives
  1382. Revision 1.34 2001/05/12 12:11:31 peter
  1383. * simplify_ppu is now the default, a recompile of the compiler now
  1384. only compiles pp.pas
  1385. Revision 1.33 2001/05/06 14:49:17 peter
  1386. * ppu object to class rewrite
  1387. * move ppu read and write stuff to fppu
  1388. Revision 1.32 2001/04/18 22:01:53 peter
  1389. * registration of targets and assemblers
  1390. Revision 1.31 2001/04/15 09:48:29 peter
  1391. * fixed crash in labelnode
  1392. * easier detection of goto and label in try blocks
  1393. Revision 1.30 2001/04/13 01:22:07 peter
  1394. * symtable change to classes
  1395. * range check generation and errors fixed, make cycle DEBUG=1 works
  1396. * memory leaks fixed
  1397. Revision 1.29 2001/04/04 21:30:42 florian
  1398. * applied several fixes to get the DD8 Delphi Unit compiled
  1399. e.g. "forward"-interfaces are working now
  1400. Revision 1.28 2001/02/20 21:41:16 peter
  1401. * new fixfilename, findfile for unix. Look first for lowercase, then
  1402. NormalCase and last for UPPERCASE names.
  1403. Revision 1.27 2001/02/09 23:05:45 peter
  1404. * default packenum=1 for tp7 mode
  1405. Revision 1.26 2001/02/05 20:47:00 peter
  1406. * support linux unit for ver1_0 compilers
  1407. Revision 1.25 2001/01/21 20:32:45 marco
  1408. * Renamefest. Compiler part. Not that hard.
  1409. Revision 1.24 2001/01/20 18:32:52 hajny
  1410. + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
  1411. Revision 1.23 2001/01/13 00:03:41 peter
  1412. * fixed findexe to also support already extension in name
  1413. Revision 1.22 2000/12/26 15:57:25 peter
  1414. * use system.paramstr()
  1415. Revision 1.21 2000/12/25 00:07:26 peter
  1416. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1417. tlinkedlist objects)
  1418. Revision 1.20 2000/11/13 15:26:12 marco
  1419. * Renamefest
  1420. Revision 1.19 2000/11/12 22:20:37 peter
  1421. * create generic toutputsection for binary writers
  1422. Revision 1.18 2000/11/04 14:25:19 florian
  1423. + merged Attila's changes for interfaces, not tested yet
  1424. Revision 1.17 2000/10/31 22:02:46 peter
  1425. * symtable splitted, no real code changes
  1426. Revision 1.16 2000/10/04 14:51:08 pierre
  1427. * IsExe restored
  1428. Revision 1.15 2000/09/27 21:20:56 peter
  1429. * also set initlocalswitches in setcompilemode (merged)
  1430. Revision 1.14 2000/09/26 10:50:41 jonas
  1431. * initmodeswitches is changed is you change the compiler mode from the
  1432. command line (the -S<x> switches didn't work anymore for changing the
  1433. compiler mode) (merged from fixes branch)
  1434. Revision 1.13 2000/09/24 21:33:46 peter
  1435. * message updates merges
  1436. Revision 1.12 2000/09/24 21:19:50 peter
  1437. * delphi compile fixes
  1438. Revision 1.11 2000/09/24 15:12:40 peter
  1439. * fixed typo
  1440. Revision 1.10 2000/09/24 15:06:16 peter
  1441. * use defines.inc
  1442. Revision 1.9 2000/09/24 10:33:07 peter
  1443. * searching of exe in path also for OS/2
  1444. * fixed searching of exe in path.
  1445. Revision 1.8 2000/09/11 17:00:22 florian
  1446. + first implementation of Netware Module support, thanks to
  1447. Armin Diehl ([email protected]) for providing the patches
  1448. Revision 1.7 2000/08/27 16:11:51 peter
  1449. * moved some util functions from globals,cobjects to cutils
  1450. * splitted files into finput,fmodule
  1451. Revision 1.6 2000/08/12 19:14:58 peter
  1452. * ELF writer works now also with -g
  1453. * ELF writer is default again for linux
  1454. Revision 1.5 2000/08/12 15:30:44 peter
  1455. * IDE patch for stream reading (merged)
  1456. Revision 1.4 2000/08/02 19:49:59 peter
  1457. * first things for default parameters
  1458. Revision 1.3 2000/07/13 12:08:25 michael
  1459. + patched to 1.1.0 with former 1.09patch from peter
  1460. Revision 1.2 2000/07/13 11:32:41 michael
  1461. + removed logs
  1462. }