scandir.pas 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  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. with current_scanner,current_module,localunitsearchpath do
  660. begin
  661. skipspace;
  662. AddPath(path^,readcomment,false);
  663. end;
  664. end;
  665. procedure dir_varstringchecks;
  666. begin
  667. do_delphiswitch('V');
  668. end;
  669. procedure dir_version;
  670. var
  671. major, minor, revision : longint;
  672. error : integer;
  673. begin
  674. if not (target_info.system in [system_i386_os2,system_i386_win32,system_i386_netware,system_i386_wdosx]) then
  675. begin
  676. Message(scan_n_version_not_support);
  677. exit;
  678. end;
  679. if (compile_level<>1) then
  680. Message(scan_n_only_exe_version)
  681. else
  682. begin
  683. { change description global var in all cases }
  684. { it not used but in win32, os2 and netware }
  685. current_scanner.skipspace;
  686. { we should only accept Major.Minor format for win32 and os2 }
  687. current_scanner.readnumber;
  688. major:=0;
  689. minor:=0;
  690. revision:=0;
  691. valint(pattern,major,error);
  692. if (error<>0) or (major > high(word)) or (major < 0) then
  693. begin
  694. Message1(scan_w_wrong_version_ignored,pattern);
  695. exit;
  696. end;
  697. if c='.' then
  698. begin
  699. current_scanner.readchar;
  700. current_scanner.readnumber;
  701. valint(pattern,minor,error);
  702. if (error<>0) or (minor > high(word)) or (minor < 0) then
  703. begin
  704. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  705. exit;
  706. end;
  707. if (c='.') and
  708. (target_info.system = system_i386_netware) then
  709. begin
  710. current_scanner.readchar;
  711. current_scanner.readnumber;
  712. valint(pattern,revision,error);
  713. if (error<>0) or (revision > high(word)) or (revision < 0) then
  714. begin
  715. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  716. exit;
  717. end;
  718. dllmajor:=word(major);
  719. dllminor:=word(minor);
  720. dllrevision:=word(revision);
  721. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  722. end
  723. else
  724. begin
  725. dllmajor:=word(major);
  726. dllminor:=word(minor);
  727. dllversion:=tostr(major)+'.'+tostr(minor);
  728. end;
  729. end
  730. else
  731. dllversion:=tostr(major);
  732. end;
  733. end;
  734. procedure dir_wait;
  735. var
  736. had_info : boolean;
  737. begin
  738. had_info:=(status.verbosity and V_Info)<>0;
  739. { this message should allways appear !! }
  740. status.verbosity:=status.verbosity or V_Info;
  741. Message(scan_i_press_enter);
  742. readln;
  743. If not(had_info) then
  744. status.verbosity:=status.verbosity and (not V_Info);
  745. end;
  746. procedure dir_warning;
  747. begin
  748. do_message(scan_w_user_defined);
  749. end;
  750. procedure dir_warnings;
  751. begin
  752. do_setverbose('W');
  753. end;
  754. procedure dir_z1;
  755. begin
  756. aktpackenum:=1;
  757. end;
  758. procedure dir_z2;
  759. begin
  760. aktpackenum:=2;
  761. end;
  762. procedure dir_z4;
  763. begin
  764. aktpackenum:=4;
  765. end;
  766. procedure dir_externalsym;
  767. begin
  768. end;
  769. procedure dir_codepage;
  770. var
  771. s : string;
  772. begin
  773. if not current_module.in_global then
  774. Message(scan_w_switch_is_global)
  775. else
  776. begin
  777. current_scanner.skipspace;
  778. s:=current_scanner.readcomment;
  779. if not(cpavailable(s)) then
  780. Message1(option_code_page_not_available,s)
  781. else
  782. aktsourcecodepage:=s;
  783. end;
  784. end;
  785. {****************************************************************************
  786. Initialize Directives
  787. ****************************************************************************}
  788. procedure InitScannerDirectives;
  789. begin
  790. AddDirective('ALIGN',{$ifdef FPCPROCVAR}@{$endif}dir_align);
  791. {$ifdef m68k}
  792. AddDirective('APPID',{$ifdef FPCPROCVAR}@{$endif}dir_appid);
  793. AddDirective('APPNAME',{$ifdef FPCPROCVAR}@{$endif}dir_appname);
  794. {$endif m68k}
  795. AddDirective('APPTYPE',{$ifdef FPCPROCVAR}@{$endif}dir_apptype);
  796. AddDirective('ASMMODE',{$ifdef FPCPROCVAR}@{$endif}dir_asmmode);
  797. AddDirective('ASSERTIONS',{$ifdef FPCPROCVAR}@{$endif}dir_assertions);
  798. AddDirective('BOOLEVAL',{$ifdef FPCPROCVAR}@{$endif}dir_booleval);
  799. AddDirective('CALLING',{$ifdef FPCPROCVAR}@{$endif}dir_calling);
  800. AddDirective('CODEPAGE',{$ifdef FPCPROCVAR}@{$endif}dir_codepage);
  801. AddDirective('COPYRIGHT',{$ifdef FPCPROCVAR}@{$endif}dir_copyright);
  802. AddDirective('D',{$ifdef FPCPROCVAR}@{$endif}dir_description);
  803. AddDirective('DEBUGINFO',{$ifdef FPCPROCVAR}@{$endif}dir_debuginfo);
  804. AddDirective('DESCRIPTION',{$ifdef FPCPROCVAR}@{$endif}dir_description);
  805. AddDirective('ERROR',{$ifdef FPCPROCVAR}@{$endif}dir_error);
  806. AddDirective('EXTENDEDSYNTAX',{$ifdef FPCPROCVAR}@{$endif}dir_extendedsyntax);
  807. AddDirective('EXTERNALSYM',{$ifdef FPCPROCVAR}@{$endif}dir_externalsym);
  808. AddDirective('FATAL',{$ifdef FPCPROCVAR}@{$endif}dir_fatal);
  809. AddDirective('GOTO',{$ifdef FPCPROCVAR}@{$endif}dir_goto);
  810. AddDirective('HINT',{$ifdef FPCPROCVAR}@{$endif}dir_hint);
  811. AddDirective('HINTS',{$ifdef FPCPROCVAR}@{$endif}dir_hints);
  812. AddDirective('IOCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_iochecks);
  813. AddDirective('IMPLICITEXCEPTIONS',{$ifdef FPCPROCVAR}@{$endif}dir_implicitexceptions);
  814. AddDirective('INCLUDEPATH',{$ifdef FPCPROCVAR}@{$endif}dir_includepath);
  815. AddDirective('INFO',{$ifdef FPCPROCVAR}@{$endif}dir_info);
  816. AddDirective('INLINE',{$ifdef FPCPROCVAR}@{$endif}dir_inline);
  817. AddDirective('INTERFACES',{$ifdef FPCPROCVAR}@{$endif}dir_interfaces);
  818. AddDirective('L',{$ifdef FPCPROCVAR}@{$endif}dir_link);
  819. AddDirective('LIBRARYPATH',{$ifdef FPCPROCVAR}@{$endif}dir_librarypath);
  820. AddDirective('LINK',{$ifdef FPCPROCVAR}@{$endif}dir_link);
  821. AddDirective('LINKLIB',{$ifdef FPCPROCVAR}@{$endif}dir_linklib);
  822. AddDirective('LOCALSYMBOLS',{$ifdef FPCPROCVAR}@{$endif}dir_localsymbols);
  823. AddDirective('LONGSTRINGS',{$ifdef FPCPROCVAR}@{$endif}dir_longstrings);
  824. AddDirective('M',{$ifdef FPCPROCVAR}@{$endif}dir_memory);
  825. AddDirective('MACRO',{$ifdef FPCPROCVAR}@{$endif}dir_macro);
  826. AddDirective('MAXFPUREGISTERS',{$ifdef FPCPROCVAR}@{$endif}dir_maxfpuregisters);
  827. AddDirective('MEMORY',{$ifdef FPCPROCVAR}@{$endif}dir_memory);
  828. AddDirective('MESSAGE',{$ifdef FPCPROCVAR}@{$endif}dir_message);
  829. AddDirective('MINENUMSIZE',{$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  830. AddDirective('MMX',{$ifdef FPCPROCVAR}@{$endif}dir_mmx);
  831. AddDirective('MODE',{$ifdef FPCPROCVAR}@{$endif}dir_mode);
  832. AddDirective('NOTE',{$ifdef FPCPROCVAR}@{$endif}dir_note);
  833. AddDirective('NOTES',{$ifdef FPCPROCVAR}@{$endif}dir_notes);
  834. AddDirective('OBJECTPATH',{$ifdef FPCPROCVAR}@{$endif}dir_objectpath);
  835. AddDirective('OPENSTRINGS',{$ifdef FPCPROCVAR}@{$endif}dir_openstrings);
  836. AddDirective('OUTPUT_FORMAT',{$ifdef FPCPROCVAR}@{$endif}dir_output_format);
  837. AddDirective('OVERFLOWCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_overflowchecks);
  838. AddDirective('PACKENUM',{$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  839. AddDirective('PACKRECORDS',{$ifdef FPCPROCVAR}@{$endif}dir_packrecords);
  840. {$IFDEF TestVarsets}
  841. AddDirective('PACKSET',{$ifdef FPCPROCVAR}@{$endif}dir_packset);
  842. {$ENDIF}
  843. AddDirective('PROFILE',{$ifdef FPCPROCVAR}@{$endif}dir_profile);
  844. AddDirective('R',{$ifdef FPCPROCVAR}@{$endif}dir_resource);
  845. AddDirective('RANGECHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_rangechecks);
  846. AddDirective('REFERENCEINFO',{$ifdef FPCPROCVAR}@{$endif}dir_referenceinfo);
  847. AddDirective('SATURATION',{$ifdef FPCPROCVAR}@{$endif}dir_saturation);
  848. AddDirective('SCREENNAME',{$ifdef FPCPROCVAR}@{$endif}dir_screenname);
  849. AddDirective('SMARTLINK',{$ifdef FPCPROCVAR}@{$endif}dir_smartlink);
  850. AddDirective('STACKFRAMES',{$ifdef FPCPROCVAR}@{$endif}dir_stackframes);
  851. AddDirective('STATIC',{$ifdef FPCPROCVAR}@{$endif}dir_static);
  852. AddDirective('STOP',{$ifdef FPCPROCVAR}@{$endif}dir_stop);
  853. AddDirective('THREADING',{$ifdef FPCPROCVAR}@{$endif}dir_threading);
  854. AddDirective('THREADNAME',{$ifdef FPCPROCVAR}@{$endif}dir_threadname);
  855. AddDirective('TYPEDADDRESS',{$ifdef FPCPROCVAR}@{$endif}dir_typedaddress);
  856. AddDirective('TYPEINFO',{$ifdef FPCPROCVAR}@{$endif}dir_typeinfo);
  857. AddDirective('UNITPATH',{$ifdef FPCPROCVAR}@{$endif}dir_unitpath);
  858. AddDirective('VARSTRINGCHECKS',{$ifdef FPCPROCVAR}@{$endif}dir_varstringchecks);
  859. AddDirective('VERSION',{$ifdef FPCPROCVAR}@{$endif}dir_version);
  860. AddDirective('WAIT',{$ifdef FPCPROCVAR}@{$endif}dir_wait);
  861. AddDirective('WARNING',{$ifdef FPCPROCVAR}@{$endif}dir_warning);
  862. AddDirective('WARNINGS',{$ifdef FPCPROCVAR}@{$endif}dir_warnings);
  863. AddDirective('Z1',{$ifdef FPCPROCVAR}@{$endif}dir_z1);
  864. AddDirective('Z2',{$ifdef FPCPROCVAR}@{$endif}dir_z2);
  865. AddDirective('Z4',{$ifdef FPCPROCVAR}@{$endif}dir_z4);
  866. end;
  867. end.
  868. {
  869. $Log$
  870. Revision 1.23 2002-12-07 14:06:20 carl
  871. * stricter version / revision checking (also remove some warnings)
  872. Revision 1.22 2002/11/20 11:12:46 mazen
  873. + module path is now passed to AddPath to fix relative unit path
  874. Revision 1.21 2002/10/16 19:01:43 peter
  875. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  876. implicit exception frames for procedures with initialized variables
  877. and for constructors. The default is on for compatibility
  878. Revision 1.20 2002/10/14 19:43:41 peter
  879. * threading switch, defines the symbol FPC_THREADING
  880. Revision 1.19 2002/08/13 18:01:52 carl
  881. * rename swatoperands to swapoperands
  882. + m68k first compilable version (still needs a lot of testing):
  883. assembler generator, system information , inline
  884. assembler reader.
  885. Revision 1.18 2002/07/26 21:15:42 florian
  886. * rewrote the system handling
  887. Revision 1.17 2002/07/20 17:16:03 florian
  888. + source code page support
  889. Revision 1.16 2002/07/16 15:37:58 florian
  890. + Directive $EXTERNALSYM added, it is ignored for now
  891. Revision 1.15 2002/05/18 13:34:17 peter
  892. * readded missing revisions
  893. Revision 1.14 2002/05/16 19:46:44 carl
  894. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  895. + try to fix temp allocation (still in ifdef)
  896. + generic constructor calls
  897. + start of tassembler / tmodulebase class cleanup
  898. Revision 1.12 2002/04/07 13:34:20 carl
  899. + wdosx target
  900. Revision 1.11 2002/04/04 19:06:05 peter
  901. * removed unused units
  902. * use tlocation.size in cg.a_*loc*() routines
  903. }