scandir.pas 71 KB

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