fpcompil.pas 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  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 or v_lineinfo,true);
  205. InsertInMessages(' Error:',v_Error or v_lineinfo,true);
  206. InsertInMessages(' Warning:',v_Warning or v_lineinfo,false);
  207. InsertInMessages(' Note:',v_Note or v_lineinfo,false);
  208. InsertInMessages(' Info:',v_Info or v_lineinfo,false);
  209. InsertInMessages(' Hint:',v_Hint or v_lineinfo,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. {$ifdef HASGETHEAPSTATUS}
  446. hstatus : THeapStatus;
  447. {$endif HASGETHEAPSTATUS}
  448. const
  449. MaxFileNameSize = 46;
  450. begin
  451. case CompilationPhase of
  452. cpCompiling :
  453. begin
  454. ClearFormatParams;
  455. if Status.Compiling_current then
  456. begin
  457. AddFormatParamStr(ShrinkPath(SmartPath(Status.Currentsourcepath+Status.CurrentSource),
  458. MaxFileNameSize - Length(msg_compilingfile)));
  459. StatusS:=FormatStrF(msg_compilingfile,FormatParams);
  460. end
  461. else
  462. begin
  463. if Status.CurrentSource='' then
  464. StatusS:=''
  465. else
  466. begin
  467. StatusS:=ShrinkPath(SmartPath(DirAndNameOf(Status.Currentsourcepath+Status.CurrentSource)),
  468. MaxFileNameSize-Length(msg_loadingunit));
  469. AddFormatParamStr(StatusS);
  470. StatusS:=FormatStrF(msg_loadingunit,FormatParams);
  471. end;
  472. end;
  473. KeyS:=msg_hint_pressesctocancel;
  474. end;
  475. cpLinking :
  476. begin
  477. ClearFormatParams;
  478. AddFormatParamStr(ShrinkPath(ExeFile,
  479. MaxFileNameSize-Length(msg_linkingfile)));
  480. StatusS:=FormatStrF(msg_linkingfile,FormatParams);
  481. KeyS:=msg_hint_pleasewait;
  482. end;
  483. cpDone :
  484. begin
  485. StatusS:=msg_compiledone;
  486. KeyS:=msg_hint_compilesuccessfulpressenter;
  487. end;
  488. cpFailed :
  489. begin
  490. StatusS:=msg_failedtocompile;
  491. KeyS:=msg_hint_compilefailed;
  492. end;
  493. cpAborted :
  494. begin
  495. StatusS:=msg_compilationaborted;
  496. KeyS:=msg_hint_compileaborted;
  497. end;
  498. end;
  499. ClearFormatParams;
  500. AddFormatParamStr(ShrinkPath(SmartPath(MainFile),
  501. MaxFileNameSize-Length('Main file: %s')));
  502. AddFormatParamStr(StatusS);
  503. AddFormatParamStr(KillTilde(TargetSwitches^.ItemName(TargetSwitches^.GetCurrSel)));
  504. AddFormatParamInt(Status.CurrentLine);
  505. AddFormatParamInt(Status.CompiledLines);
  506. {$ifdef HASGETHEAPSTATUS}
  507. GetHeapStatus(hstatus);
  508. AddFormatParamInt(hstatus.CurrHeapUsed div 1024);
  509. AddFormatParamInt(hstatus.CurrHeapSize div 1024);
  510. {$else}
  511. AddFormatParamInt((Heapsize-MemAvail) div 1024);
  512. AddFormatParamInt(Heapsize div 1024);
  513. {$endif}
  514. AddFormatParamInt(Status.ErrorCount);
  515. ST^.SetText(
  516. FormatStrF(
  517. 'Main file: %s'#13+
  518. '%s'+#13#13+
  519. 'Target: %s'#13+
  520. 'Line number: %6d '+'Total lines: %6d'+#13+
  521. 'Used memory: %6dK '+'Allocated memory: %6dK'#13+
  522. 'Total errors: %5d',
  523. FormatParams)
  524. );
  525. KeyST^.SetText(^C+KeyS);
  526. end;
  527. {****************************************************************************
  528. Compiler Hooks
  529. ****************************************************************************}
  530. function getrealtime : real;
  531. var
  532. {$IFDEF USE_SYSUTILS}
  533. h,m,s,s1000 : word;
  534. {$ELSE USE_SYSUTILS}
  535. h,m,s,s100 : word;
  536. {$ENDIF USE_SYSUTILS}
  537. begin
  538. {$IFDEF USE_SYSUTILS}
  539. DecodeTime(Time,h,m,s,s1000);
  540. getrealtime:=h*3600.0+m*60.0+s+s1000/1000.0;
  541. {$ELSE USE_SYSUTILS}
  542. gettime(h,m,s,s100);
  543. getrealtime:=h*3600.0+m*60.0+s+s100/100.0;
  544. {$ENDIF USE_SYSUTILS}
  545. end;
  546. const
  547. lasttime : real = 0;
  548. function CompilerStatus: boolean; {$ifndef FPC}far;{$endif}
  549. var
  550. event : tevent;
  551. begin
  552. GetKeyEvent(Event);
  553. if (Event.What=evKeyDown) and (Event.KeyCode=kbEsc) then
  554. begin
  555. CompilationPhase:=cpAborted;
  556. { update info messages }
  557. if assigned(CompilerStatusDialog) then
  558. begin
  559. {$ifdef redircompiler}
  560. RedirDisableAll;
  561. {$endif}
  562. CompilerStatusDialog^.Update;
  563. {$ifdef redircompiler}
  564. RedirEnableAll;
  565. {$endif}
  566. end;
  567. CompilerStatus:=true;
  568. exit;
  569. end;
  570. { only display line info every 100 lines, ofcourse all other messages
  571. will be displayed directly }
  572. if (getrealtime-lasttime>=CompilerStatusUpdateDelay) or (status.compiledlines=1) then
  573. begin
  574. lasttime:=getrealtime;
  575. { update info messages }
  576. {$ifdef redircompiler}
  577. RedirDisableAll;
  578. {$endif}
  579. if assigned(CompilerStatusDialog) then
  580. CompilerStatusDialog^.Update;
  581. {$ifdef redircompiler}
  582. RedirEnableAll;
  583. {$endif}
  584. { update memory usage }
  585. { HeapView^.Update; }
  586. end;
  587. CompilerStatus:=false;
  588. end;
  589. const
  590. LONGJMPCALLED = -1;
  591. procedure CompilerStop(err: longint); {$ifndef FPC}far;{$endif}
  592. begin
  593. {$ifdef HasSignal}
  594. if StopJmpValid then
  595. Longjmp(StopJmp,LONGJMPCALLED)
  596. else
  597. Halt(err);
  598. {$endif}
  599. end;
  600. Function CompilerGetNamedFileTime(const filename : string) : Longint; {$ifndef FPC}far;{$endif}
  601. var t: longint;
  602. W: PSourceWindow;
  603. begin
  604. W:=EditorWindowFile(FExpand(filename));
  605. if Assigned(W) and (W^.Editor^.GetModified) then
  606. t:=Now
  607. else
  608. t:=def_getnamedfiletime(filename);
  609. CompilerGetNamedFileTime:=t;
  610. end;
  611. function CompilerOpenInputFile(const filename: string): tinputfile; {$ifndef FPC}far;{$endif}
  612. var f: tinputfile;
  613. W: PSourceWindow;
  614. begin
  615. if assigned(CompilingHiddenFile) and
  616. (NameandExtof(filename)=CompilingHiddenFile^.Editor^.Filename) then
  617. W:=CompilingHiddenFile
  618. else
  619. W:=EditorWindowFile(FExpand(filename));
  620. if Assigned(W) and (W^.Editor^.GetModified) then
  621. f:=TFPInputFile.Create(W^.Editor)
  622. else
  623. f:=def_openinputfile(filename);
  624. if assigned(W) then
  625. W^.Editor^.CompileStamp:=CompileStamp;
  626. CompilerOpenInputFile:=f;
  627. end;
  628. function CompilerComment(Level:Longint; const s:string):boolean; {$ifndef FPC}far;{$endif}
  629. begin
  630. CompilerComment:=false;
  631. if (status.verbosity and Level)<>0 then
  632. begin
  633. {$ifdef redircompiler}
  634. RedirDisableAll;
  635. {$endif}
  636. if not CompilerMessageWindow^.GetState(sfVisible) then
  637. CompilerMessageWindow^.Show;
  638. if Desktop^.First<>PView(CompilerMessageWindow) then
  639. CompilerMessageWindow^.MakeFirst;
  640. CompilerMessageWindow^.AddMessage(Level,S,status.currentsourcepath+status.currentsource,
  641. status.currentline,status.currentcolumn);
  642. { update info messages }
  643. if assigned(CompilerStatusDialog) then
  644. CompilerStatusDialog^.Update;
  645. {$ifdef DEBUG}
  646. {$ifndef NODEBUG}
  647. // def_gdb_stop(level);
  648. {$endif}
  649. {$endif DEBUG}
  650. {$ifdef redircompiler}
  651. RedirEnableAll;
  652. {$endif}
  653. { update memory usage }
  654. { HeapView^.Update; }
  655. end;
  656. end;
  657. {****************************************************************************
  658. DoCompile
  659. ****************************************************************************}
  660. { This function must return '' if
  661. "Options|Directories|Exe and PPU directory" is empty }
  662. function GetExePath: string;
  663. var Path: string;
  664. I: Sw_integer;
  665. begin
  666. Path:='';
  667. if DirectorySwitches<>nil then
  668. with DirectorySwitches^ do
  669. for I:=0 to ItemCount-1 do
  670. begin
  671. if ItemParam(I)='-FE' then
  672. begin
  673. Path:=GetStringItem(I);
  674. Break;
  675. end;
  676. end;
  677. if Path<>'' then
  678. GetExePath:=CompleteDir(FExpand(Path))
  679. else
  680. GetExePath:='';
  681. end;
  682. function GetMainFile(Mode: TCompileMode): string;
  683. var FileName: string;
  684. P : PSourceWindow;
  685. begin
  686. if assigned(CompilingHiddenFile) then
  687. P:=CompilingHiddenFile
  688. else
  689. P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
  690. if (PrimaryFileMain='') and (P=nil) then
  691. FileName:='' { nothing to compile }
  692. else
  693. begin
  694. if (PrimaryFileMain<>'') and (Mode<>cCompile) then
  695. FileName:=PrimaryFileMain
  696. else if assigned(P) then
  697. begin
  698. FileName:=P^.Editor^.FileName;
  699. if FileName='' then
  700. begin
  701. P^.Editor^.SaveAsk(true);
  702. FileName:=P^.Editor^.FileName;
  703. end;
  704. end
  705. else
  706. FileName:='';
  707. end;
  708. If (FileName<>'') then
  709. FileName:=FixFileName(FExpand(FileName));
  710. GetMainFile:=FileName;
  711. end;
  712. procedure ResetErrorMessages;
  713. procedure ResetErrorLine(P: PView); {$ifndef FPC}far;{$endif}
  714. begin
  715. if assigned(P) and
  716. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  717. PSourceWindow(P)^.Editor^.SetErrorMessage('');
  718. end;
  719. begin
  720. Desktop^.ForEach(@ResetErrorLine);
  721. end;
  722. procedure DoCompile(Mode: TCompileMode);
  723. function IsExitEvent(E: TEvent): boolean;
  724. begin
  725. { following suggestion by Harsha Senanayake }
  726. IsExitEvent:=(E.What=evKeyDown);
  727. end;
  728. function GetTargetExeExt : string;
  729. begin
  730. GetTargetExeExt:=target_info.exeext;
  731. end;
  732. var
  733. s,FileName: string;
  734. ErrFile : Text;
  735. MustRestartDebugger,
  736. StoreStopJumpValid : boolean;
  737. StoreStopJmp : Jmp_buf;
  738. StoreExitProc : pointer;
  739. JmpRet,Error,LinkErrorCount : longint;
  740. E : TEvent;
  741. DummyView: PView;
  742. PPasFile : string[64];
  743. begin
  744. AskRecompileIfModifiedFlag:=true;
  745. { Get FileName }
  746. FileName:=GetMainFile(Mode);
  747. if FileName='' then
  748. begin
  749. ErrorBox(msg_nothingtocompile,nil);
  750. Exit;
  751. end else
  752. { THis is not longer necessary as unsaved files are loaded from a memorystream,
  753. and with the file as primaryfile set it is already incompatible with itself
  754. if FileName='*' then
  755. begin
  756. ErrorBox(msg_cantcompileunsavedfile,nil);
  757. Exit;
  758. end; }
  759. PushStatus('Beginning compilation...');
  760. { Show Compiler Messages Window }
  761. { if not CompilerMessageWindow^.GetState(sfVisible) then
  762. CompilerMessageWindow^.Show;
  763. CompilerMessageWindow^.MakeFirst;}
  764. CompilerMessageWindow^.ClearMessages;
  765. { Tell why we compile }
  766. NeedRecompile(Mode,true);
  767. MainFile:=FileName;
  768. SetStatus('Writing switches to file...');
  769. WriteSwitches(SwitchesPath);
  770. { leaving open browsers leads to crashes !! (PM) }
  771. SetStatus('Preparing symbol info...');
  772. CloseAllBrowsers;
  773. if ((DesktopFileFlags and dfSymbolInformation)<>0) then
  774. WriteSymbolsFile(BrowserName);
  775. { MainFile:=FixFileName(FExpand(FileName));}
  776. SetStatus('Preparing to compile...'+NameOf(MainFile));
  777. { Reset }
  778. CtrlBreakHit:=false;
  779. { Create Compiler Status Dialog }
  780. CompilationPhase:=cpCompiling;
  781. if not assigned(CompilingHiddenFile) then
  782. begin
  783. New(CompilerStatusDialog, Init);
  784. CompilerStatusDialog^.SetState(sfModal,true);
  785. { disable window closing }
  786. CompilerStatusDialog^.Flags:=CompilerStatusDialog^.Flags and not wfclose;
  787. Application^.Insert(CompilerStatusDialog);
  788. CompilerStatusDialog^.Update;
  789. end;
  790. { Restore dir that could be changed during debugging }
  791. {$I-}
  792. ChDir(StartUpDir);
  793. {$I+}
  794. EatIO;
  795. { hook compiler output }
  796. do_status:=@CompilerStatus;
  797. do_stop:=@CompilerStop;
  798. do_comment:=@CompilerComment;
  799. do_openinputfile:=@CompilerOpenInputFile;
  800. do_getnamedfiletime:=@CompilerGetNamedFileTime;
  801. do_initsymbolinfo:=@InitBrowserCol;
  802. do_donesymbolinfo:=@DoneBrowserCol;
  803. do_extractsymbolinfo:=@CreateBrowserCol;
  804. { Compile ! }
  805. {$ifdef redircompiler}
  806. ChangeRedirOut(FPOutFileName,false);
  807. ChangeRedirError(FPErrFileName,false);
  808. {$endif}
  809. { insert "" around name so that spaces are allowed }
  810. { only supported in compiler after 2000/01/14 PM }
  811. if pos(' ',FileName)>0 then
  812. FileName:='"'+FileName+'"';
  813. if mode=cBuild then
  814. FileName:='-B '+FileName;
  815. { tokens are created and distroed by compiler.compile !! PM }
  816. DoneTokens;
  817. PPasFile:='ppas'+source_info.scriptext;
  818. WUtils.DeleteFile(GetExePath+PpasFile);
  819. SetStatus('Compiling...');
  820. {$ifdef HasSignal}
  821. StoreStopJumpValid:=StopJmpValid;
  822. StoreStopJmp:=StopJmp;
  823. {$endif HasSignal}
  824. StoreExitProc:=ExitProc;
  825. {$ifdef HasSignal}
  826. StopJmpValid:=true;
  827. JmpRet:=SetJmp(StopJmp);
  828. {$else}
  829. JmpRet:=0;
  830. {$endif HasSignal}
  831. if JmpRet=0 then
  832. begin
  833. inc(CompileStamp);
  834. ResetErrorMessages;
  835. {$ifndef NODEBUG}
  836. MustRestartDebugger:=false;
  837. if assigned(Debugger) then
  838. if Debugger^.HasExe then
  839. begin
  840. Debugger^.Reset;
  841. MustRestartDebugger:=true;
  842. end;
  843. {$endif NODEBUG}
  844. FpIntF.Compile(FileName,SwitchesPath);
  845. SetStatus('Finished compiling...');
  846. end
  847. else
  848. begin
  849. { We need to restore Exitproc to the value
  850. it was before calling FPintF.compile PM }
  851. ExitProc:=StoreExitProc;
  852. Inc(status.errorCount);
  853. {$ifdef HasSignal}
  854. Case JmpRet of
  855. LONGJMPCALLED : s:='Error';
  856. SIGINT : s := 'Interrupted by Ctrl-C';
  857. SIGILL : s := 'Illegal instruction';
  858. SIGSEGV : s := 'Signal Segmentation violation';
  859. SIGFPE : s:='Floating point signal';
  860. else
  861. s:='Undetermined signal '+inttostr(JmpRet);
  862. end;
  863. CompilerMessageWindow^.AddMessage(V_error,s+' during compilation','',0,0);
  864. {$endif HasSignal}
  865. if JmpRet<>LONGJMPCALLED then
  866. begin
  867. CompilerMessageWindow^.AddMessage(V_error,'Long jumped out of compilation...','',0,0);
  868. SetStatus('Long jumped out of compilation...');
  869. end;
  870. end;
  871. {$ifdef HasSignal}
  872. StopJmpValid:=StoreStopJumpValid;
  873. StopJmp:=StoreStopJmp;
  874. {$endif HasSignal}
  875. { Retrieve created exefile }
  876. If GetEXEPath<>'' then
  877. EXEFile:=FixFileName(GetEXEPath+NameOf(MainFile)+GetTargetExeExt)
  878. else
  879. EXEFile:=DirOf(MainFile)+NameOf(MainFile)+GetTargetExeExt;
  880. { tokens are created and distroyed by compiler.compile !! PM }
  881. InitTokens;
  882. if LinkAfter and
  883. ExistsFile(GetExePath+PpasFile) and
  884. (CompilationPhase<>cpAborted) and
  885. (status.errorCount=0) then
  886. begin
  887. CompilationPhase:=cpLinking;
  888. if assigned(CompilerStatusDialog) then
  889. CompilerStatusDialog^.Update;
  890. SetStatus('Assembling and/or linking...');
  891. {$ifndef redircompiler}
  892. { At least here we want to catch output
  893. of batch file PM }
  894. ChangeRedirOut(FPOutFileName,false);
  895. ChangeRedirError(FPErrFileName,false);
  896. {$endif}
  897. {$ifdef Unix}
  898. {$ifdef ver1_0}
  899. Shell(GetExePath+PpasFile);
  900. Error:=LinuxError;
  901. {$else}
  902. error:=0;
  903. If Shell(GetExePath+PpasFile)=-1 Then
  904. Error:=fpgeterrno;
  905. {$endif}
  906. {$else}
  907. DosExecute(GetEnv('COMSPEC'),'/C '+GetExePath+PpasFile);
  908. Error:=DosError;
  909. {$endif}
  910. SetStatus('Finished linking...');
  911. RestoreRedirOut;
  912. RestoreRedirError;
  913. if Error<>0 then
  914. Inc(status.errorCount);
  915. if Status.IsExe and not Status.IsLibrary and not ExistsFile(EXEFile) then
  916. begin
  917. Inc(status.errorCount);
  918. ClearFormatParams; AddFormatParamStr(ExeFile);
  919. CompilerMessageWindow^.AddMessage(V_error,FormatStrF(msg_couldnotcreatefile,FormatParams),'',0,0);
  920. {$I-}
  921. Assign(ErrFile,FPErrFileName);
  922. Reset(ErrFile);
  923. if EatIO<>0 then
  924. ErrorBox(FormatStrStr(msg_cantopenfile,FPErrFileName),nil)
  925. else
  926. begin
  927. LinkErrorCount:=0;
  928. While not eof(ErrFile) and (LinkErrorCount<25) do
  929. begin
  930. readln(ErrFile,s);
  931. CompilerMessageWindow^.AddMessage(V_error,s,'',0,0);
  932. inc(LinkErrorCount);
  933. end;
  934. if not eof(ErrFile) then
  935. begin
  936. ClearFormatParams; AddFormatParamStr(FPErrFileName);
  937. CompilerMessageWindow^.AddMessage(V_error,
  938. FormatStrF(msg_therearemoreerrorsinfile,FormatParams),'',0,0);
  939. end;
  940. Close(ErrFile);
  941. end;
  942. EatIO;
  943. {$I+}
  944. end
  945. else if error=0 then
  946. WUtils.DeleteFile(GetExePath+PpasFile);
  947. end;
  948. {$ifdef redircompiler}
  949. RestoreRedirOut;
  950. RestoreRedirError;
  951. {$endif}
  952. PopStatus;
  953. { Set end status }
  954. if not (CompilationPhase in [cpAborted,cpFailed]) then
  955. if (status.errorCount=0) then
  956. begin
  957. CompilationPhase:=cpDone;
  958. LastCompileTime := cardinal(Now);
  959. end
  960. else
  961. CompilationPhase:=cpFailed;
  962. { Show end status }
  963. { reenable window closing }
  964. if assigned(CompilerStatusDialog) then
  965. begin
  966. CompilerStatusDialog^.Flags:=CompilerStatusDialog^.Flags or wfclose;
  967. CompilerStatusDialog^.Update;
  968. CompilerStatusDialog^.ReDraw;
  969. CompilerStatusDialog^.SetState(sfModal,false);
  970. if ((CompilationPhase in [cpAborted,cpDone,cpFailed]) or (ShowStatusOnError))
  971. and ((Mode<>cRun) or (CompilationPhase<>cpDone)) then
  972. repeat
  973. CompilerStatusDialog^.GetEvent(E);
  974. if IsExitEvent(E)=false then
  975. CompilerStatusDialog^.HandleEvent(E);
  976. until IsExitEvent(E) or not assigned(CompilerStatusDialog);
  977. {if IsExitEvent(E) then
  978. Application^.PutEvent(E);}
  979. if assigned(CompilerStatusDialog) then
  980. begin
  981. Application^.Delete(CompilerStatusDialog);
  982. Dispose(CompilerStatusDialog, Done);
  983. end;
  984. end;
  985. CompilerStatusDialog:=nil;
  986. { end compilation returns true if the messagewindow should be removed }
  987. if CompilationPhase=cpDone then
  988. begin
  989. CompilerMessageWindow^.Hide;
  990. { This is the last compiled main file }
  991. PrevMainFile:=MainFile;
  992. MainHasDebugInfo:=DebugInfoSwitches^.GetCurrSelParam<>'-';
  993. end;
  994. { Update the app }
  995. Message(Application,evCommand,cmUpdate,nil);
  996. DummyView:=Desktop^.First;
  997. while (DummyView<>nil) and (DummyView^.GetState(sfVisible)=false) do
  998. begin
  999. DummyView:=DummyView^.NextView;
  1000. end;
  1001. with DummyView^ do
  1002. if GetState(sfVisible) then
  1003. begin
  1004. SetState(sfSelected,false);
  1005. SetState(sfSelected,true);
  1006. end;
  1007. if Assigned(CompilerMessageWindow) then
  1008. with CompilerMessageWindow^ do
  1009. begin
  1010. if GetState(sfVisible) then
  1011. begin
  1012. SetState(sfSelected,false);
  1013. SetState(sfSelected,true);
  1014. end;
  1015. if (status.errorCount>0) then
  1016. MsgLB^.SelectFirstError;
  1017. end;
  1018. { ^^^ we need this trick to reactivate the desktop }
  1019. EditorModified:=false;
  1020. {$ifndef NODEBUG}
  1021. if MustRestartDebugger then
  1022. InitDebugger;
  1023. {$endif NODEBUG}
  1024. { In case we have something that the compiler touched }
  1025. AskToReloadAllModifiedFiles;
  1026. { Try to read Browser info in again if compilation failure !! }
  1027. if Not Assigned(Modules) and (CompilationPhase<>cpDone) and
  1028. ((DesktopFileFlags and dfSymbolInformation)<>0) then
  1029. ReadSymbolsFile(BrowserName);
  1030. if UseAllUnitsInCodeComplete and not assigned(CompilingHiddenFile) then
  1031. AddAvailableUnitsToCodeComplete(false);
  1032. end;
  1033. function NeedRecompile(Mode :TCompileMode; verbose : boolean): boolean;
  1034. var Need: boolean;
  1035. I: sw_integer;
  1036. SF: PSourceFile;
  1037. SourceTime,PPUTime,ObjTime: longint;
  1038. W: PSourceWindow;
  1039. begin
  1040. if Assigned(SourceFiles)=false then
  1041. Need:={(EditorModified=true)}true
  1042. else
  1043. begin
  1044. Need:=(PrevMainFile<>GetMainFile(Mode)) and (PrevMainFile<>'');
  1045. if Need then
  1046. begin
  1047. if verbose then
  1048. begin
  1049. ClearFormatParams; AddFormatParamStr(GetMainFile(Mode));
  1050. CompilerMessageWindow^.AddMessage(V_info,
  1051. FormatStrF(msg_firstcompilationof,FormatParams),
  1052. '',0,0);
  1053. end;
  1054. end
  1055. else
  1056. for I:=0 to SourceFiles^.Count-1 do
  1057. begin
  1058. SF:=SourceFiles^.At(I);
  1059. SourceTime:=GetFileTime(SF^.GetSourceFileName);
  1060. PPUTime:=GetFileTime(SF^.GetPPUFileName);
  1061. ObjTime:=GetFileTime(SF^.GetObjFileName);
  1062. { writeln('S: ',SF^.GetSourceFileName,' - ',SourceTime);
  1063. writeln('P: ',SF^.GetPPUFileName,' - ',PPUTime);
  1064. writeln('O: ',SF^.GetObjFileName,' - ',ObjTime);
  1065. writeln('------');}
  1066. { some units don't generate object files }
  1067. W:=EditorWindowFile(SF^.GetSourceFileName);
  1068. if (SourceTime<>-1) then
  1069. if ((SourceTime>PPUTime) or
  1070. ((SourceTime>ObjTime) and
  1071. (ObjTime<>-1))) or
  1072. (assigned(W) and (W^.Editor^.CompileStamp<0)) then
  1073. begin
  1074. Need:=true;
  1075. if verbose then
  1076. begin
  1077. ClearFormatParams; AddFormatParamStr(SF^.GetSourceFileName);
  1078. CompilerMessageWindow^.AddMessage(V_info,
  1079. FormatStrF(msg_recompilingbecauseof,FormatParams),
  1080. SF^.GetSourceFileName,1,1);
  1081. end;
  1082. Break;
  1083. end;
  1084. end;
  1085. { writeln('Need?', Need); system.readln;}
  1086. end;
  1087. NeedRecompile:=Need;
  1088. end;
  1089. constructor TFPInputFile.Create(AEditor: PFileEditor);
  1090. begin
  1091. if not Assigned(AEditor) then Fail;
  1092. if inherited Create(AEditor^.FileName)=nil then
  1093. Fail;
  1094. Editor:=AEditor;
  1095. end;
  1096. function TFPInputFile.fileopen(const filename: string): boolean;
  1097. var OK: boolean;
  1098. begin
  1099. S:=New(PMemoryStream, Init(0,0));
  1100. OK:=Assigned(S) and (S^.Status=stOK);
  1101. if OK then OK:=Editor^.SaveToStream(S);
  1102. if OK then
  1103. S^.Seek(0)
  1104. else
  1105. begin
  1106. if Assigned(S) then Dispose(S, Done);
  1107. S:=nil;
  1108. end;
  1109. fileopen:=OK;
  1110. end;
  1111. function TFPInputFile.fileseek(pos: longint): boolean;
  1112. var OK: boolean;
  1113. begin
  1114. OK:=assigned(S);
  1115. if OK then
  1116. begin
  1117. S^.Reset;
  1118. S^.Seek(pos);
  1119. OK:=(S^.Status=stOK);
  1120. end;
  1121. fileseek:=OK;
  1122. end;
  1123. function TFPInputFile.fileread(var databuf; maxsize: longint): longint;
  1124. var
  1125. size: longint;
  1126. begin
  1127. if not assigned(S) then size:=0 else
  1128. begin
  1129. size:=min(maxsize,(S^.GetSize-S^.GetPos));
  1130. S^.Read(databuf,size);
  1131. if S^.Status<>stOK then size:=0;
  1132. end;
  1133. fileread:=size;
  1134. end;
  1135. function TFPInputFile.fileeof: boolean;
  1136. var EOF: boolean;
  1137. begin
  1138. EOF:=not assigned(S);
  1139. if not EOF then
  1140. EOF:=(S^.Status<>stOK) or (S^.GetPos=S^.GetSize);
  1141. fileeof:=EOF;
  1142. end;
  1143. function TFPInputFile.fileclose: boolean;
  1144. var OK: boolean;
  1145. begin
  1146. OK:=assigned(S);
  1147. if OK then
  1148. begin
  1149. S^.Reset;
  1150. Dispose(S, Done);
  1151. S:=nil;
  1152. OK:=true;
  1153. end;
  1154. fileclose:=OK;
  1155. end;
  1156. procedure RegisterFPCompile;
  1157. begin
  1158. {$ifndef NOOBJREG}
  1159. RegisterType(RCompilerMessageListBox);
  1160. RegisterType(RCompilerMessageWindow);
  1161. {$endif}
  1162. end;
  1163. end.
  1164. {
  1165. $Log$
  1166. Revision 1.34 2005-01-08 12:05:13 florian
  1167. * user screen parsing fixed
  1168. Revision 1.33 2004/11/22 19:34:58 peter
  1169. * GetHeapStatus added, removed MaxAvail,MemAvail,HeapSize
  1170. Revision 1.32 2004/11/20 14:21:19 florian
  1171. * implemented reload menu item
  1172. * increased file history to 9 files
  1173. Revision 1.31 2004/11/20 10:18:41 florian
  1174. * reduced status updates by making them time dependend
  1175. Revision 1.30 2004/11/14 21:45:28 florian
  1176. * fixed non working mouse after tools call
  1177. * better handling of source/target info
  1178. * more info in about dialog
  1179. * better info in compiler status dialiog
  1180. Revision 1.29 2004/11/08 20:28:26 peter
  1181. * Breakpoints are now deleted when removed from source, disabling is
  1182. still possible from the breakpoint list
  1183. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  1184. FV and 1.9.x compilers
  1185. * Run directory added to Run menu
  1186. * Useless programinfo window removed
  1187. Revision 1.28 2004/11/06 22:02:48 peter
  1188. * fixed resize helptext
  1189. Revision 1.27 2004/11/06 17:22:52 peter
  1190. * fixes for new fv
  1191. Revision 1.26 2004/11/05 00:00:33 peter
  1192. set exefile after compilation, before the target_info is not filled
  1193. Revision 1.25 2004/11/02 23:53:19 peter
  1194. * fixed crashes with ide and 1.9.x
  1195. Revision 1.24 2004/09/09 20:33:00 jonas
  1196. * made CompilerStop declaration compliant to new tstopprocedure type in
  1197. compiler
  1198. Revision 1.23 2003/11/14 17:29:38 marco
  1199. * linuxerrorcide
  1200. Revision 1.22 2003/03/28 09:55:46 armin
  1201. * Fixed TCompilerMessageWindow.AddMessage to see line numbers with 1.1
  1202. Revision 1.21 2003/03/27 14:11:53 pierre
  1203. * fix problem in CompilerComment procedure
  1204. Revision 1.20 2003/01/13 09:05:18 pierre
  1205. * fix error in last commit
  1206. Revision 1.19 2003/01/11 15:52:54 peter
  1207. * adapted for new 1.1 compiler verbosity
  1208. Revision 1.18 2002/12/02 13:58:29 pierre
  1209. * avoid longjmp messages if quitting after compilation error
  1210. Revision 1.17 2002/11/20 17:35:00 pierre
  1211. * use target_os.ExeExt for compiled executable
  1212. Revision 1.16 2002/10/23 19:19:40 hajny
  1213. * another bunch of missing HasSignal conditionals
  1214. Revision 1.15 2002/09/26 15:00:35 pierre
  1215. * fix problems with system unit is not present for __fp__ compilation
  1216. Revision 1.14 2002/09/13 22:30:50 pierre
  1217. * only fpc uses video unit
  1218. Revision 1.13 2002/09/09 06:53:54 pierre
  1219. * avoid to save file used by codecomplete
  1220. Revision 1.12 2002/09/07 15:40:42 peter
  1221. * old logs removed and tabs fixed
  1222. Revision 1.11 2002/09/05 08:45:40 pierre
  1223. * try to fix recompilation on changes problems
  1224. Revision 1.10 2002/09/04 14:07:12 pierre
  1225. + Enhance code complete by inserting unit symbols
  1226. Revision 1.9 2002/08/26 13:03:14 pierre
  1227. + add a lock to speed up parsing of userscreen
  1228. Revision 1.8 2002/04/10 22:37:37 pierre
  1229. * save and restore Exitproc if LongJmp called
  1230. Revision 1.7 2002/03/20 14:48:27 pierre
  1231. * moved StopJmp buffer to fpcatch unit
  1232. }