globals.pas 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements some support functions and global variables
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit globals;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. {$ifdef win32}
  22. windows,
  23. {$endif}
  24. {$ifdef os2}
  25. dos,
  26. {$endif os2}
  27. {$ifdef hasunix}
  28. Baseunix,unix,
  29. {$endif}
  30. {$IFNDEF USE_FAKE_SYSUTILS}
  31. sysutils,
  32. {$ELSE}
  33. fksysutl,
  34. {$ENDIF}
  35. { comphook pulls in sysutils anyways }
  36. cutils,cclasses,cfileutl,
  37. cpuinfo,
  38. globtype,version,systems;
  39. const
  40. delphimodeswitches =
  41. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  42. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  43. m_out,m_default_para,m_duplicate_names,m_hintdirective,m_add_pointer,
  44. m_property,m_default_inline,m_except];
  45. fpcmodeswitches =
  46. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  47. m_cvar_support,m_initfinal,m_add_pointer,m_hintdirective,
  48. m_property,m_default_inline];
  49. objfpcmodeswitches =
  50. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  51. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para,m_hintdirective,
  52. m_property,m_default_inline,m_except];
  53. tpmodeswitches =
  54. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  55. {$ifdef gpc_mode}
  56. gpcmodeswitches =
  57. [m_gpc,m_all,m_tp_procvar];
  58. {$endif}
  59. macmodeswitches =
  60. [m_mac,m_all,m_result,m_cvar_support,m_mac_procvar];
  61. { maximum nesting of routines }
  62. maxnesting = 32;
  63. { Filenames and extensions }
  64. sourceext = '.pp';
  65. pasext = '.pas';
  66. pext = '.p';
  67. treelogfilename = 'tree.log';
  68. {$if defined(CPUARM) and defined(FPUFPA)}
  69. MathQNaN : tdoublerec = (bytes : (0,0,252,255,0,0,0,0));
  70. MathInf : tdoublerec = (bytes : (0,0,240,127,0,0,0,0));
  71. MathNegInf : tdoublerec = (bytes : (0,0,240,255,0,0,0,0));
  72. MathPi : tdoublerec = (bytes : (251,33,9,64,24,45,68,84));
  73. {$else}
  74. {$ifdef FPC_LITTLE_ENDIAN}
  75. MathQNaN : tdoublerec = (bytes : (0,0,0,0,0,0,252,255));
  76. MathInf : tdoublerec = (bytes : (0,0,0,0,0,0,240,127));
  77. MathNegInf : tdoublerec = (bytes : (0,0,0,0,0,0,240,255));
  78. MathPi : tdoublerec = (bytes : (24,45,68,84,251,33,9,64));
  79. MathPiExtended : textendedrec = (bytes : (53,194,104,33,162,218,15,201,0,64));
  80. {$else FPC_LITTLE_ENDIAN}
  81. MathQNaN : tdoublerec = (bytes : (255,252,0,0,0,0,0,0));
  82. MathInf : tdoublerec = (bytes : (127,240,0,0,0,0,0,0));
  83. MathNegInf : tdoublerec = (bytes : (255,240,0,0,0,0,0,0));
  84. MathPi : tdoublerec = (bytes : (64,9,33,251,84,68,45,24));
  85. MathPiExtended : textendedrec = (bytes : (64,0,201,15,218,162,33,104,194,53));
  86. {$endif FPC_LITTLE_ENDIAN}
  87. {$endif}
  88. type
  89. tcodepagestring = string[20];
  90. tsettings = record
  91. globalswitches : tglobalswitches;
  92. moduleswitches : tmoduleswitches;
  93. localswitches : tlocalswitches;
  94. modeswitches : tmodeswitches;
  95. optimizerswitches : toptimizerswitches;
  96. { generate information necessary to perform these wpo's during a subsequent compilation }
  97. genwpoptimizerswitches: twpoptimizerswitches;
  98. { perform these wpo's using information generated during a previous compilation }
  99. dowpoptimizerswitches: twpoptimizerswitches;
  100. debugswitches : tdebugswitches;
  101. { 0: old behaviour for sets <=256 elements
  102. >0: round to this size }
  103. setalloc,
  104. packenum : shortint;
  105. alignment : talignmentinfo;
  106. cputype,
  107. optimizecputype : tcputype;
  108. fputype : tfputype;
  109. asmmode : tasmmode;
  110. interfacetype : tinterfacetypes;
  111. defproccall : tproccalloption;
  112. sourcecodepage : tcodepagestring;
  113. packrecords : shortint;
  114. maxfpuregisters : shortint;
  115. minfpconstprec : tfloattype;
  116. end;
  117. const
  118. LinkMapWeightDefault = 1000;
  119. type
  120. TLinkRec = record
  121. Key : AnsiString;
  122. Value : AnsiString; // key expands to valuelist "value"
  123. Weight: longint;
  124. end;
  125. TLinkStrMap = class
  126. private
  127. itemcnt : longint;
  128. fmap : Array Of TLinkRec;
  129. function Lookup(key:Ansistring):longint;
  130. function getlinkrec(i:longint):TLinkRec;
  131. public
  132. procedure Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  133. procedure addseries(keys:AnsiString;weight:longint=LinkMapWeightDefault);
  134. function AddDep(keyvalue:String):boolean;
  135. function AddWeight(keyvalue:String):boolean;
  136. procedure SetValue(key:AnsiString;Weight:Integer);
  137. procedure SortonWeight;
  138. function Find(key:AnsiString):AnsiString;
  139. procedure Expand(src:TCmdStrList;dest: TLinkStrMap);
  140. procedure UpdateWeights(Weightmap:TLinkStrMap);
  141. constructor Create;
  142. property count : longint read itemcnt;
  143. property items[I:longint]:TLinkRec read getlinkrec; default;
  144. end;
  145. var
  146. { specified inputfile }
  147. inputfilepath : string;
  148. inputfilename : string;
  149. { specified outputfile with -o parameter }
  150. outputfilename : string;
  151. outputprefix : pshortstring;
  152. outputsuffix : pshortstring;
  153. { specified with -FE or -FU }
  154. outputexedir : TPathStr;
  155. outputunitdir : TPathStr;
  156. { specified with -FW and -Fw }
  157. wpofeedbackinput,
  158. wpofeedbackoutput : TPathStr;
  159. { things specified with parameters }
  160. paratarget : tsystem;
  161. paratargetdbg : tdbg;
  162. paratargetasm : tasm;
  163. paralinkoptions : TCmdStr;
  164. paradynamiclinker : string;
  165. paraprintnodetree : byte;
  166. parapreprocess : boolean;
  167. printnodefile : text;
  168. { typical cross compiling params}
  169. { directory where the utils can be found (options -FD) }
  170. utilsdirectory : TPathStr;
  171. { targetname specific prefix used by these utils (options -XP<path>) }
  172. utilsprefix : TCmdStr;
  173. cshared : boolean; { pass --shared to ld to link C libs shared}
  174. Dontlinkstdlibpath: Boolean; { Don't add std paths to linkpath}
  175. rlinkpath : TCmdStr; { rpath-link linkdir override}
  176. sysrootpath : TCmdStr; { target system root to search dyn linker }
  177. { some flags for global compiler switches }
  178. do_build,
  179. do_release,
  180. do_make : boolean;
  181. { path for searching units, different paths can be seperated by ; }
  182. exepath : TPathStr; { Path to ppc }
  183. librarysearchpath,
  184. unitsearchpath,
  185. objectsearchpath,
  186. includesearchpath,
  187. frameworksearchpath : TSearchPathList;
  188. autoloadunits : string;
  189. { linking }
  190. usewindowapi : boolean;
  191. description : string;
  192. SetPEFlagsSetExplicity,
  193. ImageBaseSetExplicity,
  194. MinStackSizeSetExplicity,
  195. MaxStackSizeSetExplicity,
  196. DescriptionSetExplicity : boolean;
  197. dllversion : string;
  198. dllmajor,
  199. dllminor,
  200. dllrevision : word; { revision only for netware }
  201. { win pe }
  202. peflags : longint;
  203. minstacksize,
  204. maxstacksize,
  205. imagebase : aword;
  206. UseDeffileForExports : boolean;
  207. UseDeffileForExportsSetExplicitly : boolean;
  208. GenerateImportSection,
  209. GenerateImportSectionSetExplicitly,
  210. RelocSection : boolean;
  211. RelocSectionSetExplicitly : boolean;
  212. LinkTypeSetExplicitly : boolean;
  213. current_tokenpos, { position of the last token }
  214. current_filepos : tfileposinfo; { current position }
  215. nwscreenname : string;
  216. nwthreadname : string;
  217. nwcopyright : string;
  218. codegenerror : boolean; { true if there is an error reported }
  219. block_type : tblock_type; { type of currently parsed block }
  220. compile_level : word;
  221. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  222. current_exceptblock : integer; { the exceptblock number of the current block (0 if none) }
  223. LinkLibraryAliases : TLinkStrMap;
  224. LinkLibraryOrder : TLinkStrMap;
  225. init_settings,
  226. current_settings : tsettings;
  227. nextlocalswitches : tlocalswitches;
  228. localswitcheschanged : boolean;
  229. { Memory sizes }
  230. heapsize,
  231. stacksize,
  232. jmp_buf_size : longint;
  233. {$Ifdef EXTDEBUG}
  234. { parameter switches }
  235. debugstop : boolean;
  236. {$EndIf EXTDEBUG}
  237. { windows / OS/2 application type }
  238. apptype : tapptype;
  239. features : tfeatures;
  240. const
  241. DLLsource : boolean = false;
  242. DLLImageBase : pshortstring = nil;
  243. { used to set all registers used for each global function
  244. this should dramatically decrease the number of
  245. recompilations needed PM }
  246. simplify_ppu : boolean = true;
  247. Inside_asm_statement : boolean = false;
  248. global_unit_count : word = 0;
  249. { for error info in pp.pas }
  250. parser_current_file : string = '';
  251. {$if defined(m68k) or defined(arm)}
  252. { PalmOS resources }
  253. palmos_applicationname : string = 'FPC Application';
  254. palmos_applicationid : string[4] = 'FPCA';
  255. {$endif defined(m68k) or defined(arm)}
  256. {$ifdef powerpc}
  257. { default calling convention used on MorphOS }
  258. syscall_convention : string = 'LEGACY';
  259. {$endif powerpc}
  260. { default name of the C-style "main" procedure of the library/program }
  261. { (this will be prefixed with the target_info.cprefix) }
  262. defaultmainaliasname = 'main';
  263. mainaliasname : string = defaultmainaliasname;
  264. { by default no local variable trashing }
  265. localvartrashing: longint = -1;
  266. { actual values are defined in ncgutil.pas }
  267. nroftrashvalues = 4;
  268. const
  269. default_settings : TSettings = (
  270. globalswitches : [cs_check_unit_name,cs_link_static];
  271. moduleswitches : [cs_extsyntax,cs_implicit_exceptions];
  272. localswitches : [cs_check_io,cs_typed_const_writable];
  273. modeswitches : fpcmodeswitches;
  274. optimizerswitches : [];
  275. genwpoptimizerswitches : [];
  276. dowpoptimizerswitches : [];
  277. debugswitches : [];
  278. setalloc : 0;
  279. packenum : 4;
  280. alignment : (
  281. procalign : 0;
  282. loopalign : 0;
  283. jumpalign : 0;
  284. constalignmin : 0;
  285. constalignmax : 0;
  286. varalignmin : 0;
  287. varalignmax : 0;
  288. localalignmin : 0;
  289. localalignmax : 0;
  290. recordalignmin : 0;
  291. recordalignmax : 0;
  292. maxCrecordalign : 0;
  293. );
  294. {$ifdef i386}
  295. cputype : cpu_Pentium;
  296. optimizecputype : cpu_Pentium3;
  297. fputype : fpu_x87;
  298. {$endif i386}
  299. {$ifdef m68k}
  300. cputype : cpu_MC68020;
  301. optimizecputype : cpu_MC68020;
  302. fputype : fpu_soft;
  303. {$endif m68k}
  304. {$ifdef powerpc}
  305. cputype : cpu_PPC604;
  306. optimizecputype : cpu_ppc7400;
  307. fputype : fpu_standard;
  308. {$endif powerpc}
  309. {$ifdef POWERPC64}
  310. cputype : cpu_PPC970;
  311. optimizecputype : cpu_ppc970;
  312. fputype : fpu_standard;
  313. {$endif POWERPC64}
  314. {$ifdef sparc}
  315. cputype : cpu_SPARC_V8;
  316. optimizecputype : cpu_SPARC_V8;
  317. fputype : fpu_hard;
  318. {$endif sparc}
  319. {$ifdef arm}
  320. cputype : cpu_armv3;
  321. optimizecputype : cpu_armv3;
  322. fputype : fpu_fpa;
  323. {$endif arm}
  324. {$ifdef x86_64}
  325. cputype : cpu_athlon64;
  326. optimizecputype : cpu_athlon64;
  327. fputype : fpu_sse64;
  328. {$endif x86_64}
  329. {$ifdef avr}
  330. cputype : cpuinfo.cpu_avr;
  331. optimizecputype : cpuinfo.cpu_avr;
  332. fputype : fpu_none;
  333. {$endif avr}
  334. asmmode : asmmode_standard;
  335. interfacetype : it_interfacecom;
  336. defproccall : pocall_default;
  337. sourcecodepage : '8859-1';
  338. packrecords : 0;
  339. maxfpuregisters : 0;
  340. minfpconstprec : s32real;
  341. );
  342. var
  343. starttime : real;
  344. function getdatestr:string;
  345. function gettimestr:string;
  346. function filetimestring( t : longint) : string;
  347. function getrealtime : real;
  348. procedure DefaultReplacements(var s:ansistring);
  349. function Shell(const command:ansistring): longint;
  350. function GetEnvPChar(const envname:string):pchar;
  351. procedure FreeEnvPChar(p:pchar);
  352. function is_number_float(d : double) : boolean;
  353. { discern +0.0 and -0.0 }
  354. function get_real_sign(r: bestreal): longint;
  355. procedure InitGlobals;
  356. procedure DoneGlobals;
  357. function string2guid(const s: string; var GUID: TGUID): boolean;
  358. function guid2string(const GUID: TGUID): string;
  359. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  360. function Setabitype(const s:string;var a:tabi):boolean;
  361. function Setcputype(const s:string;var a:tcputype):boolean;
  362. function SetFpuType(const s:string;var a:tfputype):boolean;
  363. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  364. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  365. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  366. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  367. function IncludeFeature(const s : string) : boolean;
  368. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  369. {# Routine to get the required alignment for size of data, which will
  370. be placed in bss segment, according to the current alignment requirements }
  371. function var_align(siz: longint): shortint;
  372. {# Routine to get the required alignment for size of data, which will
  373. be placed in data/const segment, according to the current alignment requirements }
  374. function const_align(siz: longint): shortint;
  375. {$ifdef ARM}
  376. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  377. {$endif ARM}
  378. function floating_point_range_check_error : boolean;
  379. implementation
  380. uses
  381. {$ifdef macos}
  382. macutils,
  383. {$endif}
  384. comphook;
  385. {****************************************************************************
  386. TLinkStrMap
  387. ****************************************************************************}
  388. Constructor TLinkStrMap.create;
  389. begin
  390. inherited;
  391. itemcnt:=0;
  392. end;
  393. procedure TLinkStrMap.Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  394. begin
  395. if lookup(key)<>-1 Then
  396. exit;
  397. if itemcnt<=length(fmap) Then
  398. setlength(fmap,itemcnt+10);
  399. fmap[itemcnt].key:=key;
  400. fmap[itemcnt].value:=value;
  401. fmap[itemcnt].weight:=weight;
  402. inc(itemcnt);
  403. end;
  404. function TLinkStrMap.AddDep(keyvalue:String):boolean;
  405. var
  406. i : Longint;
  407. begin
  408. AddDep:=false;
  409. i:=pos('=',keyvalue);
  410. if i=0 then
  411. exit;
  412. Add(Copy(KeyValue,1,i-1),Copy(KeyValue,i+1,length(KeyValue)-i));
  413. AddDep:=True;
  414. end;
  415. function TLinkStrMap.AddWeight(keyvalue:String):boolean;
  416. var
  417. i,j : Longint;
  418. Code : Word;
  419. s : AnsiString;
  420. begin
  421. AddWeight:=false;
  422. i:=pos('=',keyvalue);
  423. if i=0 then
  424. exit;
  425. s:=Copy(KeyValue,i+1,length(KeyValue)-i);
  426. val(s,j,code);
  427. if code=0 Then
  428. begin
  429. Add(Copy(KeyValue,1,i-1),'',j);
  430. AddWeight:=True;
  431. end;
  432. end;
  433. procedure TLinkStrMap.addseries(keys:AnsiString;weight:longint);
  434. var
  435. i,j,k : longint;
  436. begin
  437. k:=length(keys);
  438. i:=1;
  439. while i<=k do
  440. begin
  441. j:=i;
  442. while (i<=k) and (keys[i]<>',') do
  443. inc(i);
  444. add(copy(keys,j,i-j),'',weight);
  445. inc(i);
  446. end;
  447. end;
  448. procedure TLinkStrMap.SetValue(Key:Ansistring;weight:Integer);
  449. var
  450. j : longint;
  451. begin
  452. j:=lookup(key);
  453. if j<>-1 then
  454. fmap[j].weight:=weight;
  455. end;
  456. function TLinkStrMap.find(key:Ansistring):Ansistring;
  457. var
  458. j : longint;
  459. begin
  460. find:='';
  461. j:=lookup(key);
  462. if j<>-1 then
  463. find:=fmap[j].value;
  464. end;
  465. function TLinkStrMap.lookup(key:Ansistring):longint;
  466. var
  467. i : longint;
  468. begin
  469. lookup:=-1;
  470. i:=0;
  471. while (i<itemcnt) and (fmap[i].key<>key) do
  472. inc(i);
  473. if i<>itemcnt then
  474. lookup:=i;
  475. end;
  476. procedure TLinkStrMap.SortOnWeight;
  477. var
  478. i, j : longint;
  479. m : TLinkRec;
  480. begin
  481. if itemcnt <2 then exit;
  482. for i:=0 to itemcnt-1 do
  483. for j:=i+1 to itemcnt-1 do
  484. begin
  485. if fmap[i].weight>fmap[j].weight Then
  486. begin
  487. m:=fmap[i];
  488. fmap[i]:=fmap[j];
  489. fmap[j]:=m;
  490. end;
  491. end;
  492. end;
  493. function TLinkStrMap.getlinkrec(i:longint):TLinkRec;
  494. begin
  495. result:=fmap[i];
  496. end;
  497. procedure TLinkStrMap.Expand(Src:TCmdStrList;Dest:TLinkStrMap);
  498. // expands every thing in Src to Dest for linkorder purposes.
  499. var
  500. r : longint;
  501. LibN : TCmdStr;
  502. begin
  503. while not src.empty do
  504. begin
  505. LibN:=src.getfirst;
  506. r:=lookup (LibN);
  507. if r=-1 then
  508. dest.add(LibN)
  509. else
  510. dest.addseries(fmap[r].value);
  511. end;
  512. end;
  513. procedure TLinkStrMap.UpdateWeights(Weightmap:TLinkStrMap);
  514. var
  515. l,r : longint;
  516. begin
  517. for l := 0 to itemcnt-1 do
  518. begin
  519. r:=weightmap.lookup (fmap[l].key);
  520. if r<>-1 then
  521. fmap[l].weight:=weightmap[r].weight;
  522. end;
  523. end;
  524. {****************************************************************************
  525. Time Handling
  526. ****************************************************************************}
  527. Function L0(l:longint):string;
  528. {
  529. return the string of value l, if l<10 then insert a zero, so
  530. the string is always at least 2 chars '01','02',etc
  531. }
  532. var
  533. s : string;
  534. begin
  535. Str(l,s);
  536. if l<10 then
  537. s:='0'+s;
  538. L0:=s;
  539. end;
  540. function gettimestr:string;
  541. {
  542. get the current time in a string HH:MM:SS
  543. }
  544. var
  545. hour,min,sec,hsec : word;
  546. begin
  547. DecodeTime(Time,hour,min,sec,hsec);
  548. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  549. end;
  550. function getdatestr:string;
  551. {
  552. get the current date in a string YY/MM/DD
  553. }
  554. var
  555. Year,Month,Day: Word;
  556. begin
  557. DecodeDate(Date,year,month,day);
  558. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  559. end;
  560. function filetimestring( t : longint) : string;
  561. {
  562. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  563. }
  564. var
  565. DT : TDateTime;
  566. hsec : word;
  567. Year,Month,Day: Word;
  568. hour,min,sec : word;
  569. begin
  570. if t=-1 then
  571. begin
  572. Result := 'Not Found';
  573. exit;
  574. end;
  575. DT := FileDateToDateTime(t);
  576. DecodeTime(DT,hour,min,sec,hsec);
  577. DecodeDate(DT,year,month,day);
  578. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  579. end;
  580. function getrealtime : real;
  581. var
  582. h,m,s,s1000 : word;
  583. begin
  584. DecodeTime(Time,h,m,s,s1000);
  585. result:=h*3600.0+m*60.0+s+s1000/1000.0;
  586. end;
  587. {****************************************************************************
  588. Default Macro Handling
  589. ****************************************************************************}
  590. procedure DefaultReplacements(var s:ansistring);
  591. begin
  592. { Replace some macros }
  593. Replace(s,'$FPCVERSION',version_string);
  594. Replace(s,'$FPCFULLVERSION',full_version_string);
  595. Replace(s,'$FPCDATE',date_string);
  596. Replace(s,'$FPCCPU',target_cpu_string);
  597. Replace(s,'$FPCOS',target_os_string);
  598. if tf_use_8_3 in Source_Info.Flags then
  599. Replace(s,'$FPCTARGET',target_os_string)
  600. else
  601. Replace(s,'$FPCTARGET',target_full_string);
  602. end;
  603. {****************************************************************************
  604. OS Dependent things
  605. ****************************************************************************}
  606. function GetEnvPChar(const envname:string):pchar;
  607. {$ifdef win32}
  608. var
  609. s : string;
  610. i,len : longint;
  611. hp,p,p2 : pchar;
  612. {$endif}
  613. begin
  614. {$ifdef hasunix}
  615. GetEnvPchar:=BaseUnix.fpGetEnv(envname);
  616. {$define GETENVOK}
  617. {$endif}
  618. {$ifdef win32}
  619. GetEnvPchar:=nil;
  620. p:=GetEnvironmentStrings;
  621. hp:=p;
  622. while hp^<>#0 do
  623. begin
  624. s:=strpas(hp);
  625. i:=pos('=',s);
  626. len:=strlen(hp);
  627. if upper(copy(s,1,i-1))=upper(envname) then
  628. begin
  629. GetMem(p2,len-length(envname));
  630. Move(hp[i],p2^,len-length(envname));
  631. GetEnvPchar:=p2;
  632. break;
  633. end;
  634. { next string entry}
  635. hp:=hp+len+1;
  636. end;
  637. FreeEnvironmentStrings(p);
  638. {$define GETENVOK}
  639. {$endif}
  640. {$ifdef os2}
  641. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  642. {$define GETENVOK}
  643. {$endif}
  644. {$ifdef GETENVOK}
  645. {$undef GETENVOK}
  646. {$else}
  647. GetEnvPchar:=StrPNew(GetEnvironmentVariable(envname));
  648. {$endif}
  649. end;
  650. procedure FreeEnvPChar(p:pchar);
  651. begin
  652. {$ifndef hasunix}
  653. {$ifndef os2}
  654. freemem(p);
  655. {$endif}
  656. {$endif}
  657. end;
  658. {$if defined(MORPHOS) or defined(AMIGA)}
  659. {$define AMIGASHELL}
  660. {$endif}
  661. function Shell(const command:ansistring): longint;
  662. { This is already defined in the linux.ppu for linux, need for the *
  663. expansion under linux }
  664. {$ifdef hasunix}
  665. begin
  666. result := Unix.fpsystem(command);
  667. end;
  668. {$else hasunix}
  669. {$ifdef amigashell}
  670. begin
  671. result := ExecuteProcess('',command);
  672. end;
  673. {$else amigashell}
  674. var
  675. comspec : string;
  676. begin
  677. comspec:=GetEnvironmentVariable('COMSPEC');
  678. result := ExecuteProcess(comspec,' /C '+command);
  679. end;
  680. {$endif amigashell}
  681. {$endif hasunix}
  682. {$UNDEF AMIGASHELL}
  683. function is_number_float(d : double) : boolean;
  684. var
  685. bytearray : array[0..7] of byte;
  686. begin
  687. move(d,bytearray,8);
  688. { only 1.1 save, 1.0.x will use always little endian }
  689. {$ifdef FPC_BIG_ENDIAN}
  690. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  691. {$else FPC_BIG_ENDIAN}
  692. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  693. {$endif FPC_BIG_ENDIAN}
  694. end;
  695. function get_real_sign(r: bestreal): longint;
  696. var
  697. p: pbyte;
  698. begin
  699. p := pbyte(@r);
  700. {$ifdef CPU_ARM}
  701. inc(p,4);
  702. {$else}
  703. {$ifdef FPC_LITTLE_ENDIAN}
  704. inc(p,sizeof(r)-1);
  705. {$endif}
  706. {$endif}
  707. if (p^ and $80) = 0 then
  708. result := 1
  709. else
  710. result := -1;
  711. end;
  712. function convertdoublerec(d : tdoublerec) : tdoublerec;{$ifdef USEINLINE}inline;{$endif}
  713. {$ifdef CPUARM}
  714. var
  715. i : longint;
  716. begin
  717. for i:=0 to 3 do
  718. begin
  719. result.bytes[i+4]:=d.bytes[i];
  720. result.bytes[i]:=d.bytes[i+4];
  721. end;
  722. {$else CPUARM}
  723. begin
  724. result:=d;
  725. {$endif CPUARM}
  726. end;
  727. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  728. function string2guid(const s: string; var GUID: TGUID): boolean;
  729. function ishexstr(const hs: string): boolean;
  730. var
  731. i: integer;
  732. begin
  733. ishexstr:=false;
  734. for i:=1 to Length(hs) do begin
  735. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  736. exit;
  737. end;
  738. ishexstr:=true;
  739. end;
  740. function hexstr2longint(const hexs: string): longint;
  741. var
  742. i: integer;
  743. rl: longint;
  744. begin
  745. rl:=0;
  746. for i:=1 to length(hexs) do begin
  747. rl:=rl shl 4;
  748. case hexs[i] of
  749. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  750. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  751. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  752. end
  753. end;
  754. hexstr2longint:=rl;
  755. end;
  756. var
  757. i: integer;
  758. begin
  759. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  760. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  761. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  762. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  763. ishexstr(copy(s,26,12)) then begin
  764. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  765. { these values are arealdy in the correct range (4 chars = word) }
  766. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  767. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  768. for i:=0 to 1 do
  769. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  770. for i:=2 to 7 do
  771. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  772. string2guid:=true;
  773. end
  774. else if (length(s)=0) then
  775. begin
  776. FillChar(GUID,SizeOf(GUID),0);
  777. string2guid:=true;
  778. end
  779. else
  780. string2guid:=false;
  781. end;
  782. function guid2string(const GUID: TGUID): string;
  783. begin
  784. guid2string:=
  785. '{'+hexstr(GUID.D1,8)+
  786. '-'+hexstr(GUID.D2,4)+
  787. '-'+hexstr(GUID.D3,4)+
  788. '-'+hexstr(GUID.D4[0],2)+hexstr(GUID.D4[1],2)+
  789. '-'+hexstr(GUID.D4[2],2)+hexstr(GUID.D4[3],2)+
  790. hexstr(GUID.D4[4],2)+hexstr(GUID.D4[5],2)+
  791. hexstr(GUID.D4[6],2)+hexstr(GUID.D4[7],2)+
  792. '}';
  793. end;
  794. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  795. const
  796. DefProcCallName : array[tproccalloption] of string[12] = ('',
  797. 'CDECL',
  798. 'CPPDECL',
  799. 'FAR16',
  800. 'OLDFPCCALL',
  801. '', { internproc }
  802. '', { syscall }
  803. 'PASCAL',
  804. 'REGISTER',
  805. 'SAFECALL',
  806. 'STDCALL',
  807. 'SOFTFLOAT',
  808. 'MWPASCAL'
  809. );
  810. var
  811. t : tproccalloption;
  812. hs : string;
  813. begin
  814. result:=false;
  815. if (s = '') then
  816. exit;
  817. hs:=upper(s);
  818. if (hs = 'DEFAULT') then
  819. begin
  820. a := pocall_default;
  821. result := true;
  822. exit;
  823. end;
  824. for t:=low(tproccalloption) to high(tproccalloption) do
  825. if DefProcCallName[t]=hs then
  826. begin
  827. a:=t;
  828. result:=true;
  829. break;
  830. end;
  831. end;
  832. function Setabitype(const s:string;var a:tabi):boolean;
  833. var
  834. t : tabi;
  835. hs : string;
  836. begin
  837. result:=false;
  838. hs:=Upper(s);
  839. for t:=low(t) to high(t) do
  840. if abi2str[t]=hs then
  841. begin
  842. a:=t;
  843. result:=true;
  844. break;
  845. end;
  846. end;
  847. function Setcputype(const s:string;var a:tcputype):boolean;
  848. var
  849. t : tcputype;
  850. hs : string;
  851. begin
  852. result:=false;
  853. hs:=Upper(s);
  854. for t:=low(tcputype) to high(tcputype) do
  855. if cputypestr[t]=hs then
  856. begin
  857. a:=t;
  858. result:=true;
  859. break;
  860. end;
  861. end;
  862. function SetFpuType(const s:string;var a:tfputype):boolean;
  863. var
  864. t : tfputype;
  865. begin
  866. result:=false;
  867. for t:=low(tfputype) to high(tfputype) do
  868. if fputypestr[t]=s then
  869. begin
  870. a:=t;
  871. result:=true;
  872. break;
  873. end;
  874. end;
  875. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  876. var
  877. tok : string;
  878. vstr : string;
  879. l : longint;
  880. code : integer;
  881. b : talignmentinfo;
  882. begin
  883. UpdateAlignmentStr:=true;
  884. uppervar(s);
  885. fillchar(b,sizeof(b),0);
  886. repeat
  887. tok:=GetToken(s,'=');
  888. if tok='' then
  889. break;
  890. vstr:=GetToken(s,',');
  891. val(vstr,l,code);
  892. if tok='PROC' then
  893. b.procalign:=l
  894. else if tok='JUMP' then
  895. b.jumpalign:=l
  896. else if tok='LOOP' then
  897. b.loopalign:=l
  898. else if tok='CONSTMIN' then
  899. b.constalignmin:=l
  900. else if tok='CONSTMAX' then
  901. b.constalignmax:=l
  902. else if tok='VARMIN' then
  903. b.varalignmin:=l
  904. else if tok='VARMAX' then
  905. b.varalignmax:=l
  906. else if tok='LOCALMIN' then
  907. b.localalignmin:=l
  908. else if tok='LOCALMAX' then
  909. b.localalignmax:=l
  910. else if tok='RECORDMIN' then
  911. b.recordalignmin:=l
  912. else if tok='RECORDMAX' then
  913. b.recordalignmax:=l
  914. else { Error }
  915. UpdateAlignmentStr:=false;
  916. until false;
  917. UpdateAlignment(a,b);
  918. end;
  919. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  920. var
  921. tok : string;
  922. doset,
  923. found : boolean;
  924. opt : toptimizerswitch;
  925. begin
  926. result:=true;
  927. uppervar(s);
  928. repeat
  929. tok:=GetToken(s,',');
  930. if tok='' then
  931. break;
  932. if Copy(tok,1,2)='NO' then
  933. begin
  934. delete(tok,1,2);
  935. doset:=false;
  936. end
  937. else
  938. doset:=true;
  939. found:=false;
  940. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  941. begin
  942. if OptimizerSwitchStr[opt]=tok then
  943. begin
  944. found:=true;
  945. break;
  946. end;
  947. end;
  948. if found then
  949. begin
  950. if doset then
  951. include(a,opt)
  952. else
  953. exclude(a,opt);
  954. end
  955. else
  956. result:=false;
  957. until false;
  958. end;
  959. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  960. var
  961. tok : string;
  962. doset,
  963. found : boolean;
  964. opt : twpoptimizerswitch;
  965. begin
  966. result:=true;
  967. uppervar(s);
  968. repeat
  969. tok:=GetToken(s,',');
  970. if tok='' then
  971. break;
  972. if Copy(tok,1,2)='NO' then
  973. begin
  974. delete(tok,1,2);
  975. doset:=false;
  976. end
  977. else
  978. doset:=true;
  979. found:=false;
  980. if (tok = 'ALL') then
  981. begin
  982. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  983. if doset then
  984. include(a,opt)
  985. else
  986. exclude(a,opt);
  987. end
  988. else
  989. begin
  990. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  991. begin
  992. if WPOptimizerSwitchStr[opt]=tok then
  993. begin
  994. found:=true;
  995. break;
  996. end;
  997. end;
  998. if found then
  999. begin
  1000. if doset then
  1001. include(a,opt)
  1002. else
  1003. exclude(a,opt);
  1004. end
  1005. else
  1006. result:=false;
  1007. end;
  1008. until false;
  1009. end;
  1010. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  1011. var
  1012. tok : string;
  1013. doset,
  1014. found : boolean;
  1015. opt : tdebugswitch;
  1016. begin
  1017. result:=true;
  1018. uppervar(s);
  1019. repeat
  1020. tok:=GetToken(s,',');
  1021. if tok='' then
  1022. break;
  1023. if Copy(tok,1,2)='NO' then
  1024. begin
  1025. delete(tok,1,2);
  1026. doset:=false;
  1027. end
  1028. else
  1029. doset:=true;
  1030. found:=false;
  1031. for opt:=low(tdebugswitch) to high(tdebugswitch) do
  1032. begin
  1033. if DebugSwitchStr[opt]=tok then
  1034. begin
  1035. found:=true;
  1036. break;
  1037. end;
  1038. end;
  1039. if found then
  1040. begin
  1041. if doset then
  1042. include(a,opt)
  1043. else
  1044. exclude(a,opt);
  1045. end
  1046. else
  1047. result:=false;
  1048. until false;
  1049. end;
  1050. function IncludeFeature(const s : string) : boolean;
  1051. var
  1052. i : tfeature;
  1053. begin
  1054. result:=true;
  1055. for i:=low(tfeature) to high(tfeature) do
  1056. if s=featurestr[i] then
  1057. begin
  1058. include(features,i);
  1059. exit;
  1060. end;
  1061. result:=false;
  1062. end;
  1063. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  1064. var
  1065. value, error: longint;
  1066. begin
  1067. if (upper(s)='DEFAULT') then
  1068. begin
  1069. a:=s32real;
  1070. result:=true;
  1071. exit;
  1072. end;
  1073. result:=false;
  1074. val(s,value,error);
  1075. if (error<>0) then
  1076. exit;
  1077. case value of
  1078. 32: a:=s32real;
  1079. 64: a:=s64real;
  1080. { adding support for 80 bit here is tricky, since we can't really }
  1081. { check whether the target cpu+OS actually supports it }
  1082. else
  1083. exit;
  1084. end;
  1085. result:=true;
  1086. end;
  1087. function var_align(siz: longint): shortint;
  1088. begin
  1089. siz := size_2_align(siz);
  1090. var_align := used_align(siz,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
  1091. end;
  1092. function const_align(siz: longint): shortint;
  1093. begin
  1094. siz := size_2_align(siz);
  1095. const_align := used_align(siz,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
  1096. end;
  1097. {$ifdef ARM}
  1098. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  1099. begin
  1100. result := (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  1101. not(cs_fp_emulation in current_settings.moduleswitches);
  1102. {$ifdef FPC_DOUBLE_HILO_SWAPPED}
  1103. { inverse result if compiler was compiled with swapped hilo already }
  1104. result := not result;
  1105. {$endif FPC_DOUBLE_HILO_SWAPPED}
  1106. end;
  1107. {$endif ARM}
  1108. function floating_point_range_check_error : boolean;
  1109. begin
  1110. result:=((([cs_check_range,cs_check_overflow]*current_settings.localswitches)<>[]) and not
  1111. (m_delphi in current_settings.modeswitches)
  1112. ); // or (cs_ieee_errors in current_settings.localswitches);
  1113. end;
  1114. {****************************************************************************
  1115. Init
  1116. ****************************************************************************}
  1117. {$ifdef unix}
  1118. {$define need_path_search}
  1119. {$endif unix}
  1120. {$ifdef os2}
  1121. {$define need_path_search}
  1122. {$endif os2}
  1123. {$ifdef macos}
  1124. {$define need_path_search}
  1125. {$endif macos}
  1126. procedure get_exepath;
  1127. var
  1128. localExepath : TCmdStr;
  1129. exeName:TCmdStr;
  1130. {$ifdef need_path_search}
  1131. hs1 : TPathStr;
  1132. {$endif need_path_search}
  1133. begin
  1134. localexepath:=GetEnvironmentVariable('PPC_EXEC_PATH');
  1135. if localexepath='' then
  1136. begin
  1137. exeName := FixFileName(system.paramstr(0));
  1138. localexepath := ExtractFilePath(exeName);
  1139. end;
  1140. {$ifdef need_path_search}
  1141. if localexepath='' then
  1142. begin
  1143. hs1 := ExtractFileName(exeName);
  1144. ChangeFileExt(hs1,source_info.exeext);
  1145. {$ifdef macos}
  1146. FindFile(hs1,GetEnvironmentVariable('Commands'),false,localExepath);
  1147. {$else macos}
  1148. FindFile(hs1,GetEnvironmentVariable('PATH'),false,localExepath);
  1149. {$endif macos}
  1150. localExepath:=ExtractFilePath(localExepath);
  1151. end;
  1152. {$endif need_path_search}
  1153. exepath:=FixPath(localExepath,false);
  1154. end;
  1155. procedure DoneGlobals;
  1156. begin
  1157. if assigned(DLLImageBase) then
  1158. StringDispose(DLLImageBase);
  1159. librarysearchpath.Free;
  1160. unitsearchpath.Free;
  1161. objectsearchpath.Free;
  1162. includesearchpath.Free;
  1163. frameworksearchpath.Free;
  1164. LinkLibraryAliases.Free;
  1165. LinkLibraryOrder.Free;
  1166. end;
  1167. procedure InitGlobals;
  1168. begin
  1169. get_exepath;
  1170. { reset globals }
  1171. do_build:=false;
  1172. do_release:=false;
  1173. do_make:=true;
  1174. compile_level:=0;
  1175. DLLsource:=false;
  1176. paratarget:=system_none;
  1177. paratargetasm:=as_none;
  1178. paratargetdbg:=dbg_none;
  1179. { Output }
  1180. OutputFileName:='';
  1181. OutputPrefix:=Nil;
  1182. OutputSuffix:=Nil;
  1183. OutputExeDir:='';
  1184. OutputUnitDir:='';
  1185. { Utils directory }
  1186. utilsdirectory:='';
  1187. utilsprefix:='';
  1188. cshared:=false;
  1189. rlinkpath:='';
  1190. sysrootpath:='';
  1191. { Search Paths }
  1192. librarysearchpath:=TSearchPathList.Create;
  1193. unitsearchpath:=TSearchPathList.Create;
  1194. includesearchpath:=TSearchPathList.Create;
  1195. objectsearchpath:=TSearchPathList.Create;
  1196. frameworksearchpath:=TSearchPathList.Create;
  1197. { Def file }
  1198. usewindowapi:=false;
  1199. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1200. DescriptionSetExplicity:=false;
  1201. SetPEFlagsSetExplicity:=false;
  1202. ImageBaseSetExplicity:=false;
  1203. MinStackSizeSetExplicity:=false;
  1204. MaxStackSizeSetExplicity:=false;
  1205. dllversion:='';
  1206. dllmajor:=1;
  1207. dllminor:=0;
  1208. dllrevision:=0;
  1209. nwscreenname := '';
  1210. nwthreadname := '';
  1211. nwcopyright := '';
  1212. UseDeffileForExports:=false;
  1213. UseDeffileForExportsSetExplicitly:=false;
  1214. GenerateImportSection:=false;
  1215. RelocSection:=false;
  1216. RelocSectionSetExplicitly:=false;
  1217. LinkTypeSetExplicitly:=false;
  1218. { memory sizes, will be overriden by parameter or default for target
  1219. in options or init_parser }
  1220. stacksize:=0;
  1221. { not initialized yet }
  1222. jmp_buf_size:=-1;
  1223. apptype:=app_cui;
  1224. { Init values }
  1225. init_settings:=default_settings;
  1226. if init_settings.optimizecputype=cpu_none then
  1227. init_settings.optimizecputype:=init_settings.cputype;
  1228. LinkLibraryAliases :=TLinkStrMap.Create;
  1229. LinkLibraryOrder :=TLinkStrMap.Create;
  1230. { enable all features by default }
  1231. features:=[low(Tfeature)..high(Tfeature)];
  1232. end;
  1233. end.