scandir.pas 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Peter Vreman
  4. This unit implements directive parsing for the scanner
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit scandir;
  19. {$i fpcdefs.inc}
  20. interface
  21. procedure InitScannerDirectives;
  22. implementation
  23. uses
  24. cutils,
  25. globtype,globals,systems,widestr,
  26. verbose,comphook,
  27. scanner,switches,
  28. fmodule;
  29. {*****************************************************************************
  30. Helpers
  31. *****************************************************************************}
  32. procedure do_delphiswitch(sw:char);
  33. var
  34. state : char;
  35. begin
  36. { c contains the next char, a + or - would be fine }
  37. state:=current_scanner.readstate;
  38. if state in ['-','+'] then
  39. HandleSwitch(sw,state);
  40. end;
  41. procedure do_setverbose(flag:char);
  42. var
  43. state : char;
  44. begin
  45. { support ON/OFF }
  46. state:=current_scanner.ReadState;
  47. SetVerbosity(flag+state);
  48. end;
  49. procedure do_moduleswitch(sw:tmoduleswitch);
  50. var
  51. state : char;
  52. begin
  53. state:=current_scanner.readstate;
  54. if (sw<>cs_modulenone) and (state in ['-','+']) then
  55. begin
  56. if state='-' then
  57. exclude(aktmoduleswitches,sw)
  58. else
  59. include(aktmoduleswitches,sw);
  60. end;
  61. end;
  62. procedure do_localswitch(sw:tlocalswitch);
  63. var
  64. state : char;
  65. begin
  66. state:=current_scanner.readstate;
  67. if (sw<>cs_localnone) and (state in ['-','+']) then
  68. begin
  69. if not localswitcheschanged then
  70. nextaktlocalswitches:=aktlocalswitches;
  71. if state='-' then
  72. exclude(nextaktlocalswitches,sw)
  73. else
  74. include(nextaktlocalswitches,sw);
  75. localswitcheschanged:=true;
  76. end;
  77. end;
  78. procedure do_message(w:integer);
  79. begin
  80. current_scanner.skipspace;
  81. Message1(w,current_scanner.readcomment);
  82. end;
  83. {*****************************************************************************
  84. Directive Callbacks
  85. *****************************************************************************}
  86. procedure dir_align;
  87. var
  88. hs : string;
  89. begin
  90. current_scanner.skipspace;
  91. if not(c in ['0'..'9']) then
  92. begin
  93. { Support also the ON and OFF as switch }
  94. hs:=current_scanner.readid;
  95. if (hs='ON') then
  96. aktalignment.recordalignmax:=4
  97. else
  98. if (hs='OFF') then
  99. aktalignment.recordalignmax:=1
  100. else
  101. Message(scan_w_only_pack_records);
  102. end
  103. else
  104. begin
  105. case current_scanner.readval of
  106. 1 : aktalignment.recordalignmax:=1;
  107. 2 : aktalignment.recordalignmax:=2;
  108. 4 : aktalignment.recordalignmax:=4;
  109. 8 : aktalignment.recordalignmax:=8;
  110. 16 : aktalignment.recordalignmax:=16;
  111. 32 : aktalignment.recordalignmax:=32;
  112. else
  113. Message(scan_w_only_pack_records);
  114. end;
  115. end;
  116. end;
  117. procedure dir_asmmode;
  118. var
  119. s : string;
  120. begin
  121. current_scanner.skipspace;
  122. s:=current_scanner.readid;
  123. If Inside_asm_statement then
  124. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  125. if s='DEFAULT' then
  126. aktasmmode:=initasmmode
  127. else
  128. if not set_asmmode_by_string(s,aktasmmode) then
  129. Message1(scan_w_unsupported_asmmode_specifier,s);
  130. end;
  131. {$ifdef m68k}
  132. procedure dir_appid;
  133. begin
  134. if target_info.system<>system_m68k_palmos then
  135. Message(scan_w_appid_not_support);
  136. { change description global var in all cases }
  137. { it not used but in win32 and os2 }
  138. current_scanner.skipspace;
  139. palmos_applicationid:=current_scanner.readcomment;
  140. end;
  141. procedure dir_appname;
  142. begin
  143. if target_info.system<>system_m68k_palmos then
  144. Message(scan_w_appname_not_support);
  145. { change description global var in all cases }
  146. { it not used but in win32 and os2 }
  147. current_scanner.skipspace;
  148. palmos_applicationname:=current_scanner.readcomment;
  149. end;
  150. {$endif m68k}
  151. procedure dir_apptype;
  152. var
  153. hs : string;
  154. begin
  155. if not (target_info.system in [system_i386_win32,system_i386_os2,
  156. system_i386_emx]) then
  157. Message(scan_w_app_type_not_support);
  158. if not current_module.in_global then
  159. Message(scan_w_switch_is_global)
  160. else
  161. begin
  162. current_scanner.skipspace;
  163. hs:=current_scanner.readid;
  164. if hs='GUI' then
  165. apptype:=app_gui
  166. else if hs='CONSOLE' then
  167. apptype:=app_cui
  168. else if (hs='FS') and (target_info.system in [system_i386_os2,
  169. system_i386_emx]) then
  170. apptype:=app_fs
  171. else
  172. Message1(scan_w_unsupported_app_type,hs);
  173. end;
  174. end;
  175. procedure dir_calling;
  176. var
  177. hs : string;
  178. begin
  179. current_scanner.skipspace;
  180. hs:=current_scanner.readid;
  181. if not SetAktProcCall(hs,false) then
  182. Message1(parser_w_unknown_proc_directive_ignored,hs);
  183. end;
  184. procedure dir_objectchecks;
  185. begin
  186. do_localswitch(cs_check_object);
  187. end;
  188. procedure dir_assertions;
  189. begin
  190. do_delphiswitch('C');
  191. end;
  192. procedure dir_booleval;
  193. begin
  194. do_delphiswitch('B');
  195. end;
  196. procedure dir_debuginfo;
  197. begin
  198. do_delphiswitch('D');
  199. end;
  200. procedure dir_description;
  201. begin
  202. if not (target_info.system in [system_i386_os2,system_i386_emx,
  203. system_i386_win32,system_i386_netware,system_i386_wdosx]) then
  204. Message(scan_w_description_not_support);
  205. { change description global var in all cases }
  206. { it not used but in win32, os2 and netware }
  207. current_scanner.skipspace;
  208. description:=current_scanner.readcomment;
  209. end;
  210. procedure dir_screenname; {ad}
  211. begin
  212. if target_info.system <> system_i386_netware then
  213. {Message(scan_w_decription_not_support);}
  214. comment (V_Warning,'Screenname only supported for target netware');
  215. current_scanner.skipspace;
  216. nwscreenname:=current_scanner.readcomment;
  217. end;
  218. procedure dir_threadname; {ad}
  219. begin
  220. if target_info.system <> system_i386_netware then
  221. {Message(scan_w_decription_not_support);}
  222. comment (V_Warning,'Threadname only supported for target netware');
  223. current_scanner.skipspace;
  224. nwthreadname:=current_scanner.readcomment;
  225. end;
  226. procedure dir_copyright; {ad}
  227. begin
  228. if target_info.system <> system_i386_netware then
  229. {Message(scan_w_decription_not_support);}
  230. comment (V_Warning,'Copyright only supported for target netware');
  231. current_scanner.skipspace;
  232. nwcopyright:=current_scanner.readcomment;
  233. end;
  234. procedure dir_error;
  235. begin
  236. do_message(scan_e_user_defined);
  237. end;
  238. procedure dir_extendedsyntax;
  239. begin
  240. do_delphiswitch('X');
  241. end;
  242. procedure dir_fatal;
  243. begin
  244. do_message(scan_f_user_defined);
  245. end;
  246. procedure dir_goto;
  247. begin
  248. do_moduleswitch(cs_support_goto);
  249. end;
  250. procedure dir_hint;
  251. begin
  252. do_message(scan_h_user_defined);
  253. end;
  254. procedure dir_hints;
  255. begin
  256. do_setverbose('H');
  257. end;
  258. procedure dir_implicitexceptions;
  259. begin
  260. do_moduleswitch(cs_implicit_exceptions);
  261. end;
  262. procedure dir_includepath;
  263. begin
  264. if not current_module.in_global then
  265. Message(scan_w_switch_is_global)
  266. else
  267. begin
  268. current_scanner.skipspace;
  269. current_module.localincludesearchpath.AddPath(current_scanner.readcomment,false);
  270. end;
  271. end;
  272. procedure dir_info;
  273. begin
  274. do_message(scan_i_user_defined);
  275. end;
  276. procedure dir_inline;
  277. begin
  278. do_moduleswitch(cs_support_inline);
  279. end;
  280. procedure dir_interfaces;
  281. var
  282. hs : string;
  283. begin
  284. {corba/com/default}
  285. current_scanner.skipspace;
  286. hs:=current_scanner.readid;
  287. if (hs='CORBA') then
  288. aktinterfacetype:=it_interfacecorba
  289. else if (hs='COM') then
  290. aktinterfacetype:=it_interfacecom
  291. else if (hs='DEFAULT') then
  292. aktinterfacetype:=initinterfacetype
  293. else
  294. Message(scan_e_invalid_interface_type);
  295. end;
  296. procedure dir_iochecks;
  297. begin
  298. do_delphiswitch('I');
  299. end;
  300. procedure dir_librarypath;
  301. begin
  302. if not current_module.in_global then
  303. Message(scan_w_switch_is_global)
  304. else
  305. begin
  306. current_scanner.skipspace;
  307. current_module.locallibrarysearchpath.AddPath(current_scanner.readcomment,false);
  308. end;
  309. end;
  310. procedure dir_link;
  311. var
  312. s : string;
  313. begin
  314. current_scanner.skipspace;
  315. s:=AddExtension(FixFileName(current_scanner.readcomment),target_info.objext);
  316. current_module.linkotherofiles.add(s,link_allways);
  317. end;
  318. procedure dir_linklib;
  319. type
  320. tLinkMode=(lm_shared,lm_static);
  321. var
  322. s : string;
  323. quote : char;
  324. libname,
  325. linkmodestr : string;
  326. p : longint;
  327. linkMode : tLinkMode;
  328. begin
  329. current_scanner.skipspace;
  330. s:=current_scanner.readcomment;
  331. p:=pos(',',s);
  332. if p=0 then
  333. begin
  334. libname:=TrimSpace(s);
  335. linkmodeStr:='';
  336. end
  337. else
  338. begin
  339. libname:=TrimSpace(copy(s,1,p-1));
  340. linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
  341. end;
  342. if (libname='') or (libname='''''') or (libname='""') then
  343. exit;
  344. { get linkmode, default is shared linking }
  345. if linkModeStr='STATIC' then
  346. linkmode:=lm_static
  347. else if (LinkModeStr='SHARED') or (LinkModeStr='') then
  348. linkmode:=lm_shared
  349. else
  350. begin
  351. Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
  352. exit;
  353. end;
  354. { create library name }
  355. if libname[1] in ['''','"'] then
  356. begin
  357. quote:=libname[1];
  358. Delete(libname,1,1);
  359. p:=pos(quote,libname);
  360. if p>0 then
  361. Delete(libname,p,1);
  362. end;
  363. { add to the list of libraries to link }
  364. if linkMode=lm_static then
  365. current_module.linkOtherStaticLibs.add(FixFileName(libname),link_allways)
  366. else
  367. current_module.linkOtherSharedLibs.add(FixFileName(libname),link_allways);
  368. end;
  369. procedure dir_localsymbols;
  370. begin
  371. do_delphiswitch('L');
  372. end;
  373. procedure dir_longstrings;
  374. begin
  375. do_delphiswitch('H');
  376. end;
  377. procedure dir_macro;
  378. begin
  379. do_moduleswitch(cs_support_macro);
  380. end;
  381. procedure dir_maxfpuregisters;
  382. var
  383. l : integer;
  384. hs : string;
  385. begin
  386. current_scanner.skipspace;
  387. if not(c in ['0'..'9']) then
  388. begin
  389. hs:=current_scanner.readid;
  390. if (hs='NORMAL') or (hs='DEFAULT') then
  391. aktmaxfpuregisters:=-1
  392. else
  393. Message(scan_e_invalid_maxfpureg_value);
  394. end
  395. else
  396. begin
  397. l:=current_scanner.readval;
  398. case l of
  399. 0..8:
  400. aktmaxfpuregisters:=l;
  401. else
  402. Message(scan_e_invalid_maxfpureg_value);
  403. end;
  404. end;
  405. end;
  406. procedure dir_memory;
  407. var
  408. l : longint;
  409. begin
  410. current_scanner.skipspace;
  411. l:=current_scanner.readval;
  412. if l>1024 then
  413. stacksize:=l;
  414. current_scanner.skipspace;
  415. if c=',' then
  416. begin
  417. current_scanner.readchar;
  418. current_scanner.skipspace;
  419. l:=current_scanner.readval;
  420. if l>1024 then
  421. heapsize:=l;
  422. end;
  423. if c=',' then
  424. begin
  425. current_scanner.readchar;
  426. current_scanner.skipspace;
  427. l:=current_scanner.readval;
  428. { Ignore this value, because the limit is set by the OS
  429. info and shouldn't be changed by the user (PFV) }
  430. end;
  431. end;
  432. procedure dir_message;
  433. begin
  434. do_message(scan_i_user_defined);
  435. end;
  436. procedure dir_mode;
  437. begin
  438. if not current_module.in_global then
  439. Message(scan_w_switch_is_global)
  440. else
  441. begin
  442. current_scanner.skipspace;
  443. current_scanner.readstring;
  444. if not SetCompileMode(pattern,false) then
  445. Message1(scan_w_illegal_switch,pattern);
  446. end;
  447. end;
  448. procedure dir_mmx;
  449. begin
  450. do_localswitch(cs_mmx);
  451. end;
  452. procedure dir_note;
  453. begin
  454. do_message(scan_n_user_defined);
  455. end;
  456. procedure dir_notes;
  457. begin
  458. do_setverbose('N');
  459. end;
  460. procedure dir_objectpath;
  461. begin
  462. if not current_module.in_global then
  463. Message(scan_w_switch_is_global)
  464. else
  465. begin
  466. current_scanner.skipspace;
  467. current_module.localobjectsearchpath.AddPath(current_scanner.readcomment,false);
  468. end;
  469. end;
  470. procedure dir_openstrings;
  471. begin
  472. do_delphiswitch('P');
  473. end;
  474. procedure dir_output_format;
  475. begin
  476. if not current_module.in_global then
  477. Message(scan_w_switch_is_global)
  478. else
  479. begin
  480. current_scanner.skipspace;
  481. if set_target_asm_by_string(current_scanner.readid) then
  482. aktoutputformat:=target_asm.id
  483. else
  484. Message1(scan_w_illegal_switch,pattern);
  485. end;
  486. end;
  487. procedure dir_overflowchecks;
  488. begin
  489. do_delphiswitch('Q');
  490. end;
  491. procedure dir_packenum;
  492. var
  493. hs : string;
  494. begin
  495. current_scanner.skipspace;
  496. if not(c in ['0'..'9']) then
  497. begin
  498. hs:=current_scanner.readid;
  499. if (hs='NORMAL') or (hs='DEFAULT') then
  500. aktpackenum:=4
  501. else
  502. Message(scan_w_only_pack_enum);
  503. end
  504. else
  505. begin
  506. case current_scanner.readval of
  507. 1 : aktpackenum:=1;
  508. 2 : aktpackenum:=2;
  509. 4 : aktpackenum:=4;
  510. else
  511. Message(scan_w_only_pack_enum);
  512. end;
  513. end;
  514. end;
  515. procedure dir_packrecords;
  516. var
  517. hs : string;
  518. begin
  519. current_scanner.skipspace;
  520. if not(c in ['0'..'9']) then
  521. begin
  522. hs:=current_scanner.readid;
  523. { C has the special recordalignmax of -1 }
  524. if (hs='C') then
  525. aktalignment.recordalignmax:=-1
  526. else
  527. if (hs='NORMAL') or (hs='DEFAULT') then
  528. aktalignment.recordalignmax:=2
  529. else
  530. Message(scan_w_only_pack_records);
  531. end
  532. else
  533. begin
  534. case current_scanner.readval of
  535. 1 : aktalignment.recordalignmax:=1;
  536. 2 : aktalignment.recordalignmax:=2;
  537. 4 : aktalignment.recordalignmax:=4;
  538. 8 : aktalignment.recordalignmax:=8;
  539. 16 : aktalignment.recordalignmax:=16;
  540. 32 : aktalignment.recordalignmax:=32;
  541. else
  542. Message(scan_w_only_pack_records);
  543. end;
  544. end;
  545. end;
  546. {$ifdef testvarsets}
  547. procedure dir_packset;
  548. var
  549. hs : string;
  550. begin
  551. current_scanner.skipspace;
  552. if not(c in ['1','2','4']) then
  553. begin
  554. hs:=current_scanner.readid;
  555. if (hs='FIXED') or ((hs='DEFAULT') OR (hs='NORMAL')) then
  556. aktsetalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  557. else
  558. Message(scan_w_only_packset);
  559. end
  560. else
  561. begin
  562. case current_scanner.readval of
  563. 1 : aktsetalloc:=1;
  564. 2 : aktsetalloc:=2;
  565. 4 : aktsetalloc:=4;
  566. else
  567. Message(scan_w_only_packset);
  568. end;
  569. end;
  570. end;
  571. {$ENDIF}
  572. procedure dir_profile;
  573. var
  574. mac : tmacro;
  575. begin
  576. do_moduleswitch(cs_profile);
  577. { defined/undefine FPC_PROFILE }
  578. mac:=tmacro(current_scanner.macros.search('FPC_PROFILE'));
  579. if not assigned(mac) then
  580. begin
  581. mac:=tmacro.create('FPC_PROFILE');
  582. current_scanner.macros.insert(mac);
  583. end;
  584. mac.defined:=(cs_profile in aktmoduleswitches);
  585. end;
  586. procedure dir_rangechecks;
  587. begin
  588. do_delphiswitch('R');
  589. end;
  590. procedure dir_referenceinfo;
  591. begin
  592. do_delphiswitch('Y');
  593. end;
  594. procedure dir_resource;
  595. var
  596. s : string;
  597. begin
  598. current_scanner.skipspace;
  599. s:=current_scanner.readcomment;
  600. { replace * with current module name.
  601. This should always be defined. }
  602. if s[1]='*' then
  603. if Assigned(Current_Module) then
  604. begin
  605. delete(S,1,1);
  606. insert(lower(current_module.modulename^),S,1);
  607. end;
  608. s:=AddExtension(FixFileName(s),target_info.resext);
  609. if target_info.res<>res_none then
  610. if (target_info.res = res_emxbind) and
  611. not (Current_module.ResourceFiles.Empty) then
  612. Message(scan_w_only_one_resourcefile_supported)
  613. else
  614. current_module.resourcefiles.insert(FixFileName(s))
  615. else
  616. Message(scan_e_resourcefiles_not_supported);
  617. end;
  618. procedure dir_saturation;
  619. begin
  620. do_localswitch(cs_mmx_saturation);
  621. end;
  622. procedure dir_smartlink;
  623. begin
  624. do_moduleswitch(cs_create_smart);
  625. end;
  626. procedure dir_stackframes;
  627. begin
  628. do_delphiswitch('W');
  629. end;
  630. procedure dir_static;
  631. begin
  632. do_moduleswitch(cs_static_keyword);
  633. end;
  634. procedure dir_stop;
  635. begin
  636. do_message(scan_f_user_defined);
  637. end;
  638. procedure dir_threading;
  639. var
  640. mac : tmacro;
  641. begin
  642. do_moduleswitch(cs_threading);
  643. { defined/undefine FPC_THREADING }
  644. mac:=tmacro(current_scanner.macros.search('FPC_THREADING'));
  645. if not assigned(mac) then
  646. begin
  647. mac:=tmacro.create('FPC_THREADING');
  648. current_scanner.macros.insert(mac);
  649. end;
  650. mac.defined:=(cs_threading in aktmoduleswitches);
  651. end;
  652. procedure dir_typedaddress;
  653. begin
  654. do_delphiswitch('T');
  655. end;
  656. procedure dir_typeinfo;
  657. begin
  658. do_delphiswitch('M');
  659. end;
  660. procedure dir_unitpath;
  661. begin
  662. if not current_module.in_global then
  663. Message(scan_w_switch_is_global)
  664. else
  665. with current_scanner,current_module,localunitsearchpath do
  666. begin
  667. skipspace;
  668. AddPath(path^,readcomment,false);
  669. end;
  670. end;
  671. procedure dir_varstringchecks;
  672. begin
  673. do_delphiswitch('V');
  674. end;
  675. procedure dir_version;
  676. var
  677. major, minor, revision : longint;
  678. error : integer;
  679. begin
  680. if not (target_info.system in [system_i386_os2,system_i386_emx,
  681. system_i386_win32,system_i386_netware,system_i386_wdosx]) then
  682. begin
  683. Message(scan_n_version_not_support);
  684. exit;
  685. end;
  686. if (compile_level<>1) then
  687. Message(scan_n_only_exe_version)
  688. else
  689. begin
  690. { change description global var in all cases }
  691. { it not used but in win32, os2 and netware }
  692. current_scanner.skipspace;
  693. { we should only accept Major.Minor format for win32 and os2 }
  694. current_scanner.readnumber;
  695. major:=0;
  696. minor:=0;
  697. revision:=0;
  698. valint(pattern,major,error);
  699. if (error<>0) or (major > high(word)) or (major < 0) then
  700. begin
  701. Message1(scan_w_wrong_version_ignored,pattern);
  702. exit;
  703. end;
  704. if c='.' then
  705. begin
  706. current_scanner.readchar;
  707. current_scanner.readnumber;
  708. valint(pattern,minor,error);
  709. if (error<>0) or (minor > high(word)) or (minor < 0) then
  710. begin
  711. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  712. exit;
  713. end;
  714. if (c='.') and
  715. (target_info.system = system_i386_netware) then
  716. begin
  717. current_scanner.readchar;
  718. current_scanner.readnumber;
  719. valint(pattern,revision,error);
  720. if (error<>0) or (revision > high(word)) or (revision < 0) then
  721. begin
  722. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  723. exit;
  724. end;
  725. dllmajor:=word(major);
  726. dllminor:=word(minor);
  727. dllrevision:=word(revision);
  728. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  729. end
  730. else
  731. begin
  732. dllmajor:=word(major);
  733. dllminor:=word(minor);
  734. dllversion:=tostr(major)+'.'+tostr(minor);
  735. end;
  736. end
  737. else
  738. dllversion:=tostr(major);
  739. end;
  740. end;
  741. procedure dir_wait;
  742. var
  743. had_info : boolean;
  744. begin
  745. had_info:=(status.verbosity and V_Info)<>0;
  746. { this message should allways appear !! }
  747. status.verbosity:=status.verbosity or V_Info;
  748. Message(scan_i_press_enter);
  749. readln;
  750. If not(had_info) then
  751. status.verbosity:=status.verbosity and (not V_Info);
  752. end;
  753. procedure dir_warning;
  754. begin
  755. do_message(scan_w_user_defined);
  756. end;
  757. procedure dir_warnings;
  758. begin
  759. do_setverbose('W');
  760. end;
  761. procedure dir_writeableconst;
  762. begin
  763. do_delphiswitch('J');
  764. end;
  765. procedure dir_z1;
  766. begin
  767. aktpackenum:=1;
  768. end;
  769. procedure dir_z2;
  770. begin
  771. aktpackenum:=2;
  772. end;
  773. procedure dir_z4;
  774. begin
  775. aktpackenum:=4;
  776. end;
  777. procedure dir_externalsym;
  778. begin
  779. end;
  780. procedure dir_codepage;
  781. var
  782. s : string;
  783. begin
  784. if not current_module.in_global then
  785. Message(scan_w_switch_is_global)
  786. else
  787. begin
  788. current_scanner.skipspace;
  789. s:=current_scanner.readcomment;
  790. if not(cpavailable(s)) then
  791. Message1(option_code_page_not_available,s)
  792. else
  793. aktsourcecodepage:=s;
  794. end;
  795. end;
  796. {****************************************************************************
  797. Initialize Directives
  798. ****************************************************************************}
  799. procedure InitScannerDirectives;
  800. begin
  801. AddDirective('ALIGN',{$ifdef FPCPROCVAR}@{$endif}dir_align);
  802. {$ifdef m68k}
  803. AddDirective('APPID',{$ifdef FPCPROCVAR}@{$endif}dir_appid);
  804. AddDirective('APPNAME',{$ifdef FPCPROCVAR}@{$endif}dir_appname);
  805. {$endif m68k}
  806. AddDirective('APPTYPE',{$ifdef FPCPROCVAR}@{$endif}dir_apptype);
  807. AddDirective('ASMMODE',{$ifdef FPCPROCVAR}@{$endif}dir_asmmode);
  808. AddDirective('ASSERTIONS',{$ifdef FPCPROCVAR}@{$endif}dir_assertions);
  809. AddDirective('BOOLEVAL',{$ifdef FPCPROCVAR}@{$endif}dir_booleval);
  810. AddDirective('CALLING',{$ifdef FPCPROCVAR}@{$endif}dir_calling);
  811. AddDirective('CODEPAGE',{$ifdef FPCPROCVAR}@{$endif}dir_codepage);
  812. AddDirective('COPYRIGHT',{$ifdef FPCPROCVAR}@{$endif}dir_copyright);
  813. AddDirective('D',{$ifdef FPCPROCVAR}@{$endif}dir_description);
  814. AddDirective('DEBUGINFO',{$ifdef FPCPROCVAR}@{$endif}dir_debuginfo);
  815. AddDirective('DESCRIPTION',{$ifdef FPCPROCVAR}@{$endif}dir_description);
  816. AddDirective('ERROR',{$ifdef FPCPROCVAR}@{$endif}dir_error);
  817. AddDirective('EXTENDEDSYNTAX',{$ifdef FPCPROCVAR}@{$endif}dir_extendedsyntax);
  818. AddDirective('EXTERNALSYM',{$ifdef FPCPROCVAR}@{$endif}dir_externalsym);
  819. AddDirective('FATAL',{$ifdef FPCPROCVAR}@{$endif}dir_fatal);
  820. AddDirective('GOTO',{$ifdef FPCPROCVAR}@{$endif}dir_goto);
  821. AddDirective('HINT',{$ifdef FPCPROCVAR}@{$endif}dir_hint);
  822. AddDirective('HINTS',{$ifdef FPCPROCVAR}@{$endif}dir_hints);
  823. AddDirective('IOCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_iochecks);
  824. AddDirective('IMPLICITEXCEPTIONS',{$ifdef FPCPROCVAR}@{$endif}dir_implicitexceptions);
  825. AddDirective('INCLUDEPATH',{$ifdef FPCPROCVAR}@{$endif}dir_includepath);
  826. AddDirective('INFO',{$ifdef FPCPROCVAR}@{$endif}dir_info);
  827. AddDirective('INLINE',{$ifdef FPCPROCVAR}@{$endif}dir_inline);
  828. AddDirective('INTERFACES',{$ifdef FPCPROCVAR}@{$endif}dir_interfaces);
  829. AddDirective('L',{$ifdef FPCPROCVAR}@{$endif}dir_link);
  830. AddDirective('LIBRARYPATH',{$ifdef FPCPROCVAR}@{$endif}dir_librarypath);
  831. AddDirective('LINK',{$ifdef FPCPROCVAR}@{$endif}dir_link);
  832. AddDirective('LINKLIB',{$ifdef FPCPROCVAR}@{$endif}dir_linklib);
  833. AddDirective('LOCALSYMBOLS',{$ifdef FPCPROCVAR}@{$endif}dir_localsymbols);
  834. AddDirective('LONGSTRINGS',{$ifdef FPCPROCVAR}@{$endif}dir_longstrings);
  835. AddDirective('M',{$ifdef FPCPROCVAR}@{$endif}dir_memory);
  836. AddDirective('MACRO',{$ifdef FPCPROCVAR}@{$endif}dir_macro);
  837. AddDirective('MAXFPUREGISTERS',{$ifdef FPCPROCVAR}@{$endif}dir_maxfpuregisters);
  838. AddDirective('MEMORY',{$ifdef FPCPROCVAR}@{$endif}dir_memory);
  839. AddDirective('MESSAGE',{$ifdef FPCPROCVAR}@{$endif}dir_message);
  840. AddDirective('MINENUMSIZE',{$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  841. AddDirective('MMX',{$ifdef FPCPROCVAR}@{$endif}dir_mmx);
  842. AddDirective('MODE',{$ifdef FPCPROCVAR}@{$endif}dir_mode);
  843. AddDirective('NOTE',{$ifdef FPCPROCVAR}@{$endif}dir_note);
  844. AddDirective('NOTES',{$ifdef FPCPROCVAR}@{$endif}dir_notes);
  845. AddDirective('OBJECTCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_objectchecks);
  846. AddDirective('OBJECTPATH',{$ifdef FPCPROCVAR}@{$endif}dir_objectpath);
  847. AddDirective('OPENSTRINGS',{$ifdef FPCPROCVAR}@{$endif}dir_openstrings);
  848. AddDirective('OUTPUT_FORMAT',{$ifdef FPCPROCVAR}@{$endif}dir_output_format);
  849. AddDirective('OVERFLOWCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_overflowchecks);
  850. AddDirective('PACKENUM',{$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  851. AddDirective('PACKRECORDS',{$ifdef FPCPROCVAR}@{$endif}dir_packrecords);
  852. {$IFDEF TestVarsets}
  853. AddDirective('PACKSET',{$ifdef FPCPROCVAR}@{$endif}dir_packset);
  854. {$ENDIF}
  855. AddDirective('PROFILE',{$ifdef FPCPROCVAR}@{$endif}dir_profile);
  856. AddDirective('R',{$ifdef FPCPROCVAR}@{$endif}dir_resource);
  857. AddDirective('RANGECHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_rangechecks);
  858. AddDirective('REFERENCEINFO',{$ifdef FPCPROCVAR}@{$endif}dir_referenceinfo);
  859. AddDirective('SATURATION',{$ifdef FPCPROCVAR}@{$endif}dir_saturation);
  860. AddDirective('SCREENNAME',{$ifdef FPCPROCVAR}@{$endif}dir_screenname);
  861. AddDirective('SMARTLINK',{$ifdef FPCPROCVAR}@{$endif}dir_smartlink);
  862. AddDirective('STACKFRAMES',{$ifdef FPCPROCVAR}@{$endif}dir_stackframes);
  863. AddDirective('STATIC',{$ifdef FPCPROCVAR}@{$endif}dir_static);
  864. AddDirective('STOP',{$ifdef FPCPROCVAR}@{$endif}dir_stop);
  865. AddDirective('THREADING',{$ifdef FPCPROCVAR}@{$endif}dir_threading);
  866. AddDirective('THREADNAME',{$ifdef FPCPROCVAR}@{$endif}dir_threadname);
  867. AddDirective('TYPEDADDRESS',{$ifdef FPCPROCVAR}@{$endif}dir_typedaddress);
  868. AddDirective('TYPEINFO',{$ifdef FPCPROCVAR}@{$endif}dir_typeinfo);
  869. AddDirective('UNITPATH',{$ifdef FPCPROCVAR}@{$endif}dir_unitpath);
  870. AddDirective('VARSTRINGCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_varstringchecks);
  871. AddDirective('VERSION',{$ifdef FPCPROCVAR}@{$endif}dir_version);
  872. AddDirective('WAIT',{$ifdef FPCPROCVAR}@{$endif}dir_wait);
  873. AddDirective('WARNING',{$ifdef FPCPROCVAR}@{$endif}dir_warning);
  874. AddDirective('WARNINGS',{$ifdef FPCPROCVAR}@{$endif}dir_warnings);
  875. AddDirective('WRITEABLECONST',{$ifdef FPCPROCVAR}@{$endif}dir_writeableconst);
  876. AddDirective('Z1',{$ifdef FPCPROCVAR}@{$endif}dir_z1);
  877. AddDirective('Z2',{$ifdef FPCPROCVAR}@{$endif}dir_z2);
  878. AddDirective('Z4',{$ifdef FPCPROCVAR}@{$endif}dir_z4);
  879. end;
  880. end.
  881. {
  882. $Log$
  883. Revision 1.25 2003-03-23 23:20:38 hajny
  884. + emx target added
  885. Revision 1.24 2003/01/03 21:25:01 peter
  886. * OBJECTCHECKS added, equivalent of -CR
  887. * WRITEABLECONST added, equivalent of $J
  888. Revision 1.23 2002/12/07 14:06:20 carl
  889. * stricter version / revision checking (also remove some warnings)
  890. Revision 1.22 2002/11/20 11:12:46 mazen
  891. + module path is now passed to AddPath to fix relative unit path
  892. Revision 1.21 2002/10/16 19:01:43 peter
  893. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  894. implicit exception frames for procedures with initialized variables
  895. and for constructors. The default is on for compatibility
  896. Revision 1.20 2002/10/14 19:43:41 peter
  897. * threading switch, defines the symbol FPC_THREADING
  898. Revision 1.19 2002/08/13 18:01:52 carl
  899. * rename swatoperands to swapoperands
  900. + m68k first compilable version (still needs a lot of testing):
  901. assembler generator, system information , inline
  902. assembler reader.
  903. Revision 1.18 2002/07/26 21:15:42 florian
  904. * rewrote the system handling
  905. Revision 1.17 2002/07/20 17:16:03 florian
  906. + source code page support
  907. Revision 1.16 2002/07/16 15:37:58 florian
  908. + Directive $EXTERNALSYM added, it is ignored for now
  909. Revision 1.15 2002/05/18 13:34:17 peter
  910. * readded missing revisions
  911. Revision 1.14 2002/05/16 19:46:44 carl
  912. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  913. + try to fix temp allocation (still in ifdef)
  914. + generic constructor calls
  915. + start of tassembler / tmodulebase class cleanup
  916. Revision 1.12 2002/04/07 13:34:20 carl
  917. + wdosx target
  918. Revision 1.11 2002/04/04 19:06:05 peter
  919. * removed unused units
  920. * use tlocation.size in cg.a_*loc*() routines
  921. }