Changeset 60


Ignore:
Timestamp:
Dec 3, 2014, 10:45:24 PM (10 years ago)
Author:
chronos
Message:
  • Added: Free Pascal Compiler as supported target.
  • Added: Log window to examine output from background execute compilers.
  • Fixed: Execution of targets except Java target.
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Examples/Fibonacci_comments.b

    r41 r60  
    1 +++++++++++ number of digits to output
    2 > #1
    3 + initial number
    4 >>>> #5
    5 ++++++++++++++++++++++++++++++++++++++++++++ (comma)
    6 > #6
    7 ++++++++++++++++++++++++++++++++ (space)
    8 <<<<<< #0
    9 [
    10   > #1
    11   copy #1 to #7
    12   [>>>>>>+>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]
    13 
    14   <
    15   divide #7 by 10 (begins in #7)
    16   [
    17     >
    18     ++++++++++  set the divisor #8
    19     [
    20       subtract from the dividend and divisor
    21       -<-
    22       if dividend reaches zero break out
    23         copy dividend to #9
    24         [>>+>+<<<-]>>>[<<<+>>>-]
    25         set #10
    26         +
    27         if #9 clear #10
    28         <[>[-]<[-]]
    29         if #10 move remaining divisor to #11
    30         >[<<[>>>+<<<-]>>[-]]
    31       jump back to #8 (divisor possition)
    32       <<
    33     ]
    34     if #11 is empty (no remainder) increment the quotient #12
    35     >>> #11
    36     copy to #13
    37     [>>+>+<<<-]>>>[<<<+>>>-]
    38     set #14
    39     +
    40     if #13 clear #14
    41     <[>[-]<[-]]
    42     if #14 increment quotient
    43     >[<<+>>[-]]
    44     <<<<<<< #7
    45   ]
    46 
    47   quotient is in #12 and remainder is in #11
    48   >>>>> #12
    49   if #12 output value plus offset to ascii 0
    50   [++++++++++++++++++++++++++++++++++++++++++++++++.[-]]
    51   subtract #11 from 10
    52   ++++++++++  #12 is now 10
    53   < #11
    54   [->-<]
    55   > #12
    56   output #12 even if it's zero
    57   ++++++++++++++++++++++++++++++++++++++++++++++++.[-]
    58   <<<<<<<<<<< #1
    59 
    60   check for final number
    61   copy #0 to #3
    62   <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]
    63   <- #3
    64   if #3 output (comma) and (space)
    65   [>>.>.<<<[-]]
    66   << #1
    67 
    68   [>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-
    69 ]
     1[ This program prints Sierpinski triangle on 80-column display. ]
     2                                >   
     3                               + +   
     4                              +   +   
     5                             [ < + +   
     6                j            +       +   
     7                           + +     + +   
     8                          >   -   ]   >   
     9                         + + + + + + + +   
     10                        [               >   
     11                       + +             + +   
     12                      <   -           ]   >   
     13                     > + + >         > > + >   
     14                    >       >       +       <   
     15                   < <     < <     < <     < <   
     16                  <   [   -   [   -   >   +   <   
     17                 ] > [ - < + > > > . < < ] > > >   
     18                [                               [   
     19               - >                             + +   
     20              +   +                           +   +   
     21             + + [ >                         + + + +   
     22            <       -                       ]       >   
     23           . <     < [                     - >     + <   
     24          ]   +   >   [                   -   >   +   +   
     25         + + + + + + + +                 < < + > ] > . [   
     26        -               ]               >               ]   
     27       ] +             < <             < [             - [   
     28      -   >           +   <           ]   +           >   [   
     29     - < + >         > > - [         - > + <         ] + + >   
     30    [       -       <       -       >       ]       <       <   
     31   < ]     < <     < <     ] +     + +     + +     + +     + +   
     32  +   .   +   +   +   .   [   -   ]   <   ]   +   +   +   +   +   
     33 * * * * * M a d e * B y : * N Y Y R I K K I * 2 0 0 2 * * * * *
  • trunk/Forms/UFormMain.lfm

    r59 r60  
    889889        }
    890890      end
     891      object MenuItem19: TMenuItem
     892        Action = AViewLog
     893      end
    891894      object MenuItem30: TMenuItem
    892895        Action = AViewCompilers
     
    10761079      Caption = 'Show execution point'
    10771080      OnExecute = AProgramShowExecutionPointExecute
     1081    end
     1082    object AViewLog: TAction
     1083      Category = 'View'
     1084      Caption = 'Log'
     1085      OnExecute = AViewLogExecute
    10781086    end
    10791087  end
  • trunk/Forms/UFormMain.lrt

    r59 r60  
    3737TMAINFORM.ASHOWSOURCEPOSITION.CAPTION=Show position in source
    3838TMAINFORM.APROGRAMSHOWEXECUTIONPOINT.CAPTION=Show execution point
     39TMAINFORM.AVIEWLOG.CAPTION=Log
  • trunk/Forms/UFormMain.pas

    r59 r60  
    1616
    1717  TMainForm = class(TForm)
     18    AViewLog: TAction;
    1819    AProgramShowExecutionPoint: TAction;
    1920    AShowSourcePosition: TAction;
     
    5152    MenuItem17: TMenuItem;
    5253    MenuItem18: TMenuItem;
     54    MenuItem19: TMenuItem;
    5355    MenuItem2: TMenuItem;
    5456    MenuItem22: TMenuItem;
     
    133135    procedure AViewCompilersExecute(Sender: TObject);
    134136    procedure AViewInterpretterExecute(Sender: TObject);
     137    procedure AViewLogExecute(Sender: TObject);
    135138    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    136139    procedure FormCreate(Sender: TObject);
     
    140143  private
    141144    FCurrentTarget: TTarget;
     145    procedure TargetLogExecute(Lines: TStrings);
    142146    procedure SetCurrentTarget(AValue: TTarget);
    143147    procedure AProjectOpenRecentExecute(Sender: TObject);
     
    169173uses
    170174  UCore, UFormCPU, UFormOptions, UFormMessages, UFormTargets, UFormOutput, UFormInput,
    171   UFormMemory, UFormSourceCode, UFormTargetCode, UTargetInterpretter;
     175  UFormMemory, UFormSourceCode, UFormTargetCode, UTargetInterpretter, UFormLog;
    172176
    173177resourcestring
     
    189193  for I := 0 to Core.Targets.Count - 1 do
    190194    TTarget(Core.Targets[I]).OnChangeState := nil;
    191   FCurrentTarget.OnChangeState := TargetStateChanged;
    192   FCurrentTarget.Messages.OnChange := MessagesChanged;
     195  if Assigned(FCurrentTarget) then begin
     196    FCurrentTarget.OnChangeState := TargetStateChanged;
     197    FCurrentTarget.OnLog := TargetLogExecute;
     198    FCurrentTarget.Messages.OnChange := MessagesChanged;
     199  end;
    193200  UpdateTargetList;
    194201  UpdateInterface;
     
    218225  FormOutput.Reload;
    219226  FormMemory.Reload;
     227end;
     228
     229procedure TMainForm.TargetLogExecute(Lines: TStrings);
     230begin
     231  FormLog.Memo1.Lines.AddStrings(Lines);
    220232end;
    221233
     
    438450end;
    439451
     452procedure TMainForm.AViewLogExecute(Sender: TObject);
     453begin
     454  FormLog.Show;
     455end;
     456
    440457procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
    441458begin
  • trunk/Languages/LazFuckIDE.cs.po

    r59 r60  
    101101msgstr "Vstup:"
    102102
     103#: tformlog.caption
     104msgctxt "tformlog.caption"
     105msgid "Log"
     106msgstr ""
     107
    103108#: tformmemory.caption
    104109msgid "Memory"
     
    428433msgstr "Překladače"
    429434
     435#: tmainform.aviewlog.caption
     436msgctxt "tmainform.aviewlog.caption"
     437msgid "Log"
     438msgstr ""
     439
    430440#: tmainform.caption
    431441msgid "LazFuck"
     
    729739msgid "Read input error"
    730740msgstr "Chyba čtení vstupu"
     741
  • trunk/Languages/LazFuckIDE.po

    r59 r60  
    9090msgstr ""
    9191
     92#: tformlog.caption
     93msgctxt "tformlog.caption"
     94msgid "Log"
     95msgstr ""
     96
    9297#: tformmemory.caption
    9398msgid "Memory"
     
    415420msgstr ""
    416421
     422#: tmainform.aviewlog.caption
     423msgctxt "TMAINFORM.AVIEWLOG.CAPTION"
     424msgid "Log"
     425msgstr ""
     426
    417427#: tmainform.caption
    418428msgid "LazFuck"
  • trunk/LazFuckIDE.lpi

    r59 r60  
    9696      </Item6>
    9797    </RequiredPackages>
    98     <Units Count="19">
     98    <Units Count="21">
    9999      <Unit0>
    100100        <Filename Value="LazFuckIDE.lpr"/>
     
    223223        <UnitName Value="UCore"/>
    224224      </Unit18>
     225      <Unit19>
     226        <Filename Value="Target\UTargetFPC.pas"/>
     227        <IsPartOfProject Value="True"/>
     228        <UnitName Value="UTargetFPC"/>
     229      </Unit19>
     230      <Unit20>
     231        <Filename Value="Forms\UFormLog.pas"/>
     232        <IsPartOfProject Value="True"/>
     233        <ComponentName Value="FormLog"/>
     234        <ResourceBaseClass Value="Form"/>
     235        <UnitName Value="UFormLog"/>
     236      </Unit20>
    225237    </Units>
    226238  </ProjectOptions>
  • trunk/LazFuckIDE.lpr

    r59 r60  
    1010  Interfaces, // this includes the LCL widgetset
    1111  Forms, UTarget, UTargetC, UTargetDelphi, UTargetInterpretter, UTargetPHP,
    12   UTargetJava, UFormCPU, UFormMain, UFormOptions, UFormTargets, UFormOutput,
    13   UFormInput, UFormMemory, UFormMessages, UFormSourceCode, UFormTargetCode,
    14   UFormTargetOptions, UCore, Common, TemplateGenerics, CoolTranslator;
     12  UTargetJava, UTargetFPC, UFormCPU, UFormMain, UFormOptions, UFormTargets,
     13  UFormOutput, UFormInput, UFormMemory, UFormMessages, UFormSourceCode,
     14  UFormTargetCode, UFormTargetOptions, UCore, Common, TemplateGenerics,
     15  CoolTranslator, UFormLog;
    1516
    1617{$R *.res}
     
    3233  Application.CreateForm(TFormTargetCode, FormTargetCode);
    3334  Application.CreateForm(TFormTargetOptions, FormTargetOptions);
     35  Application.CreateForm(TFormLog, FormLog);
    3436  Application.Run;
    3537end.
  • trunk/Target/UTarget.pas

    r58 r60  
    6969    cmOutput, cmInput, cmLoopStart, cmLoopEnd, cmDebug);
    7070
     71  TLogEvent = procedure (Lines: TStrings) of object;
     72
    7173  { TTarget }
    7274
    7375  TTarget = class
     76  private
     77    FOnLog: TLogEvent;
    7478  protected
    7579    FCompiled: Boolean;
     
    101105    ExecutorPath: string;
    102106    SourceExtension: string;
     107    RunExtension: string;
    103108    CompiledExtension: string;
    104109    ProjectFileName: string;
     
    124129    procedure SaveToRegistry(Root: HKEY; Key: string); virtual;
    125130    property State: TRunState read FState write SetState;
    126     property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
    127131    property SourceCode: string write SetSourceCode;
    128132    property TargetCode: string read GetTargetCode;
     
    130134    property ExecutionPosition: Integer read GetExecutionPosition;
    131135    property ProgramIndex: Integer read FProgramIndex;
     136    property OnChangeState: TNotifyEvent read FOnChangeState write FOnChangeState;
     137    property OnLog: TLogEvent read FOnLog write FOnLog;
    132138  end;
    133139
     
    396402  Process: TProcess;
    397403  CompiledFile: string;
     404  Lines: TStringList;
     405  I: Integer;
    398406begin
    399407  CompiledFile := ExtractFilePath(ProjectFileName) +
     
    412420    try
    413421      Process := TProcess.Create(nil);
    414       Process.CurrentDirectory := ExtractFilePath(CompilerPath);
    415       Process.CommandLine := LongFileName(CompilerPath) + ' ' + LongFileName(CompiledFile);
    416       Process.Options := [poWaitOnExit];
     422      Process.CurrentDirectory := ExtractFilePath(CompiledFile);
     423      Process.Executable := LongFileName(CompilerPath);
     424      Process.Parameters.Add(LongFileName(CompiledFile));
     425      for I := 0 to GetEnvironmentVariableCount - 1 do
     426        Process.Environment.Add(GetEnvironmentString(I));
     427      Process.Options := [poWaitOnExit, poUsePipes];
    417428      Process.Execute;
     429      if Assigned(FOnLog) then begin
     430        Lines := TStringList.Create;
     431        Lines.LoadFromStream(Process.Output);
     432        Lines.Insert(0, Process.Executable + ' ' + Process.Parameters.Text);
     433        FOnLog(Lines);
     434        Lines.Free;
     435      end;
    418436    finally
    419437      Process.Free;
     
    426444  Process: TProcess;
    427445  CompiledFile: string;
     446  RunFile: string;
    428447begin
    429448  CompiledFile := ExtractFilePath(ProjectFileName) +
    430449    'compiled' + DirectorySeparator + Name + DirectorySeparator +
    431450    ExtractFileNameOnly(ProjectFileName) + CompiledExtension;
     451  RunFile := ExtractFilePath(ProjectFileName) +
     452    'compiled' + DirectorySeparator + Name + DirectorySeparator +
     453    ExtractFileNameOnly(ProjectFileName) + RunExtension;
    432454  if FileExistsUTF8(CompiledFile) then
    433455  try
    434456    Process := TProcess.Create(nil);
    435     if ExecutorPath <> '' then Process.CommandLine := LongFileName(ExecutorPath) + ' ';
    436     Process.CommandLine := Process.CommandLine + LongFileName(CompiledFile);
    437     Process.Options := [poWaitOnExit];
     457    if ExecutorPath <> '' then begin
     458      Process.Executable := LongFileName(ExecutorPath);
     459      Process.Parameters.Add(LongFileName(RunFile));
     460    end else Process.Executable := LongFileName(RunFile);
     461    Process.ShowWindow := swoShow;
     462    Process.Options := [poWaitOnExit, poNewConsole];
    438463    Process.Execute;
    439464  finally
  • trunk/Target/UTargetC.pas

    r52 r60  
    3131  Name := 'C';
    3232  SourceExtension := '.c';
    33   CompiledExtension := '.exe';
    3433  ImageIndex := 23;
    3534  Capabilities := [tcCompile, tcRun];
    3635  {$IFDEF Windows}
    3736  CompilerPath := 'c:\Program Files\MinGW\bin\gcc.exe';
     37  CompiledExtension := '.exe';
     38  RunExtension := '';
    3839  {$ENDIF}
    3940  {$IFDEF Linux}
    4041  CompilerPath := '/usr/bin/gcc';
     42  CompiledExtension := '';
     43  RunExtension := '';
    4144  {$ENDIF}
    4245end;
  • trunk/Target/UTargetDelphi.pas

    r52 r60  
    3030  SourceExtension := '.pas';
    3131  ImageIndex := 22;
    32   CompiledExtension := '.exe';
    3332  Capabilities := [tcCompile, tcRun];
    3433  {$IFDEF Windows}
    3534  CompilerPath := 'c:\Program Files\Embarcadero\RAD Studio\9.0\bin\DCC32.EXE';
     35  CompiledExtension := '.exe';
     36  RunExtension := '';
    3637  {$ENDIF}
    3738end;
  • trunk/Target/UTargetJava.pas

    r52 r60  
    3131  SourceExtension := '.java';
    3232  CompiledExtension := '.class';
     33  RunExtension := '';
    3334  ImageIndex := 24;
    3435  Capabilities := [tcCompile, tcRun];
  • trunk/Target/UTargetPHP.pas

    r59 r60  
    3030  Name := 'PHP';
    3131  SourceExtension := '.php';
     32  RunExtension := '.php';
     33  CompiledExtension := '.php';
    3234  ImageIndex := 21;
    3335  Capabilities := [tcCompile, tcRun];
  • trunk/UCore.pas

    r59 r60  
    3939
    4040uses
    41   UTargetJava, UTargetDelphi, UTargetPHP, UTargetC, UTargetInterpretter;
     41  UTargetJava, UTargetDelphi, UTargetPHP, UTargetC, UTargetInterpretter, UTargetFPC;
    4242
    4343
     
    5050  Targets.Add(TTargetInterpretter.Create);
    5151  Targets.Add(TTargetDelphi.Create);
     52  Targets.Add(TTargetFPC.Create);
    5253  Targets.Add(TTargetPHP.Create);
    5354  Targets.Add(TTargetC.Create);
Note: See TracChangeset for help on using the changeset viewer.