Ignore:
Timestamp:
Jun 5, 2023, 6:44:57 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Updated Common package.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormMain.pas

    r144 r145  
    1 unit UFormMain;
     1unit FormMain;
    22
    33interface
    44
    55uses
    6   Classes, SysUtils, FileUtil, Forms, Controls,
    7   Graphics, Dialogs, Menus, ActnList, ComCtrls, ExtCtrls, UTarget, Registry,
    8   URegistry, LazFileUtils;
     6  Classes, SysUtils, FileUtil, Forms, Controls, FormCPU, FormInput,
     7  Graphics, Dialogs, Menus, ActnList, ComCtrls, ExtCtrls, Target, Registry,
     8  LazFileUtils, FormOptions, FormMessages, FormTargets,
     9  FormOutput, FormMemory, FormSourceCode, FormTargetCode, FormLog,
     10  FormCompileMultiple;
    911
    1012type
     
    144146    procedure TimerRefreshTimer(Sender: TObject);
    145147  private
     148    FormCPU: TFormCPU;
     149    FormInput: TFormInput;
     150    FormLog: TFormLog;
     151    FormMemory: TFormMemory;
     152    FormMessages: TFormMessages;
     153    FormOutput: TFormOutput;
     154    FormSourceCode: TFormSourceCode;
     155    FormTargetCode: TFormTargetCode;
    146156    procedure AProjectOpenRecentExecute(Sender: TObject);
    147157    procedure MenuItemTargetClick(Sender: TObject);
     
    151161    procedure DockInit;
    152162    procedure LastOpenedListChange(Sender: TObject);
     163    procedure CurrentTargetChangeExecute(Sender: TObject);
    153164  public
    154165    procedure MessagesChanged(Sender: TObject);
    155166    procedure TargetLogExecute(Lines: TStrings);
    156167    procedure TargetStateChanged(Sender: TObject);
    157     procedure LoadFromRegistry(Context: TRegistryContext);
    158     procedure SaveToRegistry(Context: TRegistryContext);
    159168    procedure UpdateInterface;
    160169    procedure UpdateStatusBar;
     
    162171  end;
    163172
    164 var
    165   FormMain: TFormMain;
    166 
    167173
    168174implementation
     
    171177
    172178uses
    173   UCore, UFormCPU, UFormOptions, UFormMessages, UFormTargets, UFormOutput, UFormInput,
    174   UFormMemory, UFormSourceCode, UFormTargetCode, UTargetInterpretter, UFormLog,
    175   UBFTarget, UCommon, UFormCompileMultiple;
     179  Core, TargetInterpretter, BFTarget, Common;
    176180
    177181resourcestring
     
    195199procedure TFormMain.FormShow(Sender: TObject);
    196200begin
    197   Core.Init;
    198   LoadFromRegistry(Core.ApplicationInfo.GetRegistryContext);
     201  Core.Core.Init;
    199202  PageControlMain.TabIndex := 0;
    200203  try
    201     if Core.OpenProjectOnStart and (Core.LastOpenedList.Items.Count > 0) and
    202       FileExists(Core.LastOpenedList.Items[0]) then
    203       ProjectOpen(Core.LastOpenedList.Items[0])
     204    if Core.Core.OpenProjectOnStart and (Core.Core.LastOpenedList.Items.Count > 0) and
     205      FileExists(Core.Core.LastOpenedList.Items[0]) then
     206      ProjectOpen(Core.Core.LastOpenedList.Items[0])
    204207      else AProjectNew.Execute;
    205208  finally
     
    209212    UpdateTargetList;
    210213    DockInit;
    211     Core.PersistentForm1.Load(Self, True);
    212     Core.ThemeManager.UseTheme(Self);
     214    Core.Core.PersistentForm1.Load(Self, True);
     215    Core.Core.ThemeManager.UseTheme(Self);
    213216    FormSourceCode.UpdateTheme;
    214217  end;
    215   Core.Messages.OnChange := FormMain.MessagesChanged;
     218  Core.Core.Messages.OnChange := MessagesChanged;
    216219end;
    217220
     
    232235begin
    233236  UpdateInterface;
    234   if Core.CurrentTarget.State = rsPaused then
     237  if Core.Core.CurrentTarget.State = rsPaused then
    235238    AProgramShowExecutionPoint.Execute;
    236   if Core.CurrentTarget.State = rsStopped then
    237     Core.Messages.AddMessage(SProgramStopped);
     239  if Core.Core.CurrentTarget.State = rsStopped then
     240    Core.Core.Messages.AddMessage(SProgramStopped);
    238241end;
    239242
     
    249252  if Sender is TMenuItem then
    250253  with TMenuItem(Sender) do begin
    251     Core.CurrentTarget := TTarget(Core.Targets[MenuIndex]);
     254    Core.Core.CurrentTarget := Core.Core.Targets[MenuIndex];
    252255    Checked := True;
    253256    for I := 0 to Parent.Count - 1 do
     
    258261procedure TFormMain.ProjectOpen(FileName: string);
    259262begin
    260   if Core.Project.Openned then
    261     raise Exception.Create(SCloseProjectFirst);
    262   FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName);
    263   Core.AddItemToLastOpenedList(FileName);
    264   Core.Project.FileName := FileName;
    265   Core.Project.Openned := True;
    266   Core.CurrentTarget.Compiled := False;
     263  with Core.Core do begin
     264    if Project.Openned then
     265      raise Exception.Create(SCloseProjectFirst);
     266    FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName);
     267    AddItemToLastOpenedList(FileName);
     268    Project.FileName := FileName;
     269    Project.Openned := True;
     270    CurrentTarget.Compiled := False;
     271  end;
    267272  UpdateInterface;
    268273end;
     
    292297  DockForm(FormMemory, PanelMemory);
    293298  DockForm(FormMessages, TabSheetMessages);
    294   PageControlRight.Width := FormMain.Width div 3;
    295   PageControlBottom.Height := FormMain.Height div 5;
     299  PageControlRight.Width := Width div 3;
     300  PageControlBottom.Height := Height div 5;
    296301end;
    297302
    298303procedure TFormMain.LastOpenedListChange(Sender: TObject);
    299304begin
    300   Core.LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute);
    301   Core.LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute);
    302 end;
    303 
    304 procedure TFormMain.LoadFromRegistry(Context: TRegistryContext);
    305 var
    306   TargetName: string;
    307 begin
    308   with TRegistryEx.Create do
    309   try
    310     CurrentContext := Context;
    311     TargetName := ReadStringWithDefault('TargetName', 'Interpretter');
    312     Core.CurrentTarget := Core.Targets.FindByName(TargetName);
    313     if not Assigned(Core.CurrentTarget) then
    314       Core.CurrentTarget := TTarget(Core.Targets[0]);
    315     Core.Optimizations.AddSub := ReadBoolWithDefault('OptimizationAddSubEnabled', True);
    316     Core.Optimizations.SetZero := ReadBoolWithDefault('OptimizationSetZeroEnabled', True);
    317     Core.Optimizations.Merge := ReadBoolWithDefault('OptimizationMerge', True);
    318     Core.Optimizations.CopyMultiply := ReadBoolWithDefault('OptimizationCopyMultiplyEnabled', True);
    319     Core.Optimizations.RelativeIndexes := ReadBoolWithDefault('OptimizationRelativeIndexesEnabled', True);
    320   finally
    321     Free;
    322   end;
    323 end;
    324 
    325 procedure TFormMain.SaveToRegistry(Context: TRegistryContext);
    326 begin
    327   with TRegistryEx.Create do
    328   try
    329     CurrentContext := Context;
    330     WriteString('TargetName', Core.CurrentTarget.Name);
    331     WriteBool('OptimizationAddSubEnabled', Core.Optimizations.AddSub);
    332     WriteBool('OptimizationSetZeroEnabled', Core.Optimizations.SetZero);
    333     WriteBool('OptimizationMerge', Core.Optimizations.Merge);
    334     WriteBool('OptimizationCopyMultiplyEnabled', Core.Optimizations.CopyMultiply);
    335     WriteBool('OptimizationRelativeIndexesEnabled', Core.Optimizations.RelativeIndexes);
    336   finally
    337     Free;
    338   end;
     305  Core.Core.LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute);
     306  Core.Core.LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute);
     307end;
     308
     309procedure TFormMain.CurrentTargetChangeExecute(Sender: TObject);
     310begin
     311  UpdateTargetList;
     312  UpdateInterface;
    339313end;
    340314
     
    345319begin
    346320  Title := '';
    347   if Core.Project.FileName <> '' then Title := Core.Project.FileName;
    348   if Core.Project.Modified then Title := Title + ' (' + SChanged + ')';
    349   Title:= Title + ' - ' + Core.ApplicationInfo.AppName;
    350   Caption := Title;
    351   AProjectSave.Enabled := Core.Project.Modified;
    352   FormSourceCode.SynEditSource.Enabled := Core.Project.Openned;
    353   AProjectClose.Enabled := Core.Project.Openned;
    354   AProjectSaveAs.Enabled := Core.Project.Openned;
    355   AProgramRun.Enabled := (tcRun in Core.CurrentTarget.Capabilities) and
    356     Core.Project.Openned and (Core.CurrentTarget.State = rsStopped) or (Core.CurrentTarget.State = rsPaused);
    357   AProgramPause.Enabled := (tcPause in Core.CurrentTarget.Capabilities) and
    358     Core.Project.Openned and (Core.CurrentTarget.State = rsRunning);
    359   AProgramStop.Enabled := (tcStop in Core.CurrentTarget.Capabilities) and
    360     Core.Project.Openned and (Core.CurrentTarget.State <> rsStopped);
    361   AProgramCompile.Enabled := (tcCompile in Core.CurrentTarget.Capabilities) and
    362     Core.Project.Openned;
    363   CanDebug := Core.DebugEnabled and Core.Project.Openned and
    364     ((Core.CurrentTarget.State = rsPaused) or (Core.CurrentTarget.State = rsStopped));
    365   AProgramStepInto.Enabled := CanDebug and (tcStepInto in Core.CurrentTarget.Capabilities);
    366   AProgramStepOut.Enabled := CanDebug and (tcStepOut in Core.CurrentTarget.Capabilities);
    367   AProgramRunToCursor.Enabled := CanDebug and (tcRunToCursor in Core.CurrentTarget.Capabilities);
    368   AProgramStepOver.Enabled := CanDebug and (tcStepOver in Core.CurrentTarget.Capabilities);
    369   AProgramShowExecutionPoint.Enabled := CanDebug and (tcPause in Core.CurrentTarget.Capabilities);
    370   AShowSourcePosition.Enabled := Core.CurrentTarget.Compiled;
    371   AShowTargetPosition.Enabled := Core.CurrentTarget.Compiled;
     321  with Core.Core do begin
     322    if Project.FileName <> '' then Title := Project.FileName;
     323    if Project.Modified then Title := Title + ' (' + SChanged + ')';
     324    Title:= Title + ' - ' + ApplicationInfo.AppName;
     325    Caption := Title;
     326    AProjectSave.Enabled := Project.Modified;
     327    FormSourceCode.SynEditSource.Enabled := Project.Openned;
     328    AProjectClose.Enabled := Project.Openned;
     329    AProjectSaveAs.Enabled := Project.Openned;
     330    AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and
     331      Project.Openned and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused);
     332    AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and
     333      Project.Openned and (CurrentTarget.State = rsRunning);
     334    AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and
     335      Project.Openned and (CurrentTarget.State <> rsStopped);
     336    AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and
     337      Project.Openned;
     338    CanDebug := DebugEnabled and Project.Openned and
     339      ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
     340    AProgramStepInto.Enabled := CanDebug and (tcStepInto in CurrentTarget.Capabilities);
     341    AProgramStepOut.Enabled := CanDebug and (tcStepOut in CurrentTarget.Capabilities);
     342    AProgramRunToCursor.Enabled := CanDebug and (tcRunToCursor in CurrentTarget.Capabilities);
     343    AProgramStepOver.Enabled := CanDebug and (tcStepOver in CurrentTarget.Capabilities);
     344    AProgramShowExecutionPoint.Enabled := CanDebug and (tcPause in CurrentTarget.Capabilities);
     345    AShowSourcePosition.Enabled := CurrentTarget.Compiled;
     346    AShowTargetPosition.Enabled := CurrentTarget.Compiled;
     347  end;
    372348  UpdateStatusBar;
    373349end;
     
    383359  I: Integer;
    384360begin
    385   Core.Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick, Core.CurrentTarget);
    386   Core.Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick, Core.CurrentTarget);
     361  Core.Core.Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick, Core.Core.CurrentTarget);
     362  Core.Core.Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick, Core.Core.CurrentTarget);
    387363
    388364  // Update toolbutton
    389   I := Core.Targets.IndexOf(Core.CurrentTarget);
     365  I := Core.Core.Targets.IndexOf(Core.Core.CurrentTarget);
    390366  if I <> -1 then
    391   with TTarget(Core.Targets[I]) do begin
     367  with TTarget(Core.Core.Targets[I]) do begin
    392368    ToolButtonTarget.ImageIndex := ImageIndex;
    393369    ToolButtonTarget.Caption := Name;
     
    398374procedure TFormMain.FormCreate(Sender: TObject);
    399375begin
     376  Core.Core.Translator.TranslateComponentRecursive(Self);
     377  Core.Core.ThemeManager.UseTheme(Self);
     378
     379  FormSourceCode := TFormSourceCode.Create(nil);
     380  FormCPU := TFormCPU.Create(nil);
     381  FormInput := TFormInput.Create(nil);
     382  FormLog := TFormLog.Create(nil);
     383  FormMemory := TFormMemory.Create(nil);
     384  FormMessages := TFormMessages.Create(nil);
     385  FormOutput := TFormOutput.Create(nil);
     386  FormTargetCode := TFormTargetCode.Create(nil);
     387
    400388  UpdateTargetList;
    401   Core.LastOpenedList.OnChange := LastOpenedListChange;
     389  with Core.Core do begin
     390    LastOpenedList.OnChange := LastOpenedListChange;
     391    OnCurrentTargetChange := CurrentTargetChangeExecute;
     392    OnTargetChangeState := TargetStateChanged;
     393    OnTargetLog := TargetLogExecute;
     394  end;
    402395end;
    403396
    404397procedure TFormMain.FormDestroy(Sender: TObject);
    405398begin
    406   SaveToRegistry(Core.ApplicationInfo.GetRegistryContext);
     399  FreeAndNil(FormSourceCode);
     400  FreeAndNil(FormCPU);
     401  FreeAndNil(FormInput);
     402  FreeAndNil(FormLog);
     403  FreeAndNil(FormMemory);
     404  FreeAndNil(FormMessages);
     405  FreeAndNil(FormOutput);
     406  FreeAndNil(FormTargetCode);
    407407end;
    408408
    409409procedure TFormMain.AProgramRunExecute(Sender: TObject);
    410410begin
    411   if Core.CurrentTarget is TTargetInterpretter then
    412     TTargetInterpretter(Core.CurrentTarget).Input := FormInput.MemoInput.Lines.Text;
    413   if not Core.CurrentTarget.Compiled then AProgramCompile.Execute;
    414   Core.CurrentTarget.Run;
    415   Core.Messages.AddMessage(SProgramStarted);
     411  if Core.Core.CurrentTarget is TTargetInterpretter then
     412    TTargetInterpretter(Core.Core.CurrentTarget).Input := FormInput.MemoInput.Lines.Text;
     413  if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
     414  Core.Core.CurrentTarget.Run;
     415  Core.Core.Messages.AddMessage(SProgramStarted);
    416416end;
    417417
     
    420420  DebugStep: TDebugStep;
    421421begin
    422   DebugStep := Core.CurrentTarget.DebugSteps.SearchByTargetPos(FormTargetCode.SynEditTarget.SelStart - 1);
     422  DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByTargetPos(FormTargetCode.SynEditTarget.SelStart - 1);
    423423  if Assigned(DebugStep) then begin
    424424    FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1;
     
    431431  DebugStep: TDebugStep;
    432432begin
    433   DebugStep := Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
     433  DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
    434434  if Assigned(DebugStep) then begin
    435435    FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1;
     
    461461procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    462462begin
    463   Core.PersistentForm1.Save(Self);
     463  Core.Core.PersistentForm1.Save(Self);
     464  Application.Terminate;
    464465end;
    465466
    466467procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
    467468begin
    468   if Core.Project.Modified then begin
     469  if Core.Core.Project.Modified then begin
    469470    AProjectClose.Execute;
    470     if Core.Project.Openned then CanClose := False;
     471    if Core.Core.Project.Openned then CanClose := False;
    471472  end;
    472473end;
     
    478479
    479480procedure TFormMain.AOptionsExecute(Sender: TObject);
     481var
     482  FormOptions: TFormOptions;
    480483begin
    481484  FormOptions := TFormOptions.Create(nil);
     
    484487    if FormOptions.ShowModal = mrOK then begin
    485488      FormOptions.Save;
    486       if Assigned(Core.CurrentTarget) then begin
    487         Core.CurrentTarget.OptimizationLevel := Core.OptimizationLevel;
    488         if Core.CurrentTarget is TBFTarget then begin
    489           TBFTarget(Core.CurrentTarget).CellSize := Core.CellSize;
    490           TBFTarget(Core.CurrentTarget).MemorySize := Core.MemorySize;
     489      if Assigned(Core.Core.CurrentTarget) then begin
     490        Core.Core.CurrentTarget.OptimizationLevel := Core.Core.OptimizationLevel;
     491        if Core.Core.CurrentTarget is TBFTarget then begin
     492          TBFTarget(Core.Core.CurrentTarget).CellSize := Core.Core.CellSize;
     493          TBFTarget(Core.Core.CurrentTarget).MemorySize := Core.Core.MemorySize;
    491494        end;
    492495      end;
    493       Core.ThemeManager.UseTheme(Self);
     496      Core.Core.ThemeManager.UseTheme(Self);
    494497      FormSourceCode.UpdateTheme;
    495       Core.SaveToRegistry(Core.ApplicationInfo.GetRegistryContext);
    496       SaveToRegistry(Core.ApplicationInfo.GetRegistryContext);
     498      Core.Core.SaveToRegistry(Core.Core.ApplicationInfo.GetRegistryContext);
    497499    end;
    498500  finally
     
    503505procedure TFormMain.AProgramCompileExecute(Sender: TObject);
    504506begin
    505   with Core.CurrentTarget do
     507  with Core.Core, CurrentTarget do
    506508  try
    507     Core.Messages.Clear;
     509    Messages.Clear;
    508510    AProgramStop.Execute;
    509511    SourceCode := FormSourceCode.SynEditSource.Text;
    510     ProjectFileName := Core.Project.FileName;
    511     ProgramName := ExtractFileNameOnly(Core.Project.FileName);
    512     if Core.CurrentTarget is TBFTarget then
    513       TBFTarget(Core.CurrentTarget).Optimizations := Core.Optimizations;
    514     DebugEnabled := Core.DebugEnabled;
    515     Core.Messages.AddMessage(SCompileStart);
     512    ProjectFileName := Project.FileName;
     513    ProgramName := ExtractFileNameOnly(Project.FileName);
     514    if CurrentTarget is TBFTarget then
     515      TBFTarget(CurrentTarget).Optimizations := Optimizations;
     516    DebugEnabled := DebugEnabled;
     517    Messages.AddMessage(SCompileStart);
    516518    Application.ProcessMessages;
    517519    Compile;
    518     Core.Messages.AppendMessage(SDone);
     520    Messages.AppendMessage(SDone);
    519521    FormTargetCode.SynEditTarget.Text := TargetCode;
    520     FormTargetCode.SetHighlighter(Core.CurrentTarget.SourceExtension);
     522    FormTargetCode.SetHighlighter(CurrentTarget.SourceExtension);
    521523    UpdateInterface;
    522524  except
     
    533535  with TFormCompileMultiple.Create(nil) do
    534536  try
    535     Targets := Core.Targets;
     537    Targets := Core.Core.Targets;
    536538    if ShowModal = mrOk then begin
    537       Core.Messages.Clear;
     539      Core.Core.Messages.Clear;
    538540      for I := 0 to Targets.Count - 1 do
    539541      with Targets[I] do
     
    542544        AProgramStop.Execute;
    543545        SourceCode := FormSourceCode.SynEditSource.Text;
    544         ProjectFileName := Core.Project.FileName;
    545         ProgramName := ExtractFileNameOnly(Core.Project.FileName);
     546        ProjectFileName := Core.Core.Project.FileName;
     547        ProgramName := ExtractFileNameOnly(Core.Core.Project.FileName);
    546548        if Targets[I] is TBFTarget then
    547           TBFTarget(Targets[I]).Optimizations := Core.Optimizations;
    548         DebugEnabled := Core.DebugEnabled;
    549         Core.Messages.AddMessage(Name + ' ' + SCompileStart);
     549          TBFTarget(Targets[I]).Optimizations := Core.Core.Optimizations;
     550        DebugEnabled := Core.Core.DebugEnabled;
     551        Core.Core.Messages.AddMessage(Name + ' ' + SCompileStart);
    550552        Application.ProcessMessages;
    551553        Compile;
    552         Core.Messages.AppendMessage(SDone);
     554        Core.Core.Messages.AppendMessage(SDone);
    553555        FormTargetCode.SynEditTarget.Text := TargetCode;
    554         FormTargetCode.SetHighlighter(Core.CurrentTarget.SourceExtension);
     556        FormTargetCode.SetHighlighter(Core.Core.CurrentTarget.SourceExtension);
    555557        UpdateInterface;
    556558      except
     
    569571  BreakPoint: TBreakPoint;
    570572begin
    571   DebugStep := Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
     573  DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
    572574  if Assigned(DebugStep) then begin
    573     BreakPoint := Core.CurrentTarget.BreakPoints.SearchByTargetPos(DebugStep.ProgramPosition);
     575    BreakPoint := Core.Core.CurrentTarget.BreakPoints.SearchByTargetPos(DebugStep.ProgramPosition);
    574576    if Assigned(BreakPoint) then
    575       Core.CurrentTarget.BreakPoints.Delete(Core.CurrentTarget.BreakPoints.IndexOf(BreakPoint))
    576       else Core.CurrentTarget.BreakPoints.AddItem(DebugStep.ProgramPosition);
     577      Core.Core.CurrentTarget.BreakPoints.Delete(Core.Core.CurrentTarget.BreakPoints.IndexOf(BreakPoint))
     578      else Core.Core.CurrentTarget.BreakPoints.AddItem(DebugStep.ProgramPosition);
    577579  end;
    578580end;
     
    580582procedure TFormMain.AAboutExecute(Sender: TObject);
    581583begin
    582   Core.AboutDialog.Show;
     584  Core.Core.AboutDialog.Show;
    583585end;
    584586
    585587procedure TFormMain.AProgramPauseExecute(Sender: TObject);
    586588begin
    587   Core.CurrentTarget.Pause;
     589  Core.Core.CurrentTarget.Pause;
    588590end;
    589591
     
    592594  DebugStep: TDebugStep;
    593595begin
    594   if Core.CurrentTarget.State = rsStopped then begin
    595     if not Core.CurrentTarget.Compiled then AProgramCompile.Execute;
    596     DebugStep := Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
    597     Core.CurrentTarget.BreakPoints.SetSystem(DebugStep.ProgramPosition);
     596  if Core.Core.CurrentTarget.State = rsStopped then begin
     597    if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
     598    DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
     599    Core.Core.CurrentTarget.BreakPoints.SetSystem(DebugStep.ProgramPosition);
    598600    AProgramRun.Execute;
    599601  end else begin
    600     DebugStep := Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
    601     Core.CurrentTarget.RunToCursor(DebugStep.ProgramPosition);
     602    DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
     603    Core.Core.CurrentTarget.RunToCursor(DebugStep.ProgramPosition);
    602604  end;
    603605end;
     
    607609  DebugStep: TDebugStep;
    608610begin
    609   DebugStep := Core.CurrentTarget.DebugSteps.SearchByProgramPos(Core.CurrentTarget.ExecutionPosition);
     611  DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByProgramPos(
     612    Core.Core.CurrentTarget.ExecutionPosition);
    610613  FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1;
    611614  FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1;
     
    616619procedure TFormMain.AProgramStepIntoExecute(Sender: TObject);
    617620begin
    618   if Core.CurrentTarget.State = rsStopped then begin
    619     if not Core.CurrentTarget.Compiled then AProgramCompile.Execute;
    620     Core.CurrentTarget.BreakPoints.SetSystem(Core.CurrentTarget.DebugSteps.First.ProgramPosition);
     621  if Core.Core.CurrentTarget.State = rsStopped then begin
     622    if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
     623    Core.Core.CurrentTarget.BreakPoints.SetSystem(
     624      Core.Core.CurrentTarget.DebugSteps.First.ProgramPosition);
    621625    AProgramRun.Execute;
    622   end else Core.CurrentTarget.StepInto;
     626  end else Core.Core.CurrentTarget.StepInto;
    623627end;
    624628
    625629procedure TFormMain.AProgramStepOutExecute(Sender: TObject);
    626630begin
    627   Core.CurrentTarget.StepOut;
     631  Core.Core.CurrentTarget.StepOut;
    628632end;
    629633
    630634procedure TFormMain.AProgramStepOverExecute(Sender: TObject);
    631635begin
    632   if Core.CurrentTarget.State = rsStopped then begin
    633     if not Core.CurrentTarget.Compiled then AProgramCompile.Execute;
    634     Core.CurrentTarget.BreakPoints.SetSystem(TDebugStep(Core.CurrentTarget.DebugSteps.First).ProgramPosition);
     636  if Core.Core.CurrentTarget.State = rsStopped then begin
     637    if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
     638    Core.Core.CurrentTarget.BreakPoints.SetSystem(
     639      TDebugStep(Core.Core.CurrentTarget.DebugSteps.First).ProgramPosition);
    635640    AProgramRun.Execute;
    636   end else Core.CurrentTarget.StepOver;
     641  end else Core.Core.CurrentTarget.StepOver;
    637642end;
    638643
    639644procedure TFormMain.AProgramStopExecute(Sender: TObject);
    640645begin
    641   Core.CurrentTarget.Stop;
     646  Core.Core.CurrentTarget.Stop;
    642647end;
    643648
     
    647652begin
    648653  DialogResult := mrNo;
    649   if Core.Project.Modified then begin
     654  if Core.Core.Project.Modified then begin
    650655    DialogResult := MessageDlg(SUnsavedChanges, SDoYouWantToSaveProject, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
    651656    if DialogResult = mrYes then begin
     
    655660  if (DialogResult = mrNo) or (DialogResult = mrYes) then begin
    656661    AProgramStop.Execute;
    657     Core.Project.Openned := False;
     662    Core.Core.Project.Openned := False;
    658663    FormSourceCode.SynEditSource.Clear;
    659664    UpdateInterface;
     
    664669begin
    665670  AProjectClose.Execute;
    666   if Core.Project.Openned then Exit;
    667   Core.Project.FileName := CombinePaths(Core.DataDir, ExamplesDir + DirectorySeparator + SNewProject + '.b');
     671  if Core.Core.Project.Openned then Exit;
     672  Core.Core.Project.FileName := CombinePaths(Core.Core.DataDir, ExamplesDir + DirectorySeparator + SNewProject + '.b');
    668673  FormSourceCode.SynEditSource.Clear;
    669   Core.Project.Openned := True;
    670   Core.CurrentTarget.Compiled := False;
     674  Core.Core.Project.Openned := True;
     675  Core.Core.CurrentTarget.Compiled := False;
    671676  UpdateInterface;
    672677end;
     
    676681  FileName: string;
    677682begin
    678   FileName := Core.LastOpenedList.Items[TMenuItem(Sender).MenuIndex];
     683  FileName := Core.Core.LastOpenedList.Items[TMenuItem(Sender).MenuIndex];
    679684  if FileExists(FileName) then begin
    680685    AProjectClose.Execute;
    681     if Core.Project.Openned then Exit;
     686    if Core.Core.Project.Openned then Exit;
    682687    ProjectOpen(FileName);
    683688  end else ShowMessage(Format(SFileNotFound, [FileName]));
     
    688693  FileName: string;
    689694begin
    690   if Core.LastOpenedList.Items.Count > 0 then
    691     FileName := Core.LastOpenedList.Items[0]
    692     else FileName := CombinePaths(Core.DataDir, ExamplesDir);
     695  if Core.Core.LastOpenedList.Items.Count > 0 then
     696    FileName := Core.Core.LastOpenedList.Items[0]
     697    else FileName := CombinePaths(Core.Core.DataDir, ExamplesDir);
    693698  OpenDialog1.InitialDir := ExtractFileDir(FileName);
    694699  OpenDialog1.FileName := ExtractFileName(FileName);
    695700  if OpenDialog1.Execute then begin
    696701    AProjectClose.Execute;
    697     if Core.Project.Openned then Exit;
     702    if Core.Core.Project.Openned then Exit;
    698703    ProjectOpen(OpenDialog1.FileName);
    699704  end;
     
    702707procedure TFormMain.AProjectSaveAsExecute(Sender: TObject);
    703708begin
    704   SaveDialog1.InitialDir := ExtractFileDir(Core.Project.FileName);
    705   SaveDialog1.FileName := ExtractFileName(Core.Project.FileName);
     709  SaveDialog1.InitialDir := ExtractFileDir(Core.Core.Project.FileName);
     710  SaveDialog1.FileName := ExtractFileName(Core.Core.Project.FileName);
    706711  if SaveDialog1.Execute then begin
    707712    FormSourceCode.SynEditSource.Lines.SaveToFile(SaveDialog1.FileName);
    708     Core.Project.FileName := SaveDialog1.FileName;
    709     Core.AddItemToLastOpenedList(SaveDialog1.FileName);
    710     Core.Project.Modified := False;
     713    Core.Core.Project.FileName := SaveDialog1.FileName;
     714    Core.Core.AddItemToLastOpenedList(SaveDialog1.FileName);
     715    Core.Core.Project.Modified := False;
    711716    UpdateInterface;
    712717  end;
     
    715720procedure TFormMain.AProjectSaveExecute(Sender: TObject);
    716721begin
    717   if Core.Project.Modified and FileExists(Core.Project.FileName) then begin
    718     FormSourceCode.SynEditSource.Lines.SaveToFile(Core.Project.FileName);
    719     Core.AddItemToLastOpenedList(Core.Project.FileName);
    720     Core.Project.Modified := False;
     722  if Core.Core.Project.Modified and FileExists(Core.Core.Project.FileName) then begin
     723    FormSourceCode.SynEditSource.Lines.SaveToFile(Core.Core.Project.FileName);
     724    Core.Core.AddItemToLastOpenedList(Core.Core.Project.FileName);
     725    Core.Core.Project.Modified := False;
    721726    UpdateInterface;
    722727  end else AProjectSaveAs.Execute;
Note: See TracChangeset for help on using the changeset viewer.