scandir.pas 71 KB

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