scandir.pas 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  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. const
  23. switchesstatestackmax = 20;
  24. type
  25. tsavedswitchesstate = record
  26. localsw: tlocalswitches;
  27. verbosity: longint;
  28. pmessage : pmessagestaterecord;
  29. end;
  30. type
  31. tswitchesstatestack = array[0..switchesstatestackmax] of tsavedswitchesstate;
  32. var
  33. switchesstatestack:tswitchesstatestack;
  34. switchesstatestackpos: Integer;
  35. procedure InitScannerDirectives;
  36. implementation
  37. uses
  38. SysUtils,
  39. cutils,cfileutl,
  40. globals,systems,widestr,cpuinfo,
  41. verbose,comphook,ppu,
  42. scanner,switches,
  43. fmodule,
  44. symconst,symtable,
  45. rabase;
  46. {*****************************************************************************
  47. Helpers
  48. *****************************************************************************}
  49. procedure do_delphiswitch(sw:char);
  50. var
  51. state : char;
  52. begin
  53. { c contains the next char, a + or - would be fine }
  54. state:=current_scanner.readstate;
  55. if state in ['-','+'] then
  56. HandleSwitch(sw,state);
  57. end;
  58. procedure do_setverbose(flag:char);
  59. var
  60. state : char;
  61. begin
  62. { support ON/OFF }
  63. state:=current_scanner.ReadState;
  64. recordpendingverbosityswitch(flag,state);
  65. end;
  66. procedure do_moduleswitch(sw:tmoduleswitch);
  67. var
  68. state : char;
  69. begin
  70. state:=current_scanner.readstate;
  71. if (sw<>cs_modulenone) and (state in ['-','+']) then
  72. begin
  73. if state='-' then
  74. exclude(current_settings.moduleswitches,sw)
  75. else
  76. include(current_settings.moduleswitches,sw);
  77. end;
  78. end;
  79. procedure do_localswitch(sw:tlocalswitch);
  80. var
  81. state : char;
  82. begin
  83. state:=current_scanner.readstate;
  84. if (sw<>cs_localnone) and (state in ['-','+']) then
  85. recordpendinglocalswitch(sw,state);
  86. end;
  87. procedure do_localswitchdefault(sw:tlocalswitch);
  88. var
  89. state : char;
  90. begin
  91. state:=current_scanner.readstatedefault;
  92. if (sw<>cs_localnone) and (state in ['-','+','*']) then
  93. recordpendinglocalswitch(sw,state);
  94. end;
  95. procedure do_message(w:integer);
  96. begin
  97. current_scanner.skipspace;
  98. Message1(w,current_scanner.readcomment);
  99. end;
  100. {*****************************************************************************
  101. Directive Callbacks
  102. *****************************************************************************}
  103. procedure dir_align;
  104. var
  105. hs : string;
  106. begin
  107. current_scanner.skipspace;
  108. if not(c in ['0'..'9']) then
  109. begin
  110. { Support also the ON and OFF as switch }
  111. hs:=current_scanner.readid;
  112. if (hs='ON') then
  113. current_settings.packrecords:=4
  114. else if (hs='OFF') then
  115. current_settings.packrecords:=1
  116. else if m_mac in current_settings.modeswitches then
  117. begin
  118. { Support switches used in Apples Universal Interfaces}
  119. if (hs='MAC68K') then
  120. current_settings.packrecords:=mac68k_alignment
  121. { "power" alignment is the default C packrecords setting on
  122. Mac OS X }
  123. else if (hs='POWER') or (hs='POWERPC') then
  124. current_settings.packrecords:=C_alignment
  125. else if (hs='RESET') then
  126. current_settings.packrecords:=0
  127. else
  128. Message1(scan_e_illegal_pack_records,hs);
  129. end
  130. else
  131. Message1(scan_e_illegal_pack_records,hs);
  132. end
  133. else
  134. begin
  135. case current_scanner.readval of
  136. 1 : current_settings.packrecords:=1;
  137. 2 : current_settings.packrecords:=2;
  138. 4 : current_settings.packrecords:=4;
  139. 8 : current_settings.packrecords:=8;
  140. 16 : current_settings.packrecords:=16;
  141. 32 : current_settings.packrecords:=32;
  142. else
  143. Message1(scan_e_illegal_pack_records,hs);
  144. end;
  145. end;
  146. end;
  147. procedure dir_a1;
  148. begin
  149. current_settings.packrecords:=1;
  150. end;
  151. procedure dir_a2;
  152. begin
  153. current_settings.packrecords:=2;
  154. end;
  155. procedure dir_a4;
  156. begin
  157. current_settings.packrecords:=4;
  158. end;
  159. procedure dir_a8;
  160. begin
  161. current_settings.packrecords:=8;
  162. end;
  163. procedure dir_asmmode;
  164. var
  165. s : string;
  166. begin
  167. current_scanner.skipspace;
  168. s:=current_scanner.readid;
  169. If Inside_asm_statement then
  170. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  171. if s='DEFAULT' then
  172. current_settings.asmmode:=init_settings.asmmode
  173. else
  174. if not SetAsmReadMode(s,current_settings.asmmode) then
  175. Message1(scan_e_illegal_asmmode_specifier,s);
  176. end;
  177. {$if defined(m68k) or defined(arm)}
  178. procedure dir_appid;
  179. begin
  180. if target_info.system<>system_m68k_palmos then
  181. Message(scan_w_appid_not_support);
  182. { change description global var in all cases }
  183. { it not used but in win32 and os2 }
  184. current_scanner.skipspace;
  185. palmos_applicationid:=current_scanner.readcomment;
  186. end;
  187. procedure dir_appname;
  188. begin
  189. if target_info.system<>system_m68k_palmos then
  190. Message(scan_w_appname_not_support);
  191. { change description global var in all cases }
  192. { it not used but in win32 and os2 }
  193. current_scanner.skipspace;
  194. palmos_applicationname:=current_scanner.readcomment;
  195. end;
  196. {$endif defined(m68k) or defined(arm)}
  197. procedure dir_apptype;
  198. var
  199. hs : string;
  200. begin
  201. if not (target_info.system in systems_all_windows + [system_i386_os2,
  202. system_i386_emx, system_powerpc_macos,
  203. system_arm_nds] + systems_nativent) then
  204. begin
  205. if m_delphi in current_settings.modeswitches then
  206. Message(scan_n_app_type_not_support)
  207. else
  208. Message(scan_w_app_type_not_support);
  209. end
  210. else
  211. begin
  212. if not current_module.in_global then
  213. Message(scan_w_switch_is_global)
  214. else
  215. begin
  216. current_scanner.skipspace;
  217. hs:=current_scanner.readid;
  218. if hs='GUI' then
  219. apptype:=app_gui
  220. else if hs='CONSOLE' then
  221. apptype:=app_cui
  222. else if (hs='NATIVE') and (target_info.system in systems_windows + systems_nativent) then
  223. apptype:=app_native
  224. else if (hs='FS') and (target_info.system in [system_i386_os2,
  225. system_i386_emx]) then
  226. apptype:=app_fs
  227. else if (hs='TOOL') and (target_info.system in [system_powerpc_macos]) then
  228. apptype:=app_tool
  229. else if (hs='ARM9') and (target_info.system in [system_arm_nds]) then
  230. apptype:=app_arm9
  231. else if (hs='ARM7') and (target_info.system in [system_arm_nds]) then
  232. apptype:=app_arm7
  233. else
  234. Message1(scan_w_unsupported_app_type,hs);
  235. end;
  236. end;
  237. end;
  238. procedure dir_calling;
  239. var
  240. hs : string;
  241. begin
  242. current_scanner.skipspace;
  243. hs:=current_scanner.readid;
  244. if (hs='') then
  245. Message(parser_e_proc_directive_expected)
  246. else
  247. recordpendingcallingswitch(hs);
  248. end;
  249. procedure dir_checklowaddrloads;
  250. begin
  251. do_localswitchdefault(cs_check_low_addr_load);
  252. end;
  253. procedure dir_checkpointer;
  254. begin
  255. do_localswitchdefault(cs_checkpointer);
  256. end;
  257. procedure dir_objectchecks;
  258. begin
  259. do_localswitch(cs_check_object);
  260. end;
  261. procedure dir_ieeeerrors;
  262. begin
  263. do_localswitch(cs_ieee_errors);
  264. end;
  265. procedure dir_assertions;
  266. begin
  267. do_delphiswitch('C');
  268. end;
  269. procedure dir_booleval;
  270. begin
  271. do_delphiswitch('B');
  272. end;
  273. procedure dir_debuginfo;
  274. begin
  275. do_delphiswitch('D');
  276. end;
  277. procedure dir_description;
  278. begin
  279. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  280. system_i386_netware,system_i386_wdosx,system_i386_netwlibc]) then
  281. Message(scan_w_description_not_support);
  282. { change description global var in all cases }
  283. { it not used but in win32, os2 and netware }
  284. current_scanner.skipspace;
  285. description:=current_scanner.readcomment;
  286. DescriptionSetExplicity:=true;
  287. end;
  288. procedure dir_screenname; {ad}
  289. begin
  290. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  291. {Message(scan_w_decription_not_support);}
  292. comment (V_Warning,'Screenname only supported for target netware');
  293. current_scanner.skipspace;
  294. nwscreenname:=current_scanner.readcomment;
  295. end;
  296. procedure dir_threadname; {ad}
  297. begin
  298. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  299. {Message(scan_w_decription_not_support);}
  300. comment (V_Warning,'Threadname only supported for target netware');
  301. current_scanner.skipspace;
  302. nwthreadname:=current_scanner.readcomment;
  303. end;
  304. procedure dir_copyright; {ad}
  305. begin
  306. if not (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  307. {Message(scan_w_decription_not_support);}
  308. comment (V_Warning,'Copyright only supported for target netware');
  309. current_scanner.skipspace;
  310. nwcopyright:=current_scanner.readcomment;
  311. end;
  312. procedure dir_error;
  313. begin
  314. do_message(scan_e_user_defined);
  315. end;
  316. procedure dir_extendedsyntax;
  317. begin
  318. do_delphiswitch('X');
  319. end;
  320. procedure dir_fatal;
  321. begin
  322. do_message(scan_f_user_defined);
  323. end;
  324. procedure dir_fputype;
  325. begin
  326. current_scanner.skipspace;
  327. undef_system_macro('FPU'+fputypestr[current_settings.fputype]);
  328. if not(SetFPUType(upper(current_scanner.readcomment),current_settings.fputype)) then
  329. comment(V_Error,'Illegal FPU type');
  330. def_system_macro('FPU'+fputypestr[current_settings.fputype]);
  331. end;
  332. procedure dir_frameworkpath;
  333. begin
  334. if not current_module.in_global then
  335. Message(scan_w_switch_is_global)
  336. else if not(target_info.system in systems_darwin) then
  337. begin
  338. Message(scan_w_frameworks_darwin_only);
  339. current_scanner.skipspace;
  340. current_scanner.readcomment
  341. end
  342. else
  343. begin
  344. current_scanner.skipspace;
  345. current_module.localframeworksearchpath.AddPath(current_scanner.readcomment,false);
  346. end;
  347. end;
  348. procedure dir_goto;
  349. begin
  350. do_moduleswitch(cs_support_goto);
  351. end;
  352. procedure dir_hint;
  353. begin
  354. do_message(scan_h_user_defined);
  355. end;
  356. procedure dir_hints;
  357. begin
  358. do_setverbose('H');
  359. end;
  360. procedure dir_imagebase;
  361. begin
  362. if not (target_info.system in (systems_windows+systems_wince)) then
  363. Message(scan_w_imagebase_not_support);
  364. current_scanner.skipspace;
  365. imagebase:=current_scanner.readval;
  366. ImageBaseSetExplicity:=true
  367. end;
  368. procedure dir_implicitexceptions;
  369. begin
  370. do_moduleswitch(cs_implicit_exceptions);
  371. end;
  372. procedure dir_includepath;
  373. begin
  374. if not current_module.in_global then
  375. Message(scan_w_switch_is_global)
  376. else
  377. begin
  378. current_scanner.skipspace;
  379. current_module.localincludesearchpath.AddPath(current_scanner.readcomment,false);
  380. end;
  381. end;
  382. procedure dir_info;
  383. begin
  384. do_message(scan_i_user_defined);
  385. end;
  386. procedure dir_inline;
  387. begin
  388. do_localswitch(cs_do_inline);
  389. end;
  390. procedure dir_interfaces;
  391. var
  392. hs : string;
  393. begin
  394. {corba/com/default}
  395. current_scanner.skipspace;
  396. hs:=current_scanner.readid;
  397. {$ifndef jvm}
  398. if (hs='CORBA') then
  399. current_settings.interfacetype:=it_interfacecorba
  400. else if (hs='COM') then
  401. current_settings.interfacetype:=it_interfacecom
  402. else
  403. {$endif jvm}
  404. if (hs='DEFAULT') then
  405. current_settings.interfacetype:=init_settings.interfacetype
  406. else
  407. Message(scan_e_invalid_interface_type);
  408. end;
  409. procedure dir_iochecks;
  410. begin
  411. do_delphiswitch('I');
  412. end;
  413. procedure dir_libexport;
  414. begin
  415. {not implemented}
  416. end;
  417. procedure dir_librarypath;
  418. begin
  419. if not current_module.in_global then
  420. Message(scan_w_switch_is_global)
  421. else
  422. begin
  423. current_scanner.skipspace;
  424. current_module.locallibrarysearchpath.AddPath(current_scanner.readcomment,false);
  425. end;
  426. end;
  427. procedure dir_link;
  428. var
  429. s : string;
  430. begin
  431. current_scanner.skipspace;
  432. if scanner.c = '''' then
  433. begin
  434. s:= current_scanner.readquotedstring;
  435. current_scanner.readcomment
  436. end
  437. else
  438. s:= trimspace(current_scanner.readcomment);
  439. s:=FixFileName(s);
  440. if ExtractFileExt(s)='' then
  441. s:=ChangeFileExt(s,target_info.objext);
  442. current_module.linkotherofiles.add(s,link_always);
  443. end;
  444. procedure dir_linkframework;
  445. var
  446. s : string;
  447. begin
  448. current_scanner.skipspace;
  449. if scanner.c = '''' then
  450. begin
  451. s:= current_scanner.readquotedstring;
  452. current_scanner.readcomment
  453. end
  454. else
  455. s:= trimspace(current_scanner.readcomment);
  456. s:=FixFileName(s);
  457. if (target_info.system in systems_darwin) then
  458. current_module.linkotherframeworks.add(s,link_always)
  459. else
  460. Message(scan_w_frameworks_darwin_only);
  461. end;
  462. procedure dir_linklib;
  463. type
  464. tLinkMode=(lm_shared,lm_static);
  465. var
  466. s : string;
  467. quote : char;
  468. libext,
  469. libname,
  470. linkmodestr : string;
  471. p : longint;
  472. linkMode : tLinkMode;
  473. begin
  474. current_scanner.skipspace;
  475. if scanner.c = '''' then
  476. begin
  477. libname:= current_scanner.readquotedstring;
  478. s:= current_scanner.readcomment;
  479. p:=pos(',',s);
  480. end
  481. else
  482. begin
  483. s:= current_scanner.readcomment;
  484. p:=pos(',',s);
  485. if p=0 then
  486. libname:=TrimSpace(s)
  487. else
  488. libname:=TrimSpace(copy(s,1,p-1));
  489. end;
  490. if p=0 then
  491. linkmodeStr:=''
  492. else
  493. linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
  494. if (libname='') or (libname='''''') or (libname='""') then
  495. exit;
  496. { create library name }
  497. if libname[1] in ['''','"'] then
  498. begin
  499. quote:=libname[1];
  500. Delete(libname,1,1);
  501. p:=pos(quote,libname);
  502. if p>0 then
  503. Delete(libname,p,1);
  504. end;
  505. libname:=FixFileName(libname);
  506. { get linkmode, default is to check the extension for
  507. the static library, otherwise shared linking is assumed }
  508. linkmode:=lm_shared;
  509. if linkModeStr='' then
  510. begin
  511. libext:=ExtractFileExt(libname);
  512. if libext=target_info.staticClibext then
  513. linkMode:=lm_static;
  514. end
  515. else if linkModeStr='STATIC' then
  516. linkmode:=lm_static
  517. else if (LinkModeStr='SHARED') or (LinkModeStr='') then
  518. linkmode:=lm_shared
  519. else
  520. Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
  521. { add to the list of other libraries }
  522. if linkMode=lm_static then
  523. current_module.linkOtherStaticLibs.add(libname,link_always)
  524. else
  525. current_module.linkOtherSharedLibs.add(libname,link_always);
  526. end;
  527. procedure dir_localsymbols;
  528. begin
  529. do_delphiswitch('L');
  530. end;
  531. procedure dir_longstrings;
  532. begin
  533. do_delphiswitch('H');
  534. end;
  535. procedure dir_macro;
  536. begin
  537. do_moduleswitch(cs_support_macro);
  538. end;
  539. procedure dir_pascalmainname;
  540. var
  541. s: string;
  542. begin
  543. current_scanner.skipspace;
  544. s:=trimspace(current_scanner.readcomment);
  545. if assigned(current_module.mainname) and
  546. (s<>current_module.mainname^) then
  547. begin
  548. Message1(scan_w_multiple_main_name_overrides,current_module.mainname^);
  549. stringdispose(current_module.mainname)
  550. end
  551. else if (mainaliasname<>defaultmainaliasname) and
  552. (mainaliasname<>s) then
  553. Message1(scan_w_multiple_main_name_overrides,mainaliasname);
  554. mainaliasname:=s;
  555. if (mainaliasname<>defaultmainaliasname) then
  556. current_module.mainname:=stringdup(mainaliasname);
  557. end;
  558. procedure dir_maxfpuregisters;
  559. var
  560. l : integer;
  561. hs : string;
  562. begin
  563. current_scanner.skipspace;
  564. if not(c in ['0'..'9']) then
  565. begin
  566. hs:=current_scanner.readid;
  567. if (hs='NORMAL') or (hs='DEFAULT') then
  568. current_settings.maxfpuregisters:=-1
  569. else
  570. Message(scan_e_invalid_maxfpureg_value);
  571. end
  572. else
  573. begin
  574. l:=current_scanner.readval;
  575. case l of
  576. 0..8:
  577. current_settings.maxfpuregisters:=l;
  578. else
  579. Message(scan_e_invalid_maxfpureg_value);
  580. end;
  581. end;
  582. end;
  583. procedure dir_maxstacksize;
  584. begin
  585. if not (target_info.system in (systems_windows+systems_wince)) then
  586. Message(scan_w_maxstacksize_not_support);
  587. current_scanner.skipspace;
  588. maxstacksize:=current_scanner.readval;
  589. MaxStackSizeSetExplicity:=true;
  590. end;
  591. procedure dir_memory;
  592. var
  593. l : longint;
  594. begin
  595. current_scanner.skipspace;
  596. l:=current_scanner.readval;
  597. if l>1024 then
  598. stacksize:=l;
  599. if c=',' then
  600. begin
  601. current_scanner.readchar;
  602. current_scanner.skipspace;
  603. l:=current_scanner.readval;
  604. if l>1024 then
  605. heapsize:=l;
  606. end;
  607. end;
  608. procedure dir_message;
  609. var
  610. hs : string;
  611. w : longint;
  612. begin
  613. w:=0;
  614. current_scanner.skipspace;
  615. { Message level specified? }
  616. if c='''' then
  617. w:=scan_n_user_defined
  618. else
  619. begin
  620. hs:=current_scanner.readid;
  621. if (hs='WARN') or (hs='WARNING') then
  622. w:=scan_w_user_defined
  623. else
  624. if (hs='ERROR') then
  625. w:=scan_e_user_defined
  626. else
  627. if (hs='FATAL') then
  628. w:=scan_f_user_defined
  629. else
  630. if (hs='HINT') then
  631. w:=scan_h_user_defined
  632. else
  633. if (hs='NOTE') then
  634. w:=scan_n_user_defined
  635. else
  636. Message1(scan_w_illegal_directive,hs);
  637. end;
  638. { Only print message when there was no error }
  639. if w<>0 then
  640. begin
  641. current_scanner.skipspace;
  642. if c='''' then
  643. hs:=current_scanner.readquotedstring
  644. else
  645. hs:=current_scanner.readcomment;
  646. Message1(w,hs);
  647. end
  648. else
  649. current_scanner.readcomment;
  650. end;
  651. procedure dir_minstacksize;
  652. begin
  653. if not (target_info.system in (systems_windows+systems_wince)) then
  654. Message(scan_w_minstacksize_not_support);
  655. current_scanner.skipspace;
  656. minstacksize:=current_scanner.readval;
  657. MinStackSizeSetExplicity:=true;
  658. end;
  659. procedure dir_mode;
  660. begin
  661. if not current_module.in_global then
  662. Message(scan_w_switch_is_global)
  663. else
  664. begin
  665. current_scanner.skipspace;
  666. current_scanner.readstring;
  667. if not current_module.mode_switch_allowed and
  668. not ((m_mac in current_settings.modeswitches) and (pattern='MACPAS')) then
  669. Message1(scan_e_mode_switch_not_allowed,pattern)
  670. else if not SetCompileMode(pattern,false) then
  671. Message1(scan_w_illegal_switch,pattern)
  672. end;
  673. current_module.mode_switch_allowed:= false;
  674. end;
  675. procedure dir_modeswitch;
  676. var
  677. s : string;
  678. begin
  679. if not current_module.in_global then
  680. Message(scan_w_switch_is_global)
  681. else
  682. begin
  683. current_scanner.skipspace;
  684. current_scanner.readstring;
  685. s:=pattern;
  686. if c in ['+','-'] then
  687. s:=s+current_scanner.readstate;
  688. if not SetCompileModeSwitch(s,false) then
  689. Message1(scan_w_illegal_switch,s)
  690. end;
  691. end;
  692. procedure dir_namespace;
  693. var
  694. s : string;
  695. begin
  696. { used to define Java package names for all types declared in the
  697. current unit }
  698. if not current_module.in_global then
  699. Message(scan_w_switch_is_global)
  700. else
  701. begin
  702. current_scanner.skipspace;
  703. current_scanner.readstring;
  704. s:=orgpattern;
  705. while c='.' do
  706. begin
  707. current_scanner.readchar;
  708. current_scanner.readstring;
  709. s:=s+'.'+orgpattern;
  710. end;
  711. disposestr(current_module.namespace);
  712. current_module.namespace:=stringdup(s);
  713. end;
  714. end;
  715. procedure dir_mmx;
  716. begin
  717. do_localswitch(cs_mmx);
  718. end;
  719. procedure dir_note;
  720. begin
  721. do_message(scan_n_user_defined);
  722. end;
  723. procedure dir_notes;
  724. begin
  725. do_setverbose('N');
  726. end;
  727. procedure dir_objectpath;
  728. begin
  729. if not current_module.in_global then
  730. Message(scan_w_switch_is_global)
  731. else
  732. begin
  733. current_scanner.skipspace;
  734. current_module.localobjectsearchpath.AddPath(current_scanner.readcomment,false);
  735. end;
  736. end;
  737. procedure dir_openstrings;
  738. begin
  739. do_delphiswitch('P');
  740. end;
  741. procedure dir_optimization;
  742. var
  743. hs : string;
  744. begin
  745. current_scanner.skipspace;
  746. { Support also the ON and OFF as switch }
  747. hs:=current_scanner.readid;
  748. if (hs='ON') then
  749. current_settings.optimizerswitches:=level2optimizerswitches
  750. else if (hs='OFF') then
  751. current_settings.optimizerswitches:=[]
  752. else if (hs='DEFAULT') then
  753. current_settings.optimizerswitches:=init_settings.optimizerswitches
  754. else
  755. begin
  756. if not UpdateOptimizerStr(hs,current_settings.optimizerswitches) then
  757. Message1(scan_e_illegal_optimization_specifier,hs);
  758. end;
  759. end;
  760. procedure dir_overflowchecks;
  761. begin
  762. do_delphiswitch('Q');
  763. end;
  764. procedure dir_packenum;
  765. var
  766. hs : string;
  767. begin
  768. current_scanner.skipspace;
  769. if not(c in ['0'..'9']) then
  770. begin
  771. hs:=current_scanner.readid;
  772. if (hs='NORMAL') or (hs='DEFAULT') then
  773. current_settings.packenum:=4
  774. else
  775. Message1(scan_e_illegal_pack_enum, hs);
  776. end
  777. else
  778. begin
  779. case current_scanner.readval of
  780. 1 : current_settings.packenum:=1;
  781. 2 : current_settings.packenum:=2;
  782. 4 : current_settings.packenum:=4;
  783. else
  784. Message1(scan_e_illegal_pack_enum, pattern);
  785. end;
  786. end;
  787. end;
  788. procedure dir_minfpconstprec;
  789. begin
  790. current_scanner.skipspace;
  791. if not SetMinFPConstPrec(current_scanner.readid,current_settings.minfpconstprec) then
  792. Message1(scan_e_illegal_minfpconstprec, pattern);
  793. end;
  794. procedure dir_packrecords;
  795. var
  796. hs : string;
  797. begin
  798. { can't change packrecords setting on managed vm targets }
  799. if target_info.system in systems_managed_vm then
  800. Message1(scanner_w_directive_ignored_on_target, 'PACKRECORDS');
  801. current_scanner.skipspace;
  802. if not(c in ['0'..'9']) then
  803. begin
  804. hs:=current_scanner.readid;
  805. { C has the special recordalignmax of C_alignment }
  806. if (hs='C') then
  807. current_settings.packrecords:=C_alignment
  808. else
  809. if (hs='NORMAL') or (hs='DEFAULT') then
  810. current_settings.packrecords:=0
  811. else
  812. Message1(scan_e_illegal_pack_records,hs);
  813. end
  814. else
  815. begin
  816. case current_scanner.readval of
  817. 1 : current_settings.packrecords:=1;
  818. 2 : current_settings.packrecords:=2;
  819. 4 : current_settings.packrecords:=4;
  820. 8 : current_settings.packrecords:=8;
  821. 16 : current_settings.packrecords:=16;
  822. 32 : current_settings.packrecords:=32;
  823. else
  824. Message1(scan_e_illegal_pack_records,pattern);
  825. end;
  826. end;
  827. end;
  828. procedure dir_packset;
  829. var
  830. hs : string;
  831. begin
  832. current_scanner.skipspace;
  833. if not(c in ['1','2','4','8']) then
  834. begin
  835. hs:=current_scanner.readid;
  836. if (hs='FIXED') or ((hs='DEFAULT') OR (hs='NORMAL')) then
  837. current_settings.setalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  838. else
  839. Message(scan_e_only_packset);
  840. end
  841. else
  842. begin
  843. case current_scanner.readval of
  844. 1 : current_settings.setalloc:=1;
  845. 2 : current_settings.setalloc:=2;
  846. 4 : current_settings.setalloc:=4;
  847. 8 : current_settings.setalloc:=8;
  848. else
  849. Message(scan_e_only_packset);
  850. end;
  851. end;
  852. end;
  853. procedure dir_pic;
  854. begin
  855. { windows doesn't need/support pic }
  856. if tf_no_pic_supported in target_info.flags then
  857. message(scan_w_pic_ignored)
  858. else
  859. do_moduleswitch(cs_create_pic);
  860. end;
  861. procedure dir_pop;
  862. begin
  863. if switchesstatestackpos < 1 then
  864. Message(scan_e_too_many_pop);
  865. Dec(switchesstatestackpos);
  866. recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
  867. recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
  868. pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
  869. { Reset verbosity and forget previous pmeesage }
  870. RestoreLocalVerbosity(nil);
  871. current_settings.pmessage:=nil;
  872. { Do not yet activate these changes, as otherwise
  873. you get problem idf you put a $pop just right after
  874. a addition for instance fro which you explicitly truned the overflow check
  875. out by using $Q- after a $push PM 2012-08-29 }
  876. // flushpendingswitchesstate;
  877. end;
  878. procedure dir_pointermath;
  879. begin
  880. do_localswitch(cs_pointermath);
  881. end;
  882. procedure dir_profile;
  883. begin
  884. do_moduleswitch(cs_profile);
  885. { defined/undefine FPC_PROFILE }
  886. if cs_profile in current_settings.moduleswitches then
  887. def_system_macro('FPC_PROFILE')
  888. else
  889. undef_system_macro('FPC_PROFILE');
  890. end;
  891. procedure dir_push;
  892. begin
  893. if switchesstatestackpos > switchesstatestackmax then
  894. Message(scan_e_too_many_push);
  895. flushpendingswitchesstate;
  896. switchesstatestack[switchesstatestackpos].localsw:= current_settings.localswitches;
  897. switchesstatestack[switchesstatestackpos].pmessage:= current_settings.pmessage;
  898. switchesstatestack[switchesstatestackpos].verbosity:=status.verbosity;
  899. Inc(switchesstatestackpos);
  900. end;
  901. procedure dir_rangechecks;
  902. begin
  903. do_delphiswitch('R');
  904. end;
  905. procedure dir_referenceinfo;
  906. begin
  907. do_delphiswitch('Y');
  908. end;
  909. procedure dir_resource;
  910. var
  911. s : string;
  912. begin
  913. current_scanner.skipspace;
  914. if scanner.c = '''' then
  915. begin
  916. s:= current_scanner.readquotedstring;
  917. current_scanner.readcomment
  918. end
  919. else
  920. s:= trimspace(current_scanner.readcomment);
  921. { replace * with the name of the main source.
  922. This should always be defined. }
  923. if s[1]='*' then
  924. if Assigned(Current_Module) then
  925. begin
  926. delete(S,1,1);
  927. insert(ChangeFileExt(ExtractFileName(current_module.mainsource),''),S,1 );
  928. end;
  929. s:=FixFileName(s);
  930. if ExtractFileExt(s)='' then
  931. s:=ChangeFileExt(s,target_info.resext);
  932. if target_info.res<>res_none then
  933. begin
  934. current_module.flags:=current_module.flags or uf_has_resourcefiles;
  935. if (res_single_file in target_res.resflags) and
  936. not (Current_module.ResourceFiles.Empty) then
  937. Message(scan_w_only_one_resourcefile_supported)
  938. else
  939. current_module.resourcefiles.insert(FixFileName(s));
  940. end
  941. else
  942. Message(scan_e_resourcefiles_not_supported);
  943. end;
  944. procedure dir_saturation;
  945. begin
  946. do_localswitch(cs_mmx_saturation);
  947. end;
  948. procedure dir_safefpuexceptions;
  949. begin
  950. do_localswitch(cs_fpu_fwait);
  951. end;
  952. procedure dir_scopedenums;
  953. begin
  954. do_localswitch(cs_scopedenums);
  955. end;
  956. procedure dir_setpeflags;
  957. begin
  958. if not (target_info.system in (systems_all_windows)) then
  959. Message(scan_w_setpeflags_not_support);
  960. current_scanner.skipspace;
  961. peflags:=current_scanner.readval;
  962. SetPEFlagsSetExplicity:=true;
  963. end;
  964. procedure dir_smartlink;
  965. begin
  966. do_moduleswitch(cs_create_smart);
  967. if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and
  968. not(target_info.system in systems_darwin) and
  969. { smart linking does not yet work with DWARF debug info on most targets }
  970. (cs_create_smart in current_settings.moduleswitches) and
  971. not (af_outputbinary in target_asm.flags) then
  972. begin
  973. Message(option_dwarf_smart_linking);
  974. Exclude(current_settings.moduleswitches,cs_create_smart);
  975. end;
  976. end;
  977. procedure dir_stackframes;
  978. begin
  979. do_delphiswitch('W');
  980. end;
  981. procedure dir_stop;
  982. begin
  983. do_message(scan_f_user_defined);
  984. end;
  985. procedure dir_stringchecks;
  986. begin
  987. // Delphi adds checks that ansistring and unicodestring are correct in
  988. // different places. Skip it for now.
  989. end;
  990. {$ifdef powerpc}
  991. procedure dir_syscall;
  992. var
  993. sctype : string;
  994. begin
  995. { not needed on amiga/m68k for now, because there's only one }
  996. { syscall convention (legacy) (KB) }
  997. { not needed on amiga/powerpc because there's only one }
  998. { syscall convention (sysv) (KB) }
  999. if not (target_info.system in [system_powerpc_morphos]) then
  1000. comment (V_Warning,'Syscall directive is useless on this target.');
  1001. current_scanner.skipspace;
  1002. sctype:=current_scanner.readid;
  1003. if (sctype='LEGACY') or (sctype='SYSV') or (sctype='SYSVBASE') or
  1004. (sctype='BASESYSV') or (sctype='R12BASE') then
  1005. syscall_convention:=sctype
  1006. else
  1007. comment (V_Warning,'Invalid Syscall directive ignored.');
  1008. end;
  1009. {$endif}
  1010. procedure dir_typedaddress;
  1011. begin
  1012. do_delphiswitch('T');
  1013. end;
  1014. procedure dir_typeinfo;
  1015. begin
  1016. do_delphiswitch('M');
  1017. end;
  1018. procedure dir_unitpath;
  1019. begin
  1020. if not current_module.in_global then
  1021. Message(scan_w_switch_is_global)
  1022. else
  1023. with current_scanner,current_module,localunitsearchpath do
  1024. begin
  1025. skipspace;
  1026. AddPath(path,readcomment,false);
  1027. end;
  1028. end;
  1029. procedure dir_varparacopyoutcheck;
  1030. begin
  1031. if not(target_info.system in systems_jvm) then
  1032. begin
  1033. Message1(scan_w_illegal_switch,pattern);
  1034. exit;
  1035. end;
  1036. do_localswitch(cs_check_var_copyout);
  1037. end;
  1038. procedure dir_varpropsetter;
  1039. begin
  1040. do_localswitch(cs_varpropsetter);
  1041. end;
  1042. procedure dir_varstringchecks;
  1043. begin
  1044. do_delphiswitch('V');
  1045. end;
  1046. procedure dir_version;
  1047. var
  1048. major, minor, revision : longint;
  1049. error : integer;
  1050. begin
  1051. if not (target_info.system in systems_all_windows+[system_i386_os2,system_i386_emx,
  1052. system_i386_netware,system_i386_wdosx,
  1053. system_i386_netwlibc]) then
  1054. begin
  1055. Message(scan_n_version_not_support);
  1056. exit;
  1057. end;
  1058. if (compile_level<>1) then
  1059. Message(scan_n_only_exe_version)
  1060. else
  1061. begin
  1062. { change description global var in all cases }
  1063. { it not used but in win32, os2 and netware }
  1064. current_scanner.skipspace;
  1065. { we should only accept Major.Minor format for win32 and os2 }
  1066. current_scanner.readnumber;
  1067. major:=0;
  1068. minor:=0;
  1069. revision:=0;
  1070. val(pattern,major,error);
  1071. if (error<>0) or (major > high(word)) or (major < 0) then
  1072. begin
  1073. Message1(scan_w_wrong_version_ignored,pattern);
  1074. exit;
  1075. end;
  1076. if c='.' then
  1077. begin
  1078. current_scanner.readchar;
  1079. current_scanner.readnumber;
  1080. val(pattern,minor,error);
  1081. if (error<>0) or (minor > high(word)) or (minor < 0) then
  1082. begin
  1083. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  1084. exit;
  1085. end;
  1086. if (c='.') and
  1087. (target_info.system in [system_i386_netware,system_i386_netwlibc]) then
  1088. begin
  1089. current_scanner.readchar;
  1090. current_scanner.readnumber;
  1091. val(pattern,revision,error);
  1092. if (error<>0) or (revision > high(word)) or (revision < 0) then
  1093. begin
  1094. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  1095. exit;
  1096. end;
  1097. dllmajor:=word(major);
  1098. dllminor:=word(minor);
  1099. dllrevision:=word(revision);
  1100. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  1101. end
  1102. else
  1103. begin
  1104. dllmajor:=word(major);
  1105. dllminor:=word(minor);
  1106. dllversion:=tostr(major)+'.'+tostr(minor);
  1107. end;
  1108. end
  1109. else
  1110. dllversion:=tostr(major);
  1111. end;
  1112. end;
  1113. procedure dir_wait;
  1114. var
  1115. had_info : boolean;
  1116. begin
  1117. had_info:=(status.verbosity and V_Info)<>0;
  1118. { this message should allways appear !! }
  1119. status.verbosity:=status.verbosity or V_Info;
  1120. Message(scan_i_press_enter);
  1121. readln;
  1122. If not(had_info) then
  1123. status.verbosity:=status.verbosity and (not V_Info);
  1124. end;
  1125. { delphi compatible warn directive:
  1126. $warn <identifier> on
  1127. $warn <identifier> off
  1128. $warn <identifier> error
  1129. }
  1130. procedure dir_warn;
  1131. var
  1132. ident : string;
  1133. state : string;
  1134. msgstate : tmsgstate;
  1135. i : integer;
  1136. begin
  1137. current_scanner.skipspace;
  1138. ident:=current_scanner.readid;
  1139. current_scanner.skipspace;
  1140. state:=current_scanner.readid;
  1141. { support both delphi and fpc switches }
  1142. { use local ms_on/off/error tmsgstate values }
  1143. if (state='ON') or (state='+') then
  1144. msgstate:=ms_on
  1145. else
  1146. if (state='OFF') or (state='-') then
  1147. msgstate:=ms_off
  1148. else
  1149. if (state='ERROR') then
  1150. msgstate:=ms_error
  1151. else
  1152. begin
  1153. Message1(scanner_e_illegal_warn_state,state);
  1154. exit;
  1155. end;
  1156. if ident='CONSTRUCTING_ABSTRACT' then
  1157. recordpendingmessagestate(type_w_instance_with_abstract, msgstate)
  1158. else
  1159. if ident='IMPLICIT_VARIANTS' then
  1160. recordpendingmessagestate(parser_w_implicit_uses_of_variants_unit, msgstate)
  1161. else
  1162. if ident='NO_RETVAL' then
  1163. recordpendingmessagestate(sym_w_function_result_not_set, msgstate)
  1164. else
  1165. if ident='SYMBOL_DEPRECATED' then
  1166. begin
  1167. recordpendingmessagestate(sym_w_deprecated_symbol, msgstate);
  1168. recordpendingmessagestate(sym_w_deprecated_symbol_with_msg, msgstate);
  1169. end
  1170. else
  1171. if ident='SYMBOL_EXPERIMENTAL' then
  1172. recordpendingmessagestate(sym_w_experimental_symbol, msgstate)
  1173. else
  1174. if ident='SYMBOL_LIBRARY' then
  1175. recordpendingmessagestate(sym_w_library_symbol, msgstate)
  1176. else
  1177. if ident='SYMBOL_PLATFORM' then
  1178. recordpendingmessagestate(sym_w_non_portable_symbol, msgstate)
  1179. else
  1180. if ident='SYMBOL_UNIMPLEMENTED' then
  1181. recordpendingmessagestate(sym_w_non_implemented_symbol, msgstate)
  1182. else
  1183. if ident='UNIT_DEPRECATED' then
  1184. begin
  1185. recordpendingmessagestate(sym_w_deprecated_unit, msgstate);
  1186. recordpendingmessagestate(sym_w_deprecated_unit_with_msg, msgstate);
  1187. end
  1188. else
  1189. if ident='UNIT_EXPERIMENTAL' then
  1190. recordpendingmessagestate(sym_w_experimental_unit, msgstate)
  1191. else
  1192. if ident='UNIT_LIBRARY' then
  1193. recordpendingmessagestate(sym_w_library_unit, msgstate)
  1194. else
  1195. if ident='UNIT_PLATFORM' then
  1196. recordpendingmessagestate(sym_w_non_portable_unit, msgstate)
  1197. else
  1198. if ident='UNIT_UNIMPLEMENTED' then
  1199. recordpendingmessagestate(sym_w_non_implemented_unit, msgstate)
  1200. else
  1201. if ident='ZERO_NIL_COMPAT' then
  1202. recordpendingmessagestate(type_w_zero_to_nil, msgstate)
  1203. else
  1204. if ident='IMPLICIT_STRING_CAST' then
  1205. recordpendingmessagestate(type_w_implicit_string_cast, msgstate)
  1206. else
  1207. if ident='IMPLICIT_STRING_CAST_LOSS' then
  1208. recordpendingmessagestate(type_w_implicit_string_cast_loss, msgstate)
  1209. else
  1210. if ident='EXPLICIT_STRING_CAST' then
  1211. recordpendingmessagestate(type_w_explicit_string_cast, msgstate)
  1212. else
  1213. if ident='EXPLICIT_STRING_CAST_LOSS' then
  1214. recordpendingmessagestate(type_w_explicit_string_cast_loss, msgstate)
  1215. else
  1216. if ident='CVT_NARROWING_STRING_LOST' then
  1217. recordpendingmessagestate(type_w_unicode_data_loss, msgstate)
  1218. else
  1219. if ident='INTF_RAISE_VISIBILITY' then
  1220. recordpendingmessagestate(type_w_interface_lower_visibility, msgstate)
  1221. else
  1222. begin
  1223. i:=0;
  1224. if not ChangeMessageVerbosity(ident,i,msgstate) then
  1225. Message1(scanner_w_illegal_warn_identifier,ident);
  1226. end;
  1227. end;
  1228. procedure dir_warning;
  1229. begin
  1230. do_message(scan_w_user_defined);
  1231. end;
  1232. procedure dir_warnings;
  1233. begin
  1234. do_setverbose('W');
  1235. end;
  1236. procedure dir_writeableconst;
  1237. begin
  1238. do_delphiswitch('J');
  1239. end;
  1240. procedure dir_z1;
  1241. begin
  1242. current_settings.packenum:=1;
  1243. end;
  1244. procedure dir_z2;
  1245. begin
  1246. current_settings.packenum:=2;
  1247. end;
  1248. procedure dir_z4;
  1249. begin
  1250. current_settings.packenum:=4;
  1251. end;
  1252. procedure dir_externalsym;
  1253. begin
  1254. end;
  1255. procedure dir_nodefine;
  1256. begin
  1257. end;
  1258. procedure dir_hppemit;
  1259. begin
  1260. end;
  1261. procedure dir_weakpackageunit;
  1262. begin
  1263. end;
  1264. procedure dir_codealign;
  1265. var
  1266. s : string;
  1267. begin
  1268. current_scanner.skipspace;
  1269. s:=current_scanner.readcomment;
  1270. if not(UpdateAlignmentStr(s,current_settings.alignment)) then
  1271. message(scanner_e_illegal_alignment_directive);
  1272. end;
  1273. procedure dir_codepage;
  1274. var
  1275. s : string;
  1276. begin
  1277. if not current_module.in_global then
  1278. Message(scan_w_switch_is_global)
  1279. else
  1280. begin
  1281. current_scanner.skipspace;
  1282. s:=current_scanner.readcomment;
  1283. if (upper(s)='UTF8') or (upper(s)='UTF-8') then
  1284. current_settings.sourcecodepage:=CP_UTF8
  1285. else if not(cpavailable(s)) then
  1286. Message1(option_code_page_not_available,s)
  1287. else
  1288. current_settings.sourcecodepage:=codepagebyname(s);
  1289. include(current_settings.moduleswitches,cs_explicit_codepage);
  1290. end;
  1291. end;
  1292. procedure dir_coperators;
  1293. begin
  1294. do_moduleswitch(cs_support_c_operators);
  1295. end;
  1296. procedure dir_bitpacking;
  1297. begin
  1298. do_localswitch(cs_bitpacking);
  1299. end;
  1300. procedure dir_region;
  1301. begin
  1302. end;
  1303. procedure dir_endregion;
  1304. begin
  1305. end;
  1306. {****************************************************************************
  1307. Initialize Directives
  1308. ****************************************************************************}
  1309. procedure InitScannerDirectives;
  1310. begin
  1311. AddDirective('A1',directive_all, @dir_a1);
  1312. AddDirective('A2',directive_all, @dir_a2);
  1313. AddDirective('A4',directive_all, @dir_a4);
  1314. AddDirective('A8',directive_all, @dir_a8);
  1315. AddDirective('ALIGN',directive_all, @dir_align);
  1316. {$ifdef m68k}
  1317. AddDirective('APPID',directive_all, @dir_appid);
  1318. AddDirective('APPNAME',directive_all, @dir_appname);
  1319. {$endif m68k}
  1320. AddDirective('APPTYPE',directive_all, @dir_apptype);
  1321. AddDirective('ASMMODE',directive_all, @dir_asmmode);
  1322. AddDirective('ASSERTIONS',directive_all, @dir_assertions);
  1323. AddDirective('BOOLEVAL',directive_all, @dir_booleval);
  1324. AddDirective('BITPACKING',directive_all, @dir_bitpacking);
  1325. AddDirective('CALLING',directive_all, @dir_calling);
  1326. AddDirective('CHECKLOWADDRLOADS',directive_all, @dir_checklowaddrloads);
  1327. AddDirective('CHECKPOINTER',directive_all, @dir_checkpointer);
  1328. AddDirective('CODEALIGN',directive_all, @dir_codealign);
  1329. AddDirective('CODEPAGE',directive_all, @dir_codepage);
  1330. AddDirective('COPERATORS',directive_all, @dir_coperators);
  1331. AddDirective('COPYRIGHT',directive_all, @dir_copyright);
  1332. AddDirective('D',directive_all, @dir_description);
  1333. AddDirective('DEBUGINFO',directive_all, @dir_debuginfo);
  1334. AddDirective('DESCRIPTION',directive_all, @dir_description);
  1335. AddDirective('ENDREGION',directive_all, @dir_endregion);
  1336. AddDirective('ERROR',directive_all, @dir_error);
  1337. AddDirective('ERRORC',directive_mac, @dir_error);
  1338. AddDirective('EXTENDEDSYNTAX',directive_all, @dir_extendedsyntax);
  1339. AddDirective('EXTERNALSYM',directive_all, @dir_externalsym);
  1340. AddDirective('FATAL',directive_all, @dir_fatal);
  1341. AddDirective('FPUTYPE',directive_all, @dir_fputype);
  1342. AddDirective('FRAMEWORKPATH',directive_all, @dir_frameworkpath);
  1343. AddDirective('GOTO',directive_all, @dir_goto);
  1344. AddDirective('HINT',directive_all, @dir_hint);
  1345. AddDirective('HINTS',directive_all, @dir_hints);
  1346. AddDirective('HPPEMIT',directive_all, @dir_hppemit);
  1347. AddDirective('IEEEERRORS',directive_all,@dir_ieeeerrors);
  1348. AddDirective('IOCHECKS',directive_all, @dir_iochecks);
  1349. AddDirective('IMAGEBASE',directive_all, @dir_imagebase);
  1350. AddDirective('IMPLICITEXCEPTIONS',directive_all, @dir_implicitexceptions);
  1351. AddDirective('INCLUDEPATH',directive_all, @dir_includepath);
  1352. AddDirective('INFO',directive_all, @dir_info);
  1353. AddDirective('INLINE',directive_all, @dir_inline);
  1354. AddDirective('INTERFACES',directive_all, @dir_interfaces);
  1355. AddDirective('L',directive_all, @dir_link);
  1356. AddDirective('LIBEXPORT',directive_mac, @dir_libexport);
  1357. AddDirective('LIBRARYPATH',directive_all, @dir_librarypath);
  1358. AddDirective('LINK',directive_all, @dir_link);
  1359. AddDirective('LINKFRAMEWORK',directive_all, @dir_linkframework);
  1360. AddDirective('LINKLIB',directive_all, @dir_linklib);
  1361. AddDirective('LOCALSYMBOLS',directive_all, @dir_localsymbols);
  1362. AddDirective('LONGSTRINGS',directive_all, @dir_longstrings);
  1363. AddDirective('M',directive_all, @dir_memory);
  1364. AddDirective('MACRO',directive_all, @dir_macro);
  1365. AddDirective('MAXFPUREGISTERS',directive_all, @dir_maxfpuregisters);
  1366. AddDirective('MAXSTACKSIZE',directive_all, @dir_maxstacksize);
  1367. AddDirective('MEMORY',directive_all, @dir_memory);
  1368. AddDirective('MESSAGE',directive_all, @dir_message);
  1369. AddDirective('MINENUMSIZE',directive_all, @dir_packenum);
  1370. AddDirective('MINFPCONSTPREC',directive_all, @dir_minfpconstprec);
  1371. AddDirective('MINSTACKSIZE',directive_all, @dir_minstacksize);
  1372. AddDirective('MMX',directive_all, @dir_mmx);
  1373. AddDirective('MODE',directive_all, @dir_mode);
  1374. AddDirective('MODESWITCH',directive_all, @dir_modeswitch);
  1375. AddDirective('NAMESPACE',directive_all, @dir_namespace);
  1376. AddDirective('NODEFINE',directive_all, @dir_nodefine);
  1377. AddDirective('NOTE',directive_all, @dir_note);
  1378. AddDirective('NOTES',directive_all, @dir_notes);
  1379. AddDirective('OBJECTCHECKS',directive_all, @dir_objectchecks);
  1380. AddDirective('OBJECTPATH',directive_all, @dir_objectpath);
  1381. AddDirective('OPENSTRINGS',directive_all, @dir_openstrings);
  1382. AddDirective('OPTIMIZATION',directive_all, @dir_optimization);
  1383. AddDirective('OV',directive_mac, @dir_overflowchecks);
  1384. AddDirective('OVERFLOWCHECKS',directive_all, @dir_overflowchecks);
  1385. AddDirective('PACKENUM',directive_all, @dir_packenum);
  1386. AddDirective('PACKRECORDS',directive_all, @dir_packrecords);
  1387. AddDirective('PACKSET',directive_all, @dir_packset);
  1388. AddDirective('PASCALMAINNAME',directive_all, @dir_pascalmainname);
  1389. AddDirective('PIC',directive_all, @dir_pic);
  1390. AddDirective('POINTERMATH',directive_all, @dir_pointermath);
  1391. AddDirective('POP',directive_all, @dir_pop);
  1392. AddDirective('PROFILE',directive_all, @dir_profile);
  1393. AddDirective('PUSH',directive_all, @dir_push);
  1394. AddDirective('R',directive_all, @dir_resource);
  1395. AddDirective('RANGECHECKS',directive_all, @dir_rangechecks);
  1396. AddDirective('REFERENCEINFO',directive_all, @dir_referenceinfo);
  1397. AddDirective('REGION',directive_all, @dir_region);
  1398. AddDirective('RESOURCE',directive_all, @dir_resource);
  1399. AddDirective('SATURATION',directive_all, @dir_saturation);
  1400. AddDirective('SAFEFPUEXCEPTIONS',directive_all, @dir_safefpuexceptions);
  1401. AddDirective('SCOPEDENUMS',directive_all, @dir_scopedenums);
  1402. AddDirective('SETPEFLAGS', directive_all, @dir_setpeflags);
  1403. AddDirective('SCREENNAME',directive_all, @dir_screenname);
  1404. AddDirective('SMARTLINK',directive_all, @dir_smartlink);
  1405. AddDirective('STACKFRAMES',directive_all, @dir_stackframes);
  1406. AddDirective('STOP',directive_all, @dir_stop);
  1407. AddDirective('STRINGCHECKS', directive_all, @dir_stringchecks);
  1408. {$ifdef powerpc}
  1409. AddDirective('SYSCALL',directive_all, @dir_syscall);
  1410. {$endif powerpc}
  1411. AddDirective('THREADNAME',directive_all, @dir_threadname);
  1412. AddDirective('TYPEDADDRESS',directive_all, @dir_typedaddress);
  1413. AddDirective('TYPEINFO',directive_all, @dir_typeinfo);
  1414. AddDirective('UNITPATH',directive_all, @dir_unitpath);
  1415. AddDirective('VARPARACOPYOUTCHECK',directive_all, @dir_varparacopyoutcheck);
  1416. AddDirective('VARPROPSETTER',directive_all, @dir_varpropsetter);
  1417. AddDirective('VARSTRINGCHECKS',directive_all, @dir_varstringchecks);
  1418. AddDirective('VERSION',directive_all, @dir_version);
  1419. AddDirective('WAIT',directive_all, @dir_wait);
  1420. AddDirective('WARN',directive_all, @dir_warn);
  1421. AddDirective('WARNING',directive_all, @dir_warning);
  1422. AddDirective('WARNINGS',directive_all, @dir_warnings);
  1423. AddDirective('WEAKPACKAGEUNIT',directive_all, @dir_weakpackageunit);
  1424. AddDirective('WRITEABLECONST',directive_all, @dir_writeableconst);
  1425. AddDirective('Z1',directive_all, @dir_z1);
  1426. AddDirective('Z2',directive_all, @dir_z2);
  1427. AddDirective('Z4',directive_all, @dir_z4);
  1428. end;
  1429. end.