scandir.pas 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012
  1. {
  2. Copyright (c) 1998-2002 by Peter Vreman
  3. This unit implements directive parsing for the scanner
  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 scandir;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. systems;
  23. const
  24. switchesstatestackmax = 20;
  25. type
  26. tsavedswitchesstate = record
  27. localsw: tlocalswitches;
  28. verbosity: longint;
  29. pmessage : pmessagestaterecord;
  30. alignment : talignmentinfo;
  31. setalloc,
  32. packenum,
  33. packrecords : shortint;
  34. end;
  35. type
  36. tswitchesstatestack = array[0..switchesstatestackmax] of tsavedswitchesstate;
  37. var
  38. switchesstatestack:tswitchesstatestack;
  39. switchesstatestackpos: Integer;
  40. procedure InitScannerDirectives;
  41. implementation
  42. uses
  43. SysUtils,
  44. cutils,cfileutl,
  45. globals,widestr,cpuinfo,
  46. verbose,comphook,ppu,
  47. scanner,switches,
  48. fmodule,
  49. defutil,
  50. dirparse,link,
  51. syscinfo,
  52. symconst,symtable,symbase,symtype,symsym,
  53. rabase;
  54. {*****************************************************************************
  55. Helpers
  56. *****************************************************************************}
  57. procedure do_delphiswitch(sw:char);
  58. var
  59. state : char;
  60. begin
  61. { c contains the next char, a + or - would be fine }
  62. state:=current_scanner.readstate;
  63. if state in ['-','+'] then
  64. HandleSwitch(sw,state);
  65. end;
  66. procedure do_setverbose(flag:char);
  67. var
  68. state : char;
  69. begin
  70. { support ON/OFF }
  71. state:=current_scanner.ReadState;
  72. recordpendingverbosityswitch(flag,state);
  73. end;
  74. procedure do_moduleswitch(sw:tmoduleswitch);
  75. var
  76. state : char;
  77. begin
  78. state:=current_scanner.readstate;
  79. if (sw<>cs_modulenone) and (state in ['-','+']) then
  80. begin
  81. if state='-' then
  82. exclude(current_settings.moduleswitches,sw)
  83. else
  84. include(current_settings.moduleswitches,sw);
  85. end;
  86. end;
  87. procedure do_localswitch(sw:tlocalswitch);
  88. var
  89. state : char;
  90. begin
  91. state:=current_scanner.readstate;
  92. if (sw<>cs_localnone) and (state in ['-','+']) then
  93. recordpendinglocalswitch(sw,state);
  94. end;
  95. function do_localswitchdefault(sw:tlocalswitch): char;
  96. begin
  97. result:=current_scanner.readstatedefault;
  98. if (sw<>cs_localnone) and (result in ['-','+','*']) then
  99. recordpendinglocalswitch(sw,result);
  100. end;
  101. procedure do_moduleflagswitch(flag:cardinal;optional:boolean);
  102. var
  103. state : char;
  104. begin
  105. if optional then
  106. state:=current_scanner.readoptionalstate('+')
  107. else
  108. state:=current_scanner.readstate;
  109. if state='-' then
  110. current_module.flags:=current_module.flags and not flag
  111. else
  112. current_module.flags:=current_module.flags or flag;
  113. end;
  114. procedure do_message(w:integer);
  115. begin
  116. current_scanner.skipspace;
  117. Message1(w,current_scanner.readcomment);
  118. end;
  119. procedure do_version(out major, minor, revision: word; out verstr: string; allowrevision: boolean; out isset: boolean);
  120. var
  121. majorl,
  122. minorl,
  123. revisionl,
  124. error : longint;
  125. begin
  126. { change description global var in all cases }
  127. { it not used but in win32, os2 and netware }
  128. current_scanner.skipspace;
  129. { we should only accept Major.Minor format for win32 and os2 }
  130. current_scanner.readnumber;
  131. major:=0;
  132. minor:=0;
  133. revision:=0;
  134. verstr:='';
  135. isset:=false;
  136. majorl:=0;
  137. minorl:=0;
  138. revisionl:=0;
  139. val(pattern,majorl,error);
  140. if (error<>0) or (majorl > high(word)) or (majorl < 0) then
  141. begin
  142. Message1(scan_w_wrong_version_ignored,pattern);
  143. exit;
  144. end;
  145. isset:=true;
  146. if c='.' then
  147. begin
  148. current_scanner.readchar;
  149. current_scanner.readnumber;
  150. val(pattern,minorl,error);
  151. if (error<>0) or (minorl > high(word)) or (minorl < 0) then
  152. begin
  153. Message1(scan_w_wrong_version_ignored,tostr(majorl)+'.'+pattern);
  154. exit;
  155. end;
  156. if (c='.') and
  157. allowrevision then
  158. begin
  159. current_scanner.readchar;
  160. current_scanner.readnumber;
  161. val(pattern,revisionl,error);
  162. if (error<>0) or (revisionl > high(word)) or (revisionl < 0) then
  163. begin
  164. Message1(scan_w_wrong_version_ignored,tostr(majorl)+'.'+tostr(minorl)+'.'+pattern);
  165. exit;
  166. end;
  167. major:=word(majorl);
  168. minor:=word(minorl);
  169. revision:=word(revisionl);
  170. verstr:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  171. end
  172. else
  173. begin
  174. major:=word(majorl);
  175. minor:=word(minorl);
  176. verstr:=tostr(major)+'.'+tostr(minor);
  177. end;
  178. end
  179. else
  180. begin
  181. major:=word(majorl);
  182. verstr:=tostr(major);
  183. end;
  184. end;
  185. {*****************************************************************************
  186. Directive Callbacks
  187. *****************************************************************************}
  188. procedure dir_align;
  189. var
  190. hs : string;
  191. b : byte;
  192. begin
  193. current_scanner.skipspace;
  194. if not(c in ['0'..'9']) then
  195. begin
  196. { Support also the ON and OFF as switch }
  197. hs:=current_scanner.readid;
  198. if (hs='ON') then
  199. current_settings.packrecords:=4
  200. else if (hs='OFF') then
  201. current_settings.packrecords:=1
  202. else if m_mac in current_settings.modeswitches then
  203. begin
  204. { Support switches used in Apples Universal Interfaces}
  205. if (hs='MAC68K') then
  206. current_settings.packrecords:=mac68k_alignment
  207. { "power" alignment is the default C packrecords setting on
  208. Mac OS X }
  209. else if (hs='POWER') or (hs='POWERPC') then
  210. current_settings.packrecords:=C_alignment
  211. else if (hs='RESET') then
  212. current_settings.packrecords:=default_settings.packrecords
  213. else
  214. Message1(scan_e_illegal_pack_records,hs);
  215. end
  216. else
  217. Message1(scan_e_illegal_pack_records,hs);
  218. end
  219. else
  220. begin
  221. b:=current_scanner.readval;
  222. case b of
  223. 1 : current_settings.packrecords:=1;
  224. 2 : current_settings.packrecords:=2;
  225. 4 : current_settings.packrecords:=4;
  226. 8 : current_settings.packrecords:=8;
  227. 16 : current_settings.packrecords:=16;
  228. 32 : current_settings.packrecords:=32;
  229. else
  230. Message1(scan_e_illegal_pack_records,tostr(b));
  231. end;
  232. end;
  233. end;
  234. procedure dir_a1;
  235. begin
  236. current_settings.packrecords:=1;
  237. end;
  238. procedure dir_a2;
  239. begin
  240. current_settings.packrecords:=2;
  241. end;
  242. procedure dir_a4;
  243. begin
  244. current_settings.packrecords:=4;
  245. end;
  246. procedure dir_a8;
  247. begin
  248. current_settings.packrecords:=8;
  249. end;
  250. procedure dir_asmcpu;
  251. var
  252. s : string;
  253. cpu: tcputype;
  254. found: Boolean;
  255. begin
  256. current_scanner.skipspace;
  257. s:=current_scanner.readid;
  258. If Inside_asm_statement then
  259. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  260. if s='ANY' then
  261. current_settings.asmcputype:=cpu_none
  262. else if s='CURRENT' then
  263. current_settings.asmcputype:=current_settings.cputype
  264. else
  265. begin
  266. found:=false;
  267. for cpu:=succ(low(tcputype)) to high(tcputype) do
  268. if s=cputypestr[cpu] then
  269. begin
  270. found:=true;
  271. current_settings.asmcputype:=cpu;
  272. break;
  273. end;
  274. if not found then
  275. Message1(scan_e_illegal_asmcpu_specifier,s);
  276. end;
  277. end;
  278. procedure dir_asmmode;
  279. var
  280. s : string;
  281. begin
  282. current_scanner.skipspace;
  283. s:=current_scanner.readid;
  284. If Inside_asm_statement then
  285. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  286. if s='DEFAULT' then
  287. current_settings.asmmode:=init_settings.asmmode
  288. else
  289. if not SetAsmReadMode(s,current_settings.asmmode) then
  290. Message1(scan_e_illegal_asmmode_specifier,s);
  291. end;
  292. {$if defined(m68k) or defined(arm)}
  293. procedure dir_appid;
  294. begin
  295. if target_info.system<>system_m68k_palmos then
  296. Message(scan_w_appid_not_support);
  297. { change description global var in all cases }
  298. { it not used but in win32 and os2 }
  299. current_scanner.skipspace;
  300. palmos_applicationid:=current_scanner.readcomment;
  301. end;
  302. procedure dir_appname;
  303. begin
  304. if target_info.system<>system_m68k_palmos then
  305. Message(scan_w_appname_not_support);
  306. { change description global var in all cases }
  307. { it not used but in win32 and os2 }
  308. current_scanner.skipspace;
  309. palmos_applicationname:=current_scanner.readcomment;
  310. end;
  311. {$endif defined(m68k) or defined(arm)}
  312. procedure dir_apptype;
  313. var
  314. hs : string;
  315. begin
  316. if not (target_info.system in systems_all_windows + [system_i386_os2,
  317. system_i386_emx, system_powerpc_macos,
  318. system_arm_nds, system_i8086_msdos,
  319. system_i8086_embedded, system_m68k_atari] +
  320. systems_nativent) then
  321. begin
  322. if m_delphi in current_settings.modeswitches then
  323. Message(scan_n_app_type_not_support)
  324. else
  325. Message(scan_w_app_type_not_support);
  326. end
  327. else
  328. begin
  329. if not current_module.in_global then
  330. Message(scan_w_switch_is_global)
  331. else
  332. begin
  333. current_scanner.skipspace;
  334. hs:=current_scanner.readid;
  335. if (hs='GUI') and not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  336. SetApptype(app_gui)
  337. else if (hs='CONSOLE') and not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  338. SetApptype(app_cui)
  339. else if (hs='NATIVE') and (target_info.system in systems_windows + systems_nativent) then
  340. SetApptype(app_native)
  341. else if (hs='FS') and (target_info.system in [system_i386_os2,
  342. system_i386_emx]) then
  343. SetApptype(app_fs)
  344. else if (hs='TOOL') and (target_info.system in [system_powerpc_macos]) then
  345. SetApptype(app_tool)
  346. else if (hs='ARM9') and (target_info.system in [system_arm_nds]) then
  347. SetApptype(app_arm9)
  348. else if (hs='ARM7') and (target_info.system in [system_arm_nds]) then
  349. SetApptype(app_arm7)
  350. else if (hs='COM') and (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  351. SetApptype(app_com)
  352. else if (hs='EXE') and (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  353. SetApptype(app_cui)
  354. else
  355. Message1(scan_w_unsupported_app_type,hs);
  356. end;
  357. end;
  358. end;
  359. procedure dir_calling;
  360. var
  361. hs : string;
  362. begin
  363. current_scanner.skipspace;
  364. hs:=current_scanner.readid;
  365. if (hs='') then
  366. Message(parser_e_proc_directive_expected)
  367. else
  368. recordpendingcallingswitch(hs);
  369. end;
  370. procedure dir_checklowaddrloads;
  371. begin
  372. do_localswitchdefault(cs_check_low_addr_load);
  373. end;
  374. procedure dir_checkpointer;
  375. var
  376. switch: char;
  377. begin
  378. switch:=do_localswitchdefault(cs_checkpointer);
  379. if (switch='+') and
  380. not(target_info.system in systems_support_checkpointer) then
  381. Message1(scan_e_unsupported_switch,'CHECKPOINTER+');
  382. end;
  383. procedure dir_objectchecks;
  384. begin
  385. do_localswitch(cs_check_object);
  386. end;
  387. procedure dir_ieeeerrors;
  388. begin
  389. do_localswitch(cs_ieee_errors);
  390. end;
  391. procedure dir_assertions;
  392. begin
  393. do_delphiswitch('C');
  394. end;
  395. procedure dir_booleval;
  396. begin
  397. do_delphiswitch('B');
  398. end;
  399. procedure dir_debuginfo;
  400. begin
  401. do_delphiswitch('D');
  402. end;
  403. procedure dir_denypackageunit;
  404. begin
  405. do_moduleflagswitch(uf_package_deny,true);
  406. end;
  407. procedure dir_description;
  408. begin
  409. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  410. system_i386_netware,system_i386_wdosx,system_i386_netwlibc]) then
  411. Message(scan_w_description_not_support);
  412. { change description global var in all cases }
  413. { it not used but in win32, os2 and netware }
  414. current_scanner.skipspace;
  415. description:=current_scanner.readcomment;
  416. DescriptionSetExplicity:=true;
  417. end;
  418. procedure dir_screenname; {ad}
  419. begin
  420. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  421. {Message(scan_w_decription_not_support);}
  422. comment (V_Warning,'Screenname only supported for target netware');
  423. current_scanner.skipspace;
  424. nwscreenname:=current_scanner.readcomment;
  425. end;
  426. procedure dir_threadname; {ad}
  427. begin
  428. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  429. {Message(scan_w_decription_not_support);}
  430. comment (V_Warning,'Threadname only supported for target netware');
  431. current_scanner.skipspace;
  432. nwthreadname:=current_scanner.readcomment;
  433. end;
  434. procedure dir_copyright; {ad}
  435. begin
  436. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  437. {Message(scan_w_decription_not_support);}
  438. comment (V_Warning,'Copyright only supported for target netware');
  439. current_scanner.skipspace;
  440. nwcopyright:=current_scanner.readcomment;
  441. end;
  442. procedure dir_error;
  443. begin
  444. do_message(scan_e_user_defined);
  445. end;
  446. procedure dir_extendedsyntax;
  447. begin
  448. do_delphiswitch('X');
  449. end;
  450. procedure dir_forcefarcalls;
  451. begin
  452. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
  453. {$ifdef i8086}
  454. or (current_settings.x86memorymodel in x86_near_code_models)
  455. {$endif i8086}
  456. then
  457. begin
  458. Message1(scan_n_ignored_switch,pattern);
  459. exit;
  460. end;
  461. do_localswitch(cs_force_far_calls);
  462. end;
  463. procedure dir_fatal;
  464. begin
  465. do_message(scan_f_user_defined);
  466. end;
  467. procedure dir_fputype;
  468. begin
  469. current_scanner.skipspace;
  470. undef_system_macro('FPU'+fputypestr[current_settings.fputype]);
  471. if not(SetFPUType(upper(current_scanner.readcomment),current_settings.fputype)) then
  472. comment(V_Error,'Illegal FPU type');
  473. def_system_macro('FPU'+fputypestr[current_settings.fputype]);
  474. end;
  475. procedure dir_frameworkpath;
  476. begin
  477. if not current_module.in_global then
  478. Message(scan_w_switch_is_global)
  479. else if not(target_info.system in systems_darwin) then
  480. begin
  481. Message(scan_w_frameworks_darwin_only);
  482. current_scanner.skipspace;
  483. current_scanner.readcomment
  484. end
  485. else
  486. begin
  487. current_scanner.skipspace;
  488. current_module.localframeworksearchpath.AddPath(current_scanner.readcomment,false);
  489. end;
  490. end;
  491. procedure dir_goto;
  492. begin
  493. do_moduleswitch(cs_support_goto);
  494. end;
  495. procedure dir_hint;
  496. begin
  497. do_message(scan_h_user_defined);
  498. end;
  499. procedure dir_hints;
  500. begin
  501. do_setverbose('H');
  502. end;
  503. procedure dir_imagebase;
  504. begin
  505. if not (target_info.system in (systems_windows+systems_wince)) then
  506. Message(scan_w_imagebase_not_support);
  507. current_scanner.skipspace;
  508. imagebase:=current_scanner.readval;
  509. ImageBaseSetExplicity:=true
  510. end;
  511. procedure dir_implicitexceptions;
  512. begin
  513. do_moduleswitch(cs_implicit_exceptions);
  514. end;
  515. procedure dir_importeddata;
  516. begin
  517. do_delphiswitch('G');
  518. end;
  519. procedure dir_includepath;
  520. begin
  521. if not current_module.in_global then
  522. Message(scan_w_switch_is_global)
  523. else
  524. begin
  525. current_scanner.skipspace;
  526. current_module.localincludesearchpath.AddPath(current_scanner.readcomment,false);
  527. end;
  528. end;
  529. procedure dir_info;
  530. begin
  531. do_message(scan_i_user_defined);
  532. end;
  533. procedure dir_inline;
  534. begin
  535. do_localswitch(cs_do_inline);
  536. end;
  537. procedure dir_interfaces;
  538. var
  539. hs : string;
  540. begin
  541. {corba/com/default}
  542. current_scanner.skipspace;
  543. hs:=current_scanner.readid;
  544. {$ifndef jvm}
  545. if (hs='CORBA') then
  546. current_settings.interfacetype:=it_interfacecorba
  547. else if (hs='COM') then
  548. current_settings.interfacetype:=it_interfacecom
  549. else
  550. {$endif jvm}
  551. if (hs='DEFAULT') then
  552. current_settings.interfacetype:=init_settings.interfacetype
  553. else
  554. Message(scan_e_invalid_interface_type);
  555. end;
  556. procedure dir_iochecks;
  557. begin
  558. do_delphiswitch('I');
  559. end;
  560. procedure dir_libexport;
  561. begin
  562. {not implemented}
  563. end;
  564. procedure dir_librarypath;
  565. begin
  566. if not current_module.in_global then
  567. Message(scan_w_switch_is_global)
  568. else
  569. begin
  570. current_scanner.skipspace;
  571. current_module.locallibrarysearchpath.AddPath(current_scanner.readcomment,false);
  572. end;
  573. end;
  574. procedure dir_link;
  575. var
  576. s : string;
  577. begin
  578. current_scanner.skipspace;
  579. if scanner.c = '''' then
  580. begin
  581. s:= current_scanner.readquotedstring;
  582. current_scanner.readcomment
  583. end
  584. else
  585. s:= trimspace(current_scanner.readcomment);
  586. s:=FixFileName(s);
  587. if ExtractFileExt(s)='' then
  588. s:=ChangeFileExt(s,target_info.objext);
  589. current_module.linkotherofiles.add(s,link_always);
  590. end;
  591. procedure dir_linkframework;
  592. var
  593. s : string;
  594. begin
  595. current_scanner.skipspace;
  596. if scanner.c = '''' then
  597. begin
  598. s:= current_scanner.readquotedstring;
  599. current_scanner.readcomment
  600. end
  601. else
  602. s:= trimspace(current_scanner.readcomment);
  603. s:=FixFileName(s);
  604. if (target_info.system in systems_darwin) then
  605. current_module.linkotherframeworks.add(s,link_always)
  606. else
  607. Message(scan_w_frameworks_darwin_only);
  608. end;
  609. procedure dir_linklib;
  610. type
  611. tLinkMode=(lm_shared,lm_static);
  612. var
  613. s : string;
  614. quote : char;
  615. libext,
  616. libname,
  617. linkmodestr : string;
  618. p : longint;
  619. linkMode : tLinkMode;
  620. begin
  621. current_scanner.skipspace;
  622. if scanner.c = '''' then
  623. begin
  624. libname:= current_scanner.readquotedstring;
  625. s:= current_scanner.readcomment;
  626. p:=pos(',',s);
  627. end
  628. else
  629. begin
  630. s:= current_scanner.readcomment;
  631. p:=pos(',',s);
  632. if p=0 then
  633. libname:=TrimSpace(s)
  634. else
  635. libname:=TrimSpace(copy(s,1,p-1));
  636. end;
  637. if p=0 then
  638. linkmodeStr:=''
  639. else
  640. linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
  641. if (libname='') or (libname='''''') or (libname='""') then
  642. exit;
  643. { create library name }
  644. if libname[1] in ['''','"'] then
  645. begin
  646. quote:=libname[1];
  647. Delete(libname,1,1);
  648. p:=pos(quote,libname);
  649. if p>0 then
  650. Delete(libname,p,1);
  651. end;
  652. libname:=FixFileName(libname);
  653. { get linkmode, default is to check the extension for
  654. the static library, otherwise shared linking is assumed }
  655. linkmode:=lm_shared;
  656. if linkModeStr='' then
  657. begin
  658. libext:=ExtractFileExt(libname);
  659. if libext=target_info.staticClibext then
  660. linkMode:=lm_static;
  661. end
  662. else if linkModeStr='STATIC' then
  663. linkmode:=lm_static
  664. else if (LinkModeStr='SHARED') or (LinkModeStr='') then
  665. linkmode:=lm_shared
  666. else
  667. Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
  668. { add to the list of other libraries }
  669. if linkMode=lm_static then
  670. current_module.linkOtherStaticLibs.add(libname,link_always)
  671. else
  672. current_module.linkOtherSharedLibs.add(libname,link_always);
  673. end;
  674. procedure dir_localsymbols;
  675. begin
  676. do_delphiswitch('L');
  677. end;
  678. procedure dir_longstrings;
  679. begin
  680. do_delphiswitch('H');
  681. end;
  682. procedure dir_macro;
  683. begin
  684. do_moduleswitch(cs_support_macro);
  685. end;
  686. procedure dir_pascalmainname;
  687. var
  688. s: string;
  689. begin
  690. current_scanner.skipspace;
  691. s:=trimspace(current_scanner.readcomment);
  692. if assigned(current_module.mainname) and
  693. (s<>current_module.mainname^) then
  694. begin
  695. Message1(scan_w_multiple_main_name_overrides,current_module.mainname^);
  696. stringdispose(current_module.mainname)
  697. end
  698. else if (mainaliasname<>defaultmainaliasname) and
  699. (mainaliasname<>s) then
  700. Message1(scan_w_multiple_main_name_overrides,mainaliasname);
  701. mainaliasname:=s;
  702. if (mainaliasname<>defaultmainaliasname) then
  703. current_module.mainname:=stringdup(mainaliasname);
  704. end;
  705. procedure dir_maxfpuregisters;
  706. var
  707. l : integer;
  708. hs : string;
  709. begin
  710. current_scanner.skipspace;
  711. if not(c in ['0'..'9']) then
  712. begin
  713. hs:=current_scanner.readid;
  714. if (hs='NORMAL') or (hs='DEFAULT') then
  715. current_settings.maxfpuregisters:=-1
  716. else
  717. Message(scan_e_invalid_maxfpureg_value);
  718. end
  719. else
  720. begin
  721. l:=current_scanner.readval;
  722. case l of
  723. 0..8:
  724. current_settings.maxfpuregisters:=l;
  725. else
  726. Message(scan_e_invalid_maxfpureg_value);
  727. end;
  728. end;
  729. end;
  730. procedure dir_maxstacksize;
  731. begin
  732. if not (target_info.system in (systems_windows+systems_wince)) then
  733. Message(scan_w_maxstacksize_not_support);
  734. current_scanner.skipspace;
  735. maxstacksize:=current_scanner.readval;
  736. MaxStackSizeSetExplicity:=true;
  737. end;
  738. procedure dir_memory;
  739. var
  740. l : longint;
  741. heapsize_limit: longint;
  742. maxheapsize_limit: longint;
  743. begin
  744. {$if defined(i8086)}
  745. if current_settings.x86memorymodel in x86_far_data_models then
  746. begin
  747. heapsize_limit:=655360;
  748. maxheapsize_limit:=655360;
  749. end
  750. else
  751. begin
  752. heapsize_limit:=65520;
  753. maxheapsize_limit:=65520;
  754. end;
  755. {$elseif defined(cpu16bitaddr)}
  756. heapsize_limit:=65520;
  757. maxheapsize_limit:=65520;
  758. {$else}
  759. heapsize_limit:=high(heapsize);
  760. maxheapsize_limit:=high(maxheapsize);
  761. {$endif}
  762. current_scanner.skipspace;
  763. l:=current_scanner.readval;
  764. if (l>=1024)
  765. {$ifdef cpu16bitaddr}
  766. and (l<=65521) { TP7's $M directive allows specifying a stack size of
  767. 65521, but it actually sets the stack size to 65520 }
  768. {$else cpu16bitaddr}
  769. and (l<67107840)
  770. {$endif cpu16bitaddr}
  771. then
  772. stacksize:=min(l,{$ifdef cpu16bitaddr}65520{$else}67107839{$endif})
  773. else
  774. Message(scan_w_invalid_stacksize);
  775. if c=',' then
  776. begin
  777. current_scanner.readchar;
  778. current_scanner.skipspace;
  779. l:=current_scanner.readval;
  780. if l>=1024 then
  781. heapsize:=min(l,heapsize_limit);
  782. if c=',' then
  783. begin
  784. current_scanner.readchar;
  785. current_scanner.skipspace;
  786. l:=current_scanner.readval;
  787. if l>=heapsize then
  788. maxheapsize:=min(l,maxheapsize_limit)
  789. else
  790. Message(scan_w_heapmax_lessthan_heapmin);
  791. end;
  792. end;
  793. end;
  794. procedure dir_message;
  795. var
  796. hs : string;
  797. w : longint;
  798. begin
  799. w:=0;
  800. current_scanner.skipspace;
  801. { Message level specified? }
  802. if c='''' then
  803. w:=scan_n_user_defined
  804. else
  805. begin
  806. hs:=current_scanner.readid;
  807. if (hs='WARN') or (hs='WARNING') then
  808. w:=scan_w_user_defined
  809. else
  810. if (hs='ERROR') then
  811. w:=scan_e_user_defined
  812. else
  813. if (hs='FATAL') then
  814. w:=scan_f_user_defined
  815. else
  816. if (hs='HINT') then
  817. w:=scan_h_user_defined
  818. else
  819. if (hs='NOTE') then
  820. w:=scan_n_user_defined
  821. else
  822. if (hs='INFO') then
  823. w:=scan_i_user_defined
  824. else
  825. Message1(scan_w_illegal_directive,hs);
  826. end;
  827. { Only print message when there was no error }
  828. if w<>0 then
  829. begin
  830. current_scanner.skipspace;
  831. if c='''' then
  832. hs:=current_scanner.readquotedstring
  833. else
  834. hs:=current_scanner.readcomment;
  835. Message1(w,hs);
  836. end
  837. else
  838. current_scanner.readcomment;
  839. end;
  840. procedure dir_minstacksize;
  841. begin
  842. if not (target_info.system in (systems_windows+systems_wince)) then
  843. Message(scan_w_minstacksize_not_support);
  844. current_scanner.skipspace;
  845. minstacksize:=current_scanner.readval;
  846. MinStackSizeSetExplicity:=true;
  847. end;
  848. procedure dir_mode;
  849. begin
  850. if not current_module.in_global then
  851. Message(scan_w_switch_is_global)
  852. else
  853. begin
  854. current_scanner.skipspace;
  855. current_scanner.readstring;
  856. if not current_module.mode_switch_allowed and
  857. not ((m_mac in current_settings.modeswitches) and (pattern='MACPAS')) then
  858. Message1(scan_e_mode_switch_not_allowed,pattern)
  859. else if not SetCompileMode(pattern,false) then
  860. Message1(scan_w_illegal_switch,pattern)
  861. end;
  862. current_module.mode_switch_allowed:= false;
  863. end;
  864. procedure dir_modeswitch;
  865. var
  866. s : string;
  867. begin
  868. if not current_module.in_global then
  869. Message(scan_w_switch_is_global)
  870. else
  871. begin
  872. current_scanner.skipspace;
  873. current_scanner.readstring;
  874. s:=pattern;
  875. if c in ['+','-'] then
  876. s:=s+current_scanner.readstate;
  877. if not SetCompileModeSwitch(s,false) then
  878. Message1(scan_w_illegal_switch,s)
  879. end;
  880. end;
  881. procedure dir_namespace;
  882. var
  883. s : string;
  884. begin
  885. { used to define Java package names for all types declared in the
  886. current unit }
  887. if not current_module.in_global then
  888. Message(scan_w_switch_is_global)
  889. else
  890. begin
  891. current_scanner.skipspace;
  892. current_scanner.readstring;
  893. s:=orgpattern;
  894. while c='.' do
  895. begin
  896. current_scanner.readchar;
  897. current_scanner.readstring;
  898. s:=s+'.'+orgpattern;
  899. end;
  900. disposestr(current_module.namespace);
  901. current_module.namespace:=stringdup(s);
  902. end;
  903. end;
  904. procedure dir_mmx;
  905. begin
  906. do_localswitch(cs_mmx);
  907. end;
  908. procedure dir_note;
  909. begin
  910. do_message(scan_n_user_defined);
  911. end;
  912. procedure dir_notes;
  913. begin
  914. do_setverbose('N');
  915. end;
  916. procedure dir_objectpath;
  917. begin
  918. if not current_module.in_global then
  919. Message(scan_w_switch_is_global)
  920. else
  921. begin
  922. current_scanner.skipspace;
  923. current_module.localobjectsearchpath.AddPath(current_scanner.readcomment,false);
  924. end;
  925. end;
  926. procedure dir_openstrings;
  927. begin
  928. do_delphiswitch('P');
  929. end;
  930. procedure dir_optimization;
  931. var
  932. hs : string;
  933. begin
  934. current_scanner.skipspace;
  935. { Support also the ON and OFF as switch }
  936. hs:=current_scanner.readid;
  937. if (hs='ON') then
  938. current_settings.optimizerswitches:=level2optimizerswitches
  939. else if (hs='OFF') then
  940. current_settings.optimizerswitches:=[]
  941. else if (hs='DEFAULT') then
  942. current_settings.optimizerswitches:=init_settings.optimizerswitches
  943. else
  944. begin
  945. if not UpdateOptimizerStr(hs,current_settings.optimizerswitches) then
  946. Message1(scan_e_illegal_optimization_specifier,hs);
  947. end;
  948. end;
  949. procedure dir_overflowchecks;
  950. begin
  951. do_delphiswitch('Q');
  952. end;
  953. procedure dir_packenum;
  954. var
  955. hs : string;
  956. begin
  957. current_scanner.skipspace;
  958. if not(c in ['0'..'9']) then
  959. begin
  960. hs:=current_scanner.readid;
  961. if (hs='NORMAL') or (hs='DEFAULT') then
  962. current_settings.packenum:=4
  963. else
  964. Message1(scan_e_illegal_pack_enum, hs);
  965. end
  966. else
  967. begin
  968. case current_scanner.readval of
  969. 1 : current_settings.packenum:=1;
  970. 2 : current_settings.packenum:=2;
  971. 4 : current_settings.packenum:=4;
  972. else
  973. Message1(scan_e_illegal_pack_enum, pattern);
  974. end;
  975. end;
  976. end;
  977. procedure dir_minfpconstprec;
  978. begin
  979. current_scanner.skipspace;
  980. if not SetMinFPConstPrec(current_scanner.readid,current_settings.minfpconstprec) then
  981. Message1(scan_e_illegal_minfpconstprec, pattern);
  982. end;
  983. procedure dir_packrecords;
  984. var
  985. hs : string;
  986. begin
  987. { can't change packrecords setting on managed vm targets }
  988. if target_info.system in systems_managed_vm then
  989. Message1(scanner_w_directive_ignored_on_target, 'PACKRECORDS');
  990. current_scanner.skipspace;
  991. if not(c in ['0'..'9']) then
  992. begin
  993. hs:=current_scanner.readid;
  994. { C has the special recordalignmax of C_alignment }
  995. if (hs='C') then
  996. current_settings.packrecords:=C_alignment
  997. else
  998. if (hs='NORMAL') or (hs='DEFAULT') then
  999. current_settings.packrecords:=default_settings.packrecords
  1000. else
  1001. Message1(scan_e_illegal_pack_records,hs);
  1002. end
  1003. else
  1004. begin
  1005. case current_scanner.readval of
  1006. 1 : current_settings.packrecords:=1;
  1007. 2 : current_settings.packrecords:=2;
  1008. 4 : current_settings.packrecords:=4;
  1009. 8 : current_settings.packrecords:=8;
  1010. 16 : current_settings.packrecords:=16;
  1011. 32 : current_settings.packrecords:=32;
  1012. else
  1013. Message1(scan_e_illegal_pack_records,pattern);
  1014. end;
  1015. end;
  1016. end;
  1017. procedure dir_packset;
  1018. var
  1019. hs : string;
  1020. begin
  1021. current_scanner.skipspace;
  1022. if not(c in ['1','2','4','8']) then
  1023. begin
  1024. hs:=current_scanner.readid;
  1025. if (hs='FIXED') or (hs='DEFAULT') OR (hs='NORMAL') then
  1026. current_settings.setalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  1027. else
  1028. Message(scan_e_only_packset);
  1029. end
  1030. else
  1031. begin
  1032. case current_scanner.readval of
  1033. 1 : current_settings.setalloc:=1;
  1034. 2 : current_settings.setalloc:=2;
  1035. 4 : current_settings.setalloc:=4;
  1036. 8 : current_settings.setalloc:=8;
  1037. else
  1038. Message(scan_e_only_packset);
  1039. end;
  1040. end;
  1041. end;
  1042. procedure dir_pic;
  1043. begin
  1044. { windows doesn't need/support pic }
  1045. if tf_no_pic_supported in target_info.flags then
  1046. message(scan_w_pic_ignored)
  1047. else
  1048. do_moduleswitch(cs_create_pic);
  1049. end;
  1050. procedure dir_pop;
  1051. begin
  1052. if switchesstatestackpos < 1 then
  1053. Message(scan_e_too_many_pop);
  1054. Dec(switchesstatestackpos);
  1055. recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
  1056. recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
  1057. recordpendingalignmentfullswitch(switchesstatestack[switchesstatestackpos].alignment);
  1058. recordpendingpackenum(switchesstatestack[switchesstatestackpos].packenum);
  1059. recordpendingpackrecords(switchesstatestack[switchesstatestackpos].packrecords);
  1060. recordpendingsetalloc(switchesstatestack[switchesstatestackpos].setalloc);
  1061. pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
  1062. { Reset verbosity and forget previous pmeesage }
  1063. RestoreLocalVerbosity(nil);
  1064. current_settings.pmessage:=nil;
  1065. { Do not yet activate these changes, as otherwise
  1066. you get problem idf you put a $pop just right after
  1067. a addition for instance fro which you explicitly truned the overflow check
  1068. out by using $Q- after a $push PM 2012-08-29 }
  1069. // flushpendingswitchesstate;
  1070. end;
  1071. procedure dir_pointermath;
  1072. begin
  1073. do_localswitch(cs_pointermath);
  1074. end;
  1075. procedure dir_profile;
  1076. begin
  1077. do_moduleswitch(cs_profile);
  1078. { defined/undefine FPC_PROFILE }
  1079. if cs_profile in current_settings.moduleswitches then
  1080. def_system_macro('FPC_PROFILE')
  1081. else
  1082. undef_system_macro('FPC_PROFILE');
  1083. end;
  1084. procedure dir_push;
  1085. begin
  1086. if switchesstatestackpos > switchesstatestackmax then
  1087. Message(scan_e_too_many_push);
  1088. flushpendingswitchesstate;
  1089. switchesstatestack[switchesstatestackpos].localsw:= current_settings.localswitches;
  1090. switchesstatestack[switchesstatestackpos].pmessage:= current_settings.pmessage;
  1091. switchesstatestack[switchesstatestackpos].verbosity:=status.verbosity;
  1092. switchesstatestack[switchesstatestackpos].alignment:=current_settings.alignment;
  1093. switchesstatestack[switchesstatestackpos].setalloc:=current_settings.setalloc;
  1094. switchesstatestack[switchesstatestackpos].packenum:=current_settings.packenum;
  1095. switchesstatestack[switchesstatestackpos].packrecords:=current_settings.packrecords;
  1096. Inc(switchesstatestackpos);
  1097. end;
  1098. procedure dir_rangechecks;
  1099. begin
  1100. do_delphiswitch('R');
  1101. end;
  1102. procedure dir_referenceinfo;
  1103. begin
  1104. do_delphiswitch('Y');
  1105. end;
  1106. procedure dir_resource;
  1107. var
  1108. s : string;
  1109. begin
  1110. current_scanner.skipspace;
  1111. if scanner.c = '''' then
  1112. begin
  1113. s:= current_scanner.readquotedstring;
  1114. current_scanner.readcomment
  1115. end
  1116. else
  1117. s:= trimspace(current_scanner.readcomment);
  1118. { replace * with the name of the main source.
  1119. This should always be defined. }
  1120. if s[1]='*' then
  1121. if Assigned(Current_Module) then
  1122. begin
  1123. delete(S,1,1);
  1124. insert(ChangeFileExt(ExtractFileName(current_module.mainsource),''),S,1 );
  1125. end;
  1126. s:=FixFileName(s);
  1127. if ExtractFileExt(s)='' then
  1128. s:=ChangeFileExt(s,target_info.resext);
  1129. if target_info.res<>res_none then
  1130. begin
  1131. current_module.flags:=current_module.flags or uf_has_resourcefiles;
  1132. if (res_single_file in target_res.resflags) and
  1133. not (Current_module.ResourceFiles.Empty) then
  1134. Message(scan_w_only_one_resourcefile_supported)
  1135. else
  1136. current_module.resourcefiles.insert(FixFileName(s));
  1137. end
  1138. else
  1139. Message(scan_e_resourcefiles_not_supported);
  1140. end;
  1141. procedure dir_saturation;
  1142. begin
  1143. do_localswitch(cs_mmx_saturation);
  1144. end;
  1145. procedure dir_safefpuexceptions;
  1146. begin
  1147. do_localswitch(cs_fpu_fwait);
  1148. end;
  1149. procedure dir_scopedenums;
  1150. begin
  1151. do_localswitch(cs_scopedenums);
  1152. end;
  1153. function get_peflag_const(const ident:string;error:longint):longint;
  1154. var
  1155. srsym : tsym;
  1156. srsymtable : tsymtable;
  1157. begin
  1158. result:=0;
  1159. if searchsym(ident,srsym,srsymtable) then
  1160. if (srsym.typ=constsym) and
  1161. (tconstsym(srsym).consttyp=constord) and
  1162. is_integer(tconstsym(srsym).constdef) then
  1163. with tconstsym(srsym).value.valueord do
  1164. if signed then
  1165. result:=tconstsym(srsym).value.valueord.svalue
  1166. else
  1167. result:=tconstsym(srsym).value.valueord.uvalue
  1168. else
  1169. message(error)
  1170. else
  1171. message1(sym_e_id_not_found,ident);
  1172. end;
  1173. procedure dir_setpeflags;
  1174. var
  1175. ident : string;
  1176. begin
  1177. if not (target_info.system in (systems_all_windows)) then
  1178. Message(scan_w_setpeflags_not_support);
  1179. current_scanner.skipspace;
  1180. ident:=current_scanner.readid;
  1181. if ident<>'' then
  1182. peflags:=peflags or get_peflag_const(ident,scan_e_illegal_peflag)
  1183. else
  1184. peflags:=peflags or current_scanner.readval;
  1185. SetPEFlagsSetExplicity:=true;
  1186. end;
  1187. procedure dir_setpeoptflags;
  1188. var
  1189. ident : string;
  1190. begin
  1191. if not (target_info.system in (systems_all_windows)) then
  1192. Message(scan_w_setpeoptflags_not_support);
  1193. current_scanner.skipspace;
  1194. ident:=current_scanner.readid;
  1195. if ident<>'' then
  1196. peoptflags:=peoptflags or get_peflag_const(ident,scan_e_illegal_peoptflag)
  1197. else
  1198. peoptflags:=peoptflags or current_scanner.readval;
  1199. SetPEOptFlagsSetExplicity:=true;
  1200. end;
  1201. procedure dir_setpeuserversion;
  1202. var
  1203. dummystr : string;
  1204. dummyrev : word;
  1205. begin
  1206. if not (target_info.system in systems_all_windows) then
  1207. Message(scan_w_setpeuserversion_not_support);
  1208. if (compile_level<>1) then
  1209. Message(scan_n_only_exe_version)
  1210. else
  1211. do_version(peuserversionmajor,peuserversionminor,dummyrev,dummystr,false,SetPEUserVersionSetExplicitely);
  1212. end;
  1213. procedure dir_setpeosversion;
  1214. var
  1215. dummystr : string;
  1216. dummyrev : word;
  1217. begin
  1218. if not (target_info.system in systems_all_windows) then
  1219. Message(scan_w_setpeosversion_not_support);
  1220. if (compile_level<>1) then
  1221. Message(scan_n_only_exe_version)
  1222. else
  1223. do_version(peosversionmajor,peosversionminor,dummyrev,dummystr,false,SetPEOSVersionSetExplicitely);
  1224. end;
  1225. procedure dir_setpesubsysversion;
  1226. var
  1227. dummystr : string;
  1228. dummyrev : word;
  1229. begin
  1230. if not (target_info.system in systems_all_windows) then
  1231. Message(scan_w_setpesubsysversion_not_support);
  1232. if (compile_level<>1) then
  1233. Message(scan_n_only_exe_version)
  1234. else
  1235. do_version(pesubsysversionmajor,pesubsysversionminor,dummyrev,dummystr,false,SetPESubSysVersionSetExplicitely);
  1236. end;
  1237. procedure dir_smartlink;
  1238. begin
  1239. do_moduleswitch(cs_create_smart);
  1240. if (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  1241. not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) and
  1242. { smart linking does not yet work with DWARF debug info on most targets }
  1243. (cs_create_smart in current_settings.moduleswitches) and
  1244. not (af_outputbinary in target_asm.flags) then
  1245. begin
  1246. Message(option_dwarf_smart_linking);
  1247. Exclude(current_settings.moduleswitches,cs_create_smart);
  1248. end;
  1249. { Also create a smartlinked version, on an assembler that
  1250. does not support smartlink sections like nasm?
  1251. This is not compatible with using internal linker. }
  1252. if ((cs_link_smart in current_settings.globalswitches) or
  1253. (cs_create_smart in current_settings.moduleswitches)) and
  1254. (af_needar in target_asm.flags) and
  1255. not (af_smartlink_sections in target_asm.flags) and
  1256. not (cs_link_extern in current_settings.globalswitches) then
  1257. begin
  1258. DoneLinker;
  1259. Message(option_smart_link_requires_external_linker);
  1260. include(current_settings.globalswitches,cs_link_extern);
  1261. InitLinker;
  1262. end
  1263. end;
  1264. procedure dir_stackframes;
  1265. begin
  1266. do_delphiswitch('W');
  1267. end;
  1268. procedure dir_stop;
  1269. begin
  1270. do_message(scan_f_user_defined);
  1271. end;
  1272. procedure dir_stringchecks;
  1273. begin
  1274. // Delphi adds checks that ansistring and unicodestring are correct in
  1275. // different places. Skip it for now.
  1276. end;
  1277. procedure dir_syscall;
  1278. var
  1279. sctype : string;
  1280. syscall : psyscallinfo;
  1281. begin
  1282. current_scanner.skipspace;
  1283. sctype:=current_scanner.readid;
  1284. syscall:=get_syscall_by_name(sctype);
  1285. if assigned(syscall) then
  1286. begin
  1287. if not (target_info.system in syscall^.validon) then
  1288. Message(scan_w_syscall_convention_not_useable_on_target)
  1289. else
  1290. set_default_syscall(syscall^.procoption);
  1291. exit;
  1292. end;
  1293. Message(scan_w_syscall_convention_invalid);
  1294. end;
  1295. procedure dir_targetswitch;
  1296. var
  1297. name, value: string;
  1298. begin
  1299. { note: *not* recorded in the tokenstream, so not replayed for generics }
  1300. current_scanner.skipspace;
  1301. name:=current_scanner.readid;
  1302. if c='=' then
  1303. begin
  1304. current_scanner.readchar;
  1305. current_scanner.readid;
  1306. value:=orgpattern;
  1307. UpdateTargetSwitchStr(name+'='+value,current_settings.targetswitches,current_module.in_global);
  1308. end
  1309. else if c='-' then
  1310. begin
  1311. current_scanner.readchar;
  1312. UpdateTargetSwitchStr(name+'-',current_settings.targetswitches,current_module.in_global);
  1313. end
  1314. else
  1315. UpdateTargetSwitchStr(name,current_settings.targetswitches,current_module.in_global);
  1316. end;
  1317. procedure dir_typedaddress;
  1318. begin
  1319. do_delphiswitch('T');
  1320. end;
  1321. procedure dir_typeinfo;
  1322. begin
  1323. do_delphiswitch('M');
  1324. end;
  1325. procedure dir_unitpath;
  1326. begin
  1327. if not current_module.in_global then
  1328. Message(scan_w_switch_is_global)
  1329. else
  1330. with current_scanner,current_module,localunitsearchpath do
  1331. begin
  1332. skipspace;
  1333. AddPath(path,readcomment,false);
  1334. end;
  1335. end;
  1336. procedure dir_varparacopyoutcheck;
  1337. begin
  1338. if not(target_info.system in systems_jvm) then
  1339. begin
  1340. Message1(scan_w_illegal_switch,pattern);
  1341. exit;
  1342. end;
  1343. do_localswitch(cs_check_var_copyout);
  1344. end;
  1345. procedure dir_varpropsetter;
  1346. begin
  1347. do_localswitch(cs_varpropsetter);
  1348. end;
  1349. procedure dir_varstringchecks;
  1350. begin
  1351. do_delphiswitch('V');
  1352. end;
  1353. procedure dir_version;
  1354. var
  1355. major, minor, revision : longint;
  1356. error : integer;
  1357. begin
  1358. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  1359. system_i386_netware,system_i386_wdosx,
  1360. system_i386_netwlibc]) then
  1361. begin
  1362. Message(scan_n_version_not_support);
  1363. exit;
  1364. end;
  1365. if (compile_level<>1) then
  1366. Message(scan_n_only_exe_version)
  1367. else
  1368. begin
  1369. { change description global var in all cases }
  1370. { it not used but in win32, os2 and netware }
  1371. current_scanner.skipspace;
  1372. { we should only accept Major.Minor format for win32 and os2 }
  1373. current_scanner.readnumber;
  1374. major:=0;
  1375. minor:=0;
  1376. revision:=0;
  1377. val(pattern,major,error);
  1378. if (error<>0) or (major > high(word)) or (major < 0) then
  1379. begin
  1380. Message1(scan_w_wrong_version_ignored,pattern);
  1381. exit;
  1382. end;
  1383. if c='.' then
  1384. begin
  1385. current_scanner.readchar;
  1386. current_scanner.readnumber;
  1387. val(pattern,minor,error);
  1388. if (error<>0) or (minor > high(word)) or (minor < 0) then
  1389. begin
  1390. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  1391. exit;
  1392. end;
  1393. if (c='.') and
  1394. (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  1395. begin
  1396. current_scanner.readchar;
  1397. current_scanner.readnumber;
  1398. val(pattern,revision,error);
  1399. if (error<>0) or (revision > high(word)) or (revision < 0) then
  1400. begin
  1401. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  1402. exit;
  1403. end;
  1404. dllmajor:=word(major);
  1405. dllminor:=word(minor);
  1406. dllrevision:=word(revision);
  1407. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  1408. end
  1409. else
  1410. begin
  1411. dllmajor:=word(major);
  1412. dllminor:=word(minor);
  1413. dllversion:=tostr(major)+'.'+tostr(minor);
  1414. end;
  1415. end
  1416. else
  1417. dllversion:=tostr(major);
  1418. end;
  1419. end;
  1420. procedure dir_wait;
  1421. var
  1422. had_info : boolean;
  1423. begin
  1424. had_info:=(status.verbosity and V_Info)<>0;
  1425. { this message should allways appear !! }
  1426. status.verbosity:=status.verbosity or V_Info;
  1427. Message(scan_i_press_enter);
  1428. readln;
  1429. If not(had_info) then
  1430. status.verbosity:=status.verbosity and (not V_Info);
  1431. end;
  1432. { delphi compatible warn directive:
  1433. $warn <identifier> on
  1434. $warn <identifier> off
  1435. $warn <identifier> error
  1436. }
  1437. procedure dir_warn;
  1438. var
  1439. ident : string;
  1440. state : string;
  1441. msgstate : tmsgstate;
  1442. i : integer;
  1443. begin
  1444. current_scanner.skipspace;
  1445. ident:=current_scanner.readid;
  1446. current_scanner.skipspace;
  1447. state:=current_scanner.readid;
  1448. { support both delphi and fpc switches }
  1449. { use local ms_on/off/error tmsgstate values }
  1450. if (state='ON') or (state='+') then
  1451. msgstate:=ms_on
  1452. else
  1453. if (state='OFF') or (state='-') then
  1454. msgstate:=ms_off
  1455. else
  1456. if (state='ERROR') then
  1457. msgstate:=ms_error
  1458. else
  1459. begin
  1460. Message1(scanner_e_illegal_warn_state,state);
  1461. exit;
  1462. end;
  1463. if ident='CONSTRUCTING_ABSTRACT' then
  1464. begin
  1465. recordpendingmessagestate(type_w_instance_with_abstract, msgstate);
  1466. recordpendingmessagestate(type_w_instance_abstract_class, msgstate);
  1467. end
  1468. else
  1469. if ident='IMPLICIT_VARIANTS' then
  1470. recordpendingmessagestate(parser_w_implicit_uses_of_variants_unit, msgstate)
  1471. else
  1472. if ident='NO_RETVAL' then
  1473. recordpendingmessagestate(sym_w_function_result_not_set, msgstate)
  1474. else
  1475. if ident='SYMBOL_DEPRECATED' then
  1476. begin
  1477. recordpendingmessagestate(sym_w_deprecated_symbol, msgstate);
  1478. recordpendingmessagestate(sym_w_deprecated_symbol_with_msg, msgstate);
  1479. end
  1480. else
  1481. if ident='SYMBOL_EXPERIMENTAL' then
  1482. recordpendingmessagestate(sym_w_experimental_symbol, msgstate)
  1483. else
  1484. if ident='SYMBOL_LIBRARY' then
  1485. recordpendingmessagestate(sym_w_library_symbol, msgstate)
  1486. else
  1487. if ident='SYMBOL_PLATFORM' then
  1488. recordpendingmessagestate(sym_w_non_portable_symbol, msgstate)
  1489. else
  1490. if ident='SYMBOL_UNIMPLEMENTED' then
  1491. recordpendingmessagestate(sym_w_non_implemented_symbol, msgstate)
  1492. else
  1493. if ident='UNIT_DEPRECATED' then
  1494. begin
  1495. recordpendingmessagestate(sym_w_deprecated_unit, msgstate);
  1496. recordpendingmessagestate(sym_w_deprecated_unit_with_msg, msgstate);
  1497. end
  1498. else
  1499. if ident='UNIT_EXPERIMENTAL' then
  1500. recordpendingmessagestate(sym_w_experimental_unit, msgstate)
  1501. else
  1502. if ident='UNIT_LIBRARY' then
  1503. recordpendingmessagestate(sym_w_library_unit, msgstate)
  1504. else
  1505. if ident='UNIT_PLATFORM' then
  1506. recordpendingmessagestate(sym_w_non_portable_unit, msgstate)
  1507. else
  1508. if ident='UNIT_UNIMPLEMENTED' then
  1509. recordpendingmessagestate(sym_w_non_implemented_unit, msgstate)
  1510. else
  1511. if ident='ZERO_NIL_COMPAT' then
  1512. recordpendingmessagestate(type_w_zero_to_nil, msgstate)
  1513. else
  1514. if ident='IMPLICIT_STRING_CAST' then
  1515. recordpendingmessagestate(type_w_implicit_string_cast, msgstate)
  1516. else
  1517. if ident='IMPLICIT_STRING_CAST_LOSS' then
  1518. recordpendingmessagestate(type_w_implicit_string_cast_loss, msgstate)
  1519. else
  1520. if ident='EXPLICIT_STRING_CAST' then
  1521. recordpendingmessagestate(type_w_explicit_string_cast, msgstate)
  1522. else
  1523. if ident='EXPLICIT_STRING_CAST_LOSS' then
  1524. recordpendingmessagestate(type_w_explicit_string_cast_loss, msgstate)
  1525. else
  1526. if ident='CVT_NARROWING_STRING_LOST' then
  1527. recordpendingmessagestate(type_w_unicode_data_loss, msgstate)
  1528. else
  1529. if ident='INTF_RAISE_VISIBILITY' then
  1530. recordpendingmessagestate(type_w_interface_lower_visibility, msgstate)
  1531. else
  1532. begin
  1533. i:=0;
  1534. if not ChangeMessageVerbosity(ident,i,msgstate) then
  1535. Message1(scanner_w_illegal_warn_identifier,ident);
  1536. end;
  1537. end;
  1538. procedure dir_warning;
  1539. begin
  1540. do_message(scan_w_user_defined);
  1541. end;
  1542. procedure dir_warnings;
  1543. begin
  1544. do_setverbose('W');
  1545. end;
  1546. procedure dir_weakpackageunit;
  1547. begin
  1548. { old Delphi versions seem to use merely $WEAKPACKAGEUNIT while newer
  1549. Delphis have $WEAPACKAGEUNIT ON... :/ }
  1550. do_moduleflagswitch(uf_package_weak, true);
  1551. end;
  1552. procedure dir_writeableconst;
  1553. begin
  1554. do_delphiswitch('J');
  1555. end;
  1556. procedure dir_z1;
  1557. begin
  1558. current_settings.packenum:=1;
  1559. end;
  1560. procedure dir_z2;
  1561. begin
  1562. current_settings.packenum:=2;
  1563. end;
  1564. procedure dir_z4;
  1565. begin
  1566. current_settings.packenum:=4;
  1567. end;
  1568. procedure dir_externalsym;
  1569. begin
  1570. end;
  1571. procedure dir_nodefine;
  1572. begin
  1573. end;
  1574. procedure dir_hppemit;
  1575. begin
  1576. end;
  1577. procedure dir_hugecode;
  1578. begin
  1579. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
  1580. {$ifdef i8086}
  1581. or (current_settings.x86memorymodel in x86_near_code_models)
  1582. {$endif i8086}
  1583. then
  1584. begin
  1585. Message1(scan_n_ignored_switch,pattern);
  1586. exit;
  1587. end;
  1588. do_moduleswitch(cs_huge_code);
  1589. end;
  1590. procedure dir_hugepointernormalization;
  1591. var
  1592. hs : string;
  1593. begin
  1594. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1595. begin
  1596. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERNORMALIZATION');
  1597. exit;
  1598. end;
  1599. current_scanner.skipspace;
  1600. hs:=current_scanner.readid;
  1601. case hs of
  1602. 'BORLANDC':
  1603. begin
  1604. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'+');
  1605. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1606. end;
  1607. 'MICROSOFTC':
  1608. begin
  1609. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1610. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'-');
  1611. end;
  1612. 'WATCOMC':
  1613. begin
  1614. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1615. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1616. end;
  1617. else
  1618. Message(scan_e_illegal_hugepointernormalization);
  1619. end;
  1620. end;
  1621. procedure dir_hugepointerarithmeticnormalization;
  1622. begin
  1623. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1624. begin
  1625. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERARITHMETICNORMALIZATION');
  1626. exit;
  1627. end;
  1628. do_localswitch(cs_hugeptr_arithmetic_normalization);
  1629. end;
  1630. procedure dir_hugepointercomparisonnormalization;
  1631. begin
  1632. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1633. begin
  1634. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERCOMPARISONNORMALIZATION');
  1635. exit;
  1636. end;
  1637. do_localswitch(cs_hugeptr_comparison_normalization);
  1638. end;
  1639. procedure dir_codealign;
  1640. var
  1641. s : string;
  1642. begin
  1643. current_scanner.skipspace;
  1644. s:=current_scanner.readcomment;
  1645. if not(UpdateAlignmentStr(s,current_settings.alignment)) then
  1646. message(scanner_e_illegal_alignment_directive);
  1647. end;
  1648. procedure dir_codepage;
  1649. var
  1650. s : string;
  1651. begin
  1652. if not current_module.in_global then
  1653. Message(scan_w_switch_is_global)
  1654. else
  1655. begin
  1656. current_scanner.skipspace;
  1657. s:=current_scanner.readcomment;
  1658. if (upper(s)='UTF8') or (upper(s)='UTF-8') then
  1659. current_settings.sourcecodepage:=CP_UTF8
  1660. else if not cpavailable(s) then
  1661. Message1(option_code_page_not_available,s)
  1662. else
  1663. current_settings.sourcecodepage:=codepagebyname(s);
  1664. { we're not using the system code page now }
  1665. exclude(current_settings.modeswitches,m_systemcodepage);
  1666. exclude(current_settings.moduleswitches,cs_system_codepage);
  1667. include(current_settings.moduleswitches,cs_explicit_codepage);
  1668. end;
  1669. end;
  1670. procedure dir_coperators;
  1671. begin
  1672. do_moduleswitch(cs_support_c_operators);
  1673. end;
  1674. procedure dir_bitpacking;
  1675. begin
  1676. do_localswitch(cs_bitpacking);
  1677. end;
  1678. procedure dir_region;
  1679. begin
  1680. end;
  1681. procedure dir_endregion;
  1682. begin
  1683. end;
  1684. procedure dir_zerobasesstrings;
  1685. begin
  1686. do_localswitch(cs_zerobasedstrings);
  1687. end;
  1688. {****************************************************************************
  1689. Initialize Directives
  1690. ****************************************************************************}
  1691. procedure InitScannerDirectives;
  1692. begin
  1693. AddDirective('A1',directive_all, @dir_a1);
  1694. AddDirective('A2',directive_all, @dir_a2);
  1695. AddDirective('A4',directive_all, @dir_a4);
  1696. AddDirective('A8',directive_all, @dir_a8);
  1697. AddDirective('ALIGN',directive_all, @dir_align);
  1698. {$ifdef m68k}
  1699. AddDirective('APPID',directive_all, @dir_appid);
  1700. AddDirective('APPNAME',directive_all, @dir_appname);
  1701. {$endif m68k}
  1702. AddDirective('APPTYPE',directive_all, @dir_apptype);
  1703. AddDirective('ASMCPU',directive_all, @dir_asmcpu);
  1704. AddDirective('ASMMODE',directive_all, @dir_asmmode);
  1705. AddDirective('ASSERTIONS',directive_all, @dir_assertions);
  1706. AddDirective('BOOLEVAL',directive_all, @dir_booleval);
  1707. AddDirective('BITPACKING',directive_all, @dir_bitpacking);
  1708. AddDirective('CALLING',directive_all, @dir_calling);
  1709. AddDirective('CHECKLOWADDRLOADS',directive_all, @dir_checklowaddrloads);
  1710. AddDirective('CHECKPOINTER',directive_all, @dir_checkpointer);
  1711. AddDirective('CODEALIGN',directive_all, @dir_codealign);
  1712. AddDirective('CODEPAGE',directive_all, @dir_codepage);
  1713. AddDirective('COPERATORS',directive_all, @dir_coperators);
  1714. AddDirective('COPYRIGHT',directive_all, @dir_copyright);
  1715. AddDirective('D',directive_all, @dir_description);
  1716. AddDirective('DEBUGINFO',directive_all, @dir_debuginfo);
  1717. AddDirective('DENYPACKAGEUNIT',directive_all,@dir_denypackageunit);
  1718. AddDirective('DESCRIPTION',directive_all, @dir_description);
  1719. AddDirective('ENDREGION',directive_all, @dir_endregion);
  1720. AddDirective('ERROR',directive_all, @dir_error);
  1721. AddDirective('ERRORC',directive_mac, @dir_error);
  1722. AddDirective('EXTENDEDSYNTAX',directive_all, @dir_extendedsyntax);
  1723. AddDirective('EXTERNALSYM',directive_all, @dir_externalsym);
  1724. AddDirective('F',directive_all, @dir_forcefarcalls);
  1725. AddDirective('FATAL',directive_all, @dir_fatal);
  1726. AddDirective('FPUTYPE',directive_all, @dir_fputype);
  1727. AddDirective('FRAMEWORKPATH',directive_all, @dir_frameworkpath);
  1728. AddDirective('GOTO',directive_all, @dir_goto);
  1729. AddDirective('HINT',directive_all, @dir_hint);
  1730. AddDirective('HINTS',directive_all, @dir_hints);
  1731. AddDirective('HPPEMIT',directive_all, @dir_hppemit);
  1732. AddDirective('HUGECODE',directive_all, @dir_hugecode);
  1733. AddDirective('HUGEPOINTERNORMALIZATION',directive_all,@dir_hugepointernormalization);
  1734. AddDirective('HUGEPOINTERARITHMETICNORMALIZATION',directive_all,@dir_hugepointerarithmeticnormalization);
  1735. AddDirective('HUGEPOINTERCOMPARISONNORMALIZATION',directive_all,@dir_hugepointercomparisonnormalization);
  1736. AddDirective('IEEEERRORS',directive_all,@dir_ieeeerrors);
  1737. AddDirective('IOCHECKS',directive_all, @dir_iochecks);
  1738. AddDirective('IMAGEBASE',directive_all, @dir_imagebase);
  1739. AddDirective('IMPLICITEXCEPTIONS',directive_all, @dir_implicitexceptions);
  1740. AddDirective('IMPORTEDDATA',directive_all, @dir_importeddata);
  1741. AddDirective('INCLUDEPATH',directive_all, @dir_includepath);
  1742. AddDirective('INFO',directive_all, @dir_info);
  1743. AddDirective('INLINE',directive_all, @dir_inline);
  1744. AddDirective('INTERFACES',directive_all, @dir_interfaces);
  1745. AddDirective('L',directive_all, @dir_link);
  1746. AddDirective('LIBEXPORT',directive_mac, @dir_libexport);
  1747. AddDirective('LIBRARYPATH',directive_all, @dir_librarypath);
  1748. AddDirective('LINK',directive_all, @dir_link);
  1749. AddDirective('LINKFRAMEWORK',directive_all, @dir_linkframework);
  1750. AddDirective('LINKLIB',directive_all, @dir_linklib);
  1751. AddDirective('LOCALSYMBOLS',directive_all, @dir_localsymbols);
  1752. AddDirective('LONGSTRINGS',directive_all, @dir_longstrings);
  1753. AddDirective('M',directive_all, @dir_memory);
  1754. AddDirective('MACRO',directive_all, @dir_macro);
  1755. AddDirective('MAXFPUREGISTERS',directive_all, @dir_maxfpuregisters);
  1756. AddDirective('MAXSTACKSIZE',directive_all, @dir_maxstacksize);
  1757. AddDirective('MEMORY',directive_all, @dir_memory);
  1758. AddDirective('MESSAGE',directive_all, @dir_message);
  1759. AddDirective('MINENUMSIZE',directive_all, @dir_packenum);
  1760. AddDirective('MINFPCONSTPREC',directive_all, @dir_minfpconstprec);
  1761. AddDirective('MINSTACKSIZE',directive_all, @dir_minstacksize);
  1762. AddDirective('MMX',directive_all, @dir_mmx);
  1763. AddDirective('MODE',directive_all, @dir_mode);
  1764. AddDirective('MODESWITCH',directive_all, @dir_modeswitch);
  1765. AddDirective('NAMESPACE',directive_all, @dir_namespace);
  1766. AddDirective('NODEFINE',directive_all, @dir_nodefine);
  1767. AddDirective('NOTE',directive_all, @dir_note);
  1768. AddDirective('NOTES',directive_all, @dir_notes);
  1769. AddDirective('OBJECTCHECKS',directive_all, @dir_objectchecks);
  1770. AddDirective('OBJECTPATH',directive_all, @dir_objectpath);
  1771. AddDirective('OPENSTRINGS',directive_all, @dir_openstrings);
  1772. AddDirective('OPTIMIZATION',directive_all, @dir_optimization);
  1773. AddDirective('OV',directive_mac, @dir_overflowchecks);
  1774. AddDirective('OVERFLOWCHECKS',directive_all, @dir_overflowchecks);
  1775. AddDirective('PACKENUM',directive_all, @dir_packenum);
  1776. AddDirective('PACKRECORDS',directive_all, @dir_packrecords);
  1777. AddDirective('PACKSET',directive_all, @dir_packset);
  1778. AddDirective('PASCALMAINNAME',directive_all, @dir_pascalmainname);
  1779. AddDirective('PIC',directive_all, @dir_pic);
  1780. AddDirective('POINTERMATH',directive_all, @dir_pointermath);
  1781. AddDirective('POP',directive_all, @dir_pop);
  1782. AddDirective('PROFILE',directive_all, @dir_profile);
  1783. AddDirective('PUSH',directive_all, @dir_push);
  1784. AddDirective('R',directive_all, @dir_resource);
  1785. AddDirective('RANGECHECKS',directive_all, @dir_rangechecks);
  1786. AddDirective('REFERENCEINFO',directive_all, @dir_referenceinfo);
  1787. AddDirective('REGION',directive_all, @dir_region);
  1788. AddDirective('RESOURCE',directive_all, @dir_resource);
  1789. AddDirective('SATURATION',directive_all, @dir_saturation);
  1790. AddDirective('SAFEFPUEXCEPTIONS',directive_all, @dir_safefpuexceptions);
  1791. AddDirective('SCOPEDENUMS',directive_all, @dir_scopedenums);
  1792. AddDirective('SETPEFLAGS', directive_all, @dir_setpeflags);
  1793. AddDirective('SETPEOPTFLAGS', directive_all, @dir_setpeoptflags);
  1794. AddDirective('SETPEOSVERSION', directive_all, @dir_setpeosversion);
  1795. AddDirective('SETPEUSERVERSION', directive_all, @dir_setpeuserversion);
  1796. AddDirective('SETPESUBSYSVERSION', directive_all, @dir_setpesubsysversion);
  1797. AddDirective('SCREENNAME',directive_all, @dir_screenname);
  1798. AddDirective('SMARTLINK',directive_all, @dir_smartlink);
  1799. AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
  1800. AddDirective('STOP',directive_all, @dir_stop);
  1801. AddDirective('STRINGCHECKS', directive_all, @dir_stringchecks);
  1802. AddDirective('SYSCALL',directive_all, @dir_syscall);
  1803. AddDirective('TARGETSWITCH',directive_all, @dir_targetswitch);
  1804. AddDirective('THREADNAME',directive_all, @dir_threadname);
  1805. AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
  1806. AddDirective('TYPEINFO',directive_all, @dir_typeinfo);
  1807. AddDirective('UNITPATH',directive_all, @dir_unitpath);
  1808. AddDirective('VARPARACOPYOUTCHECK',directive_all, @dir_varparacopyoutcheck);
  1809. AddDirective('VARPROPSETTER',directive_all, @dir_varpropsetter);
  1810. AddDirective('VARSTRINGCHECKS',directive_all, @dir_varstringchecks);
  1811. AddDirective('VERSION',directive_all, @dir_version);
  1812. AddDirective('WAIT',directive_all, @dir_wait);
  1813. AddDirective('WARN',directive_all, @dir_warn);
  1814. AddDirective('WARNING',directive_all, @dir_warning);
  1815. AddDirective('WARNINGS',directive_all, @dir_warnings);
  1816. AddDirective('WEAKPACKAGEUNIT',directive_all, @dir_weakpackageunit);
  1817. AddDirective('WRITEABLECONST',directive_all, @dir_writeableconst);
  1818. AddDirective('Z1',directive_all, @dir_z1);
  1819. AddDirective('Z2',directive_all, @dir_z2);
  1820. AddDirective('Z4',directive_all, @dir_z4);
  1821. AddDirective('ZEROBASEDSTRINGS',directive_all, @dir_zerobasesstrings);
  1822. end;
  1823. end.