2
0

scandir.pas 64 KB

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