3 Copyright (C) 1998-2000 by Florian Klaempfl
5 This unit implements some support functions and global variables
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ****************************************************************************
48 globtype
,version
,tokens
,systems
,cobjects
;
67 testsplit
: boolean = false;
70 delphimodeswitches
: tmodeswitches
=
71 [m_delphi
,m_tp
,m_all
,m_class
,m_objpas
,m_result
,m_string_pchar
,
72 m_pointer_2_procedure
,m_autoderef
,m_tp_procvar
,m_initfinal
,m_default_ansistring
];
73 fpcmodeswitches
: tmodeswitches
=
74 [m_fpc
,m_all
,m_string_pchar
,m_nested_comment
,m_repeat_forward
,
75 m_cvar_support
,m_initfinal
,m_add_pointer
];
76 objfpcmodeswitches
: tmodeswitches
=
77 [m_objfpc
,m_fpc
,m_all
,m_class
,m_objpas
,m_result
,m_string_pchar
,m_nested_comment
,
78 m_repeat_forward
,m_cvar_support
,m_initfinal
,m_add_pointer
];
79 tpmodeswitches
: tmodeswitches
=
80 [m_tp7
,m_tp
,m_all
,m_tp_procvar
];
81 gpcmodeswitches
: tmodeswitches
=
85 TSearchPathList
= object(TStringQueue
)
86 procedure AddPath(s
:string;addfirst
:boolean);
87 procedure AddList(list
:TSearchPathList
;addfirst
:boolean);
88 function FindFile(const f
: string;var b
: boolean) : string;
92 { specified inputfile }
95 inputextension
: extstr
;
96 { specified outputfile with -o parameter }
98 { specified with -FE or -FU }
99 outputexedir
: dirstr
;
100 outputunitdir
: dirstr
;
102 { things specified with parameters }
104 paradynamiclinker
: string;
105 parapreprocess
: boolean;
107 { directory where the utils can be found (options -FD) }
108 utilsdirectory
: dirstr
;
110 { some flags for global compiler switches }
113 not_unit_proc
: boolean;
114 { path for searching units, different paths can be seperated by ; }
115 exepath
: dirstr
; { Path to ppc }
119 includesearchpath
: TSearchPathList
;
122 usewindowapi
: boolean;
123 description
: string;
125 dllmajor
,dllminor
: word;
128 token
, { current token being parsed }
129 idtoken
: ttoken
; { holds the token if the pattern is a known word }
130 tokenpos
, { last postion of the read token }
131 aktfilepos
: tfileposinfo
; { current position }
133 { type of currently parsed block }
134 { isn't full implemented (FK) }
135 block_type
: tblock_type
;
137 in_args
: boolean; { arguments must be checked especially }
138 parsing_para_level
: longint; { parameter level, used to convert
139 proc calls to proc loads in firstcalln }
140 { Must_be_valid : boolean; should the variable already have a value
141 obsolete replace by set_varstate function }
142 compile_level
: word;
144 resolving_forward
: boolean; { used to add forward reference as second ref }
145 use_esp_stackframe
: boolean; { to test for call with ESP as stack frame }
146 inlining_procedure
: boolean; { are we inlining a procedure }
152 { commandline values }
153 initdefines
: tlinkedlist
;
154 initglobalswitches
: tglobalswitches
;
155 initmoduleswitches
: tmoduleswitches
;
156 initlocalswitches
: tlocalswitches
;
157 initmodeswitches
: tmodeswitches
;
159 Initsetalloc
, {0=fixed, 1 =var}
161 initpackenum
: longint;
162 initpackrecords
: tpackrecords
;
163 initoutputformat
: tasm
;
165 initspecificoptprocessor
: tprocessors
;
166 initasmmode
: tasmmode
;
167 { current state values }
168 aktglobalswitches
: tglobalswitches
;
169 aktmoduleswitches
: tmoduleswitches
;
170 aktlocalswitches
: tlocalswitches
;
171 nextaktlocalswitches
: tlocalswitches
;
172 localswitcheschanged
: boolean;
173 aktmodeswitches
: tmodeswitches
;
177 aktpackenum
: longint;
178 aktmaxfpuregisters
: longint;
179 aktpackrecords
: tpackrecords
;
180 aktoutputformat
: tasm
;
182 aktspecificoptprocessor
: tprocessors
;
183 aktasmmode
: tasmmode
;
192 firstpass_several
: longint;
194 EntryMemUsed
: longint;
196 { parameter switches }
198 only_one_pass
: boolean;
200 { windows application type }
204 RelocSection
: boolean = true;
205 RelocSectionSetExplicitly
: boolean = false;
206 LinkTypeSetExplicitly
: boolean = false;
207 DLLsource
: boolean = false;
208 DLLImageBase
: pstring
= nil;
209 UseDeffileForExport
: boolean = true;
210 ForceDeffileForExport
: boolean = false;
212 { used to set all registers used for each global function
213 this should dramatically decrease the number of
214 recompilations needed PM }
215 simplify_ppu
: boolean = false;
217 { should we allow non static members ? }
218 allow_only_static
: boolean = false;
220 Inside_asm_statement
: boolean = false;
222 { for error info in pp.pas }
224 parser_current_file
: string = '';
227 { if the pointer don't point to the heap then write an error }
228 function assigned(p
: pointer) : boolean;
230 function min(a
,b
: longint) : longint;
231 function max(a
,b
: longint) : longint;
232 function align(i
,a
:longint):longint;
233 function align_from_size(datasize
:longint;length
:longint):longint;
234 procedure Replace(var s
:string;s1
:string;const s2
:string);
235 procedure ReplaceCase(var s
:string;const s1
,s2
:string);
236 function upper(const s
: string) : string;
237 function lower(const s
: string) : string;
238 function trimspace(const s
:string):string;
240 function tostru(i
:cardinal) : string;
242 function tostru(i
:longint) : string;
244 procedure uppervar(var s
: string);
245 function hexstr(val
: longint;cnt
: byte) : string;
246 function tostr(i
: longint) : string;
247 function tostr_with_plus(i
: longint) : string;
248 procedure valint(S
: string;var V
: longint;var code
: integer);
249 function is_number(const s
: string) : boolean;
250 function ispowerof2(value
: longint;var power
: longint) : boolean;
251 { enable ansistring comparison }
252 function compareansistrings(p1
,p2
: pchar
;length1
,length2
: longint) : longint;
253 function concatansistrings(p1
,p2
: pchar
;length1
,length2
: longint) : pchar
;
254 function bstoslash(const s
: string) : string;
257 function getdatestr
:string;
258 function gettimestr
:string;
259 function filetimestring( t
: longint) : string;
261 procedure DefaultReplacements(var s
:string);
262 function GetCurrentDir
:string;
263 function path_absolute(const s
: string) : boolean;
264 Function PathExists ( F
: String) : Boolean;
265 Function FileExists ( Const F
: String) : Boolean;
266 Function RemoveFile(const f
:string):boolean;
267 Function RemoveDir(d
:string):boolean;
268 Function GetFileTime ( Var F
: File) : Longint;
269 Function GetNamedFileTime ( Const F
: String) : Longint;
270 Function SplitPath(const s
:string):string;
271 Function SplitFileName(const s
:string):string;
272 Function SplitName(const s
:string):string;
273 Function SplitExtension(Const HStr
:String):String;
274 Function AddExtension(Const HStr
,ext
:String):String;
275 Function ForceExtension(Const HStr
,ext
:String):String;
276 Function FixPath(s
:string;allowdot
:boolean):string;
277 function FixFileName(const s
:string):string;
278 procedure SplitBinCmd(const s
:string;var bstr
,cstr
:string);
279 procedure SynchronizeFileTime(const fn1
,fn2
:string);
280 function FindFile(const f
: string;path
: string;var b
: boolean) : string;
281 function FindExe(bin
:string;var found
:boolean):string;
282 function GetShortName(const n
:string):string;
284 Procedure Shell(const command
:string);
285 function GetEnvPChar(const envname
:string):pchar
;
286 procedure FreeEnvPChar(p
:pchar
);
288 Function SetCompileMode(const s
:string; changeInit
: boolean):boolean;
290 procedure InitGlobals
;
291 procedure DoneGlobals
;
301 do_internalerror(255);
305 function ngraphsearchvalue(const s1
,s2
: string) : double;
309 equals
,i
,j
: longint;
313 { is the string long enough ? }
314 if min(length(s1
),length(s2
))-n
+1<1 then
316 ngraphsearchvalue
:=0.0;
319 for i
:=1 to length(s1
)-n
+1 do
322 for j
:=1 to length(s2
)-n
+1 do
323 if hs
=copy(s2
,j
,n
) then
327 ngraphsearchvalue
:=equals
/double(max(length(s1
),length(s2
))-n
+1);
329 ngraphsearchvalue
:=equals
/(max(length(s1
),length(s2
))-n
+1);
334 function bstoslash(const s
: string) : string;
336 return string s with all \ changed into /
341 for i
:=1to length(s
) do
348 setlength(bstoslash
,length(s
));
359 function assigned(p
: pointer) : boolean;
372 { Assigned is used for procvar and
373 stack stored temp records !! PM }
377 do_internalerror(230); *)
386 lp
:=longint(ptrrec(p
).seg
)*16+longint(ptrrec(p
).ofs
);
388 ((lp
<longint(seg(heaporg
^))*16+longint(ofs(heaporg
^))) or
389 (lp
>longint(seg(heapptr
^))*16+longint(ofs(heapptr
^)))) then
390 do_internalerror(230);
398 function min(a
,b
: longint) : longint;
400 return the minimal of a and b
410 function max(a
,b
: longint) : longint;
412 return the maximum of a and b
421 function align_from_size(datasize
:longint;length
:longint):longint;
423 {Increases the datasize with the required alignment; i.e. on pentium
424 words should be aligned word; and dwords should be aligned dword.
425 So for a word (len=2), datasize is increased to the nearest multiple
426 of 2, and for len=4, datasize is increased to the nearest multiple of
435 else if length
>1 then
443 align_from_size
:=(datasize
+data_align
-1) and not(data_align
-1);
447 function align(i
,a
:longint):longint;
449 return value <i> aligned <a> boundary
452 align
:=(i
+a
-1) and not(a
-1);
456 procedure Replace(var s
:string;s1
:string;const s2
:string);
469 Delete(s
,i
,length(s1
));
477 procedure ReplaceCase(var s
:string;const s1
,s2
:string);
489 Delete(s
,i
,length(s1
));
497 function upper(const s
: string) : string;
499 return uppercased string of s
504 for i
:=1 to length(s
) do
505 if s
[i
] in ['a'..'z'] then
506 upper
[i
]:=char(byte(s
[i
])-32)
513 function lower(const s
: string) : string;
515 return lowercased string of s
520 for i
:=1 to length(s
) do
521 if s
[i
] in ['A'..'Z'] then
522 lower
[i
]:=char(byte(s
[i
])+32)
529 procedure uppervar(var s
: string);
536 for i
:=1 to length(s
) do
537 if s
[i
] in ['a'..'z'] then
538 s
[i
]:=char(byte(s
[i
])-32);
541 function hexstr(val
: longint;cnt
: byte) : string;
543 HexTbl
: array[0..15] of char='0123456789ABCDEF';
547 hexstr
[0]:=char(cnt
);
548 for i
:=cnt
downto 1 do
550 hexstr
[i
]:=hextbl
[val
and $f];
556 function tostru(i
:cardinal):string;
558 return string of value i, but for cardinals
567 function tostru(i
:longint):string;
574 function trimspace(const s
:string):string;
576 return s with all leading and ending spaces and tabs removed
582 while (i
>0) and (s
[i
] in [#9,' ']) do
585 while (j
<i
) and (s
[j
] in [#9,' ']) do
587 trimspace
:=Copy(s
,j
,i
-j
+1);
591 function tostr(i
: longint) : string;
593 return string of value i
603 function tostr_with_plus(i
: longint) : string;
605 return string of value i, but always include a + when i>=0
612 tostr_with_plus
:='+'+hs
618 procedure valint(S
: string;var V
: longint;var code
: integer);
620 val() with support for octal, which is not supported under tp7
631 for c
:=2 to length(s
) do
648 system
.val(S
,V
,code
);
652 system
.val(S
,V
,code
);
657 function is_number(const s
: string) : boolean;
659 is string a correct number ?
670 function ispowerof2(value
: longint;var power
: longint) : boolean;
672 return if value is a power of 2. And if correct return the power
693 { enable ansistring comparison }
697 function compareansistrings(p1
,p2
: pchar
;length1
,length2
: longint) : longint;
702 compareansistrings
:=0;
703 j
:=min(length1
,length2
);
709 compareansistrings
:=1;
715 compareansistrings
:=-1;
720 if length1
>length2
then
721 compareansistrings
:=1
723 if length1
<length2
then
724 compareansistrings
:=-1;
728 function concatansistrings(p1
,p2
: pchar
;length1
,length2
: longint) : pchar
;
732 getmem(p
,length1
+length2
+1);
733 move(p1
[0],p
[0],length1
);
734 move(p2
[0],p
[length1
],length2
+1);
735 concatansistrings
:=p
;
739 {****************************************************************************
741 ****************************************************************************}
743 Function L0(l
:longint):string;
745 return the string of value l, if l<10 then insert a zero, so
746 the string is always at least 2 chars '01','02',etc
758 function gettimestr
:string;
760 get the current time in a string HH:MM:SS
763 hour
,min
,sec
,hsec
: word;
766 dmisc
.gettime(hour
,min
,sec
,hsec
);
768 dos
.gettime(hour
,min
,sec
,hsec
);
770 gettimestr
:=L0(Hour
)+':'+L0(min
)+':'+L0(sec
);
774 function getdatestr
:string;
776 get the current date in a string YY/MM/DD
779 Year
,Month
,Day
,Wday
: Word;
782 dmisc
.getdate(year
,month
,day
,wday
);
784 dos
.getdate(year
,month
,day
,wday
);
786 getdatestr
:=L0(Year
)+'/'+L0(Month
)+'/'+L0(Day
);
790 function filetimestring( t
: longint) : string;
792 convert dos datetime t to a string YY/MM/DD HH:MM:SS
798 Year
,Month
,Day
,Hour
,Min
,Sec
: Word;
802 FileTimeString
:='Not Found';
807 Year
:=dT
.year
;month
:=dt
.month
;day
:=dt
.day
;
808 Hour
:=dt
.hour
;min
:=dt
.min
;sec
:=dt
.sec
;
810 EpochToLocal (t
,year
,month
,day
,hour
,min
,sec
);
812 filetimestring
:=L0(Year
)+'/'+L0(Month
)+'/'+L0(Day
)+' '+L0(Hour
)+':'+L0(min
)+':'+L0(sec
);
816 {****************************************************************************
817 Default Macro Handling
818 ****************************************************************************}
820 procedure DefaultReplacements(var s
:string);
822 { Replace some macro's }
823 Replace(s
,'$FPCVER',version_string
);
824 Replace(s
,'$VERSION',version_string
);
825 Replace(s
,'$FULLVERSION',full_version_string
);
826 Replace(s
,'$FPCDATE',date_string
);
827 Replace(s
,'$FPCTARGET',target_cpu_string
);
828 Replace(s
,'$FPCCPU',target_cpu_string
);
829 Replace(s
,'$TARGET',target_path
);
830 Replace(s
,'$FPCOS',target_path
);
834 {****************************************************************************
836 ****************************************************************************}
838 function GetCurrentDir
:string;
842 GetDir(0,CurrentDir
);
843 GetCurrentDir
:=FixPath(CurrentDir
,false);
847 function path_absolute(const s
: string) : boolean;
849 is path s an absolute path?
852 path_absolute
:=false;
854 if (length(s
)>0) and (s
[1]='/') then
858 if ((length(s
)>0) and ((s
[1]='\') or (s
[1]='/'))) or (Pos(':',s
) = length(s
)) then
861 if ((length(s
)>0) and ((s
[1]='\') or (s
[1]='/'))) or
862 ((length(s
)>2) and (s
[2]=':') and ((s
[3]='\') or (s
[3]='/'))) then
869 Procedure FindClose(var Info
: SearchRec
);
875 Function FileExists ( Const F
: String) : Boolean;
882 FileExists
:=sysutils
.FileExists(f
);
884 findfirst(F
,readonly
+archive
+hidden
,info
);
885 FileExists
:=(doserror
=0);
891 Function PathExists ( F
: String) : Boolean;
895 if F
[Length(f
)] in ['/','\'] then
896 Delete(f
,length(f
),1);
897 findfirst(F
,readonly
+archive
+hidden
+directory
,info
);
898 PathExists
:=(doserror
=0) and ((info
.attr
and directory
)=directory
);
903 Function RemoveFile(const f
:string):boolean;
911 RemoveFile
:=(ioresult
=0);
915 Function RemoveDir(d
:string):boolean;
917 if d
[length(d
)]=DirSep
then
918 Delete(d
,length(d
),1);
922 RemoveDir
:=(ioresult
=0);
926 Function SplitPath(const s
:string):string;
931 while (i
>0) and not(s
[i
] in ['/','\']) do
933 SplitPath
:=Copy(s
,1,i
);
937 Function SplitFileName(const s
:string):string;
948 Function SplitName(const s
:string):string;
954 while (i
>0) and not(s
[i
] in ['/','\']) do
956 while (j
>0) and (s
[j
]<>'.') do
960 SplitName
:=Copy(s
,i
+1,j
-(i
+1));
964 Function SplitExtension(Const HStr
:String):String;
969 while (j
>0) and (Hstr
[j
]<>'.') do
971 if hstr
[j
]=DirSep
then
978 SplitExtension
:=Copy(Hstr
,j
,255);
982 Function AddExtension(Const HStr
,ext
:String):String;
984 if (Ext
<>'') and (SplitExtension(HStr
)='') then
985 AddExtension
:=Hstr
+Ext
991 Function ForceExtension(Const HStr
,ext
:String):String;
996 while (j
>0) and (Hstr
[j
]<>'.') do
1000 ForceExtension
:=Copy(Hstr
,1,j
-1)+Ext
;
1004 Function FixPath(s
:string;allowdot
:boolean):string;
1009 for i
:=1 to length(s
) do
1010 if s
[i
] in ['/','\'] then
1013 if (length(s
)>0) and (s
[length(s
)]<>DirSep
) and
1014 (s
[length(s
)]<>':') then
1017 if (not allowdot
) and (s
='.'+DirSep
) then
1028 function FixFileName(const s
:string):string;
1038 for i
:=length(s
) downto 1 do
1043 FixFileName
[i
]:='/';
1044 NoPath
:=false; {Skip lowercasing path: 'X11'<>'x11' }
1046 'A'..'Z' : if NoPath
then
1047 FixFileName
[i
]:=char(byte(s
[i
])+32)
1049 FixFileName
[i
]:=s
[i
];
1051 '/' : FixFileName
[i
]:='\';
1052 'A'..'Z' : FixFileName
[i
]:=char(byte(s
[i
])+32);
1055 FixFileName
[i
]:=s
[i
];
1060 SetLength(FixFileName
,length(s
));
1062 FixFileName
[0]:=s
[0];
1065 FixFileName
[0]:=s
[0];
1070 procedure SplitBinCmd(const s
:string;var bstr
,cstr
:string);
1077 bstr
:=Copy(s
,1,i
-1);
1078 cstr
:=Copy(s
,i
+1,length(s
)-i
);
1089 procedure TSearchPathList
.AddPath(s
:string;addfirst
:boolean);
1099 hp
: PStringQueueItem
;
1102 procedure addcurrpath
;
1111 { Check if already in path, then we don't add it }
1113 if not assigned(hp
) then
1121 { Support default macro's }
1122 DefaultReplacements(s
);
1124 CurrentDir
:=GetCurrentDir
;
1130 while (j
>0) and (s
[j
]<>';') do
1132 CurrPath
:=FixPath(Copy(s
,j
+1,length(s
)-j
),false);
1136 System
.Delete(s
,j
,length(s
)-j
+1);
1143 CurrPath
:=FixPath(Copy(s
,1,j
-1),false);
1144 System
.Delete(s
,1,j
);
1148 CurrPath
:='.'+DirSep
1151 CurrPath
:=FixPath(FExpand(CurrPath
),false);
1152 if (CurrentDir
<>'') and (Copy(CurrPath
,1,length(CurrentDir
))=CurrentDir
) then
1153 CurrPath
:='.'+DirSep
+Copy(CurrPath
,length(CurrentDir
)+1,255);
1155 { wildcard adding ? }
1156 if pos('*',currpath
)>0 then
1158 if currpath
[length(currpath
)]=dirsep
then
1159 hs
:=Copy(currpath
,1,length(CurrPath
)-1)
1163 findfirst(hs
,directory
,dir
);
1166 if (dir
.name
<>'.') and
1167 (dir
.name
<>'..') and
1168 ((dir
.attr
and directory
)<>0) then
1170 currpath
:=hsd
+dir
.name
+dirsep
;
1172 if not assigned(hp
) then
1181 if PathExists(currpath
) then
1188 procedure TSearchPathList
.AddList(list
:TSearchPathList
;addfirst
:boolean);
1191 hl
: TSearchPathList
;
1193 hp
,hp2
: PStringItem
;
1195 hp
,hp2
: PStringQueueItem
;
1200 { create temp and reverse the list }
1205 while assigned(hp
) do
1207 hl
.insert(hp
^.data
^);
1210 while not hl
.empty
do
1221 while assigned(hp
) do
1223 hp2
:=Find(hp
^.data
^);
1224 { Check if already in path, then we don't add it }
1225 if not assigned(hp2
) then
1233 function TSearchPathList
.FindFile(const f
: string;var b
: boolean) : string;
1238 p
: PStringQueueItem
;
1244 while assigned(p
) do
1246 If FileExists(p
^.data
^+f
) then
1257 Function GetFileTime ( Var F
: File) : Longint;
1274 Function GetNamedFileTime (Const F
: String) : Longint;
1276 GetNamedFileTime
:=do_getnamedfiletime(F
);
1280 {Touch Assembler and object time to ppu time is there is a ppufilename}
1281 procedure SynchronizeFileTime(const fn1
,fn2
:string);
1293 { just to be sure in case there are rounding errors }
1309 function FindFile(const f
: string;path
: string;var b
: boolean) : string;
1311 singlepathstring
: string;
1315 for i
:=1 to length(path
) do
1325 singlepathstring
:=FixPath(copy(path
,1,i
-1),false);
1327 If FileExists (singlepathstring
+f
) then
1329 FindFile
:=singlepathstring
;
1336 function FindExe(bin
:string;var found
:boolean):string;
1338 bin
:=FixFileName(bin
)+source_os
.exeext
;
1340 FindExe
:=FindFile(bin
,'.;'+exepath
+';'+dmisc
.getenv('PATH'),found
)+bin
;
1342 FindExe
:=FindFile(bin
,'.;'+exepath
+';'+dos
.getenv('PATH'),found
)+bin
;
1347 function GetShortName(const n
:string):string;
1361 i
:=Windows
.GetShortPathName(@hs
[1],@hs2
[1],high(hs2
));
1362 if (i
>0) and (i
<=high(hs2
)) then
1364 hs2
[0]:=chr(strlen(@hs2
[1]));
1370 if Dos
.GetShortName(hs
) then
1376 {****************************************************************************
1378 ****************************************************************************}
1380 function GetEnvPChar(const envname
:string):pchar
;
1389 GetEnvPchar
:=Linux
.Getenv(envname
);
1394 p
:=GetEnvironmentStrings
;
1401 if upper(copy(s
,1,i
-1))=upper(envname
) then
1403 GetMem(p2
,len
-length(envname
));
1404 Move(hp
[i
],p2
^,len
-length(envname
));
1408 { next string entry}
1411 FreeEnvironmentStrings(p
);
1417 GetEnvPchar
:=StrPNew(Dos
.Getenv(envname
));
1422 procedure FreeEnvPChar(p
:pchar
);
1429 Procedure Shell(const command
:string);
1430 { This is already defined in the linux.ppu for linux, need for the *
1431 expansion under linux }
1434 Linux
.Shell(command
);
1440 comspec
:=getenv('COMSPEC');
1441 Exec(comspec
,' /C '+command
);
1446 Function SetCompileMode(const s
:string; changeInit
: boolean):boolean;
1452 aktmodeswitches
:=initmodeswitches
1455 aktmodeswitches
:=delphimodeswitches
1458 aktmodeswitches
:=tpmodeswitches
1461 aktmodeswitches
:=fpcmodeswitches
1464 aktmodeswitches
:=objfpcmodeswitches
1467 aktmodeswitches
:=gpcmodeswitches
1471 if b
and changeInit
then
1472 initmodeswitches
:= aktmodeswitches
;
1476 { turn ansistrings on by default ? }
1477 if (m_default_ansistring
in aktmodeswitches
) then
1479 include(aktlocalswitches
,cs_ansistrings
);
1481 include(initlocalswitches
,cs_ansistrings
);
1485 exclude(aktlocalswitches
,cs_ansistrings
);
1487 exclude(initlocalswitches
,cs_ansistrings
);
1495 {****************************************************************************
1497 ****************************************************************************}
1500 {$define need_path_search}
1503 {$define need_path_search}
1506 procedure get_exepath
;
1510 {$ifdef need_path_search}
1515 exepath
:=dmisc
.getenv('PPC_EXEC_PATH');
1517 exepath
:=dos
.getenv('PPC_EXEC_PATH');
1520 fsplit(FixFileName(paramstr(0)),exepath
,hs1
,hs2
);
1521 {$ifndef VER0_99_15}
1522 {$ifdef need_path_search}
1525 if pos(source_os
.exeext
,hs1
) <>
1526 (length(hs1
) - length(source_os
.exeext
)+1) then
1527 hs1
:= hs1
+ source_os
.exeext
;
1529 exepath
:= findfile(hs1
,dmisc
.getenv('PATH'),b
);
1531 exepath
:= findfile(hs1
,dos
.getenv('PATH'),b
);
1534 {$endif need_path_search}
1536 exepath
:=FixPath(exepath
,false);
1541 procedure DoneGlobals
;
1544 if assigned(DLLImageBase
) then
1545 StringDispose(DLLImageBase
);
1547 RelocSectionSetExplicitly
:=false;
1549 UseDeffileForExport
:=true;
1550 librarysearchpath
.Done
;
1551 unitsearchpath
.Done
;
1552 objectsearchpath
.Done
;
1553 includesearchpath
.Done
;
1556 procedure InitGlobals
;
1558 { set global switches }
1575 librarysearchpath
.Init
;
1576 unitsearchpath
.Init
;
1577 includesearchpath
.Init
;
1578 objectsearchpath
.Init
;
1581 usewindowapi
:=false;
1582 description
:='Compiled by FPC '+version_string
+' - '+target_cpu_string
;
1586 initmodeswitches
:=fpcmodeswitches
;
1587 initlocalswitches
:=[cs_check_io
];
1588 initmoduleswitches
:=[cs_extsyntax
,cs_browser
];
1589 initglobalswitches
:=[cs_check_unit_name
,cs_link_static
];
1591 initoptprocessor
:=Class386
;
1592 initspecificoptprocessor
:=Class386
;
1594 {$IFDEF testvarsets}
1597 initpackrecords
:=packrecord_2
;
1598 initoutputformat
:=target_asm
.id
;
1599 initasmmode
:=asmmode_i386_att
;
1602 initoptprocessor:=MC68000
;
1603 include(initmoduleswitches
,cs_fp_emulation
);
1605 {$IFDEF testvarsets}
1608 initpackrecords:=packrecord_2
;
1609 initoutputformat:=as_m68k_as
;
1610 initasmmode:=asmmode_m68k_mot
;
1615 { memory sizes, will be overriden by parameter or default for target
1616 in options or init_parser }
1623 { must_be_valid:=true; obsolete PM }
1624 not_unit_proc:=true
;
1633 EntryMemUsed
:=system
.HeapSize
-MemAvail
;
1639 Revision 1.1 2002/02/19 08:22:21 sasu
1642 Revision 1.1.2.6 2000/09/27 21:20:04 peter
1643 * also set initlocalswitches in setcompilemode
1645 Revision 1.1.2.5 2000/09/26 10:36:11 jonas
1646 * initmodeswitches is changed is you change the compiler mode from the
1647 command line (the -S<x> switches didn't work anymore for changing the
1650 Revision 1.1.2.4 2000/09/24 21:36:26 peter
1651 + setcompilemode() routine
1653 Revision 1.1.2.3 2000/09/24 10:39:15 peter
1654 * fixed ^Z in previous log message
1656 Revision 1.1.2.2 2000/09/24 10:17:07 jonas
1657 + searching of exe in path also for OS/2
1658 * fixed searching of exe in path
1660 Revision 1.1.2.1 2000/08/12 15:29:52 peter
1661 * patch from Gabor for IDE to support memory stream reading
1663 Revision 1.1 2000/07/13 06:29:50 michael
1666 Revision 1.67 2000/06/19 19:57:19 pierre
1667 * smart link is default on win32
1669 Revision 1.66 2000/06/18 18:05:54 peter
1670 * no binary value reading with % if not fpc mode
1671 * extended illegal char message with the char itself (Delphi like)
1673 Revision 1.65 2000/06/15 18:10:11 peter
1674 * first look for ppu in cwd and outputpath and after that for source
1676 * fixpath() for not linux makes path now lowercase so comparing paths
1677 with different cases (sometimes a drive letter could be
1678 uppercased) gives the expected results
1679 * sources_checked flag if there was already a full search for sources
1680 which aren't found, so another scan isn't done when checking for the
1681 sources only when recompile is needed
1683 Revision 1.64 2000/06/11 07:00:21 peter
1684 * fixed pchar->string conversion for delphi mode
1686 Revision 1.63 2000/05/12 08:58:51 pierre
1687 * adapted to Delphi 3
1689 Revision 1.62 2000/05/12 05:55:04 pierre
1690 * * get it to compile with Delphi by Kovacs Attila Zoltan
1692 Revision 1.61 2000/05/11 09:37:25 pierre
1693 * do not use upcase for strings, reported by Kovacs Attila Zoltan
1695 Revision 1.60 2000/05/04 20:46:17 peter
1696 * ansistrings are now default on for delphi mode, as most ppl expect
1699 Revision 1.59 2000/05/03 14:36:57 pierre
1700 * fix for tests/test/testrang.pp bug
1702 Revision 1.58 2000/04/14 12:27:57 pierre
1703 * setfiletime to both files in synchronize
1705 Revision 1.57 2000/03/23 15:35:47 peter
1706 * $VERSION is now version_string
1707 + $FULLVERSION is now full_version_string
1709 Revision 1.56 2000/03/20 16:04:05 pierre
1710 * probably a fix for bug 615
1712 Revision 1.55 2000/03/08 15:39:45 daniel
1713 + Added align_from_size function as suggested by Peter.
1715 Revision 1.54 2000/02/28 17:23:57 daniel
1716 * Current work of symtable integration committed. The symtable can be
1717 activated by defining 'newst', but doesn't compile yet. Changes in type
1718 checking and oop are completed. What is left is to write a new
1719 symtablestack and adapt the parser to use it.
1721 Revision 1.53 2000/02/14 20:58:44 marco
1722 * Basic structures for new sethandling implemented.
1724 Revision 1.52 2000/02/10 11:45:48 peter
1725 * addpath fixed with list of paths when inserting at the beginning
1726 * if exepath=currentdir then it's not inserted in path list
1727 * searchpaths in ppc386.cfg are now added at the beginning of the
1728 list instead of at the end. (commandline is not changed)
1729 * check paths before inserting in list
1731 Revision 1.51 2000/02/09 13:22:53 peter
1734 Revision 1.50 2000/01/26 14:31:03 marco
1735 * $VERSION is now also substituted in -F paths (that have subst active)
1737 Revision 1.49 2000/01/23 21:29:14 florian
1738 * CMOV support in optimizer (in define USECMOV)
1739 + start of support of exceptions in constructors
1741 Revision 1.48 2000/01/23 16:36:37 peter
1742 * better auto RTL dir detection
1744 Revision 1.47 2000/01/20 00:23:03 pierre
1745 * fix for GetShortName, now checks results from Win32
1747 Revision 1.46 2000/01/07 01:14:27 peter
1748 * updated copyright to 2000
1750 Revision 1.45 2000/01/07 00:08:09 peter
1753 Revision 1.44 2000/01/06 15:48:59 peter
1754 * wildcard support for directory adding, this allows the use of units/*
1757 Revision 1.43 2000/01/04 15:15:50 florian
1758 + added compiler switch $maxfpuregisters
1759 + fixed a small problem in secondvecn
1761 Revision 1.42 1999/12/22 01:01:48 peter
1762 - removed freelabel()
1763 * added undefined label detection in internal assembler, this prevents
1764 a lot of ld crashes and wrong .o files
1765 * .o files aren't written anymore if errors have occured
1766 * inlining of assembler labels is now correct
1768 Revision 1.41 1999/12/20 23:23:28 pierre
1769 + $description $version
1771 Revision 1.40 1999/12/20 21:42:34 pierre
1772 + dllversion global variable
1773 * FPC_USE_CPREFIX code removed, not necessary anymore
1774 as we use .edata direct writing by default now.
1776 Revision 1.39 1999/12/08 10:40:00 pierre
1777 + allow use of unit var in exports of DLL for win32
1778 by using direct export writing by default instead of use of DEFFILE
1779 that does not allow assembler labels that do not
1780 start with an underscore.
1781 Use -WD to force use of Deffile for Win32 DLL
1783 Revision 1.38 1999/12/06 18:21:03 peter
1784 * support !ENVVAR for long commandlines
1785 * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
1786 finally supported as installdir.
1788 Revision 1.37 1999/12/02 17:34:34 peter
1789 * preprocessor support. But it fails on the caret in type blocks
1791 Revision 1.36 1999/11/18 15:34:45 pierre
1792 * Notes/Hints for local syms changed to
1793 Set_varstate function
1795 Revision 1.35 1999/11/17 17:04:59 pierre
1796 * Notes/hints changes
1798 Revision 1.34 1999/11/15 17:42:41 pierre
1799 * -g disables reloc section for win32
1801 Revision 1.33 1999/11/12 11:03:50 peter
1802 * searchpaths changed to stringqueue object
1804 Revision 1.32 1999/11/09 23:34:46 pierre
1805 + resolving_forward boolean used for references
1807 Revision 1.31 1999/11/09 13:00:38 peter
1808 * define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
1809 * initial support for ansistring default with modes