verbose.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Peter Vreman
  4. This unit handles the verbose management
  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 verbose;
  19. {$i fpcdefs.inc}
  20. { Don't include messages in the executable }
  21. {$ifdef Delphi}
  22. {$define EXTERN_MSG}
  23. {$endif}
  24. interface
  25. uses
  26. cutils,
  27. globals,finput,
  28. cmsgs;
  29. {$ifndef EXTERN_MSG}
  30. {$i msgtxt.inc}
  31. {$endif}
  32. {$i msgidx.inc}
  33. Const
  34. { Levels }
  35. V_None = $0;
  36. V_Fatal = $1;
  37. V_Error = $2;
  38. V_Normal = $4; { doesn't show a text like Error: }
  39. V_Warning = $8;
  40. V_Note = $10;
  41. V_Hint = $20;
  42. V_LineInfoMask = $fff;
  43. { From here by default no line info }
  44. V_Info = $1000;
  45. V_Status = $2000;
  46. V_Used = $4000;
  47. V_Tried = $8000;
  48. V_Conditional = $10000;
  49. V_Debug = $20000;
  50. V_Executable = $40000;
  51. V_LevelMask = $fffffff;
  52. V_All = V_LevelMask;
  53. V_Default = V_Fatal + V_Error + V_Normal;
  54. { Flags }
  55. V_LineInfo = $10000000;
  56. var
  57. msg : pmessage;
  58. const
  59. msgfilename : string = '';
  60. procedure SetRedirectFile(const fn:string);
  61. function SetVerbosity(const s:string):boolean;
  62. procedure PrepareReport;
  63. function CheckVerbosity(v:longint):boolean;
  64. procedure SetCompileModule(p:tmodulebase);
  65. procedure Stop;
  66. procedure ShowStatus;
  67. function ErrorCount:longint;
  68. procedure SetErrorFlags(const s:string);
  69. procedure GenerateError;
  70. procedure Internalerror(i:longint);
  71. procedure Comment(l:longint;s:string);
  72. function MessagePchar(w:longint):pchar;
  73. procedure Message(w:longint);
  74. procedure Message1(w:longint;const s1:string);
  75. procedure Message2(w:longint;const s1,s2:string);
  76. procedure Message3(w:longint;const s1,s2,s3:string);
  77. procedure Message4(w:longint;const s1,s2,s3,s4:string);
  78. procedure MessagePos(const pos:tfileposinfo;w:longint);
  79. procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
  80. procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
  81. procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
  82. procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
  83. { message calls with codegenerror support }
  84. procedure cgmessage(t : longint);
  85. procedure cgmessage1(t : longint;const s : string);
  86. procedure cgmessage2(t : longint;const s1,s2 : string);
  87. procedure cgmessage3(t : longint;const s1,s2,s3 : string);
  88. procedure CGMessagePos(const pos:tfileposinfo;t:longint);
  89. procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:string);
  90. procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:string);
  91. procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:string);
  92. procedure InitVerbose;
  93. procedure DoneVerbose;
  94. implementation
  95. uses
  96. comphook;
  97. var
  98. compiling_module : tmodulebase;
  99. {****************************************************************************
  100. Extra Handlers for default compiler
  101. ****************************************************************************}
  102. procedure DoneRedirectFile;
  103. begin
  104. if status.use_redir then
  105. begin
  106. close(status.redirfile);
  107. status.use_redir:=false;
  108. end;
  109. if status.use_bugreport then
  110. begin
  111. close(status.reportbugfile);
  112. status.use_bugreport:=false;
  113. end;
  114. end;
  115. procedure SetRedirectFile(const fn:string);
  116. begin
  117. assign(status.redirfile,fn);
  118. {$I-}
  119. append(status.redirfile);
  120. if ioresult <> 0 then
  121. rewrite(status.redirfile);
  122. {$I+}
  123. status.use_redir:=(ioresult=0);
  124. end;
  125. procedure PrepareReport;
  126. var
  127. fn : string;
  128. begin
  129. if status.use_bugreport then
  130. exit;
  131. fn:='fpcdebug.txt';
  132. assign(status.reportbugfile,fn);
  133. {$I-}
  134. append(status.reportbugfile);
  135. if ioresult <> 0 then
  136. rewrite(status.reportbugfile);
  137. {$I+}
  138. status.use_bugreport:=(ioresult=0);
  139. if status.use_bugreport then
  140. writeln(status.reportbugfile,'FPC bug report file');
  141. end;
  142. function CheckVerbosity(v:longint):boolean;
  143. begin
  144. CheckVerbosity:=status.use_bugreport or
  145. ((status.verbosity and (v and V_LevelMask))=(v and V_LevelMask));
  146. end;
  147. function SetVerbosity(const s:string):boolean;
  148. var
  149. m : Longint;
  150. i : Integer;
  151. inverse : boolean;
  152. c : char;
  153. begin
  154. Setverbosity:=false;
  155. val(s,m,i);
  156. if (i=0) and (s<>'') then
  157. status.verbosity:=m
  158. else
  159. begin
  160. i:=1;
  161. while i<=length(s) do
  162. begin
  163. c:=upcase(s[i]);
  164. inverse:=false;
  165. { on/off ? }
  166. if (i<length(s)) then
  167. case s[i+1] of
  168. '-' : begin
  169. inc(i);
  170. inverse:=true;
  171. end;
  172. '+' : inc(i);
  173. end;
  174. { handle switch }
  175. case c of
  176. { Special cases }
  177. 'A' : status.verbosity:=V_All;
  178. '0' : status.verbosity:=V_Default;
  179. 'P' : begin
  180. if inverse then
  181. paraprintnodetree:=0
  182. else
  183. paraprintnodetree:=1;
  184. end;
  185. 'R' : begin
  186. if inverse then
  187. begin
  188. status.use_gccoutput:=false;
  189. status.use_stderr:=false;
  190. end
  191. else
  192. begin
  193. status.use_gccoutput:=true;
  194. status.use_stderr:=true;
  195. end;
  196. end;
  197. { Normal cases - do an or }
  198. 'E' : if inverse then
  199. status.verbosity:=status.verbosity and (not V_Error)
  200. else
  201. status.verbosity:=status.verbosity or V_Error;
  202. 'I' : if inverse then
  203. status.verbosity:=status.verbosity and (not V_Info)
  204. else
  205. status.verbosity:=status.verbosity or V_Info;
  206. 'W' : if inverse then
  207. status.verbosity:=status.verbosity and (not V_Warning)
  208. else
  209. status.verbosity:=status.verbosity or V_Warning;
  210. 'N' : if inverse then
  211. status.verbosity:=status.verbosity and (not V_Note)
  212. else
  213. status.verbosity:=status.verbosity or V_Note;
  214. 'H' : if inverse then
  215. status.verbosity:=status.verbosity and (not V_Hint)
  216. else
  217. status.verbosity:=status.verbosity or V_Hint;
  218. 'L' : if inverse then
  219. status.verbosity:=status.verbosity and (not V_Status)
  220. else
  221. status.verbosity:=status.verbosity or V_Status;
  222. 'U' : if inverse then
  223. status.verbosity:=status.verbosity and (not V_Used)
  224. else
  225. status.verbosity:=status.verbosity or V_Used;
  226. 'T' : if inverse then
  227. status.verbosity:=status.verbosity and (not V_Tried)
  228. else
  229. status.verbosity:=status.verbosity or V_Tried;
  230. 'C' : if inverse then
  231. status.verbosity:=status.verbosity and (not V_Conditional)
  232. else
  233. status.verbosity:=status.verbosity or V_Conditional;
  234. 'D' : if inverse then
  235. status.verbosity:=status.verbosity and (not V_Debug)
  236. else
  237. status.verbosity:=status.verbosity or V_Debug;
  238. 'X' : if inverse then
  239. status.verbosity:=status.verbosity and (not V_Executable)
  240. else
  241. status.verbosity:=status.verbosity or V_Executable;
  242. end;
  243. inc(i);
  244. end;
  245. end;
  246. if status.verbosity=0 then
  247. status.verbosity:=V_Default;
  248. setverbosity:=true;
  249. end;
  250. procedure Loadprefixes;
  251. function loadprefix(w:longint):string;
  252. var
  253. s : string;
  254. idx : longint;
  255. begin
  256. s:=msg^.get(w);
  257. idx:=pos('_',s);
  258. if idx>0 then
  259. Loadprefix:=Copy(s,idx+1,255)
  260. else
  261. Loadprefix:=s;
  262. end;
  263. begin
  264. { Load the prefixes }
  265. fatalstr:=Loadprefix(general_i_fatal);
  266. errorstr:=Loadprefix(general_i_error);
  267. warningstr:=Loadprefix(general_i_warning);
  268. notestr:=Loadprefix(general_i_note);
  269. hintstr:=Loadprefix(general_i_hint);
  270. end;
  271. procedure LoadMsgFile(const fn:string);
  272. begin
  273. { reload the internal messages if not already loaded }
  274. {$ifndef EXTERN_MSG}
  275. if not msg^.msgintern then
  276. msg^.LoadIntern(@msgtxt,msgtxtsize);
  277. {$endif}
  278. if not msg^.LoadExtern(fn) then
  279. begin
  280. {$ifdef EXTERN_MSG}
  281. writeln('Fatal: Cannot find error message file.');
  282. halt(3);
  283. {$else}
  284. msg^.LoadIntern(@msgtxt,msgtxtsize);
  285. {$endif}
  286. end;
  287. { reload the prefixes using the new messages }
  288. Loadprefixes;
  289. end;
  290. procedure MaybeLoadMessageFile;
  291. begin
  292. { Load new message file }
  293. if (msgfilename<>'') then
  294. begin
  295. LoadMsgFile(msgfilename);
  296. msgfilename:='';
  297. end;
  298. end;
  299. procedure SetCompileModule(p:tmodulebase);
  300. begin
  301. compiling_module:=p;
  302. end;
  303. var
  304. lastfileidx,
  305. lastmoduleidx : longint;
  306. Procedure UpdateStatus;
  307. begin
  308. { fix status }
  309. status.currentline:=aktfilepos.line;
  310. status.currentcolumn:=aktfilepos.column;
  311. if assigned(compiling_module) and
  312. assigned(compiling_module.sourcefiles) and
  313. ((compiling_module.unit_index<>lastmoduleidx) or
  314. (aktfilepos.fileindex<>lastfileidx)) then
  315. begin
  316. { update status record }
  317. status.currentmodule:=compiling_module.modulename^;
  318. status.currentsource:=compiling_module.sourcefiles.get_file_name(aktfilepos.fileindex);
  319. status.currentsourcepath:=compiling_module.sourcefiles.get_file_path(aktfilepos.fileindex);
  320. { update lastfileidx only if name known PM }
  321. if status.currentsource<>'' then
  322. lastfileidx:=aktfilepos.fileindex
  323. else
  324. lastfileidx:=0;
  325. lastmoduleidx:=compiling_module.unit_index;
  326. end;
  327. if assigned(compiling_module) then
  328. status.compiling_current:=(compiling_module.state in [ms_compile,ms_second_compile]);
  329. end;
  330. procedure stop;
  331. begin
  332. do_stop{$ifdef FPCPROCVAR}(){$endif};
  333. end;
  334. procedure ShowStatus;
  335. begin
  336. UpdateStatus;
  337. if do_status{$ifdef FPCPROCVAR}(){$endif} then
  338. stop;
  339. end;
  340. function ErrorCount:longint;
  341. begin
  342. ErrorCount:=status.errorcount;
  343. end;
  344. procedure SetErrorFlags(const s:string);
  345. var
  346. code : integer;
  347. i,j,l : longint;
  348. begin
  349. { empty string means error count = 1 for backward compatibility (PFV) }
  350. if s='' then
  351. begin
  352. status.maxerrorcount:=1;
  353. exit;
  354. end;
  355. i:=0;
  356. while (i<length(s)) do
  357. begin
  358. inc(i);
  359. case s[i] of
  360. '0'..'9' :
  361. begin
  362. j:=i;
  363. while (j<=length(s)) and (s[j] in ['0'..'9']) do
  364. inc(j);
  365. val(copy(s,i,j-i),l,code);
  366. if code<>0 then
  367. l:=1;
  368. status.maxerrorcount:=l;
  369. i:=j;
  370. end;
  371. 'w','W' :
  372. status.errorwarning:=true;
  373. 'n','N' :
  374. status.errornote:=true;
  375. 'h','H' :
  376. status.errorhint:=true;
  377. end;
  378. end;
  379. end;
  380. procedure GenerateError;
  381. begin
  382. inc(status.errorcount);
  383. end;
  384. procedure internalerror(i : longint);
  385. begin
  386. UpdateStatus;
  387. do_internalerror(i);
  388. inc(status.errorcount);
  389. stop;
  390. end;
  391. procedure Comment(l:longint;s:string);
  392. var
  393. dostop : boolean;
  394. begin
  395. dostop:=((l and V_Fatal)<>0);
  396. if ((l and V_Error)<>0) or
  397. (status.errorwarning and ((l and V_Warning)<>0)) or
  398. (status.errornote and ((l and V_Note)<>0)) or
  399. (status.errorhint and ((l and V_Hint)<>0)) then
  400. inc(status.errorcount);
  401. { check verbosity level }
  402. if not CheckVerbosity(l) then
  403. exit;
  404. if (l and V_LineInfoMask)<>0 then
  405. l:=l or V_LineInfo;
  406. { Create status info }
  407. UpdateStatus;
  408. { Fix replacements }
  409. DefaultReplacements(s);
  410. { show comment }
  411. if do_comment(l,s) or dostop then
  412. stop;
  413. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  414. begin
  415. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  416. status.skip_error:=true;
  417. stop;
  418. end;
  419. end;
  420. Procedure Msg2Comment(s:string);
  421. var
  422. idx,i,v : longint;
  423. dostop : boolean;
  424. begin
  425. {Reset}
  426. dostop:=false;
  427. v:=0;
  428. {Parse options}
  429. idx:=pos('_',s);
  430. if idx=0 then
  431. v:=V_Normal
  432. else
  433. if (idx >= 1) And (idx <= 5) then
  434. begin
  435. for i:=1 to idx do
  436. begin
  437. case upcase(s[i]) of
  438. 'F' :
  439. begin
  440. v:=v or V_Fatal;
  441. inc(status.errorcount);
  442. dostop:=true;
  443. end;
  444. 'E' :
  445. begin
  446. v:=v or V_Error;
  447. inc(status.errorcount);
  448. end;
  449. 'O' :
  450. v:=v or V_Normal;
  451. 'W':
  452. begin
  453. v:=v or V_Warning;
  454. if status.errorwarning then
  455. inc(status.errorcount);
  456. end;
  457. 'N' :
  458. begin
  459. v:=v or V_Note;
  460. if status.errornote then
  461. inc(status.errorcount);
  462. end;
  463. 'H' :
  464. begin
  465. v:=v or V_Hint;
  466. if status.errorhint then
  467. inc(status.errorcount);
  468. end;
  469. 'I' :
  470. v:=v or V_Info;
  471. 'L' :
  472. v:=v or V_LineInfo;
  473. 'U' :
  474. v:=v or V_Used;
  475. 'T' :
  476. v:=v or V_Tried;
  477. 'C' :
  478. v:=v or V_Conditional;
  479. 'D' :
  480. v:=v or V_Debug;
  481. 'X' :
  482. v:=v or V_Executable;
  483. 'S' :
  484. dostop:=true;
  485. '_' : ;
  486. end;
  487. end;
  488. end;
  489. Delete(s,1,idx);
  490. { check verbosity level }
  491. if not CheckVerbosity(v) then
  492. exit;
  493. if (v and V_LineInfoMask)<>0 then
  494. v:=v or V_LineInfo;
  495. { fix status }
  496. UpdateStatus;
  497. { Fix replacements }
  498. DefaultReplacements(s);
  499. { show comment }
  500. if do_comment(v,s) or dostop then
  501. stop;
  502. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  503. begin
  504. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  505. status.skip_error:=true;
  506. stop;
  507. end;
  508. end;
  509. function MessagePchar(w:longint):pchar;
  510. begin
  511. MaybeLoadMessageFile;
  512. MessagePchar:=msg^.GetPchar(w)
  513. end;
  514. procedure Message(w:longint);
  515. begin
  516. MaybeLoadMessageFile;
  517. Msg2Comment(msg^.Get(w));
  518. end;
  519. procedure Message1(w:longint;const s1:string);
  520. begin
  521. MaybeLoadMessageFile;
  522. Msg2Comment(msg^.Get1(w,s1));
  523. end;
  524. procedure Message2(w:longint;const s1,s2:string);
  525. begin
  526. MaybeLoadMessageFile;
  527. Msg2Comment(msg^.Get2(w,s1,s2));
  528. end;
  529. procedure Message3(w:longint;const s1,s2,s3:string);
  530. begin
  531. MaybeLoadMessageFile;
  532. Msg2Comment(msg^.Get3(w,s1,s2,s3));
  533. end;
  534. procedure Message4(w:longint;const s1,s2,s3,s4:string);
  535. begin
  536. MaybeLoadMessageFile;
  537. Msg2Comment(msg^.Get4(w,s1,s2,s3,s4));
  538. end;
  539. procedure MessagePos(const pos:tfileposinfo;w:longint);
  540. var
  541. oldpos : tfileposinfo;
  542. begin
  543. oldpos:=aktfilepos;
  544. aktfilepos:=pos;
  545. MaybeLoadMessageFile;
  546. Msg2Comment(msg^.Get(w));
  547. aktfilepos:=oldpos;
  548. end;
  549. procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
  550. var
  551. oldpos : tfileposinfo;
  552. begin
  553. oldpos:=aktfilepos;
  554. aktfilepos:=pos;
  555. MaybeLoadMessageFile;
  556. Msg2Comment(msg^.Get1(w,s1));
  557. aktfilepos:=oldpos;
  558. end;
  559. procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
  560. var
  561. oldpos : tfileposinfo;
  562. begin
  563. oldpos:=aktfilepos;
  564. aktfilepos:=pos;
  565. MaybeLoadMessageFile;
  566. Msg2Comment(msg^.Get2(w,s1,s2));
  567. aktfilepos:=oldpos;
  568. end;
  569. procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
  570. var
  571. oldpos : tfileposinfo;
  572. begin
  573. oldpos:=aktfilepos;
  574. aktfilepos:=pos;
  575. MaybeLoadMessageFile;
  576. Msg2Comment(msg^.Get3(w,s1,s2,s3));
  577. aktfilepos:=oldpos;
  578. end;
  579. procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
  580. var
  581. oldpos : tfileposinfo;
  582. begin
  583. oldpos:=aktfilepos;
  584. aktfilepos:=pos;
  585. MaybeLoadMessageFile;
  586. Msg2Comment(msg^.Get4(w,s1,s2,s3,s4));
  587. aktfilepos:=oldpos;
  588. end;
  589. {*****************************************************************************
  590. override the message calls to set codegenerror
  591. *****************************************************************************}
  592. procedure cgmessage(t : longint);
  593. var
  594. olderrorcount : longint;
  595. begin
  596. if not(codegenerror) then
  597. begin
  598. olderrorcount:=Errorcount;
  599. verbose.Message(t);
  600. codegenerror:=olderrorcount<>Errorcount;
  601. end;
  602. end;
  603. procedure cgmessage1(t : longint;const s : string);
  604. var
  605. olderrorcount : longint;
  606. begin
  607. if not(codegenerror) then
  608. begin
  609. olderrorcount:=Errorcount;
  610. verbose.Message1(t,s);
  611. codegenerror:=olderrorcount<>Errorcount;
  612. end;
  613. end;
  614. procedure cgmessage2(t : longint;const s1,s2 : string);
  615. var
  616. olderrorcount : longint;
  617. begin
  618. if not(codegenerror) then
  619. begin
  620. olderrorcount:=Errorcount;
  621. verbose.Message2(t,s1,s2);
  622. codegenerror:=olderrorcount<>Errorcount;
  623. end;
  624. end;
  625. procedure cgmessage3(t : longint;const s1,s2,s3 : string);
  626. var
  627. olderrorcount : longint;
  628. begin
  629. if not(codegenerror) then
  630. begin
  631. olderrorcount:=Errorcount;
  632. verbose.Message3(t,s1,s2,s3);
  633. codegenerror:=olderrorcount<>Errorcount;
  634. end;
  635. end;
  636. procedure cgmessagepos(const pos:tfileposinfo;t : longint);
  637. var
  638. olderrorcount : longint;
  639. begin
  640. if not(codegenerror) then
  641. begin
  642. olderrorcount:=Errorcount;
  643. verbose.MessagePos(pos,t);
  644. codegenerror:=olderrorcount<>Errorcount;
  645. end;
  646. end;
  647. procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : string);
  648. var
  649. olderrorcount : longint;
  650. begin
  651. if not(codegenerror) then
  652. begin
  653. olderrorcount:=Errorcount;
  654. verbose.MessagePos1(pos,t,s1);
  655. codegenerror:=olderrorcount<>Errorcount;
  656. end;
  657. end;
  658. procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : string);
  659. var
  660. olderrorcount : longint;
  661. begin
  662. if not(codegenerror) then
  663. begin
  664. olderrorcount:=Errorcount;
  665. verbose.MessagePos2(pos,t,s1,s2);
  666. codegenerror:=olderrorcount<>Errorcount;
  667. end;
  668. end;
  669. procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : string);
  670. var
  671. olderrorcount : longint;
  672. begin
  673. if not(codegenerror) then
  674. begin
  675. olderrorcount:=Errorcount;
  676. verbose.MessagePos3(pos,t,s1,s2,s3);
  677. codegenerror:=olderrorcount<>Errorcount;
  678. end;
  679. end;
  680. {*****************************************************************************
  681. Initialization
  682. *****************************************************************************}
  683. procedure InitVerbose;
  684. begin
  685. { Init }
  686. msg:=new(pmessage,Init(20,msgidxmax));
  687. if msg=nil then
  688. begin
  689. writeln('Fatal: MsgIdx Wrong');
  690. halt(3);
  691. end;
  692. {$ifndef EXTERN_MSG}
  693. msg^.LoadIntern(@msgtxt,msgtxtsize);
  694. {$else EXTERN_MSG}
  695. LoadMsgFile(exepath+'errore.msg');
  696. {$endif EXTERN_MSG}
  697. FillChar(Status,sizeof(TCompilerStatus),0);
  698. status.verbosity:=V_Default;
  699. Status.MaxErrorCount:=50;
  700. Loadprefixes;
  701. lastfileidx:=-1;
  702. lastmoduleidx:=-1;
  703. status.currentmodule:='';
  704. status.currentsource:='';
  705. status.currentsourcepath:='';
  706. status.compiling_current:=false;
  707. end;
  708. procedure DoneVerbose;
  709. begin
  710. if assigned(msg) then
  711. begin
  712. dispose(msg,Done);
  713. msg:=nil;
  714. end;
  715. DoneRedirectFile;
  716. end;
  717. initialization
  718. finalization
  719. { Be sure to close the redirect files to flush all data }
  720. DoneRedirectFile;
  721. end.
  722. {
  723. $Log$
  724. Revision 1.27 2003-10-01 20:34:49 peter
  725. * procinfo unit contains tprocinfo
  726. * cginfo renamed to cgbase
  727. * moved cgmessage to verbose
  728. * fixed ppc and sparc compiles
  729. Revision 1.26 2003/04/25 20:59:35 peter
  730. * removed funcretn,funcretsym, function result is now in varsym
  731. and aliases for result and function name are added using absolutesym
  732. * vs_hidden parameter for funcret passed in parameter
  733. * vs_hidden fixes
  734. * writenode changed to printnode and released from extdebug
  735. * -vp option added to generate a tree.log with the nodetree
  736. * nicer printnode for statements, callnode
  737. Revision 1.25 2003/04/22 14:33:38 peter
  738. * removed some notes/hints
  739. Revision 1.24 2003/01/09 21:52:38 peter
  740. * merged some verbosity options.
  741. * V_LineInfo is a verbosity flag to include line info
  742. Revision 1.23 2002/12/29 14:57:50 peter
  743. * unit loading changed to first register units and load them
  744. afterwards. This is needed to support uses xxx in yyy correctly
  745. * unit dependency check fixed
  746. Revision 1.22 2002/11/15 01:58:54 peter
  747. * merged changes from 1.0.7 up to 04-11
  748. - -V option for generating bug report tracing
  749. - more tracing for option parsing
  750. - errors for cdecl and high()
  751. - win32 import stabs
  752. - win32 records<=8 are returned in eax:edx (turned off by default)
  753. - heaptrc update
  754. - more info for temp management in .s file with EXTDEBUG
  755. Revision 1.21 2002/10/05 12:43:29 carl
  756. * fixes for Delphi 6 compilation
  757. (warning : Some features do not work under Delphi)
  758. Revision 1.20 2002/08/18 19:59:03 peter
  759. * renamed local current_module to compiling_module because it
  760. confused a lot in gdb
  761. Revision 1.19 2002/05/18 13:34:21 peter
  762. * readded missing revisions
  763. Revision 1.18 2002/05/16 19:46:47 carl
  764. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  765. + try to fix temp allocation (still in ifdef)
  766. + generic constructor calls
  767. + start of tassembler / tmodulebase class cleanup
  768. }