scandir.pas 72 KB

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