scandir.pas 30 KB

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