2
0

scandir.pas 65 KB

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