2
0

scandir.pas 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204
  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 : longint;
  756. heapsize_limit: longint;
  757. maxheapsize_limit: longint;
  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(cpu16bitaddr)}
  776. heapsize_limit:=65520;
  777. maxheapsize_limit:=65520;
  778. {$else}
  779. heapsize_limit:=high(heapsize);
  780. maxheapsize_limit:=high(maxheapsize);
  781. {$endif}
  782. current_scanner.skipspace;
  783. l:=current_scanner.readval;
  784. if (l>=1024)
  785. {$ifdef cpu16bitaddr}
  786. and (l<=65521) { TP7's $M directive allows specifying a stack size of
  787. 65521, but it actually sets the stack size to 65520 }
  788. {$else cpu16bitaddr}
  789. and (l<67107840)
  790. {$endif cpu16bitaddr}
  791. then
  792. stacksize:=min(l,{$ifdef cpu16bitaddr}65520{$else}67107839{$endif})
  793. else
  794. Message(scan_w_invalid_stacksize);
  795. if c=',' then
  796. begin
  797. current_scanner.readchar;
  798. current_scanner.skipspace;
  799. l:=current_scanner.readval;
  800. if l>=1024 then
  801. heapsize:=min(l,heapsize_limit);
  802. if c=',' then
  803. begin
  804. current_scanner.readchar;
  805. current_scanner.skipspace;
  806. l:=current_scanner.readval;
  807. if l>=heapsize then
  808. maxheapsize:=min(l,maxheapsize_limit)
  809. else
  810. Message(scan_w_heapmax_lessthan_heapmin);
  811. end;
  812. end;
  813. end;
  814. procedure dir_message;
  815. var
  816. hs : string;
  817. w : longint;
  818. begin
  819. w:=0;
  820. current_scanner.skipspace;
  821. { Message level specified? }
  822. if c='''' then
  823. w:=scan_n_user_defined
  824. else
  825. begin
  826. hs:=current_scanner.readid;
  827. if (hs='WARN') or (hs='WARNING') then
  828. w:=scan_w_user_defined
  829. else
  830. if (hs='ERROR') then
  831. w:=scan_e_user_defined
  832. else
  833. if (hs='FATAL') then
  834. w:=scan_f_user_defined
  835. else
  836. if (hs='HINT') then
  837. w:=scan_h_user_defined
  838. else
  839. if (hs='NOTE') then
  840. w:=scan_n_user_defined
  841. else
  842. if (hs='INFO') then
  843. w:=scan_i_user_defined
  844. else
  845. Message1(scan_w_illegal_directive,hs);
  846. end;
  847. { Only print message when there was no error }
  848. if w<>0 then
  849. begin
  850. current_scanner.skipspace;
  851. if c='''' then
  852. hs:=current_scanner.readquotedstring
  853. else
  854. hs:=current_scanner.readcomment;
  855. Message1(w,hs);
  856. end
  857. else
  858. current_scanner.readcomment;
  859. end;
  860. procedure dir_minstacksize;
  861. begin
  862. if not (target_info.system in (systems_windows+systems_wince)) then
  863. Message(scan_w_minstacksize_not_support);
  864. current_scanner.skipspace;
  865. minstacksize:=current_scanner.readval;
  866. MinStackSizeSetExplicity:=true;
  867. end;
  868. procedure dir_mode;
  869. begin
  870. if not current_module.in_global then
  871. Message(scan_w_switch_is_global)
  872. else
  873. begin
  874. current_scanner.skipspace;
  875. current_scanner.readstring;
  876. if not current_module.mode_switch_allowed and
  877. not ((m_mac in current_settings.modeswitches) and (pattern='MACPAS')) then
  878. Message1(scan_e_mode_switch_not_allowed,pattern)
  879. else if not SetCompileMode(pattern,false) then
  880. Message1(scan_w_illegal_switch,pattern)
  881. end;
  882. current_module.mode_switch_allowed:= false;
  883. end;
  884. procedure dir_modeswitch;
  885. var
  886. s : string;
  887. begin
  888. if not current_module.in_global then
  889. Message(scan_w_switch_is_global)
  890. else
  891. begin
  892. current_scanner.skipspace;
  893. current_scanner.readstring;
  894. s:=pattern;
  895. { don't combine the assignments to s as the method call will be
  896. done before "pattern" is assigned to s and the method changes
  897. "pattern" }
  898. s:=s+current_scanner.readoptionalstate('+');
  899. if not SetCompileModeSwitch(s,false) then
  900. Message1(scan_w_illegal_switch,s)
  901. end;
  902. end;
  903. procedure dir_namespaces;
  904. { add namespaces to the local namespace list }
  905. var
  906. s : string;
  907. begin
  908. if not current_module.in_global then
  909. Message(scan_w_switch_is_global)
  910. else
  911. begin
  912. current_scanner.skipspace;
  913. current_scanner.readstring;
  914. s:=orgpattern;
  915. While (s<>'') do
  916. begin
  917. // We may not yet have a correct module namespacelist.
  918. if assigned(current_namespacelist) then
  919. current_namespacelist.Insert(s)
  920. else // copied when correct module is activated
  921. premodule_namespacelist.Insert(s);
  922. s:='';
  923. if c=',' then
  924. begin
  925. current_scanner.readchar;
  926. current_scanner.skipspace;
  927. current_scanner.readstring;
  928. s:=orgpattern;
  929. end;
  930. end;
  931. end;
  932. end;
  933. procedure dir_namespace;
  934. var
  935. s : string;
  936. begin
  937. { used to define Java package names for all types declared in the
  938. current unit }
  939. if not current_module.in_global then
  940. Message(scan_w_switch_is_global)
  941. else
  942. begin
  943. current_scanner.skipspace;
  944. current_scanner.readstring;
  945. s:=orgpattern;
  946. while c='.' do
  947. begin
  948. current_scanner.readchar;
  949. current_scanner.readstring;
  950. s:=s+'.'+orgpattern;
  951. end;
  952. disposestr(current_module.namespace);
  953. current_module.namespace:=stringdup(s);
  954. end;
  955. end;
  956. procedure dir_legacyifend;
  957. begin
  958. do_localswitch(cs_legacyifend);
  959. end;
  960. procedure dir_mmx;
  961. begin
  962. do_localswitch(cs_mmx);
  963. end;
  964. procedure dir_note;
  965. begin
  966. do_message(scan_n_user_defined);
  967. end;
  968. procedure dir_notes;
  969. begin
  970. do_setverbose('N');
  971. end;
  972. procedure dir_objectpath;
  973. begin
  974. if not current_module.in_global then
  975. Message(scan_w_switch_is_global)
  976. else
  977. begin
  978. current_scanner.skipspace;
  979. current_module.localobjectsearchpath.AddPath(current_scanner.readcomment,false);
  980. end;
  981. end;
  982. procedure dir_openstrings;
  983. begin
  984. do_delphiswitch('P');
  985. end;
  986. procedure dir_optimization;
  987. var
  988. hs : string;
  989. begin
  990. current_scanner.skipspace;
  991. { Support also the ON and OFF as switch }
  992. hs:=current_scanner.readid;
  993. if (hs='ON') then
  994. current_settings.optimizerswitches:=level2optimizerswitches
  995. else if (hs='OFF') then
  996. current_settings.optimizerswitches:=[]
  997. else if (hs='DEFAULT') then
  998. current_settings.optimizerswitches:=init_settings.optimizerswitches
  999. else
  1000. begin
  1001. if not UpdateOptimizerStr(hs,current_settings.optimizerswitches) then
  1002. Message1(scan_e_illegal_optimization_specifier,hs);
  1003. end;
  1004. end;
  1005. procedure dir_overflowchecks;
  1006. begin
  1007. do_delphiswitch('Q');
  1008. end;
  1009. procedure dir_packenum;
  1010. var
  1011. hs : string;
  1012. v : longint;
  1013. begin
  1014. current_scanner.skipspace;
  1015. if not(c in ['0'..'9']) then
  1016. begin
  1017. hs:=current_scanner.readid;
  1018. if (hs='NORMAL') or (hs='DEFAULT') then
  1019. recordpendingpackenum(4)
  1020. else
  1021. Message1(scan_e_illegal_pack_enum, hs);
  1022. end
  1023. else
  1024. begin
  1025. v:=current_scanner.readval;
  1026. case v of
  1027. 1,2,4 : recordpendingpackenum(v);
  1028. else
  1029. Message1(scan_e_illegal_pack_enum, pattern);
  1030. end;
  1031. end;
  1032. end;
  1033. procedure dir_minfpconstprec;
  1034. begin
  1035. current_scanner.skipspace;
  1036. if not SetMinFPConstPrec(current_scanner.readid,current_settings.minfpconstprec) then
  1037. Message1(scan_e_illegal_minfpconstprec, pattern);
  1038. end;
  1039. procedure dir_packrecords;
  1040. var
  1041. hs : string;
  1042. v : longint;
  1043. begin
  1044. { can't change packrecords setting on managed vm targets }
  1045. if target_info.system in systems_managed_vm then
  1046. Message1(scanner_w_directive_ignored_on_target, 'PACKRECORDS');
  1047. current_scanner.skipspace;
  1048. if not(c in ['0'..'9']) then
  1049. begin
  1050. hs:=current_scanner.readid;
  1051. { C has the special recordalignmax of C_alignment }
  1052. if (hs='C') then
  1053. recordpendingpackrecords(C_alignment)
  1054. else
  1055. if (hs='NORMAL') or (hs='DEFAULT') then
  1056. recordpendingpackrecords(default_settings.packrecords)
  1057. else
  1058. Message1(scan_e_illegal_pack_records,hs);
  1059. end
  1060. else
  1061. begin
  1062. v:=current_scanner.readval;
  1063. case v of
  1064. 1,2,4,8,16,32 : recordpendingpackrecords(v);
  1065. else
  1066. Message1(scan_e_illegal_pack_records,pattern);
  1067. end;
  1068. end;
  1069. end;
  1070. procedure dir_packset;
  1071. var
  1072. hs : string;
  1073. v : longint;
  1074. begin
  1075. current_scanner.skipspace;
  1076. if not(c in ['1','2','4','8']) then
  1077. begin
  1078. hs:=current_scanner.readid;
  1079. if (hs='FIXED') or (hs='DEFAULT') OR (hs='NORMAL') then
  1080. recordpendingsetalloc(0) {Fixed mode, sets are 4 or 32 bytes}
  1081. else
  1082. Message(scan_e_only_packset);
  1083. end
  1084. else
  1085. begin
  1086. v:=current_scanner.readval;
  1087. case v of
  1088. 1,2,4,8 : recordpendingsetalloc(v);
  1089. else
  1090. Message(scan_e_only_packset);
  1091. end;
  1092. end;
  1093. end;
  1094. procedure dir_pic;
  1095. begin
  1096. { windows doesn't need/support pic }
  1097. if tf_no_pic_supported in target_info.flags then
  1098. message(scan_w_pic_ignored)
  1099. else
  1100. do_moduleswitch(cs_create_pic);
  1101. end;
  1102. procedure dir_pop;
  1103. begin
  1104. if switchesstatestackpos < 1 then
  1105. Message(scan_e_too_many_pop)
  1106. else
  1107. begin
  1108. Dec(switchesstatestackpos);
  1109. recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
  1110. recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
  1111. recordpendingalignmentfullswitch(switchesstatestack[switchesstatestackpos].alignment);
  1112. recordpendingpackenum(switchesstatestack[switchesstatestackpos].packenum);
  1113. recordpendingpackrecords(switchesstatestack[switchesstatestackpos].packrecords);
  1114. recordpendingsetalloc(switchesstatestack[switchesstatestackpos].setalloc);
  1115. pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
  1116. { Reset verbosity and forget previous pmeesage }
  1117. RestoreLocalVerbosity(nil);
  1118. current_settings.pmessage:=nil;
  1119. { Do not activate these changes yet, as otherwise
  1120. you get a problem if you put a $pop just right after
  1121. a addition for instance for which you explicitly turned the overflow check
  1122. off by using $Q- after a $push PM 2012-08-29 }
  1123. // flushpendingswitchesstate;
  1124. end;
  1125. end;
  1126. procedure dir_pointermath;
  1127. begin
  1128. do_localswitch(cs_pointermath);
  1129. end;
  1130. procedure dir_profile;
  1131. begin
  1132. do_moduleswitch(cs_profile);
  1133. { defined/undefine FPC_PROFILE }
  1134. if cs_profile in current_settings.moduleswitches then
  1135. def_system_macro('FPC_PROFILE')
  1136. else
  1137. undef_system_macro('FPC_PROFILE');
  1138. end;
  1139. procedure dir_push;
  1140. begin
  1141. if switchesstatestackpos > switchesstatestackmax then
  1142. Message(scan_e_too_many_push);
  1143. { do not flush here as we might have read directives which shall not be active yet,
  1144. see e.g. tests/webtbs/tw22744b.pp }
  1145. if psf_alignment_changed in pendingstate.flags then
  1146. switchesstatestack[switchesstatestackpos].alignment:=pendingstate.nextalignment
  1147. else
  1148. switchesstatestack[switchesstatestackpos].alignment:=current_settings.alignment;
  1149. if psf_verbosity_full_switched in pendingstate.flags then
  1150. switchesstatestack[switchesstatestackpos].verbosity:=pendingstate.nextverbosityfullswitch
  1151. else
  1152. switchesstatestack[switchesstatestackpos].verbosity:=status.verbosity;
  1153. if psf_local_switches_changed in pendingstate.flags then
  1154. switchesstatestack[switchesstatestackpos].localsw:=pendingstate.nextlocalswitches
  1155. else
  1156. switchesstatestack[switchesstatestackpos].localsw:=current_settings.localswitches;
  1157. if psf_packenum_changed in pendingstate.flags then
  1158. switchesstatestack[switchesstatestackpos].packenum:=pendingstate.nextpackenum
  1159. else
  1160. switchesstatestack[switchesstatestackpos].packenum:=current_settings.packenum;
  1161. if psf_packrecords_changed in pendingstate.flags then
  1162. switchesstatestack[switchesstatestackpos].packrecords:=pendingstate.nextpackrecords
  1163. else
  1164. switchesstatestack[switchesstatestackpos].packrecords:=current_settings.packrecords;
  1165. if psf_setalloc_changed in pendingstate.flags then
  1166. switchesstatestack[switchesstatestackpos].setalloc:=pendingstate.nextsetalloc
  1167. else
  1168. switchesstatestack[switchesstatestackpos].setalloc:=current_settings.setalloc;
  1169. switchesstatestack[switchesstatestackpos].pmessage:=pendingstate.nextmessagerecord;
  1170. Inc(switchesstatestackpos);
  1171. end;
  1172. procedure dir_rangechecks;
  1173. begin
  1174. do_delphiswitch('R');
  1175. end;
  1176. procedure dir_referenceinfo;
  1177. begin
  1178. do_delphiswitch('Y');
  1179. end;
  1180. procedure dir_resource;
  1181. var
  1182. s : string;
  1183. begin
  1184. current_scanner.skipspace;
  1185. if scanner.c = '''' then
  1186. begin
  1187. s:= current_scanner.readquotedstring;
  1188. current_scanner.readcomment
  1189. end
  1190. else
  1191. s:= trimspace(current_scanner.readcomment);
  1192. { replace * with the name of the main source.
  1193. This should always be defined. }
  1194. if s[1]='*' then
  1195. if Assigned(Current_Module) then
  1196. begin
  1197. delete(S,1,1);
  1198. insert(ChangeFileExt(ExtractFileName(current_module.mainsource),''),S,1 );
  1199. end;
  1200. s:=FixFileName(s);
  1201. if ExtractFileExt(s)='' then
  1202. s:=ChangeFileExt(s,target_info.resext);
  1203. if target_info.res<>res_none then
  1204. begin
  1205. include(current_module.moduleflags,mf_has_resourcefiles);
  1206. if (res_single_file in target_res.resflags) and
  1207. not (Current_module.ResourceFiles.Empty) then
  1208. Message(scan_w_only_one_resourcefile_supported)
  1209. else
  1210. current_module.resourcefiles.insert(FixFileName(s));
  1211. end
  1212. else
  1213. Message(scan_e_resourcefiles_not_supported);
  1214. end;
  1215. procedure dir_rtti;
  1216. function read_rtti_options: trtti_visibilities;
  1217. var
  1218. sym: ttypesym;
  1219. value: tnormalset;
  1220. begin
  1221. result:=[];
  1222. sym:=search_system_type('TVISIBILITYCLASSES');
  1223. if current_scanner.readpreprocset(tsetdef(sym.typedef),value,'RTTI') then
  1224. begin
  1225. result:=prtti_visibilities(@value)^;
  1226. // if the set was empty we need to read the next id
  1227. if result=[] then
  1228. begin
  1229. current_scanner.skipspace;
  1230. current_scanner.readid
  1231. end;
  1232. end;
  1233. end;
  1234. var
  1235. dir: trtti_directive;
  1236. option: trtti_option;
  1237. options: array[trtti_option] of boolean;
  1238. begin
  1239. { the system unit has not yet loaded which means the directive is misplaced}
  1240. if systemunit=nil then
  1241. begin
  1242. Message(scan_e_misplaced_rtti_directive);
  1243. exit;
  1244. end;
  1245. dir:=default(trtti_directive);
  1246. options[ro_fields]:=false;
  1247. options[ro_methods]:=false;
  1248. options[ro_properties]:=false;
  1249. { read the clause }
  1250. current_scanner.skipspace;
  1251. current_scanner.readid;
  1252. case pattern of
  1253. 'INHERIT':
  1254. dir.clause:=rtc_inherit;
  1255. 'EXPLICIT':
  1256. dir.clause:=rtc_explicit;
  1257. otherwise
  1258. Message(scan_e_invalid_rtti_clause);
  1259. end;
  1260. { read the visibility options}
  1261. current_scanner.skipspace;
  1262. current_scanner.readid;
  1263. { the inherit clause doesn't require any options but explicit does }
  1264. if (pattern='') and (dir.clause=rtc_explicit) then
  1265. Message(scan_e_incomplete_rtti_clause);
  1266. while pattern<>'' do
  1267. begin
  1268. case pattern of
  1269. 'METHODS':
  1270. option:=ro_methods;
  1271. 'PROPERTIES':
  1272. option:=ro_properties;
  1273. 'FIELDS':
  1274. option:=ro_fields;
  1275. otherwise
  1276. begin
  1277. if current_scanner.preproc_token=_ID then
  1278. Message1(scan_e_invalid_rtti_option,pattern);
  1279. break;
  1280. end;
  1281. end;
  1282. { the option has already been used }
  1283. if options[option] then
  1284. begin
  1285. Message1(scan_e_duplicate_rtti_option,pattern);
  1286. break;
  1287. end;
  1288. dir.options[option]:=read_rtti_options;
  1289. options[option]:=true;
  1290. end;
  1291. { set the directive in the module }
  1292. current_module.rtti_directive:=dir;
  1293. end;
  1294. procedure dir_saturation;
  1295. begin
  1296. do_localswitch(cs_mmx_saturation);
  1297. end;
  1298. procedure dir_safefpuexceptions;
  1299. begin
  1300. do_localswitch(cs_fpu_fwait);
  1301. end;
  1302. procedure dir_scopedenums;
  1303. begin
  1304. do_localswitch(cs_scopedenums);
  1305. end;
  1306. function get_peflag_const(const ident:string;error:longint):longint;
  1307. var
  1308. srsym : tsym;
  1309. srsymtable : tsymtable;
  1310. begin
  1311. result:=0;
  1312. if searchsym(ident,srsym,srsymtable) then
  1313. if (srsym.typ=constsym) and
  1314. (tconstsym(srsym).consttyp=constord) and
  1315. is_integer(tconstsym(srsym).constdef) then
  1316. with tconstsym(srsym).value.valueord do
  1317. if signed then
  1318. result:=tconstsym(srsym).value.valueord.svalue
  1319. else
  1320. result:=tconstsym(srsym).value.valueord.uvalue
  1321. else
  1322. message(error)
  1323. else
  1324. message1(sym_e_id_not_found,ident);
  1325. end;
  1326. procedure dir_setpeflags;
  1327. var
  1328. flags : int64;
  1329. begin
  1330. if not (target_info.system in (systems_all_windows)) then
  1331. Message(scan_w_setpeflags_not_support);
  1332. if current_scanner.readpreprocint(flags,'SETPEFLAGS') then
  1333. begin
  1334. if flags>$ffff then
  1335. message(scan_e_illegal_peflag);
  1336. peflags:=peflags or uint16(flags);
  1337. end;
  1338. SetPEFlagsSetExplicity:=true;
  1339. end;
  1340. procedure dir_setpeoptflags;
  1341. var
  1342. flags : int64;
  1343. begin
  1344. if not (target_info.system in (systems_all_windows)) then
  1345. Message(scan_w_setpeoptflags_not_support);
  1346. if current_scanner.readpreprocint(flags,'SETPEOPTFLAGS') then
  1347. begin
  1348. if flags>$ffff then
  1349. message(scan_e_illegal_peoptflag);
  1350. peoptflags:=peoptflags or uint16(flags);
  1351. end;
  1352. SetPEOptFlagsSetExplicity:=true;
  1353. end;
  1354. procedure dir_setpeuserversion;
  1355. var
  1356. dummystr : string;
  1357. dummyrev : word;
  1358. begin
  1359. if not (target_info.system in systems_all_windows) then
  1360. Message(scan_w_setpeuserversion_not_support);
  1361. if (not current_module.is_initial) then
  1362. Message(scan_n_only_exe_version)
  1363. else
  1364. do_version(peuserversionmajor,peuserversionminor,dummyrev,dummystr,false,SetPEUserVersionSetExplicitely);
  1365. end;
  1366. procedure dir_setpeosversion;
  1367. var
  1368. dummystr : string;
  1369. dummyrev : word;
  1370. begin
  1371. if not (target_info.system in systems_all_windows) then
  1372. Message(scan_w_setpeosversion_not_support);
  1373. if (not current_module.is_initial) then
  1374. Message(scan_n_only_exe_version)
  1375. else
  1376. do_version(peosversionmajor,peosversionminor,dummyrev,dummystr,false,SetPEOSVersionSetExplicitely);
  1377. end;
  1378. procedure dir_setpesubsysversion;
  1379. var
  1380. dummystr : string;
  1381. dummyrev : word;
  1382. begin
  1383. if not (target_info.system in systems_all_windows) then
  1384. Message(scan_w_setpesubsysversion_not_support);
  1385. if (not current_module.is_initial) then
  1386. Message(scan_n_only_exe_version)
  1387. else
  1388. do_version(pesubsysversionmajor,pesubsysversionminor,dummyrev,dummystr,false,SetPESubSysVersionSetExplicitely);
  1389. end;
  1390. procedure dir_smartlink;
  1391. begin
  1392. do_moduleswitch(cs_create_smart);
  1393. if (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  1394. not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) and
  1395. { smart linking does not yet work with DWARF debug info on most targets }
  1396. (cs_create_smart in current_settings.moduleswitches) and
  1397. not (af_outputbinary in target_asm.flags) then
  1398. begin
  1399. Message(option_dwarf_smart_linking);
  1400. Exclude(current_settings.moduleswitches,cs_create_smart);
  1401. end;
  1402. { Also create a smartlinked version, on an assembler that
  1403. does not support smartlink sections like nasm?
  1404. This is not compatible with using internal linker. }
  1405. if ((cs_link_smart in current_settings.globalswitches) or
  1406. (cs_create_smart in current_settings.moduleswitches)) and
  1407. (af_needar in target_asm.flags) and
  1408. not (af_smartlink_sections in target_asm.flags) and
  1409. not (cs_link_extern in current_settings.globalswitches) then
  1410. begin
  1411. DoneLinker;
  1412. Message(option_smart_link_requires_external_linker);
  1413. include(current_settings.globalswitches,cs_link_extern);
  1414. InitLinker;
  1415. end
  1416. end;
  1417. procedure dir_stackframes;
  1418. begin
  1419. do_delphiswitch('W');
  1420. end;
  1421. procedure dir_stop;
  1422. begin
  1423. do_message(scan_f_user_defined);
  1424. end;
  1425. procedure dir_stringchecks;
  1426. begin
  1427. // Delphi adds checks that ansistring and unicodestring are correct in
  1428. // different places. Skip it for now.
  1429. end;
  1430. procedure dir_syscall;
  1431. var
  1432. sctype : string;
  1433. syscall : psyscallinfo;
  1434. begin
  1435. current_scanner.skipspace;
  1436. sctype:=current_scanner.readid;
  1437. syscall:=get_syscall_by_name(sctype);
  1438. if assigned(syscall) then
  1439. begin
  1440. if not (target_info.system in syscall^.validon) then
  1441. Message(scan_w_syscall_convention_not_useable_on_target)
  1442. else
  1443. set_default_syscall(syscall^.procoption);
  1444. exit;
  1445. end;
  1446. Message(scan_w_syscall_convention_invalid);
  1447. end;
  1448. procedure dir_targetswitch;
  1449. var
  1450. name, value: string;
  1451. begin
  1452. { note: *not* recorded in the tokenstream, so not replayed for generics }
  1453. current_scanner.skipspace;
  1454. name:=current_scanner.readid;
  1455. if c='=' then
  1456. begin
  1457. current_scanner.readchar;
  1458. current_scanner.readid;
  1459. value:=orgpattern;
  1460. UpdateTargetSwitchStr(name+'='+value,current_settings.targetswitches,current_module.in_global);
  1461. end
  1462. else if c='-' then
  1463. begin
  1464. current_scanner.readchar;
  1465. UpdateTargetSwitchStr(name+'-',current_settings.targetswitches,current_module.in_global);
  1466. end
  1467. else
  1468. UpdateTargetSwitchStr(name,current_settings.targetswitches,current_module.in_global);
  1469. end;
  1470. procedure dir_typedaddress;
  1471. begin
  1472. do_delphiswitch('T');
  1473. end;
  1474. procedure dir_typeinfo;
  1475. begin
  1476. do_delphiswitch('M');
  1477. end;
  1478. procedure dir_unitpath;
  1479. var
  1480. unitpath: TPathStr;
  1481. begin
  1482. if not current_module.in_global then
  1483. Message(scan_w_switch_is_global)
  1484. else
  1485. begin
  1486. current_scanner.skipspace;
  1487. unitpath:=current_scanner.readcomment;
  1488. if (current_module.path<>'') and
  1489. not path_absolute(unitpath) then
  1490. unitpath:=current_module.path+source_info.DirSep+unitpath;
  1491. current_module.localunitsearchpath.AddPath(unitpath,false);
  1492. end;
  1493. end;
  1494. procedure dir_varparacopyoutcheck;
  1495. begin
  1496. if not(target_info.system in systems_jvm) then
  1497. begin
  1498. Message1(scan_w_illegal_switch,pattern);
  1499. exit;
  1500. end;
  1501. do_localswitch(cs_check_var_copyout);
  1502. end;
  1503. procedure dir_varpropsetter;
  1504. begin
  1505. do_localswitch(cs_varpropsetter);
  1506. end;
  1507. procedure dir_varstringchecks;
  1508. begin
  1509. do_delphiswitch('V');
  1510. end;
  1511. procedure dir_version;
  1512. var
  1513. major, minor, revision : longint;
  1514. error : integer;
  1515. begin
  1516. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  1517. system_i386_netware,system_i386_wdosx,
  1518. system_i386_netwlibc]) then
  1519. begin
  1520. Message(scan_n_version_not_support);
  1521. exit;
  1522. end;
  1523. if (not current_module.is_initial) then
  1524. Message(scan_n_only_exe_version)
  1525. else
  1526. begin
  1527. { change description global var in all cases }
  1528. { it not used but in win32, os2 and netware }
  1529. current_scanner.skipspace;
  1530. { we should only accept Major.Minor format for win32 and os2 }
  1531. current_scanner.readnumber;
  1532. major:=0;
  1533. minor:=0;
  1534. revision:=0;
  1535. val(pattern,major,error);
  1536. if (error<>0) or (major > high(word)) or (major < 0) then
  1537. begin
  1538. Message1(scan_w_wrong_version_ignored,pattern);
  1539. exit;
  1540. end;
  1541. if c='.' then
  1542. begin
  1543. current_scanner.readchar;
  1544. current_scanner.readnumber;
  1545. val(pattern,minor,error);
  1546. if (error<>0) or (minor > high(word)) or (minor < 0) then
  1547. begin
  1548. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  1549. exit;
  1550. end;
  1551. if (c='.') and
  1552. (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  1553. begin
  1554. current_scanner.readchar;
  1555. current_scanner.readnumber;
  1556. val(pattern,revision,error);
  1557. if (error<>0) or (revision > high(word)) or (revision < 0) then
  1558. begin
  1559. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  1560. exit;
  1561. end;
  1562. dllmajor:=word(major);
  1563. dllminor:=word(minor);
  1564. dllrevision:=word(revision);
  1565. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  1566. end
  1567. else
  1568. begin
  1569. dllmajor:=word(major);
  1570. dllminor:=word(minor);
  1571. dllversion:=tostr(major)+'.'+tostr(minor);
  1572. end;
  1573. end
  1574. else
  1575. dllversion:=tostr(major);
  1576. end;
  1577. end;
  1578. procedure dir_wait;
  1579. var
  1580. had_info : boolean;
  1581. begin
  1582. had_info:=(status.verbosity and V_Info)<>0;
  1583. { this message should allways appear !! }
  1584. status.verbosity:=status.verbosity or V_Info;
  1585. Message(scan_i_press_enter);
  1586. readln;
  1587. If not(had_info) then
  1588. status.verbosity:=status.verbosity and (not V_Info);
  1589. end;
  1590. { delphi compatible warn directive:
  1591. $warn <identifier> on
  1592. $warn <identifier> off
  1593. $warn <identifier> error
  1594. }
  1595. procedure dir_warn;
  1596. var
  1597. ident : string;
  1598. state : string;
  1599. msgstate : tmsgstate;
  1600. i : integer;
  1601. begin
  1602. current_scanner.skipspace;
  1603. ident:=current_scanner.readid;
  1604. current_scanner.skipspace;
  1605. state:=current_scanner.readid;
  1606. { support both delphi and fpc switches }
  1607. { use local ms_on/off/error tmsgstate values }
  1608. if (state='ON') or (state='+') then
  1609. msgstate:=ms_on
  1610. else
  1611. if (state='OFF') or (state='-') then
  1612. msgstate:=ms_off
  1613. else
  1614. if (state='ERROR') then
  1615. msgstate:=ms_error
  1616. else
  1617. begin
  1618. Message1(scanner_e_illegal_warn_state,state);
  1619. exit;
  1620. end;
  1621. if ident='CONSTRUCTING_ABSTRACT' then
  1622. begin
  1623. recordpendingmessagestate(type_w_instance_with_abstract, msgstate);
  1624. recordpendingmessagestate(type_w_instance_abstract_class, msgstate);
  1625. end
  1626. else
  1627. if ident='IMPLICIT_VARIANTS' then
  1628. recordpendingmessagestate(parser_w_implicit_uses_of_variants_unit, msgstate)
  1629. else
  1630. if ident='NO_RETVAL' then
  1631. recordpendingmessagestate(sym_w_function_result_not_set, msgstate)
  1632. else
  1633. if ident='SYMBOL_DEPRECATED' then
  1634. begin
  1635. recordpendingmessagestate(sym_w_deprecated_symbol, msgstate);
  1636. recordpendingmessagestate(sym_w_deprecated_symbol_with_msg, msgstate);
  1637. end
  1638. else
  1639. if ident='SYMBOL_EXPERIMENTAL' then
  1640. recordpendingmessagestate(sym_w_experimental_symbol, msgstate)
  1641. else
  1642. if ident='SYMBOL_LIBRARY' then
  1643. recordpendingmessagestate(sym_w_library_symbol, msgstate)
  1644. else
  1645. if ident='SYMBOL_PLATFORM' then
  1646. recordpendingmessagestate(sym_w_non_portable_symbol, msgstate)
  1647. else
  1648. if ident='SYMBOL_UNIMPLEMENTED' then
  1649. recordpendingmessagestate(sym_w_non_implemented_symbol, msgstate)
  1650. else
  1651. if ident='UNIT_DEPRECATED' then
  1652. begin
  1653. recordpendingmessagestate(sym_w_deprecated_unit, msgstate);
  1654. recordpendingmessagestate(sym_w_deprecated_unit_with_msg, msgstate);
  1655. end
  1656. else
  1657. if ident='UNIT_EXPERIMENTAL' then
  1658. recordpendingmessagestate(sym_w_experimental_unit, msgstate)
  1659. else
  1660. if ident='UNIT_LIBRARY' then
  1661. recordpendingmessagestate(sym_w_library_unit, msgstate)
  1662. else
  1663. if ident='UNIT_PLATFORM' then
  1664. recordpendingmessagestate(sym_w_non_portable_unit, msgstate)
  1665. else
  1666. if ident='UNIT_UNIMPLEMENTED' then
  1667. recordpendingmessagestate(sym_w_non_implemented_unit, msgstate)
  1668. else
  1669. if ident='ZERO_NIL_COMPAT' then
  1670. recordpendingmessagestate(type_w_zero_to_nil, msgstate)
  1671. else
  1672. if ident='IMPLICIT_STRING_CAST' then
  1673. recordpendingmessagestate(type_w_implicit_string_cast, msgstate)
  1674. else
  1675. if ident='IMPLICIT_STRING_CAST_LOSS' then
  1676. recordpendingmessagestate(type_w_implicit_string_cast_loss, msgstate)
  1677. else
  1678. if ident='EXPLICIT_STRING_CAST' then
  1679. recordpendingmessagestate(type_w_explicit_string_cast, msgstate)
  1680. else
  1681. if ident='EXPLICIT_STRING_CAST_LOSS' then
  1682. recordpendingmessagestate(type_w_explicit_string_cast_loss, msgstate)
  1683. else
  1684. if ident='CVT_NARROWING_STRING_LOST' then
  1685. recordpendingmessagestate(type_w_unicode_data_loss, msgstate)
  1686. else
  1687. if ident='INTF_RAISE_VISIBILITY' then
  1688. recordpendingmessagestate(type_w_interface_lower_visibility, msgstate)
  1689. else
  1690. begin
  1691. i:=0;
  1692. if not ChangeMessageVerbosity(ident,i,msgstate) then
  1693. Message1(scanner_w_illegal_warn_identifier,ident);
  1694. end;
  1695. end;
  1696. procedure dir_warning;
  1697. begin
  1698. do_message(scan_w_user_defined);
  1699. end;
  1700. procedure dir_warnings;
  1701. begin
  1702. do_setverbose('W');
  1703. end;
  1704. procedure dir_weakpackageunit;
  1705. begin
  1706. { old Delphi versions seem to use merely $WEAKPACKAGEUNIT while newer
  1707. Delphis have $WEAPACKAGEUNIT ON... :/ }
  1708. do_moduleflagswitch(mf_package_weak, true);
  1709. end;
  1710. procedure dir_writeableconst;
  1711. begin
  1712. do_delphiswitch('J');
  1713. end;
  1714. procedure dir_z1;
  1715. begin
  1716. current_settings.packenum:=1;
  1717. end;
  1718. procedure dir_z2;
  1719. begin
  1720. current_settings.packenum:=2;
  1721. end;
  1722. procedure dir_z4;
  1723. begin
  1724. current_settings.packenum:=4;
  1725. end;
  1726. procedure dir_externalsym;
  1727. begin
  1728. end;
  1729. procedure dir_nodefine;
  1730. begin
  1731. end;
  1732. procedure dir_hppemit;
  1733. begin
  1734. end;
  1735. procedure dir_hugecode;
  1736. begin
  1737. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded])
  1738. {$ifdef i8086}
  1739. or (current_settings.x86memorymodel in x86_near_code_models)
  1740. {$endif i8086}
  1741. then
  1742. begin
  1743. Message1(scan_n_ignored_switch,pattern);
  1744. exit;
  1745. end;
  1746. do_moduleswitch(cs_huge_code);
  1747. end;
  1748. procedure dir_hugepointernormalization;
  1749. var
  1750. hs : string;
  1751. begin
  1752. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1753. begin
  1754. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERNORMALIZATION');
  1755. exit;
  1756. end;
  1757. current_scanner.skipspace;
  1758. hs:=current_scanner.readid;
  1759. case hs of
  1760. 'BORLANDC':
  1761. begin
  1762. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'+');
  1763. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1764. end;
  1765. 'MICROSOFTC':
  1766. begin
  1767. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1768. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'-');
  1769. end;
  1770. 'WATCOMC':
  1771. begin
  1772. recordpendinglocalswitch(cs_hugeptr_arithmetic_normalization,'-');
  1773. recordpendinglocalswitch(cs_hugeptr_comparison_normalization,'+');
  1774. end;
  1775. else
  1776. Message(scan_e_illegal_hugepointernormalization);
  1777. end;
  1778. end;
  1779. procedure dir_hugepointerarithmeticnormalization;
  1780. begin
  1781. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1782. begin
  1783. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERARITHMETICNORMALIZATION');
  1784. exit;
  1785. end;
  1786. do_localswitch(cs_hugeptr_arithmetic_normalization);
  1787. end;
  1788. procedure dir_hugepointercomparisonnormalization;
  1789. begin
  1790. if not (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
  1791. begin
  1792. Message1(scanner_w_directive_ignored_on_target, 'HUGEPOINTERCOMPARISONNORMALIZATION');
  1793. exit;
  1794. end;
  1795. do_localswitch(cs_hugeptr_comparison_normalization);
  1796. end;
  1797. procedure dir_codealign;
  1798. var
  1799. s : string;
  1800. begin
  1801. current_scanner.skipspace;
  1802. s:=current_scanner.readcomment;
  1803. if not(UpdateAlignmentStr(s,current_settings.alignment)) then
  1804. message(scanner_e_illegal_alignment_directive);
  1805. end;
  1806. procedure dir_codepage;
  1807. var
  1808. s : string;
  1809. begin
  1810. if not current_module.in_global then
  1811. Message(scan_w_switch_is_global)
  1812. else
  1813. begin
  1814. current_scanner.skipspace;
  1815. s:=current_scanner.readcomment;
  1816. if (upper(s)='UTF8') or (upper(s)='UTF-8') then
  1817. current_settings.sourcecodepage:=CP_UTF8
  1818. else if not cpavailable(s) then
  1819. Message1(option_code_page_not_available,s)
  1820. else
  1821. current_settings.sourcecodepage:=codepagebyname(s);
  1822. { we're not using the system code page now }
  1823. exclude(current_settings.modeswitches,m_systemcodepage);
  1824. exclude(current_settings.moduleswitches,cs_system_codepage);
  1825. include(current_settings.moduleswitches,cs_explicit_codepage);
  1826. end;
  1827. end;
  1828. procedure dir_coperators;
  1829. begin
  1830. do_moduleswitch(cs_support_c_operators);
  1831. end;
  1832. procedure dir_bitpacking;
  1833. begin
  1834. do_localswitch(cs_bitpacking);
  1835. end;
  1836. procedure dir_region;
  1837. begin
  1838. current_scanner.skipspace;
  1839. current_scanner.readquotedstring;
  1840. end;
  1841. procedure dir_endregion;
  1842. begin
  1843. end;
  1844. procedure dir_zerobasesstrings;
  1845. begin
  1846. do_localswitch(cs_zerobasedstrings);
  1847. end;
  1848. {****************************************************************************
  1849. Initialize Directives
  1850. ****************************************************************************}
  1851. procedure InitScannerDirectives;
  1852. begin
  1853. AddDirective('A1',directive_all, @dir_a1);
  1854. AddDirective('A2',directive_all, @dir_a2);
  1855. AddDirective('A4',directive_all, @dir_a4);
  1856. AddDirective('A8',directive_all, @dir_a8);
  1857. AddDirective('ALIGN',directive_all, @dir_align);
  1858. {$ifdef m68k}
  1859. AddDirective('APPID',directive_all, @dir_appid);
  1860. AddDirective('APPNAME',directive_all, @dir_appname);
  1861. {$endif m68k}
  1862. AddDirective('APPTYPE',directive_all, @dir_apptype);
  1863. AddDirective('ASMCPU',directive_all, @dir_asmcpu);
  1864. AddDirective('ASMMODE',directive_all, @dir_asmmode);
  1865. AddDirective('ASSERTIONS',directive_all, @dir_assertions);
  1866. AddDirective('BOOLEVAL',directive_all, @dir_booleval);
  1867. AddDirective('BITPACKING',directive_all, @dir_bitpacking);
  1868. AddDirective('CALLING',directive_all, @dir_calling);
  1869. AddDirective('CHECKCASECOVERAGE',directive_all, @dir_checkcasecoverage);
  1870. AddDirective('CHECKFPUEXCEPTIONS',directive_all, @dir_checkfpuexceptions);
  1871. AddDirective('CHECKLOWADDRLOADS',directive_all, @dir_checklowaddrloads);
  1872. AddDirective('CHECKPOINTER',directive_all, @dir_checkpointer);
  1873. AddDirective('CODEALIGN',directive_all, @dir_codealign);
  1874. AddDirective('CODEPAGE',directive_all, @dir_codepage);
  1875. AddDirective('COPERATORS',directive_all, @dir_coperators);
  1876. AddDirective('COPYRIGHT',directive_all, @dir_copyright);
  1877. AddDirective('D',directive_all, @dir_description);
  1878. AddDirective('DEBUGINFO',directive_all, @dir_debuginfo);
  1879. AddDirective('DENYPACKAGEUNIT',directive_all,@dir_denypackageunit);
  1880. AddDirective('DESCRIPTION',directive_all, @dir_description);
  1881. AddDirective('ENDREGION',directive_all, @dir_endregion);
  1882. AddDirective('ERROR',directive_all, @dir_error);
  1883. AddDirective('ERRORC',directive_mac, @dir_error);
  1884. AddDirective('EXCESSPRECISION',directive_all, @dir_excessprecision);
  1885. AddDirective('EXTENDEDSYNTAX',directive_all, @dir_extendedsyntax);
  1886. AddDirective('EXTERNALSYM',directive_all, @dir_externalsym);
  1887. AddDirective('F',directive_all, @dir_forcefarcalls);
  1888. AddDirective('FARCALLS',directive_all, @dir_forcefarcalls);
  1889. AddDirective('FATAL',directive_all, @dir_fatal);
  1890. AddDirective('FLOATINGPOINTEMULATION',directive_all,@dir_floatingpointemulation);
  1891. AddDirective('FPUTYPE',directive_all, @dir_fputype);
  1892. AddDirective('FRAMEWORKPATH',directive_all, @dir_frameworkpath);
  1893. AddDirective('GOTO',directive_all, @dir_goto);
  1894. AddDirective('HINT',directive_all, @dir_hint);
  1895. AddDirective('HINTS',directive_all, @dir_hints);
  1896. AddDirective('HPPEMIT',directive_all, @dir_hppemit);
  1897. AddDirective('HUGECODE',directive_all, @dir_hugecode);
  1898. AddDirective('HUGEPOINTERNORMALIZATION',directive_all,@dir_hugepointernormalization);
  1899. AddDirective('HUGEPOINTERARITHMETICNORMALIZATION',directive_all,@dir_hugepointerarithmeticnormalization);
  1900. AddDirective('HUGEPOINTERCOMPARISONNORMALIZATION',directive_all,@dir_hugepointercomparisonnormalization);
  1901. AddDirective('IEEEERRORS',directive_all,@dir_ieeeerrors);
  1902. AddDirective('IOCHECKS',directive_all, @dir_iochecks);
  1903. AddDirective('IMAGEBASE',directive_all, @dir_imagebase);
  1904. AddDirective('IMPLICITEXCEPTIONS',directive_all, @dir_implicitexceptions);
  1905. AddDirective('IMPORTEDDATA',directive_all, @dir_importeddata);
  1906. AddDirective('INCLUDEPATH',directive_all, @dir_includepath);
  1907. AddDirective('INFO',directive_all, @dir_info);
  1908. AddDirective('INLINE',directive_all, @dir_inline);
  1909. AddDirective('INTERFACES',directive_all, @dir_interfaces);
  1910. AddDirective('L',directive_all, @dir_link);
  1911. AddDirective('LEGACYIFEND',directive_all, @dir_legacyifend);
  1912. AddDirective('LIBEXPORT',directive_mac, @dir_libexport);
  1913. AddDirective('LIBRARYPATH',directive_all, @dir_librarypath);
  1914. AddDirective('LINK',directive_all, @dir_link);
  1915. AddDirective('LINKFRAMEWORK',directive_all, @dir_linkframework);
  1916. AddDirective('LINKLIB',directive_all, @dir_linklib);
  1917. AddDirective('LOCALSYMBOLS',directive_all, @dir_localsymbols);
  1918. AddDirective('LONGSTRINGS',directive_all, @dir_longstrings);
  1919. AddDirective('M',directive_all, @dir_memory);
  1920. AddDirective('MACRO',directive_all, @dir_macro);
  1921. AddDirective('MAXFPUREGISTERS',directive_all, @dir_maxfpuregisters);
  1922. AddDirective('MAXSTACKSIZE',directive_all, @dir_maxstacksize);
  1923. AddDirective('MEMORY',directive_all, @dir_memory);
  1924. AddDirective('MESSAGE',directive_all, @dir_message);
  1925. AddDirective('MINENUMSIZE',directive_all, @dir_packenum);
  1926. AddDirective('MINFPCONSTPREC',directive_all, @dir_minfpconstprec);
  1927. AddDirective('MINSTACKSIZE',directive_all, @dir_minstacksize);
  1928. AddDirective('MMX',directive_all, @dir_mmx);
  1929. AddDirective('MODE',directive_all, @dir_mode);
  1930. AddDirective('MODESWITCH',directive_all, @dir_modeswitch);
  1931. AddDirective('NAMESPACE',directive_all, @dir_namespace);
  1932. AddDirective('NAMESPACES',directive_all, @dir_namespaces);
  1933. AddDirective('NODEFINE',directive_all, @dir_nodefine);
  1934. AddDirective('NOTE',directive_all, @dir_note);
  1935. AddDirective('NOTES',directive_all, @dir_notes);
  1936. AddDirective('OBJECTCHECKS',directive_all, @dir_objectchecks);
  1937. AddDirective('OBJECTPATH',directive_all, @dir_objectpath);
  1938. AddDirective('OPENSTRINGS',directive_all, @dir_openstrings);
  1939. AddDirective('OPTIMIZATION',directive_all, @dir_optimization);
  1940. AddDirective('OV',directive_mac, @dir_overflowchecks);
  1941. AddDirective('OVERFLOWCHECKS',directive_all, @dir_overflowchecks);
  1942. AddDirective('PACKENUM',directive_all, @dir_packenum);
  1943. AddDirective('PACKRECORDS',directive_all, @dir_packrecords);
  1944. AddDirective('PACKSET',directive_all, @dir_packset);
  1945. AddDirective('PASCALMAINNAME',directive_all, @dir_pascalmainname);
  1946. AddDirective('PIC',directive_all, @dir_pic);
  1947. AddDirective('POINTERMATH',directive_all, @dir_pointermath);
  1948. AddDirective('POP',directive_all, @dir_pop);
  1949. AddDirective('PROFILE',directive_all, @dir_profile);
  1950. AddDirective('PUSH',directive_all, @dir_push);
  1951. AddDirective('R',directive_all, @dir_resource);
  1952. AddDirective('RTTI',directive_all, @dir_rtti);
  1953. AddDirective('RANGECHECKS',directive_all, @dir_rangechecks);
  1954. AddDirective('REFERENCEINFO',directive_all, @dir_referenceinfo);
  1955. AddDirective('REGION',directive_all, @dir_region);
  1956. AddDirective('RESOURCE',directive_all, @dir_resource);
  1957. AddDirective('SATURATION',directive_all, @dir_saturation);
  1958. AddDirective('SAFEFPUEXCEPTIONS',directive_all, @dir_safefpuexceptions);
  1959. AddDirective('SCOPEDENUMS',directive_all, @dir_scopedenums);
  1960. AddDirective('SETPEFLAGS', directive_all, @dir_setpeflags);
  1961. AddDirective('SETPEOPTFLAGS', directive_all, @dir_setpeoptflags);
  1962. AddDirective('SETPEOSVERSION', directive_all, @dir_setpeosversion);
  1963. AddDirective('SETPEUSERVERSION', directive_all, @dir_setpeuserversion);
  1964. AddDirective('SETPESUBSYSVERSION', directive_all, @dir_setpesubsysversion);
  1965. AddDirective('SCREENNAME',directive_all, @dir_screenname);
  1966. AddDirective('SMARTLINK',directive_all, @dir_smartlink);
  1967. AddDirective('STACKCHECKING',directive_all,@dir_stackchecking);
  1968. AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
  1969. AddDirective('STOP',directive_all, @dir_stop);
  1970. AddDirective('STRINGCHECKS', directive_all, @dir_stringchecks);
  1971. AddDirective('SYSCALL',directive_all, @dir_syscall);
  1972. AddDirective('TARGETSWITCH',directive_all, @dir_targetswitch);
  1973. AddDirective('THREADNAME',directive_all, @dir_threadname);
  1974. AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
  1975. AddDirective('TYPEINFO',directive_all, @dir_typeinfo);
  1976. AddDirective('UNITPATH',directive_all, @dir_unitpath);
  1977. AddDirective('VARPARACOPYOUTCHECK',directive_all, @dir_varparacopyoutcheck);
  1978. AddDirective('VARPROPSETTER',directive_all, @dir_varpropsetter);
  1979. AddDirective('VARSTRINGCHECKS',directive_all, @dir_varstringchecks);
  1980. AddDirective('VERSION',directive_all, @dir_version);
  1981. AddDirective('WAIT',directive_all, @dir_wait);
  1982. AddDirective('WARN',directive_all, @dir_warn);
  1983. AddDirective('WARNING',directive_all, @dir_warning);
  1984. AddDirective('WARNINGS',directive_all, @dir_warnings);
  1985. AddDirective('WEAKPACKAGEUNIT',directive_all, @dir_weakpackageunit);
  1986. AddDirective('WRITEABLECONST',directive_all, @dir_writeableconst);
  1987. AddDirective('Z1',directive_all, @dir_z1);
  1988. AddDirective('Z2',directive_all, @dir_z2);
  1989. AddDirective('Z4',directive_all, @dir_z4);
  1990. AddDirective('ZEROBASEDSTRINGS',directive_all, @dir_zerobasesstrings);
  1991. end;
  1992. end.