verbose.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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. 'v' : PrepareReport;
  243. end;
  244. inc(i);
  245. end;
  246. end;
  247. if status.verbosity=0 then
  248. status.verbosity:=V_Default;
  249. setverbosity:=true;
  250. end;
  251. procedure Loadprefixes;
  252. function loadprefix(w:longint):string;
  253. var
  254. s : string;
  255. idx : longint;
  256. begin
  257. s:=msg^.get(w);
  258. idx:=pos('_',s);
  259. if idx>0 then
  260. Loadprefix:=Copy(s,idx+1,255)
  261. else
  262. Loadprefix:=s;
  263. end;
  264. begin
  265. { Load the prefixes }
  266. fatalstr:=Loadprefix(general_i_fatal);
  267. errorstr:=Loadprefix(general_i_error);
  268. warningstr:=Loadprefix(general_i_warning);
  269. notestr:=Loadprefix(general_i_note);
  270. hintstr:=Loadprefix(general_i_hint);
  271. end;
  272. procedure LoadMsgFile(const fn:string);
  273. begin
  274. { reload the internal messages if not already loaded }
  275. {$ifndef EXTERN_MSG}
  276. if not msg^.msgintern then
  277. msg^.LoadIntern(@msgtxt,msgtxtsize);
  278. {$endif}
  279. if not msg^.LoadExtern(fn) then
  280. begin
  281. {$ifdef EXTERN_MSG}
  282. writeln('Fatal: Cannot find error message file.');
  283. halt(3);
  284. {$else}
  285. msg^.LoadIntern(@msgtxt,msgtxtsize);
  286. {$endif}
  287. end;
  288. { reload the prefixes using the new messages }
  289. Loadprefixes;
  290. end;
  291. procedure MaybeLoadMessageFile;
  292. begin
  293. { Load new message file }
  294. if (msgfilename<>'') then
  295. begin
  296. LoadMsgFile(msgfilename);
  297. msgfilename:='';
  298. end;
  299. end;
  300. procedure SetCompileModule(p:tmodulebase);
  301. begin
  302. compiling_module:=p;
  303. end;
  304. var
  305. lastfileidx,
  306. lastmoduleidx : longint;
  307. Procedure UpdateStatus;
  308. begin
  309. { fix status }
  310. status.currentline:=aktfilepos.line;
  311. status.currentcolumn:=aktfilepos.column;
  312. if assigned(compiling_module) and
  313. assigned(compiling_module.sourcefiles) and
  314. ((compiling_module.unit_index<>lastmoduleidx) or
  315. (aktfilepos.fileindex<>lastfileidx)) then
  316. begin
  317. { update status record }
  318. status.currentmodule:=compiling_module.modulename^;
  319. status.currentsource:=compiling_module.sourcefiles.get_file_name(aktfilepos.fileindex);
  320. status.currentsourcepath:=compiling_module.sourcefiles.get_file_path(aktfilepos.fileindex);
  321. { update lastfileidx only if name known PM }
  322. if status.currentsource<>'' then
  323. lastfileidx:=aktfilepos.fileindex
  324. else
  325. lastfileidx:=0;
  326. lastmoduleidx:=compiling_module.unit_index;
  327. end;
  328. if assigned(compiling_module) then
  329. status.compiling_current:=(compiling_module.state in [ms_compile,ms_second_compile]);
  330. end;
  331. procedure stop;
  332. begin
  333. do_stop{$ifdef FPCPROCVAR}(){$endif};
  334. end;
  335. procedure ShowStatus;
  336. begin
  337. UpdateStatus;
  338. if do_status{$ifdef FPCPROCVAR}(){$endif} then
  339. stop;
  340. end;
  341. function ErrorCount:longint;
  342. begin
  343. ErrorCount:=status.errorcount;
  344. end;
  345. procedure SetErrorFlags(const s:string);
  346. var
  347. code : integer;
  348. i,j,l : longint;
  349. begin
  350. { empty string means error count = 1 for backward compatibility (PFV) }
  351. if s='' then
  352. begin
  353. status.maxerrorcount:=1;
  354. exit;
  355. end;
  356. i:=0;
  357. while (i<length(s)) do
  358. begin
  359. inc(i);
  360. case s[i] of
  361. '0'..'9' :
  362. begin
  363. j:=i;
  364. while (j<=length(s)) and (s[j] in ['0'..'9']) do
  365. inc(j);
  366. val(copy(s,i,j-i),l,code);
  367. if code<>0 then
  368. l:=1;
  369. status.maxerrorcount:=l;
  370. i:=j;
  371. end;
  372. 'w','W' :
  373. status.errorwarning:=true;
  374. 'n','N' :
  375. status.errornote:=true;
  376. 'h','H' :
  377. status.errorhint:=true;
  378. end;
  379. end;
  380. end;
  381. procedure GenerateError;
  382. begin
  383. inc(status.errorcount);
  384. end;
  385. procedure internalerror(i : longint);
  386. begin
  387. UpdateStatus;
  388. do_internalerror(i);
  389. inc(status.errorcount);
  390. stop;
  391. end;
  392. procedure Comment(l:longint;s:string);
  393. var
  394. dostop : boolean;
  395. begin
  396. dostop:=((l and V_Fatal)<>0);
  397. if ((l and V_Error)<>0) or
  398. (status.errorwarning and ((l and V_Warning)<>0)) or
  399. (status.errornote and ((l and V_Note)<>0)) or
  400. (status.errorhint and ((l and V_Hint)<>0)) then
  401. inc(status.errorcount);
  402. { check verbosity level }
  403. if not CheckVerbosity(l) then
  404. exit;
  405. if (l and V_LineInfoMask)<>0 then
  406. l:=l or V_LineInfo;
  407. { Create status info }
  408. UpdateStatus;
  409. { Fix replacements }
  410. DefaultReplacements(s);
  411. { show comment }
  412. if do_comment(l,s) or dostop then
  413. stop;
  414. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  415. begin
  416. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  417. status.skip_error:=true;
  418. stop;
  419. end;
  420. end;
  421. Procedure Msg2Comment(s:string);
  422. var
  423. idx,i,v : longint;
  424. dostop : boolean;
  425. begin
  426. {Reset}
  427. dostop:=false;
  428. v:=0;
  429. {Parse options}
  430. idx:=pos('_',s);
  431. if idx=0 then
  432. v:=V_Normal
  433. else
  434. if (idx >= 1) And (idx <= 5) then
  435. begin
  436. for i:=1 to idx do
  437. begin
  438. case upcase(s[i]) of
  439. 'F' :
  440. begin
  441. v:=v or V_Fatal;
  442. inc(status.errorcount);
  443. dostop:=true;
  444. end;
  445. 'E' :
  446. begin
  447. v:=v or V_Error;
  448. inc(status.errorcount);
  449. end;
  450. 'O' :
  451. v:=v or V_Normal;
  452. 'W':
  453. begin
  454. v:=v or V_Warning;
  455. if status.errorwarning then
  456. inc(status.errorcount);
  457. end;
  458. 'N' :
  459. begin
  460. v:=v or V_Note;
  461. if status.errornote then
  462. inc(status.errorcount);
  463. end;
  464. 'H' :
  465. begin
  466. v:=v or V_Hint;
  467. if status.errorhint then
  468. inc(status.errorcount);
  469. end;
  470. 'I' :
  471. v:=v or V_Info;
  472. 'L' :
  473. v:=v or V_LineInfo;
  474. 'U' :
  475. v:=v or V_Used;
  476. 'T' :
  477. v:=v or V_Tried;
  478. 'C' :
  479. v:=v or V_Conditional;
  480. 'D' :
  481. v:=v or V_Debug;
  482. 'X' :
  483. v:=v or V_Executable;
  484. 'S' :
  485. dostop:=true;
  486. '_' : ;
  487. end;
  488. end;
  489. end;
  490. Delete(s,1,idx);
  491. { check verbosity level }
  492. if not CheckVerbosity(v) then
  493. exit;
  494. if (v and V_LineInfoMask)<>0 then
  495. v:=v or V_LineInfo;
  496. { fix status }
  497. UpdateStatus;
  498. { Fix replacements }
  499. DefaultReplacements(s);
  500. { show comment }
  501. if do_comment(v,s) or dostop then
  502. stop;
  503. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  504. begin
  505. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  506. status.skip_error:=true;
  507. stop;
  508. end;
  509. end;
  510. function MessagePchar(w:longint):pchar;
  511. begin
  512. MaybeLoadMessageFile;
  513. MessagePchar:=msg^.GetPchar(w)
  514. end;
  515. procedure Message(w:longint);
  516. begin
  517. MaybeLoadMessageFile;
  518. Msg2Comment(msg^.Get(w));
  519. end;
  520. procedure Message1(w:longint;const s1:string);
  521. begin
  522. MaybeLoadMessageFile;
  523. Msg2Comment(msg^.Get1(w,s1));
  524. end;
  525. procedure Message2(w:longint;const s1,s2:string);
  526. begin
  527. MaybeLoadMessageFile;
  528. Msg2Comment(msg^.Get2(w,s1,s2));
  529. end;
  530. procedure Message3(w:longint;const s1,s2,s3:string);
  531. begin
  532. MaybeLoadMessageFile;
  533. Msg2Comment(msg^.Get3(w,s1,s2,s3));
  534. end;
  535. procedure Message4(w:longint;const s1,s2,s3,s4:string);
  536. begin
  537. MaybeLoadMessageFile;
  538. Msg2Comment(msg^.Get4(w,s1,s2,s3,s4));
  539. end;
  540. procedure MessagePos(const pos:tfileposinfo;w:longint);
  541. var
  542. oldpos : tfileposinfo;
  543. begin
  544. oldpos:=aktfilepos;
  545. aktfilepos:=pos;
  546. MaybeLoadMessageFile;
  547. Msg2Comment(msg^.Get(w));
  548. aktfilepos:=oldpos;
  549. end;
  550. procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
  551. var
  552. oldpos : tfileposinfo;
  553. begin
  554. oldpos:=aktfilepos;
  555. aktfilepos:=pos;
  556. MaybeLoadMessageFile;
  557. Msg2Comment(msg^.Get1(w,s1));
  558. aktfilepos:=oldpos;
  559. end;
  560. procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
  561. var
  562. oldpos : tfileposinfo;
  563. begin
  564. oldpos:=aktfilepos;
  565. aktfilepos:=pos;
  566. MaybeLoadMessageFile;
  567. Msg2Comment(msg^.Get2(w,s1,s2));
  568. aktfilepos:=oldpos;
  569. end;
  570. procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
  571. var
  572. oldpos : tfileposinfo;
  573. begin
  574. oldpos:=aktfilepos;
  575. aktfilepos:=pos;
  576. MaybeLoadMessageFile;
  577. Msg2Comment(msg^.Get3(w,s1,s2,s3));
  578. aktfilepos:=oldpos;
  579. end;
  580. procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
  581. var
  582. oldpos : tfileposinfo;
  583. begin
  584. oldpos:=aktfilepos;
  585. aktfilepos:=pos;
  586. MaybeLoadMessageFile;
  587. Msg2Comment(msg^.Get4(w,s1,s2,s3,s4));
  588. aktfilepos:=oldpos;
  589. end;
  590. {*****************************************************************************
  591. override the message calls to set codegenerror
  592. *****************************************************************************}
  593. procedure cgmessage(t : longint);
  594. var
  595. olderrorcount : longint;
  596. begin
  597. if not(codegenerror) then
  598. begin
  599. olderrorcount:=Errorcount;
  600. verbose.Message(t);
  601. codegenerror:=olderrorcount<>Errorcount;
  602. end;
  603. end;
  604. procedure cgmessage1(t : longint;const s : string);
  605. var
  606. olderrorcount : longint;
  607. begin
  608. if not(codegenerror) then
  609. begin
  610. olderrorcount:=Errorcount;
  611. verbose.Message1(t,s);
  612. codegenerror:=olderrorcount<>Errorcount;
  613. end;
  614. end;
  615. procedure cgmessage2(t : longint;const s1,s2 : string);
  616. var
  617. olderrorcount : longint;
  618. begin
  619. if not(codegenerror) then
  620. begin
  621. olderrorcount:=Errorcount;
  622. verbose.Message2(t,s1,s2);
  623. codegenerror:=olderrorcount<>Errorcount;
  624. end;
  625. end;
  626. procedure cgmessage3(t : longint;const s1,s2,s3 : string);
  627. var
  628. olderrorcount : longint;
  629. begin
  630. if not(codegenerror) then
  631. begin
  632. olderrorcount:=Errorcount;
  633. verbose.Message3(t,s1,s2,s3);
  634. codegenerror:=olderrorcount<>Errorcount;
  635. end;
  636. end;
  637. procedure cgmessagepos(const pos:tfileposinfo;t : longint);
  638. var
  639. olderrorcount : longint;
  640. begin
  641. if not(codegenerror) then
  642. begin
  643. olderrorcount:=Errorcount;
  644. verbose.MessagePos(pos,t);
  645. codegenerror:=olderrorcount<>Errorcount;
  646. end;
  647. end;
  648. procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : string);
  649. var
  650. olderrorcount : longint;
  651. begin
  652. if not(codegenerror) then
  653. begin
  654. olderrorcount:=Errorcount;
  655. verbose.MessagePos1(pos,t,s1);
  656. codegenerror:=olderrorcount<>Errorcount;
  657. end;
  658. end;
  659. procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : string);
  660. var
  661. olderrorcount : longint;
  662. begin
  663. if not(codegenerror) then
  664. begin
  665. olderrorcount:=Errorcount;
  666. verbose.MessagePos2(pos,t,s1,s2);
  667. codegenerror:=olderrorcount<>Errorcount;
  668. end;
  669. end;
  670. procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : string);
  671. var
  672. olderrorcount : longint;
  673. begin
  674. if not(codegenerror) then
  675. begin
  676. olderrorcount:=Errorcount;
  677. verbose.MessagePos3(pos,t,s1,s2,s3);
  678. codegenerror:=olderrorcount<>Errorcount;
  679. end;
  680. end;
  681. {*****************************************************************************
  682. Initialization
  683. *****************************************************************************}
  684. procedure InitVerbose;
  685. begin
  686. { Init }
  687. msg:=new(pmessage,Init(20,msgidxmax));
  688. if msg=nil then
  689. begin
  690. writeln('Fatal: MsgIdx Wrong');
  691. halt(3);
  692. end;
  693. {$ifndef EXTERN_MSG}
  694. msg^.LoadIntern(@msgtxt,msgtxtsize);
  695. {$else EXTERN_MSG}
  696. LoadMsgFile(exepath+'errore.msg');
  697. {$endif EXTERN_MSG}
  698. FillChar(Status,sizeof(TCompilerStatus),0);
  699. status.verbosity:=V_Default;
  700. Status.MaxErrorCount:=50;
  701. Loadprefixes;
  702. lastfileidx:=-1;
  703. lastmoduleidx:=-1;
  704. status.currentmodule:='';
  705. status.currentsource:='';
  706. status.currentsourcepath:='';
  707. status.compiling_current:=false;
  708. end;
  709. procedure DoneVerbose;
  710. begin
  711. if assigned(msg) then
  712. begin
  713. dispose(msg,Done);
  714. msg:=nil;
  715. end;
  716. DoneRedirectFile;
  717. end;
  718. initialization
  719. finalization
  720. { Be sure to close the redirect files to flush all data }
  721. DoneRedirectFile;
  722. end.
  723. {
  724. $Log$
  725. Revision 1.28 2003-10-08 19:17:43 peter
  726. * -P to -ap
  727. * -V to -vv
  728. Revision 1.27 2003/10/01 20:34:49 peter
  729. * procinfo unit contains tprocinfo
  730. * cginfo renamed to cgbase
  731. * moved cgmessage to verbose
  732. * fixed ppc and sparc compiles
  733. Revision 1.26 2003/04/25 20:59:35 peter
  734. * removed funcretn,funcretsym, function result is now in varsym
  735. and aliases for result and function name are added using absolutesym
  736. * vs_hidden parameter for funcret passed in parameter
  737. * vs_hidden fixes
  738. * writenode changed to printnode and released from extdebug
  739. * -vp option added to generate a tree.log with the nodetree
  740. * nicer printnode for statements, callnode
  741. Revision 1.25 2003/04/22 14:33:38 peter
  742. * removed some notes/hints
  743. Revision 1.24 2003/01/09 21:52:38 peter
  744. * merged some verbosity options.
  745. * V_LineInfo is a verbosity flag to include line info
  746. Revision 1.23 2002/12/29 14:57:50 peter
  747. * unit loading changed to first register units and load them
  748. afterwards. This is needed to support uses xxx in yyy correctly
  749. * unit dependency check fixed
  750. Revision 1.22 2002/11/15 01:58:54 peter
  751. * merged changes from 1.0.7 up to 04-11
  752. - -V option for generating bug report tracing
  753. - more tracing for option parsing
  754. - errors for cdecl and high()
  755. - win32 import stabs
  756. - win32 records<=8 are returned in eax:edx (turned off by default)
  757. - heaptrc update
  758. - more info for temp management in .s file with EXTDEBUG
  759. Revision 1.21 2002/10/05 12:43:29 carl
  760. * fixes for Delphi 6 compilation
  761. (warning : Some features do not work under Delphi)
  762. Revision 1.20 2002/08/18 19:59:03 peter
  763. * renamed local current_module to compiling_module because it
  764. confused a lot in gdb
  765. Revision 1.19 2002/05/18 13:34:21 peter
  766. * readded missing revisions
  767. Revision 1.18 2002/05/16 19:46:47 carl
  768. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  769. + try to fix temp allocation (still in ifdef)
  770. + generic constructor calls
  771. + start of tassembler / tmodulebase class cleanup
  772. }