scandir.pas 67 KB

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