fpcompil.pas 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Compiler call routines for the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$i globdir.inc}
  13. unit FPCompil;
  14. interface
  15. { don't redir under linux, because all stdout (also from the ide!) will
  16. then be redired (PFV) }
  17. { this should work now correctly because
  18. RedirDisableAll and RedirEnableAll function are added in fpredir (PM) }
  19. { $define VERBOSETXT}
  20. {$mode objfpc}
  21. uses
  22. Objects,
  23. FInput,
  24. Drivers,Views,Dialogs,
  25. WUtils,WViews,WCEdit,
  26. FPSymbol,
  27. FPViews;
  28. type
  29. TCompileMode = (cBuild,cMake,cCompile,cRun);
  30. type
  31. PCompilerMessage = ^TCompilerMessage;
  32. TCompilerMessage = object(TMessageItem)
  33. function GetText(MaxLen: Sw_Integer): String; virtual;
  34. end;
  35. PCompilerMessageListBox = ^TCompilerMessageListBox;
  36. TCompilerMessageListBox = object(TMessageListBox)
  37. function GetPalette: PPalette; virtual;
  38. procedure SelectFirstError;
  39. end;
  40. PCompilerMessageWindow = ^TCompilerMessageWindow;
  41. TCompilerMessageWindow = object(TFPWindow)
  42. constructor Init;
  43. procedure HandleEvent(var Event: TEvent); virtual;
  44. function GetPalette: PPalette; virtual;
  45. procedure Close;virtual;
  46. destructor Done; virtual;
  47. procedure SizeLimits(var Min, Max: TPoint); virtual;
  48. procedure AddMessage(AClass: longint;const Msg, Module: string; Line, Column: longint);
  49. procedure ClearMessages;
  50. constructor Load(var S: TStream);
  51. procedure Store(var S: TStream);
  52. procedure SetState(AState: Word; Enable: Boolean); virtual;
  53. procedure UpdateCommands; virtual;
  54. private
  55. {CompileShowed : boolean;}
  56. {Mode : TCompileMode;}
  57. MsgLB : PCompilerMessageListBox;
  58. {CurrST,
  59. InfoST : PColorStaticText;}
  60. end;
  61. PCompilerStatusDialog = ^TCompilerStatusDialog;
  62. TCompilerStatusDialog = object(TCenterDialog)
  63. ST : PAdvancedStaticText;
  64. KeyST : PColorStaticText;
  65. constructor Init;
  66. destructor Done;virtual;
  67. procedure Update;
  68. end;
  69. TFPInputFile = class(tinputfile)
  70. constructor Create(AEditor: PFileEditor);
  71. protected
  72. function fileopen(const filename: string): boolean; override;
  73. function fileseek(pos: longint): boolean; override;
  74. function fileread(var databuf; maxsize: longint): longint; override;
  75. function fileeof: boolean; override;
  76. function fileclose: boolean; override;
  77. private
  78. Editor: PFileEditor;
  79. S: PStream;
  80. end;
  81. const
  82. CompilerMessageWindow : PCompilerMessageWindow = nil;
  83. CompilerStatusDialog : PCompilerStatusDialog = nil;
  84. CompileStamp : longint = 0;
  85. RestartingDebugger : boolean = false;
  86. procedure DoCompile(Mode: TCompileMode);
  87. function NeedRecompile(Mode :TCompileMode; verbose : boolean): boolean;
  88. procedure ParseUserScreen;
  89. procedure RegisterFPCompile;
  90. const
  91. CompilingHiddenFile : PSourceWindow = nil;
  92. implementation
  93. uses
  94. {$ifdef Unix}
  95. {$ifdef VER1_0}
  96. Linux,
  97. {$else}
  98. Unix, BaseUnix,
  99. {$endif}
  100. {$endif}
  101. {$ifdef go32v2}
  102. dpmiexcp,
  103. {$endif}
  104. {$ifdef win32}
  105. signals,
  106. {$endif}
  107. {$ifdef HasSignal}
  108. fpcatch,
  109. {$endif HasSignal}
  110. Dos,
  111. {$ifdef fpc}
  112. Video,
  113. {$endif fpc}
  114. StdDlg,App,tokens,
  115. FVConsts,
  116. CompHook, Compiler, systems, browcol,
  117. WEditor,
  118. FPString,FPRedir,FPDesk,
  119. FPUsrScr,FPHelp,
  120. {$ifndef NODEBUG}FPDebug,{$endif}
  121. FPConst,FPVars,FPUtils,
  122. FPCodCmp,FPIntf,FPSwitch;
  123. {$ifndef NOOBJREG}
  124. const
  125. RCompilerMessageListBox: TStreamRec = (
  126. ObjType: 1211;
  127. VmtLink: Ofs(TypeOf(TCompilerMessageListBox)^);
  128. Load: @TCompilerMessageListBox.Load;
  129. Store: @TCompilerMessageListBox.Store
  130. );
  131. RCompilerMessageWindow: TStreamRec = (
  132. ObjType: 1212;
  133. VmtLink: Ofs(TypeOf(TCompilerMessageWindow)^);
  134. Load: @TCompilerMessageWindow.Load;
  135. Store: @TCompilerMessageWindow.Store
  136. );
  137. {$endif}
  138. procedure ParseUserScreen;
  139. var
  140. y : longint;
  141. Text,Attr : String;
  142. DisplayCompilerWindow : boolean;
  143. cc: integer;
  144. procedure SearchBackTrace;
  145. var AText,ModuleName,st : String;
  146. row : longint;
  147. begin
  148. if pos(' 0x',Text)=1 then
  149. begin
  150. AText:=Text;
  151. Delete(Text,1,10);
  152. While pos(' ',Text)=1 do
  153. Delete(Text,1,1);
  154. if pos('of ',Text)>0 then
  155. begin
  156. ModuleName:=Copy(Text,pos('of ',Text)+3,255);
  157. While ModuleName[Length(ModuleName)]=' ' do
  158. Delete(ModuleName,Length(ModuleName),1);
  159. end
  160. else
  161. ModuleName:='';
  162. if pos('line ',Text)>0 then
  163. begin
  164. Text:=Copy(Text,Pos('line ',Text)+5,255);
  165. st:=Copy(Text,1,Pos(' ',Text)-1);
  166. Val(st,row,cc);
  167. end
  168. else
  169. row:=0;
  170. CompilerMessageWindow^.AddMessage(V_Fatal,AText
  171. ,ModuleName,row,1);
  172. DisplayCompilerWindow:=true;
  173. end;
  174. end;
  175. procedure InsertInMessages(Const TypeStr : String;_Type : longint;EnableDisplay : boolean);
  176. var p,p2,col,row : longint;
  177. St,ModuleName : string;
  178. begin
  179. p:=pos(TypeStr,Text);
  180. p2:=Pos('(',Text);
  181. if (p>0) and (p2>0) and (p2<p) then
  182. begin
  183. ModuleName:=Copy(Text,1,p2-1);
  184. st:=Copy(Text,p2+1,255);
  185. Val(Copy(st,1,pos(',',st)-1),row,cc);
  186. st:=Copy(st,Pos(',',st)+1,255);
  187. Val(Copy(st,1,pos(')',st)-1),col,cc);
  188. CompilerMessageWindow^.AddMessage(_type,Copy(Text,pos(':',Text)+1,255)
  189. ,ModuleName,row,col);
  190. If EnableDisplay then
  191. DisplayCompilerWindow:=true;
  192. end;
  193. end;
  194. begin
  195. if not assigned(UserScreen) then
  196. exit;
  197. DisplayCompilerWindow:=false;
  198. PushStatus('Parsing User Screen');
  199. CompilerMessageWindow^.Lock;
  200. for Y:=0 to UserScreen^.GetHeight do
  201. begin
  202. UserScreen^.GetLine(Y,Text,Attr);
  203. SearchBackTrace;
  204. InsertInMessages(' Fatal:',v_Fatal,true);
  205. InsertInMessages(' Error:',v_Error,true);
  206. InsertInMessages(' Warning:',v_Warning,false);
  207. InsertInMessages(' Note:',v_Note,false);
  208. InsertInMessages(' Info:',v_Info,false);
  209. InsertInMessages(' Hint:',v_Hint,false);
  210. end;
  211. if DisplayCompilerWindow then
  212. begin
  213. if not CompilerMessageWindow^.GetState(sfVisible) then
  214. CompilerMessageWindow^.Show;
  215. CompilerMessageWindow^.MakeFirst;
  216. CompilerMessageWindow^.MsgLB^.SelectFirstError;
  217. end;
  218. CompilerMessageWindow^.UnLock;
  219. PopStatus;
  220. end;
  221. {*****************************************************************************
  222. TCompilerMessage
  223. *****************************************************************************}
  224. function TCompilerMessage.GetText(MaxLen: Sw_Integer): String;
  225. var
  226. ClassS: string[20];
  227. S: string;
  228. begin
  229. case TClass and V_LevelMask of
  230. V_Fatal : ClassS:=msg_class_Fatal;
  231. V_Error : ClassS:=msg_class_Error;
  232. V_Normal : ClassS:=msg_class_Normal;
  233. V_Warning : ClassS:=msg_class_Warning;
  234. V_Note : ClassS:=msg_class_Note;
  235. V_Hint : ClassS:=msg_class_Hint;
  236. {$ifdef VERBOSETXT}
  237. V_Conditional : ClassS:=msg_class_conditional;
  238. V_Info : ClassS:=msg_class_info;
  239. V_Status : ClassS:=msg_class_status;
  240. V_Used : ClassS:=msg_class_used;
  241. V_Tried : ClassS:=msg_class_tried;
  242. V_Debug : ClassS:=msg_class_debug;
  243. else
  244. ClassS:='???';
  245. {$endif}
  246. else
  247. ClassS:='';
  248. end;
  249. if ClassS<>'' then
  250. ClassS:=RExpand(ClassS,0)+': ';
  251. if assigned(Module) and
  252. ((TClass and V_LineInfo)=V_LineInfo) then
  253. begin
  254. if Row>0 then
  255. begin
  256. if Col>0 then
  257. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+','+IntToStr(Col)+') '+ClassS
  258. else
  259. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+ClassS;
  260. end
  261. else
  262. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+ClassS
  263. end
  264. else
  265. S:=ClassS;
  266. if assigned(Text) then
  267. S:=S+Text^;
  268. if length(S)>MaxLen then
  269. S:=copy(S,1,MaxLen-2)+'..';
  270. GetText:=S;
  271. end;
  272. {*****************************************************************************
  273. TCompilerMessageListBox
  274. *****************************************************************************}
  275. function TCompilerMessageListBox.GetPalette: PPalette;
  276. const
  277. P: string[length(CBrowserListBox)] = CBrowserListBox;
  278. begin
  279. GetPalette:=@P;
  280. end;
  281. procedure TCompilerMessageListBox.SelectFirstError;
  282. function IsError(P : PCompilerMessage) : boolean;
  283. begin
  284. IsError:=(P^.TClass and (V_Fatal or V_Error))<>0;
  285. end;
  286. var
  287. P : PCompilerMessage;
  288. begin
  289. P:=List^.FirstThat(@IsError);
  290. If Assigned(P) then
  291. Begin
  292. FocusItem(List^.IndexOf(P));
  293. DrawView;
  294. End;
  295. end;
  296. {*****************************************************************************
  297. TCompilerMessageWindow
  298. *****************************************************************************}
  299. constructor TCompilerMessageWindow.Init;
  300. var R: TRect;
  301. HSB,VSB: PScrollBar;
  302. begin
  303. Desktop^.GetExtent(R);
  304. R.A.Y:=R.B.Y-7;
  305. inherited Init(R,dialog_compilermessages,{SearchFreeWindowNo}wnNoNumber);
  306. HelpCtx:=hcCompilerMessagesWindow;
  307. AutoNumber:=true;
  308. HSB:=StandardScrollBar(sbHorizontal+sbHandleKeyboard);
  309. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
  310. Insert(HSB);
  311. VSB:=StandardScrollBar(sbVertical+sbHandleKeyboard);
  312. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  313. Insert(VSB);
  314. GetExtent(R);
  315. R.Grow(-1,-1);
  316. New(MsgLB, Init(R, HSB, VSB));
  317. MsgLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  318. Insert(MsgLB);
  319. CompilerMessageWindow:=@self;
  320. end;
  321. procedure TCompilerMessageWindow.AddMessage(AClass: longint;const Msg, Module: string; Line, Column: longint);
  322. begin
  323. if (AClass and V_LineInfo)<>V_LineInfo then
  324. Line:=0;
  325. MsgLB^.AddItem(New(PCompilerMessage,Init(AClass, Msg, MsgLB^.AddModuleName(Module), Line, Column)));
  326. if (@Self=CompilerMessageWindow) and ((AClass = V_fatal) or (AClass = V_Error)) then
  327. begin
  328. if not GetState(sfVisible) then
  329. Show;
  330. if Desktop^.First<>PView(CompilerMessageWindow) then
  331. MakeFirst;
  332. end;
  333. end;
  334. procedure TCompilerMessageWindow.ClearMessages;
  335. begin
  336. MsgLB^.Clear;
  337. ReDraw;
  338. end;
  339. {procedure TCompilerMessageWindow.Updateinfo;
  340. begin
  341. if CompileShowed then
  342. begin
  343. InfoST^.SetText(
  344. RExpand(' Main file : '#1#$7f+Copy(SmartPath(MainFile),1,39),40)+#2+
  345. 'Total lines : '#1#$7e+IntToStr(Status.CompiledLines)+#2#13+
  346. RExpand(' Target : '#1#$7f+KillTilde(TargetSwitches^.ItemName(TargetSwitches^.GetCurrSel)),40)+#2+
  347. 'Total errors : '#1#$7e+IntToStr(Status.ErrorCount)
  348. );
  349. if status.currentline>0 then
  350. CurrST^.SetText(' Status: '#1#$7e+status.currentsource+'('+IntToStr(status.currentline)+')'#2)
  351. else
  352. CurrST^.SetText(' Status: '#1#$7e+status.currentsource+#2);
  353. end;
  354. ReDraw;
  355. end;}
  356. procedure TCompilerMessageWindow.HandleEvent(var Event: TEvent);
  357. begin
  358. case Event.What of
  359. evBroadcast :
  360. case Event.Command of
  361. cmListFocusChanged :
  362. if Event.InfoPtr=MsgLB then
  363. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  364. end;
  365. end;
  366. inherited HandleEvent(Event);
  367. end;
  368. procedure TCompilerMessageWindow.SizeLimits(var Min, Max: TPoint);
  369. begin
  370. inherited SizeLimits(Min,Max);
  371. Min.X:=20;
  372. Min.Y:=4;
  373. end;
  374. procedure TCompilerMessageWindow.Close;
  375. begin
  376. Hide;
  377. end;
  378. function TCompilerMessageWindow.GetPalette: PPalette;
  379. const
  380. S : string[length(CBrowserWindow)] = CBrowserWindow;
  381. begin
  382. GetPalette:=@S;
  383. end;
  384. constructor TCompilerMessageWindow.Load(var S: TStream);
  385. begin
  386. inherited Load(S);
  387. GetSubViewPtr(S,MsgLB);
  388. end;
  389. procedure TCompilerMessageWindow.Store(var S: TStream);
  390. begin
  391. if MsgLB^.List=nil then
  392. MsgLB^.NewList(New(PCollection, Init(100,100)));
  393. inherited Store(S);
  394. PutSubViewPtr(S,MsgLB);
  395. end;
  396. procedure TCompilerMessageWindow.UpdateCommands;
  397. var Active: boolean;
  398. begin
  399. Active:=GetState(sfActive);
  400. SetCmdState(CompileCmds,Active);
  401. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  402. end;
  403. procedure TCompilerMessageWindow.SetState(AState: Word; Enable: Boolean);
  404. var OldState: word;
  405. begin
  406. OldState:=State;
  407. inherited SetState(AState,Enable);
  408. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  409. UpdateCommands;
  410. end;
  411. destructor TCompilerMessageWindow.Done;
  412. begin
  413. CompilerMessageWindow:=nil;
  414. inherited Done;
  415. end;
  416. {****************************************************************************
  417. CompilerStatusDialog
  418. ****************************************************************************}
  419. constructor TCompilerStatusDialog.Init;
  420. var R: TRect;
  421. begin
  422. R.Assign(0,0,56,11);
  423. ClearFormatParams; AddFormatParamStr(KillTilde(SwitchesModeName[SwitchesMode]));
  424. inherited Init(R, FormatStrF(dialog_compilingwithmode, FormatParams));
  425. GetExtent(R); R.B.Y:=11;
  426. R.Grow(-3,-2);
  427. New(ST, Init(R, ''));
  428. Insert(ST);
  429. GetExtent(R); R.B.Y:=11;
  430. R.Grow(-1,-1); R.A.Y:=R.B.Y-1;
  431. New(KeyST, Init(R, '', Blue*16+White+longint($80+Blue*16+White)*256,true));
  432. Insert(KeyST);
  433. { Reset Status infos see bug 1585 }
  434. Fillchar(Status,SizeOf(Status),#0);
  435. end;
  436. destructor TCompilerStatusDialog.Done;
  437. begin
  438. if @Self=CompilerStatusDialog then
  439. CompilerStatusDialog:=nil;
  440. Inherited Done;
  441. end;
  442. procedure TCompilerStatusDialog.Update;
  443. var
  444. StatusS,KeyS: string;
  445. const
  446. MaxFileNameSize = 46;
  447. begin
  448. case CompilationPhase of
  449. cpCompiling :
  450. begin
  451. ClearFormatParams;
  452. if Status.Compiling_current then
  453. begin
  454. AddFormatParamStr(ShrinkPath(SmartPath(Status.Currentsourcepath+Status.CurrentSource),
  455. MaxFileNameSize - Length(msg_compilingfile)));
  456. StatusS:=FormatStrF(msg_compilingfile,FormatParams);
  457. end
  458. else
  459. begin
  460. if Status.CurrentSource='' then
  461. StatusS:=''
  462. else
  463. begin
  464. StatusS:=ShrinkPath(SmartPath(DirAndNameOf(Status.Currentsourcepath+Status.CurrentSource)),
  465. MaxFileNameSize-Length(msg_loadingunit));
  466. AddFormatParamStr(StatusS);
  467. StatusS:=FormatStrF(msg_loadingunit,FormatParams);
  468. end;
  469. end;
  470. KeyS:=msg_hint_pressesctocancel;
  471. end;
  472. cpLinking :
  473. begin
  474. ClearFormatParams;
  475. AddFormatParamStr(ShrinkPath(ExeFile,
  476. MaxFileNameSize-Length(msg_linkingfile)));
  477. StatusS:=FormatStrF(msg_linkingfile,FormatParams);
  478. KeyS:=msg_hint_pleasewait;
  479. end;
  480. cpDone :
  481. begin
  482. StatusS:=msg_compiledone;
  483. KeyS:=msg_hint_compilesuccessfulpressenter;
  484. end;
  485. cpFailed :
  486. begin
  487. StatusS:=msg_failedtocompile;
  488. KeyS:=msg_hint_compilefailed;
  489. end;
  490. cpAborted :
  491. begin
  492. StatusS:=msg_compilationaborted;
  493. KeyS:=msg_hint_compileaborted;
  494. end;
  495. end;
  496. ClearFormatParams;
  497. AddFormatParamStr(ShrinkPath(SmartPath(MainFile),
  498. MaxFileNameSize-Length('Main file: %s')));
  499. AddFormatParamStr(StatusS);
  500. AddFormatParamStr(KillTilde(TargetSwitches^.ItemName(TargetSwitches^.GetCurrSel)));
  501. AddFormatParamInt(Status.CurrentLine);
  502. AddFormatParamInt(Status.CompiledLines);
  503. AddFormatParamInt((Heapsize-MemAvail) div 1024);
  504. AddFormatParamInt(Heapsize div 1024);
  505. AddFormatParamInt(Status.ErrorCount);
  506. ST^.SetText(
  507. FormatStrF(
  508. 'Main file: %s'#13+
  509. '%s'+#13#13+
  510. 'Target: %s'#13+
  511. 'Line number: %6d '+'Total lines: %6d'+#13+
  512. 'Used memory: %6dK '+'Allocated memory: %6dK'#13+
  513. 'Total errors: %5d',
  514. FormatParams)
  515. );
  516. KeyST^.SetText(^C+KeyS);
  517. end;
  518. {****************************************************************************
  519. Compiler Hooks
  520. ****************************************************************************}
  521. function getrealtime : real;
  522. var
  523. {$IFDEF USE_SYSUTILS}
  524. h,m,s,s1000 : word;
  525. {$ELSE USE_SYSUTILS}
  526. h,m,s,s100 : word;
  527. {$ENDIF USE_SYSUTILS}
  528. begin
  529. {$IFDEF USE_SYSUTILS}
  530. DecodeTime(Time,h,m,s,s1000);
  531. getrealtime:=h*3600.0+m*60.0+s+s1000/1000.0;
  532. {$ELSE USE_SYSUTILS}
  533. gettime(h,m,s,s100);
  534. getrealtime:=h*3600.0+m*60.0+s+s100/100.0;
  535. {$ENDIF USE_SYSUTILS}
  536. end;
  537. const
  538. lasttime : real = 0;
  539. function CompilerStatus: boolean; {$ifndef FPC}far;{$endif}
  540. var
  541. event : tevent;
  542. begin
  543. GetKeyEvent(Event);
  544. if (Event.What=evKeyDown) and (Event.KeyCode=kbEsc) then
  545. begin
  546. CompilationPhase:=cpAborted;
  547. { update info messages }
  548. if assigned(CompilerStatusDialog) then
  549. begin
  550. {$ifdef redircompiler}
  551. RedirDisableAll;
  552. {$endif}
  553. CompilerStatusDialog^.Update;
  554. {$ifdef redircompiler}
  555. RedirEnableAll;
  556. {$endif}
  557. end;
  558. CompilerStatus:=true;
  559. exit;
  560. end;
  561. { only display line info every 100 lines, ofcourse all other messages
  562. will be displayed directly }
  563. if (getrealtime-lasttime>=CompilerStatusUpdateDelay) or (status.compiledlines=1) then
  564. begin
  565. lasttime:=getrealtime;
  566. { update info messages }
  567. {$ifdef redircompiler}
  568. RedirDisableAll;
  569. {$endif}
  570. if assigned(CompilerStatusDialog) then
  571. CompilerStatusDialog^.Update;
  572. {$ifdef redircompiler}
  573. RedirEnableAll;
  574. {$endif}
  575. { update memory usage }
  576. { HeapView^.Update; }
  577. end;
  578. CompilerStatus:=false;
  579. end;
  580. const
  581. LONGJMPCALLED = -1;
  582. procedure CompilerStop(err: longint); {$ifndef FPC}far;{$endif}
  583. begin
  584. {$ifdef HasSignal}
  585. if StopJmpValid then
  586. Longjmp(StopJmp,LONGJMPCALLED)
  587. else
  588. Halt(err);
  589. {$endif}
  590. end;
  591. Function CompilerGetNamedFileTime(const filename : string) : Longint; {$ifndef FPC}far;{$endif}
  592. var t: longint;
  593. W: PSourceWindow;
  594. begin
  595. W:=EditorWindowFile(FExpand(filename));
  596. if Assigned(W) and (W^.Editor^.GetModified) then
  597. t:=Now
  598. else
  599. t:=def_getnamedfiletime(filename);
  600. CompilerGetNamedFileTime:=t;
  601. end;
  602. function CompilerOpenInputFile(const filename: string): tinputfile; {$ifndef FPC}far;{$endif}
  603. var f: tinputfile;
  604. W: PSourceWindow;
  605. begin
  606. if assigned(CompilingHiddenFile) and
  607. (NameandExtof(filename)=CompilingHiddenFile^.Editor^.Filename) then
  608. W:=CompilingHiddenFile
  609. else
  610. W:=EditorWindowFile(FExpand(filename));
  611. if Assigned(W) and (W^.Editor^.GetModified) then
  612. f:=TFPInputFile.Create(W^.Editor)
  613. else
  614. f:=def_openinputfile(filename);
  615. if assigned(W) then
  616. W^.Editor^.CompileStamp:=CompileStamp;
  617. CompilerOpenInputFile:=f;
  618. end;
  619. function CompilerComment(Level:Longint; const s:string):boolean; {$ifndef FPC}far;{$endif}
  620. begin
  621. CompilerComment:=false;
  622. if (status.verbosity and Level)<>0 then
  623. begin
  624. {$ifdef redircompiler}
  625. RedirDisableAll;
  626. {$endif}
  627. if not CompilerMessageWindow^.GetState(sfVisible) then
  628. CompilerMessageWindow^.Show;
  629. if Desktop^.First<>PView(CompilerMessageWindow) then
  630. CompilerMessageWindow^.MakeFirst;
  631. CompilerMessageWindow^.AddMessage(Level,S,status.currentsourcepath+status.currentsource,
  632. status.currentline,status.currentcolumn);
  633. { update info messages }
  634. if assigned(CompilerStatusDialog) then
  635. CompilerStatusDialog^.Update;
  636. {$ifdef DEBUG}
  637. {$ifndef NODEBUG}
  638. // def_gdb_stop(level);
  639. {$endif}
  640. {$endif DEBUG}
  641. {$ifdef redircompiler}
  642. RedirEnableAll;
  643. {$endif}
  644. { update memory usage }
  645. { HeapView^.Update; }
  646. end;
  647. end;
  648. {****************************************************************************
  649. DoCompile
  650. ****************************************************************************}
  651. { This function must return '' if
  652. "Options|Directories|Exe and PPU directory" is empty }
  653. function GetExePath: string;
  654. var Path: string;
  655. I: Sw_integer;
  656. begin
  657. Path:='';
  658. if DirectorySwitches<>nil then
  659. with DirectorySwitches^ do
  660. for I:=0 to ItemCount-1 do
  661. begin
  662. if ItemParam(I)='-FE' then
  663. begin
  664. Path:=GetStringItem(I);
  665. Break;
  666. end;
  667. end;
  668. if Path<>'' then
  669. GetExePath:=CompleteDir(FExpand(Path))
  670. else
  671. GetExePath:='';
  672. end;
  673. function GetMainFile(Mode: TCompileMode): string;
  674. var FileName: string;
  675. P : PSourceWindow;
  676. begin
  677. if assigned(CompilingHiddenFile) then
  678. P:=CompilingHiddenFile
  679. else
  680. P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
  681. if (PrimaryFileMain='') and (P=nil) then
  682. FileName:='' { nothing to compile }
  683. else
  684. begin
  685. if (PrimaryFileMain<>'') and (Mode<>cCompile) then
  686. FileName:=PrimaryFileMain
  687. else if assigned(P) then
  688. begin
  689. FileName:=P^.Editor^.FileName;
  690. if FileName='' then
  691. begin
  692. P^.Editor^.SaveAsk(true);
  693. FileName:=P^.Editor^.FileName;
  694. end;
  695. end
  696. else
  697. FileName:='';
  698. end;
  699. If (FileName<>'') then
  700. FileName:=FixFileName(FExpand(FileName));
  701. GetMainFile:=FileName;
  702. end;
  703. procedure ResetErrorMessages;
  704. procedure ResetErrorLine(P: PView); {$ifndef FPC}far;{$endif}
  705. begin
  706. if assigned(P) and
  707. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  708. PSourceWindow(P)^.Editor^.SetErrorMessage('');
  709. end;
  710. begin
  711. Desktop^.ForEach(@ResetErrorLine);
  712. end;
  713. procedure DoCompile(Mode: TCompileMode);
  714. function IsExitEvent(E: TEvent): boolean;
  715. begin
  716. { following suggestion by Harsha Senanayake }
  717. IsExitEvent:=(E.What=evKeyDown);
  718. end;
  719. function GetTargetExeExt : string;
  720. begin
  721. GetTargetExeExt:=target_info.exeext;
  722. end;
  723. var
  724. s,FileName: string;
  725. ErrFile : Text;
  726. MustRestartDebugger,
  727. StoreStopJumpValid : boolean;
  728. StoreStopJmp : Jmp_buf;
  729. StoreExitProc : pointer;
  730. JmpRet,Error,LinkErrorCount : longint;
  731. E : TEvent;
  732. DummyView: PView;
  733. PPasFile : string[64];
  734. begin
  735. AskRecompileIfModifiedFlag:=true;
  736. { Get FileName }
  737. FileName:=GetMainFile(Mode);
  738. if FileName='' then
  739. begin
  740. ErrorBox(msg_nothingtocompile,nil);
  741. Exit;
  742. end else
  743. { THis is not longer necessary as unsaved files are loaded from a memorystream,
  744. and with the file as primaryfile set it is already incompatible with itself
  745. if FileName='*' then
  746. begin
  747. ErrorBox(msg_cantcompileunsavedfile,nil);
  748. Exit;
  749. end; }
  750. PushStatus('Beginning compilation...');
  751. { Show Compiler Messages Window }
  752. { if not CompilerMessageWindow^.GetState(sfVisible) then
  753. CompilerMessageWindow^.Show;
  754. CompilerMessageWindow^.MakeFirst;}
  755. CompilerMessageWindow^.ClearMessages;
  756. { Tell why we compile }
  757. NeedRecompile(Mode,true);
  758. MainFile:=FileName;
  759. SetStatus('Writing switches to file...');
  760. WriteSwitches(SwitchesPath);
  761. { leaving open browsers leads to crashes !! (PM) }
  762. SetStatus('Preparing symbol info...');
  763. CloseAllBrowsers;
  764. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  765. WriteSymbolsFile(BrowserName);
  766. { MainFile:=FixFileName(FExpand(FileName));}
  767. SetStatus('Preparing to compile...'+NameOf(MainFile));
  768. { Reset }
  769. CtrlBreakHit:=false;
  770. { Create Compiler Status Dialog }
  771. CompilationPhase:=cpCompiling;
  772. if not assigned(CompilingHiddenFile) then
  773. begin
  774. New(CompilerStatusDialog, Init);
  775. CompilerStatusDialog^.SetState(sfModal,true);
  776. { disable window closing }
  777. CompilerStatusDialog^.Flags:=CompilerStatusDialog^.Flags and not wfclose;
  778. Application^.Insert(CompilerStatusDialog);
  779. CompilerStatusDialog^.Update;
  780. end;
  781. { Restore dir that could be changed during debugging }
  782. {$I-}
  783. ChDir(StartUpDir);
  784. {$I+}
  785. EatIO;
  786. { hook compiler output }
  787. do_status:=@CompilerStatus;
  788. do_stop:=@CompilerStop;
  789. do_comment:=@CompilerComment;
  790. do_openinputfile:=@CompilerOpenInputFile;
  791. do_getnamedfiletime:=@CompilerGetNamedFileTime;
  792. do_initsymbolinfo:=@InitBrowserCol;
  793. do_donesymbolinfo:=@DoneBrowserCol;
  794. do_extractsymbolinfo:=@CreateBrowserCol;
  795. { Compile ! }
  796. {$ifdef redircompiler}
  797. ChangeRedirOut(FPOutFileName,false);
  798. ChangeRedirError(FPErrFileName,false);
  799. {$endif}
  800. { insert "" around name so that spaces are allowed }
  801. { only supported in compiler after 2000/01/14 PM }
  802. if pos(' ',FileName)>0 then
  803. FileName:='"'+FileName+'"';
  804. if mode=cBuild then
  805. FileName:='-B '+FileName;
  806. { tokens are created and distroed by compiler.compile !! PM }
  807. DoneTokens;
  808. PPasFile:='ppas'+source_info.scriptext;
  809. WUtils.DeleteFile(GetExePath+PpasFile);
  810. SetStatus('Compiling...');
  811. {$ifdef HasSignal}
  812. StoreStopJumpValid:=StopJmpValid;
  813. StoreStopJmp:=StopJmp;
  814. {$endif HasSignal}
  815. StoreExitProc:=ExitProc;
  816. {$ifdef HasSignal}
  817. StopJmpValid:=true;
  818. JmpRet:=SetJmp(StopJmp);
  819. {$else}
  820. JmpRet:=0;
  821. {$endif HasSignal}
  822. if JmpRet=0 then
  823. begin
  824. inc(CompileStamp);
  825. ResetErrorMessages;
  826. {$ifndef NODEBUG}
  827. MustRestartDebugger:=false;
  828. if assigned(Debugger) then
  829. if Debugger^.HasExe then
  830. begin
  831. Debugger^.Reset;
  832. MustRestartDebugger:=true;
  833. end;
  834. {$endif NODEBUG}
  835. FpIntF.Compile(FileName,SwitchesPath);
  836. SetStatus('Finished compiling...');
  837. end
  838. else
  839. begin
  840. { We need to restore Exitproc to the value
  841. it was before calling FPintF.compile PM }
  842. ExitProc:=StoreExitProc;
  843. Inc(status.errorCount);
  844. {$ifdef HasSignal}
  845. Case JmpRet of
  846. LONGJMPCALLED : s:='Error';
  847. SIGINT : s := 'Interrupted by Ctrl-C';
  848. SIGILL : s := 'Illegal instruction';
  849. SIGSEGV : s := 'Signal Segmentation violation';
  850. SIGFPE : s:='Floating point signal';
  851. else
  852. s:='Undetermined signal '+inttostr(JmpRet);
  853. end;
  854. CompilerMessageWindow^.AddMessage(V_error,s+' during compilation','',0,0);
  855. {$endif HasSignal}
  856. if JmpRet<>LONGJMPCALLED then
  857. begin
  858. CompilerMessageWindow^.AddMessage(V_error,'Long jumped out of compilation...','',0,0);
  859. SetStatus('Long jumped out of compilation...');
  860. end;
  861. end;
  862. {$ifdef HasSignal}
  863. StopJmpValid:=StoreStopJumpValid;
  864. StopJmp:=StoreStopJmp;
  865. {$endif HasSignal}
  866. { Retrieve created exefile }
  867. If GetEXEPath<>'' then
  868. EXEFile:=FixFileName(GetEXEPath+NameOf(MainFile)+GetTargetExeExt)
  869. else
  870. EXEFile:=DirOf(MainFile)+NameOf(MainFile)+GetTargetExeExt;
  871. { tokens are created and distroyed by compiler.compile !! PM }
  872. InitTokens;
  873. if LinkAfter and
  874. ExistsFile(GetExePath+PpasFile) and
  875. (CompilationPhase<>cpAborted) and
  876. (status.errorCount=0) then
  877. begin
  878. CompilationPhase:=cpLinking;
  879. if assigned(CompilerStatusDialog) then
  880. CompilerStatusDialog^.Update;
  881. SetStatus('Assembling and/or linking...');
  882. {$ifndef redircompiler}
  883. { At least here we want to catch output
  884. of batch file PM }
  885. ChangeRedirOut(FPOutFileName,false);
  886. ChangeRedirError(FPErrFileName,false);
  887. {$endif}
  888. {$ifdef Unix}
  889. {$ifdef ver1_0}
  890. Shell(GetExePath+PpasFile);
  891. Error:=LinuxError;
  892. {$else}
  893. error:=0;
  894. If Shell(GetExePath+PpasFile)=-1 Then
  895. Error:=fpgeterrno;
  896. {$endif}
  897. {$else}
  898. DosExecute(GetEnv('COMSPEC'),'/C '+GetExePath+PpasFile);
  899. Error:=DosError;
  900. {$endif}
  901. SetStatus('Finished linking...');
  902. RestoreRedirOut;
  903. RestoreRedirError;
  904. if Error<>0 then
  905. Inc(status.errorCount);
  906. if Status.IsExe and not Status.IsLibrary and not ExistsFile(EXEFile) then
  907. begin
  908. Inc(status.errorCount);
  909. ClearFormatParams; AddFormatParamStr(ExeFile);
  910. CompilerMessageWindow^.AddMessage(V_error,FormatStrF(msg_couldnotcreatefile,FormatParams),'',0,0);
  911. {$I-}
  912. Assign(ErrFile,FPErrFileName);
  913. Reset(ErrFile);
  914. if EatIO<>0 then
  915. ErrorBox(FormatStrStr(msg_cantopenfile,FPErrFileName),nil)
  916. else
  917. begin
  918. LinkErrorCount:=0;
  919. While not eof(ErrFile) and (LinkErrorCount<25) do
  920. begin
  921. readln(ErrFile,s);
  922. CompilerMessageWindow^.AddMessage(V_error,s,'',0,0);
  923. inc(LinkErrorCount);
  924. end;
  925. if not eof(ErrFile) then
  926. begin
  927. ClearFormatParams; AddFormatParamStr(FPErrFileName);
  928. CompilerMessageWindow^.AddMessage(V_error,
  929. FormatStrF(msg_therearemoreerrorsinfile,FormatParams),'',0,0);
  930. end;
  931. Close(ErrFile);
  932. end;
  933. EatIO;
  934. {$I+}
  935. end
  936. else if error=0 then
  937. WUtils.DeleteFile(GetExePath+PpasFile);
  938. end;
  939. {$ifdef redircompiler}
  940. RestoreRedirOut;
  941. RestoreRedirError;
  942. {$endif}
  943. PopStatus;
  944. { Set end status }
  945. if not (CompilationPhase in [cpAborted,cpFailed]) then
  946. if (status.errorCount=0) then
  947. begin
  948. CompilationPhase:=cpDone;
  949. LastCompileTime := cardinal(Now);
  950. end
  951. else
  952. CompilationPhase:=cpFailed;
  953. { Show end status }
  954. { reenable window closing }
  955. if assigned(CompilerStatusDialog) then
  956. begin
  957. CompilerStatusDialog^.Flags:=CompilerStatusDialog^.Flags or wfclose;
  958. CompilerStatusDialog^.Update;
  959. CompilerStatusDialog^.ReDraw;
  960. CompilerStatusDialog^.SetState(sfModal,false);
  961. if ((CompilationPhase in [cpAborted,cpDone,cpFailed]) or (ShowStatusOnError))
  962. and ((Mode<>cRun) or (CompilationPhase<>cpDone)) then
  963. repeat
  964. CompilerStatusDialog^.GetEvent(E);
  965. if IsExitEvent(E)=false then
  966. CompilerStatusDialog^.HandleEvent(E);
  967. until IsExitEvent(E) or not assigned(CompilerStatusDialog);
  968. {if IsExitEvent(E) then
  969. Application^.PutEvent(E);}
  970. if assigned(CompilerStatusDialog) then
  971. begin
  972. Application^.Delete(CompilerStatusDialog);
  973. Dispose(CompilerStatusDialog, Done);
  974. end;
  975. end;
  976. CompilerStatusDialog:=nil;
  977. { end compilation returns true if the messagewindow should be removed }
  978. if CompilationPhase=cpDone then
  979. begin
  980. CompilerMessageWindow^.Hide;
  981. { This is the last compiled main file }
  982. PrevMainFile:=MainFile;
  983. MainHasDebugInfo:=DebugInfoSwitches^.GetCurrSelParam<>'-';
  984. end;
  985. { Update the app }
  986. Message(Application,evCommand,cmUpdate,nil);
  987. DummyView:=Desktop^.First;
  988. while (DummyView<>nil) and (DummyView^.GetState(sfVisible)=false) do
  989. begin
  990. DummyView:=DummyView^.NextView;
  991. end;
  992. with DummyView^ do
  993. if GetState(sfVisible) then
  994. begin
  995. SetState(sfSelected,false);
  996. SetState(sfSelected,true);
  997. end;
  998. if Assigned(CompilerMessageWindow) then
  999. with CompilerMessageWindow^ do
  1000. begin
  1001. if GetState(sfVisible) then
  1002. begin
  1003. SetState(sfSelected,false);
  1004. SetState(sfSelected,true);
  1005. end;
  1006. if (status.errorCount>0) then
  1007. MsgLB^.SelectFirstError;
  1008. end;
  1009. { ^^^ we need this trick to reactivate the desktop }
  1010. EditorModified:=false;
  1011. {$ifndef NODEBUG}
  1012. if MustRestartDebugger then
  1013. InitDebugger;
  1014. {$endif NODEBUG}
  1015. { In case we have something that the compiler touched }
  1016. AskToReloadAllModifiedFiles;
  1017. { Try to read Browser info in again if compilation failure !! }
  1018. if Not Assigned(Modules) and (CompilationPhase<>cpDone) and
  1019. ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1020. ReadSymbolsFile(BrowserName);
  1021. if UseAllUnitsInCodeComplete and not assigned(CompilingHiddenFile) then
  1022. AddAvailableUnitsToCodeComplete(false);
  1023. end;
  1024. function NeedRecompile(Mode :TCompileMode; verbose : boolean): boolean;
  1025. var Need: boolean;
  1026. I: sw_integer;
  1027. SF: PSourceFile;
  1028. SourceTime,PPUTime,ObjTime: longint;
  1029. W: PSourceWindow;
  1030. begin
  1031. if Assigned(SourceFiles)=false then
  1032. Need:={(EditorModified=true)}true
  1033. else
  1034. begin
  1035. Need:=(PrevMainFile<>GetMainFile(Mode)) and (PrevMainFile<>'');
  1036. if Need then
  1037. begin
  1038. if verbose then
  1039. begin
  1040. ClearFormatParams; AddFormatParamStr(GetMainFile(Mode));
  1041. CompilerMessageWindow^.AddMessage(V_info,
  1042. FormatStrF(msg_firstcompilationof,FormatParams),
  1043. '',0,0);
  1044. end;
  1045. end
  1046. else
  1047. for I:=0 to SourceFiles^.Count-1 do
  1048. begin
  1049. SF:=SourceFiles^.At(I);
  1050. SourceTime:=GetFileTime(SF^.GetSourceFileName);
  1051. PPUTime:=GetFileTime(SF^.GetPPUFileName);
  1052. ObjTime:=GetFileTime(SF^.GetObjFileName);
  1053. { writeln('S: ',SF^.GetSourceFileName,' - ',SourceTime);
  1054. writeln('P: ',SF^.GetPPUFileName,' - ',PPUTime);
  1055. writeln('O: ',SF^.GetObjFileName,' - ',ObjTime);
  1056. writeln('------');}
  1057. { some units don't generate object files }
  1058. W:=EditorWindowFile(SF^.GetSourceFileName);
  1059. if (SourceTime<>-1) then
  1060. if ((SourceTime>PPUTime) or
  1061. ((SourceTime>ObjTime) and
  1062. (ObjTime<>-1))) or
  1063. (assigned(W) and (W^.Editor^.CompileStamp<0)) then
  1064. begin
  1065. Need:=true;
  1066. if verbose then
  1067. begin
  1068. ClearFormatParams; AddFormatParamStr(SF^.GetSourceFileName);
  1069. CompilerMessageWindow^.AddMessage(V_info,
  1070. FormatStrF(msg_recompilingbecauseof,FormatParams),
  1071. SF^.GetSourceFileName,1,1);
  1072. end;
  1073. Break;
  1074. end;
  1075. end;
  1076. { writeln('Need?', Need); system.readln;}
  1077. end;
  1078. NeedRecompile:=Need;
  1079. end;
  1080. constructor TFPInputFile.Create(AEditor: PFileEditor);
  1081. begin
  1082. if not Assigned(AEditor) then Fail;
  1083. if inherited Create(AEditor^.FileName)=nil then
  1084. Fail;
  1085. Editor:=AEditor;
  1086. end;
  1087. function TFPInputFile.fileopen(const filename: string): boolean;
  1088. var OK: boolean;
  1089. begin
  1090. S:=New(PMemoryStream, Init(0,0));
  1091. OK:=Assigned(S) and (S^.Status=stOK);
  1092. if OK then OK:=Editor^.SaveToStream(S);
  1093. if OK then
  1094. S^.Seek(0)
  1095. else
  1096. begin
  1097. if Assigned(S) then Dispose(S, Done);
  1098. S:=nil;
  1099. end;
  1100. fileopen:=OK;
  1101. end;
  1102. function TFPInputFile.fileseek(pos: longint): boolean;
  1103. var OK: boolean;
  1104. begin
  1105. OK:=assigned(S);
  1106. if OK then
  1107. begin
  1108. S^.Reset;
  1109. S^.Seek(pos);
  1110. OK:=(S^.Status=stOK);
  1111. end;
  1112. fileseek:=OK;
  1113. end;
  1114. function TFPInputFile.fileread(var databuf; maxsize: longint): longint;
  1115. var
  1116. size: longint;
  1117. begin
  1118. if not assigned(S) then size:=0 else
  1119. begin
  1120. size:=min(maxsize,(S^.GetSize-S^.GetPos));
  1121. S^.Read(databuf,size);
  1122. if S^.Status<>stOK then size:=0;
  1123. end;
  1124. fileread:=size;
  1125. end;
  1126. function TFPInputFile.fileeof: boolean;
  1127. var EOF: boolean;
  1128. begin
  1129. EOF:=not assigned(S);
  1130. if not EOF then
  1131. EOF:=(S^.Status<>stOK) or (S^.GetPos=S^.GetSize);
  1132. fileeof:=EOF;
  1133. end;
  1134. function TFPInputFile.fileclose: boolean;
  1135. var OK: boolean;
  1136. begin
  1137. OK:=assigned(S);
  1138. if OK then
  1139. begin
  1140. S^.Reset;
  1141. Dispose(S, Done);
  1142. S:=nil;
  1143. OK:=true;
  1144. end;
  1145. fileclose:=OK;
  1146. end;
  1147. procedure RegisterFPCompile;
  1148. begin
  1149. {$ifndef NOOBJREG}
  1150. RegisterType(RCompilerMessageListBox);
  1151. RegisterType(RCompilerMessageWindow);
  1152. {$endif}
  1153. end;
  1154. end.
  1155. {
  1156. $Log$
  1157. Revision 1.32 2004-11-20 14:21:19 florian
  1158. * implemented reload menu item
  1159. * increased file history to 9 files
  1160. Revision 1.31 2004/11/20 10:18:41 florian
  1161. * reduced status updates by making them time dependend
  1162. Revision 1.30 2004/11/14 21:45:28 florian
  1163. * fixed non working mouse after tools call
  1164. * better handling of source/target info
  1165. * more info in about dialog
  1166. * better info in compiler status dialiog
  1167. Revision 1.29 2004/11/08 20:28:26 peter
  1168. * Breakpoints are now deleted when removed from source, disabling is
  1169. still possible from the breakpoint list
  1170. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  1171. FV and 1.9.x compilers
  1172. * Run directory added to Run menu
  1173. * Useless programinfo window removed
  1174. Revision 1.28 2004/11/06 22:02:48 peter
  1175. * fixed resize helptext
  1176. Revision 1.27 2004/11/06 17:22:52 peter
  1177. * fixes for new fv
  1178. Revision 1.26 2004/11/05 00:00:33 peter
  1179. set exefile after compilation, before the target_info is not filled
  1180. Revision 1.25 2004/11/02 23:53:19 peter
  1181. * fixed crashes with ide and 1.9.x
  1182. Revision 1.24 2004/09/09 20:33:00 jonas
  1183. * made CompilerStop declaration compliant to new tstopprocedure type in
  1184. compiler
  1185. Revision 1.23 2003/11/14 17:29:38 marco
  1186. * linuxerrorcide
  1187. Revision 1.22 2003/03/28 09:55:46 armin
  1188. * Fixed TCompilerMessageWindow.AddMessage to see line numbers with 1.1
  1189. Revision 1.21 2003/03/27 14:11:53 pierre
  1190. * fix problem in CompilerComment procedure
  1191. Revision 1.20 2003/01/13 09:05:18 pierre
  1192. * fix error in last commit
  1193. Revision 1.19 2003/01/11 15:52:54 peter
  1194. * adapted for new 1.1 compiler verbosity
  1195. Revision 1.18 2002/12/02 13:58:29 pierre
  1196. * avoid longjmp messages if quitting after compilation error
  1197. Revision 1.17 2002/11/20 17:35:00 pierre
  1198. * use target_os.ExeExt for compiled executable
  1199. Revision 1.16 2002/10/23 19:19:40 hajny
  1200. * another bunch of missing HasSignal conditionals
  1201. Revision 1.15 2002/09/26 15:00:35 pierre
  1202. * fix problems with system unit is not present for __fp__ compilation
  1203. Revision 1.14 2002/09/13 22:30:50 pierre
  1204. * only fpc uses video unit
  1205. Revision 1.13 2002/09/09 06:53:54 pierre
  1206. * avoid to save file used by codecomplete
  1207. Revision 1.12 2002/09/07 15:40:42 peter
  1208. * old logs removed and tabs fixed
  1209. Revision 1.11 2002/09/05 08:45:40 pierre
  1210. * try to fix recompilation on changes problems
  1211. Revision 1.10 2002/09/04 14:07:12 pierre
  1212. + Enhance code complete by inserting unit symbols
  1213. Revision 1.9 2002/08/26 13:03:14 pierre
  1214. + add a lock to speed up parsing of userscreen
  1215. Revision 1.8 2002/04/10 22:37:37 pierre
  1216. * save and restore Exitproc if LongJmp called
  1217. Revision 1.7 2002/03/20 14:48:27 pierre
  1218. * moved StopJmp buffer to fpcatch unit
  1219. }