scandir.pas 66 KB

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