scandir.pas 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  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_macosclassic,
  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_macosclassic]) 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. flags : int64;
  1187. begin
  1188. if not (target_info.system in (systems_all_windows)) then
  1189. Message(scan_w_setpeflags_not_support);
  1190. if current_scanner.readpreprocint(flags,'SETPEFLAGS') then
  1191. begin
  1192. if flags>$ffff then
  1193. message(scan_e_illegal_peflag);
  1194. peflags:=peflags or uint16(flags);
  1195. end;
  1196. SetPEFlagsSetExplicity:=true;
  1197. end;
  1198. procedure dir_setpeoptflags;
  1199. var
  1200. ident : string;
  1201. flags : int64;
  1202. begin
  1203. if not (target_info.system in (systems_all_windows)) then
  1204. Message(scan_w_setpeoptflags_not_support);
  1205. if current_scanner.readpreprocint(flags,'SETPEOPTFLAGS') then
  1206. begin
  1207. if flags>$ffff then
  1208. message(scan_e_illegal_peoptflag);
  1209. peoptflags:=peoptflags or uint16(flags);
  1210. end;
  1211. SetPEOptFlagsSetExplicity:=true;
  1212. end;
  1213. procedure dir_setpeuserversion;
  1214. var
  1215. dummystr : string;
  1216. dummyrev : word;
  1217. begin
  1218. if not (target_info.system in systems_all_windows) then
  1219. Message(scan_w_setpeuserversion_not_support);
  1220. if (compile_level<>1) then
  1221. Message(scan_n_only_exe_version)
  1222. else
  1223. do_version(peuserversionmajor,peuserversionminor,dummyrev,dummystr,false,SetPEUserVersionSetExplicitely);
  1224. end;
  1225. procedure dir_setpeosversion;
  1226. var
  1227. dummystr : string;
  1228. dummyrev : word;
  1229. begin
  1230. if not (target_info.system in systems_all_windows) then
  1231. Message(scan_w_setpeosversion_not_support);
  1232. if (compile_level<>1) then
  1233. Message(scan_n_only_exe_version)
  1234. else
  1235. do_version(peosversionmajor,peosversionminor,dummyrev,dummystr,false,SetPEOSVersionSetExplicitely);
  1236. end;
  1237. procedure dir_setpesubsysversion;
  1238. var
  1239. dummystr : string;
  1240. dummyrev : word;
  1241. begin
  1242. if not (target_info.system in systems_all_windows) then
  1243. Message(scan_w_setpesubsysversion_not_support);
  1244. if (compile_level<>1) then
  1245. Message(scan_n_only_exe_version)
  1246. else
  1247. do_version(pesubsysversionmajor,pesubsysversionminor,dummyrev,dummystr,false,SetPESubSysVersionSetExplicitely);
  1248. end;
  1249. procedure dir_smartlink;
  1250. begin
  1251. do_moduleswitch(cs_create_smart);
  1252. if (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  1253. not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) and
  1254. { smart linking does not yet work with DWARF debug info on most targets }
  1255. (cs_create_smart in current_settings.moduleswitches) and
  1256. not (af_outputbinary in target_asm.flags) then
  1257. begin
  1258. Message(option_dwarf_smart_linking);
  1259. Exclude(current_settings.moduleswitches,cs_create_smart);
  1260. end;
  1261. { Also create a smartlinked version, on an assembler that
  1262. does not support smartlink sections like nasm?
  1263. This is not compatible with using internal linker. }
  1264. if ((cs_link_smart in current_settings.globalswitches) or
  1265. (cs_create_smart in current_settings.moduleswitches)) and
  1266. (af_needar in target_asm.flags) and
  1267. not (af_smartlink_sections in target_asm.flags) and
  1268. not (cs_link_extern in current_settings.globalswitches) then
  1269. begin
  1270. DoneLinker;
  1271. Message(option_smart_link_requires_external_linker);
  1272. include(current_settings.globalswitches,cs_link_extern);
  1273. InitLinker;
  1274. end
  1275. end;
  1276. procedure dir_stackframes;
  1277. begin
  1278. do_delphiswitch('W');
  1279. end;
  1280. procedure dir_stop;
  1281. begin
  1282. do_message(scan_f_user_defined);
  1283. end;
  1284. procedure dir_stringchecks;
  1285. begin
  1286. // Delphi adds checks that ansistring and unicodestring are correct in
  1287. // different places. Skip it for now.
  1288. end;
  1289. procedure dir_syscall;
  1290. var
  1291. sctype : string;
  1292. syscall : psyscallinfo;
  1293. begin
  1294. current_scanner.skipspace;
  1295. sctype:=current_scanner.readid;
  1296. syscall:=get_syscall_by_name(sctype);
  1297. if assigned(syscall) then
  1298. begin
  1299. if not (target_info.system in syscall^.validon) then
  1300. Message(scan_w_syscall_convention_not_useable_on_target)
  1301. else
  1302. set_default_syscall(syscall^.procoption);
  1303. exit;
  1304. end;
  1305. Message(scan_w_syscall_convention_invalid);
  1306. end;
  1307. procedure dir_targetswitch;
  1308. var
  1309. name, value: string;
  1310. begin
  1311. { note: *not* recorded in the tokenstream, so not replayed for generics }
  1312. current_scanner.skipspace;
  1313. name:=current_scanner.readid;
  1314. if c='=' then
  1315. begin
  1316. current_scanner.readchar;
  1317. current_scanner.readid;
  1318. value:=orgpattern;
  1319. UpdateTargetSwitchStr(name+'='+value,current_settings.targetswitches,current_module.in_global);
  1320. end
  1321. else if c='-' then
  1322. begin
  1323. current_scanner.readchar;
  1324. UpdateTargetSwitchStr(name+'-',current_settings.targetswitches,current_module.in_global);
  1325. end
  1326. else
  1327. UpdateTargetSwitchStr(name,current_settings.targetswitches,current_module.in_global);
  1328. end;
  1329. procedure dir_typedaddress;
  1330. begin
  1331. do_delphiswitch('T');
  1332. end;
  1333. procedure dir_typeinfo;
  1334. begin
  1335. do_delphiswitch('M');
  1336. end;
  1337. procedure dir_unitpath;
  1338. var
  1339. unitpath: TPathStr;
  1340. begin
  1341. if not current_module.in_global then
  1342. Message(scan_w_switch_is_global)
  1343. else
  1344. begin
  1345. current_scanner.skipspace;
  1346. unitpath:=current_scanner.readcomment;
  1347. if (current_module.path<>'') and
  1348. not path_absolute(unitpath) then
  1349. unitpath:=current_module.path+source_info.DirSep+unitpath;
  1350. current_module.localunitsearchpath.AddPath(unitpath,false);
  1351. end;
  1352. end;
  1353. procedure dir_varparacopyoutcheck;
  1354. begin
  1355. if not(target_info.system in systems_jvm) then
  1356. begin
  1357. Message1(scan_w_illegal_switch,pattern);
  1358. exit;
  1359. end;
  1360. do_localswitch(cs_check_var_copyout);
  1361. end;
  1362. procedure dir_varpropsetter;
  1363. begin
  1364. do_localswitch(cs_varpropsetter);
  1365. end;
  1366. procedure dir_varstringchecks;
  1367. begin
  1368. do_delphiswitch('V');
  1369. end;
  1370. procedure dir_version;
  1371. var
  1372. major, minor, revision : longint;
  1373. error : integer;
  1374. begin
  1375. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  1376. system_i386_netware,system_i386_wdosx,
  1377. system_i386_netwlibc]) then
  1378. begin
  1379. Message(scan_n_version_not_support);
  1380. exit;
  1381. end;
  1382. if (compile_level<>1) then
  1383. Message(scan_n_only_exe_version)
  1384. else
  1385. begin
  1386. { change description global var in all cases }
  1387. { it not used but in win32, os2 and netware }
  1388. current_scanner.skipspace;
  1389. { we should only accept Major.Minor format for win32 and os2 }
  1390. current_scanner.readnumber;
  1391. major:=0;
  1392. minor:=0;
  1393. revision:=0;
  1394. val(pattern,major,error);
  1395. if (error<>0) or (major > high(word)) or (major < 0) then
  1396. begin
  1397. Message1(scan_w_wrong_version_ignored,pattern);
  1398. exit;
  1399. end;
  1400. if c='.' then
  1401. begin
  1402. current_scanner.readchar;
  1403. current_scanner.readnumber;
  1404. val(pattern,minor,error);
  1405. if (error<>0) or (minor > high(word)) or (minor < 0) then
  1406. begin
  1407. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  1408. exit;
  1409. end;
  1410. if (c='.') and
  1411. (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  1412. begin
  1413. current_scanner.readchar;
  1414. current_scanner.readnumber;
  1415. val(pattern,revision,error);
  1416. if (error<>0) or (revision > high(word)) or (revision < 0) then
  1417. begin
  1418. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  1419. exit;
  1420. end;
  1421. dllmajor:=word(major);
  1422. dllminor:=word(minor);
  1423. dllrevision:=word(revision);
  1424. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  1425. end
  1426. else
  1427. begin
  1428. dllmajor:=word(major);
  1429. dllminor:=word(minor);
  1430. dllversion:=tostr(major)+'.'+tostr(minor);
  1431. end;
  1432. end
  1433. else
  1434. dllversion:=tostr(major);
  1435. end;
  1436. end;
  1437. procedure dir_wait;
  1438. var
  1439. had_info : boolean;
  1440. begin
  1441. had_info:=(status.verbosity and V_Info)<>0;
  1442. { this message should allways appear !! }
  1443. status.verbosity:=status.verbosity or V_Info;
  1444. Message(scan_i_press_enter);
  1445. readln;
  1446. If not(had_info) then
  1447. status.verbosity:=status.verbosity and (not V_Info);
  1448. end;
  1449. { delphi compatible warn directive:
  1450. $warn <identifier> on
  1451. $warn <identifier> off
  1452. $warn <identifier> error
  1453. }
  1454. procedure dir_warn;
  1455. var
  1456. ident : string;
  1457. state : string;
  1458. msgstate : tmsgstate;
  1459. i : integer;
  1460. begin
  1461. current_scanner.skipspace;
  1462. ident:=current_scanner.readid;
  1463. current_scanner.skipspace;
  1464. state:=current_scanner.readid;
  1465. { support both delphi and fpc switches }
  1466. { use local ms_on/off/error tmsgstate values }
  1467. if (state='ON') or (state='+') then
  1468. msgstate:=ms_on
  1469. else
  1470. if (state='OFF') or (state='-') then
  1471. msgstate:=ms_off
  1472. else
  1473. if (state='ERROR') then
  1474. msgstate:=ms_error
  1475. else
  1476. begin
  1477. Message1(scanner_e_illegal_warn_state,state);
  1478. exit;
  1479. end;
  1480. if ident='CONSTRUCTING_ABSTRACT' then
  1481. begin
  1482. recordpendingmessagestate(type_w_instance_with_abstract, msgstate);
  1483. recordpendingmessagestate(type_w_instance_abstract_class, msgstate);
  1484. end
  1485. else
  1486. if ident='IMPLICIT_VARIANTS' then
  1487. recordpendingmessagestate(parser_w_implicit_uses_of_variants_unit, msgstate)
  1488. else
  1489. if ident='NO_RETVAL' then
  1490. recordpendingmessagestate(sym_w_function_result_not_set, msgstate)
  1491. else
  1492. if ident='SYMBOL_DEPRECATED' then
  1493. begin
  1494. recordpendingmessagestate(sym_w_deprecated_symbol, msgstate);
  1495. recordpendingmessagestate(sym_w_deprecated_symbol_with_msg, msgstate);
  1496. end
  1497. else
  1498. if ident='SYMBOL_EXPERIMENTAL' then
  1499. recordpendingmessagestate(sym_w_experimental_symbol, msgstate)
  1500. else
  1501. if ident='SYMBOL_LIBRARY' then
  1502. recordpendingmessagestate(sym_w_library_symbol, msgstate)
  1503. else
  1504. if ident='SYMBOL_PLATFORM' then
  1505. recordpendingmessagestate(sym_w_non_portable_symbol, msgstate)
  1506. else
  1507. if ident='SYMBOL_UNIMPLEMENTED' then
  1508. recordpendingmessagestate(sym_w_non_implemented_symbol, msgstate)
  1509. else
  1510. if ident='UNIT_DEPRECATED' then
  1511. begin
  1512. recordpendingmessagestate(sym_w_deprecated_unit, msgstate);
  1513. recordpendingmessagestate(sym_w_deprecated_unit_with_msg, msgstate);
  1514. end
  1515. else
  1516. if ident='UNIT_EXPERIMENTAL' then
  1517. recordpendingmessagestate(sym_w_experimental_unit, msgstate)
  1518. else
  1519. if ident='UNIT_LIBRARY' then
  1520. recordpendingmessagestate(sym_w_library_unit, msgstate)
  1521. else
  1522. if ident='UNIT_PLATFORM' then
  1523. recordpendingmessagestate(sym_w_non_portable_unit, msgstate)
  1524. else
  1525. if ident='UNIT_UNIMPLEMENTED' then
  1526. recordpendingmessagestate(sym_w_non_implemented_unit, msgstate)
  1527. else
  1528. if ident='ZERO_NIL_COMPAT' then
  1529. recordpendingmessagestate(type_w_zero_to_nil, msgstate)
  1530. else
  1531. if ident='IMPLICIT_STRING_CAST' then
  1532. recordpendingmessagestate(type_w_implicit_string_cast, msgstate)
  1533. else
  1534. if ident='IMPLICIT_STRING_CAST_LOSS' then
  1535. recordpendingmessagestate(type_w_implicit_string_cast_loss, msgstate)
  1536. else
  1537. if ident='EXPLICIT_STRING_CAST' then
  1538. recordpendingmessagestate(type_w_explicit_string_cast, msgstate)
  1539. else
  1540. if ident='EXPLICIT_STRING_CAST_LOSS' then
  1541. recordpendingmessagestate(type_w_explicit_string_cast_loss, msgstate)
  1542. else
  1543. if ident='CVT_NARROWING_STRING_LOST' then
  1544. recordpendingmessagestate(type_w_unicode_data_loss, msgstate)
  1545. else
  1546. if ident='INTF_RAISE_VISIBILITY' then
  1547. recordpendingmessagestate(type_w_interface_lower_visibility, msgstate)
  1548. else
  1549. begin
  1550. i:=0;
  1551. if not ChangeMessageVerbosity(ident,i,msgstate) then
  1552. Message1(scanner_w_illegal_warn_identifier,ident);
  1553. end;
  1554. end;
  1555. procedure dir_warning;
  1556. begin
  1557. do_message(scan_w_user_defined);
  1558. end;
  1559. procedure dir_warnings;
  1560. begin
  1561. do_setverbose('W');
  1562. end;
  1563. procedure dir_weakpackageunit;
  1564. begin
  1565. { old Delphi versions seem to use merely $WEAKPACKAGEUNIT while newer
  1566. Delphis have $WEAPACKAGEUNIT ON... :/ }
  1567. do_moduleflagswitch(uf_package_weak, true);
  1568. end;
  1569. procedure dir_writeableconst;
  1570. begin
  1571. do_delphiswitch('J');
  1572. end;
  1573. procedure dir_z1;
  1574. begin
  1575. current_settings.packenum:=1;
  1576. end;
  1577. procedure dir_z2;
  1578. begin
  1579. current_settings.packenum:=2;
  1580. end;
  1581. procedure dir_z4;
  1582. begin
  1583. current_settings.packenum:=4;
  1584. end;
  1585. procedure dir_externalsym;
  1586. begin
  1587. end;
  1588. procedure dir_nodefine;
  1589. begin
  1590. end;
  1591. procedure dir_hppemit;
  1592. begin
  1593. end;
  1594. procedure dir_hugecode;
  1595. begin
  1596. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
  1597. {$ifdef i8086}
  1598. or (current_settings.x86memorymodel in x86_near_code_models)
  1599. {$endif i8086}
  1600. then
  1601. begin
  1602. Message1(scan_n_ignored_switch,pattern);
  1603. exit;
  1604. end;
  1605. do_moduleswitch(cs_huge_code);
  1606. end;
  1607. procedure dir_hugepointernormalization;
  1608. var
  1609. hs : string;
  1610. begin
  1611. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1612. begin
  1613. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERNORMALIZATION');
  1614. exit;
  1615. end;
  1616. current_scanner.skipspace;
  1617. hs:=current_scanner.readid;
  1618. case hs of
  1619. 'BORLANDC':
  1620. begin
  1621. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'+');
  1622. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1623. end;
  1624. 'MICROSOFTC':
  1625. begin
  1626. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1627. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'-');
  1628. end;
  1629. 'WATCOMC':
  1630. begin
  1631. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1632. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1633. end;
  1634. else
  1635. Message(scan_e_illegal_hugepointernormalization);
  1636. end;
  1637. end;
  1638. procedure dir_hugepointerarithmeticnormalization;
  1639. begin
  1640. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1641. begin
  1642. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERARITHMETICNORMALIZATION');
  1643. exit;
  1644. end;
  1645. do_localswitch(cs_hugeptr_arithmetic_normalization);
  1646. end;
  1647. procedure dir_hugepointercomparisonnormalization;
  1648. begin
  1649. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1650. begin
  1651. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERCOMPARISONNORMALIZATION');
  1652. exit;
  1653. end;
  1654. do_localswitch(cs_hugeptr_comparison_normalization);
  1655. end;
  1656. procedure dir_codealign;
  1657. var
  1658. s : string;
  1659. begin
  1660. current_scanner.skipspace;
  1661. s:=current_scanner.readcomment;
  1662. if not(UpdateAlignmentStr(s,current_settings.alignment)) then
  1663. message(scanner_e_illegal_alignment_directive);
  1664. end;
  1665. procedure dir_codepage;
  1666. var
  1667. s : string;
  1668. begin
  1669. if not current_module.in_global then
  1670. Message(scan_w_switch_is_global)
  1671. else
  1672. begin
  1673. current_scanner.skipspace;
  1674. s:=current_scanner.readcomment;
  1675. if (upper(s)='UTF8') or (upper(s)='UTF-8') then
  1676. current_settings.sourcecodepage:=CP_UTF8
  1677. else if not cpavailable(s) then
  1678. Message1(option_code_page_not_available,s)
  1679. else
  1680. current_settings.sourcecodepage:=codepagebyname(s);
  1681. { we're not using the system code page now }
  1682. exclude(current_settings.modeswitches,m_systemcodepage);
  1683. exclude(current_settings.moduleswitches,cs_system_codepage);
  1684. include(current_settings.moduleswitches,cs_explicit_codepage);
  1685. end;
  1686. end;
  1687. procedure dir_coperators;
  1688. begin
  1689. do_moduleswitch(cs_support_c_operators);
  1690. end;
  1691. procedure dir_bitpacking;
  1692. begin
  1693. do_localswitch(cs_bitpacking);
  1694. end;
  1695. procedure dir_region;
  1696. begin
  1697. end;
  1698. procedure dir_endregion;
  1699. begin
  1700. end;
  1701. procedure dir_zerobasesstrings;
  1702. begin
  1703. do_localswitch(cs_zerobasedstrings);
  1704. end;
  1705. {****************************************************************************
  1706. Initialize Directives
  1707. ****************************************************************************}
  1708. procedure InitScannerDirectives;
  1709. begin
  1710. AddDirective('A1',directive_all, @dir_a1);
  1711. AddDirective('A2',directive_all, @dir_a2);
  1712. AddDirective('A4',directive_all, @dir_a4);
  1713. AddDirective('A8',directive_all, @dir_a8);
  1714. AddDirective('ALIGN',directive_all, @dir_align);
  1715. {$ifdef m68k}
  1716. AddDirective('APPID',directive_all, @dir_appid);
  1717. AddDirective('APPNAME',directive_all, @dir_appname);
  1718. {$endif m68k}
  1719. AddDirective('APPTYPE',directive_all, @dir_apptype);
  1720. AddDirective('ASMCPU',directive_all, @dir_asmcpu);
  1721. AddDirective('ASMMODE',directive_all, @dir_asmmode);
  1722. AddDirective('ASSERTIONS',directive_all, @dir_assertions);
  1723. AddDirective('BOOLEVAL',directive_all, @dir_booleval);
  1724. AddDirective('BITPACKING',directive_all, @dir_bitpacking);
  1725. AddDirective('CALLING',directive_all, @dir_calling);
  1726. AddDirective('CHECKFPUEXCEPTIONS',directive_all, @dir_checkfpuexceptions);
  1727. AddDirective('CHECKLOWADDRLOADS',directive_all, @dir_checklowaddrloads);
  1728. AddDirective('CHECKPOINTER',directive_all, @dir_checkpointer);
  1729. AddDirective('CODEALIGN',directive_all, @dir_codealign);
  1730. AddDirective('CODEPAGE',directive_all, @dir_codepage);
  1731. AddDirective('COPERATORS',directive_all, @dir_coperators);
  1732. AddDirective('COPYRIGHT',directive_all, @dir_copyright);
  1733. AddDirective('D',directive_all, @dir_description);
  1734. AddDirective('DEBUGINFO',directive_all, @dir_debuginfo);
  1735. AddDirective('DENYPACKAGEUNIT',directive_all,@dir_denypackageunit);
  1736. AddDirective('DESCRIPTION',directive_all, @dir_description);
  1737. AddDirective('ENDREGION',directive_all, @dir_endregion);
  1738. AddDirective('ERROR',directive_all, @dir_error);
  1739. AddDirective('ERRORC',directive_mac, @dir_error);
  1740. AddDirective('EXCESSPRECISION',directive_all, @dir_excessprecision);
  1741. AddDirective('EXTENDEDSYNTAX',directive_all, @dir_extendedsyntax);
  1742. AddDirective('EXTERNALSYM',directive_all, @dir_externalsym);
  1743. AddDirective('F',directive_all, @dir_forcefarcalls);
  1744. AddDirective('FATAL',directive_all, @dir_fatal);
  1745. AddDirective('FPUTYPE',directive_all, @dir_fputype);
  1746. AddDirective('FRAMEWORKPATH',directive_all, @dir_frameworkpath);
  1747. AddDirective('GOTO',directive_all, @dir_goto);
  1748. AddDirective('HINT',directive_all, @dir_hint);
  1749. AddDirective('HINTS',directive_all, @dir_hints);
  1750. AddDirective('HPPEMIT',directive_all, @dir_hppemit);
  1751. AddDirective('HUGECODE',directive_all, @dir_hugecode);
  1752. AddDirective('HUGEPOINTERNORMALIZATION',directive_all,@dir_hugepointernormalization);
  1753. AddDirective('HUGEPOINTERARITHMETICNORMALIZATION',directive_all,@dir_hugepointerarithmeticnormalization);
  1754. AddDirective('HUGEPOINTERCOMPARISONNORMALIZATION',directive_all,@dir_hugepointercomparisonnormalization);
  1755. AddDirective('IEEEERRORS',directive_all,@dir_ieeeerrors);
  1756. AddDirective('IOCHECKS',directive_all, @dir_iochecks);
  1757. AddDirective('IMAGEBASE',directive_all, @dir_imagebase);
  1758. AddDirective('IMPLICITEXCEPTIONS',directive_all, @dir_implicitexceptions);
  1759. AddDirective('IMPORTEDDATA',directive_all, @dir_importeddata);
  1760. AddDirective('INCLUDEPATH',directive_all, @dir_includepath);
  1761. AddDirective('INFO',directive_all, @dir_info);
  1762. AddDirective('INLINE',directive_all, @dir_inline);
  1763. AddDirective('INTERFACES',directive_all, @dir_interfaces);
  1764. AddDirective('L',directive_all, @dir_link);
  1765. AddDirective('LIBEXPORT',directive_mac, @dir_libexport);
  1766. AddDirective('LIBRARYPATH',directive_all, @dir_librarypath);
  1767. AddDirective('LINK',directive_all, @dir_link);
  1768. AddDirective('LINKFRAMEWORK',directive_all, @dir_linkframework);
  1769. AddDirective('LINKLIB',directive_all, @dir_linklib);
  1770. AddDirective('LOCALSYMBOLS',directive_all, @dir_localsymbols);
  1771. AddDirective('LONGSTRINGS',directive_all, @dir_longstrings);
  1772. AddDirective('M',directive_all, @dir_memory);
  1773. AddDirective('MACRO',directive_all, @dir_macro);
  1774. AddDirective('MAXFPUREGISTERS',directive_all, @dir_maxfpuregisters);
  1775. AddDirective('MAXSTACKSIZE',directive_all, @dir_maxstacksize);
  1776. AddDirective('MEMORY',directive_all, @dir_memory);
  1777. AddDirective('MESSAGE',directive_all, @dir_message);
  1778. AddDirective('MINENUMSIZE',directive_all, @dir_packenum);
  1779. AddDirective('MINFPCONSTPREC',directive_all, @dir_minfpconstprec);
  1780. AddDirective('MINSTACKSIZE',directive_all, @dir_minstacksize);
  1781. AddDirective('MMX',directive_all, @dir_mmx);
  1782. AddDirective('MODE',directive_all, @dir_mode);
  1783. AddDirective('MODESWITCH',directive_all, @dir_modeswitch);
  1784. AddDirective('NAMESPACE',directive_all, @dir_namespace);
  1785. AddDirective('NODEFINE',directive_all, @dir_nodefine);
  1786. AddDirective('NOTE',directive_all, @dir_note);
  1787. AddDirective('NOTES',directive_all, @dir_notes);
  1788. AddDirective('OBJECTCHECKS',directive_all, @dir_objectchecks);
  1789. AddDirective('OBJECTPATH',directive_all, @dir_objectpath);
  1790. AddDirective('OPENSTRINGS',directive_all, @dir_openstrings);
  1791. AddDirective('OPTIMIZATION',directive_all, @dir_optimization);
  1792. AddDirective('OV',directive_mac, @dir_overflowchecks);
  1793. AddDirective('OVERFLOWCHECKS',directive_all, @dir_overflowchecks);
  1794. AddDirective('PACKENUM',directive_all, @dir_packenum);
  1795. AddDirective('PACKRECORDS',directive_all, @dir_packrecords);
  1796. AddDirective('PACKSET',directive_all, @dir_packset);
  1797. AddDirective('PASCALMAINNAME',directive_all, @dir_pascalmainname);
  1798. AddDirective('PIC',directive_all, @dir_pic);
  1799. AddDirective('POINTERMATH',directive_all, @dir_pointermath);
  1800. AddDirective('POP',directive_all, @dir_pop);
  1801. AddDirective('PROFILE',directive_all, @dir_profile);
  1802. AddDirective('PUSH',directive_all, @dir_push);
  1803. AddDirective('R',directive_all, @dir_resource);
  1804. AddDirective('RANGECHECKS',directive_all, @dir_rangechecks);
  1805. AddDirective('REFERENCEINFO',directive_all, @dir_referenceinfo);
  1806. AddDirective('REGION',directive_all, @dir_region);
  1807. AddDirective('RESOURCE',directive_all, @dir_resource);
  1808. AddDirective('SATURATION',directive_all, @dir_saturation);
  1809. AddDirective('SAFEFPUEXCEPTIONS',directive_all, @dir_safefpuexceptions);
  1810. AddDirective('SCOPEDENUMS',directive_all, @dir_scopedenums);
  1811. AddDirective('SETPEFLAGS', directive_all, @dir_setpeflags);
  1812. AddDirective('SETPEOPTFLAGS', directive_all, @dir_setpeoptflags);
  1813. AddDirective('SETPEOSVERSION', directive_all, @dir_setpeosversion);
  1814. AddDirective('SETPEUSERVERSION', directive_all, @dir_setpeuserversion);
  1815. AddDirective('SETPESUBSYSVERSION', directive_all, @dir_setpesubsysversion);
  1816. AddDirective('SCREENNAME',directive_all, @dir_screenname);
  1817. AddDirective('SMARTLINK',directive_all, @dir_smartlink);
  1818. AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
  1819. AddDirective('STOP',directive_all, @dir_stop);
  1820. AddDirective('STRINGCHECKS', directive_all, @dir_stringchecks);
  1821. AddDirective('SYSCALL',directive_all, @dir_syscall);
  1822. AddDirective('TARGETSWITCH',directive_all, @dir_targetswitch);
  1823. AddDirective('THREADNAME',directive_all, @dir_threadname);
  1824. AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
  1825. AddDirective('TYPEINFO',directive_all, @dir_typeinfo);
  1826. AddDirective('UNITPATH',directive_all, @dir_unitpath);
  1827. AddDirective('VARPARACOPYOUTCHECK',directive_all, @dir_varparacopyoutcheck);
  1828. AddDirective('VARPROPSETTER',directive_all, @dir_varpropsetter);
  1829. AddDirective('VARSTRINGCHECKS',directive_all, @dir_varstringchecks);
  1830. AddDirective('VERSION',directive_all, @dir_version);
  1831. AddDirective('WAIT',directive_all, @dir_wait);
  1832. AddDirective('WARN',directive_all, @dir_warn);
  1833. AddDirective('WARNING',directive_all, @dir_warning);
  1834. AddDirective('WARNINGS',directive_all, @dir_warnings);
  1835. AddDirective('WEAKPACKAGEUNIT',directive_all, @dir_weakpackageunit);
  1836. AddDirective('WRITEABLECONST',directive_all, @dir_writeableconst);
  1837. AddDirective('Z1',directive_all, @dir_z1);
  1838. AddDirective('Z2',directive_all, @dir_z2);
  1839. AddDirective('Z4',directive_all, @dir_z4);
  1840. AddDirective('ZEROBASEDSTRINGS',directive_all, @dir_zerobasesstrings);
  1841. end;
  1842. end.