Changeset 25 for trunk/Compiler


Ignore:
Timestamp:
Feb 13, 2012, 9:47:18 AM (13 years ago)
Author:
chronos
Message:
  • Added: List of supported compiler targets.
  • Added: Action to compile and run project.
Location:
trunk/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/UCompiler.pas

    r20 r25  
    66
    77uses
    8   Classes, SysUtils, StrUtils;
     8  Classes, SysUtils, StrUtils, Registry, URegistry, SpecializedList;
    99
    1010type
     
    2323    Output: string;
    2424    Optimization: TCompilerOptimization;
     25    CompilerPath: string;
     26    SourceExtension: string;
     27    CompiledExtension: string;
    2528    constructor Create; virtual;
    2629    procedure OptimizeSource;
     
    2831  end;
    2932
     33  { TCompilerList }
     34
     35  TCompilerList = class(TListObject)
     36    procedure LoadFromRegistry(Root: HKEY; Key: string);
     37    procedure SaveToRegistry(Root: HKEY; Key: string);
     38  end;
     39
    3040
    3141implementation
     42
     43{ TCompilerList }
     44
     45procedure TCompilerList.LoadFromRegistry(Root: HKEY; Key: string);
     46var
     47  I: Integer;
     48begin
     49  with TRegistryEx.Create do
     50  try
     51    RootKey := Root;
     52    OpenKey(Key + '\Compiler', True);
     53    for I := 0 to Count - 1 do
     54    with TBrainFuckCompiler(Items[I]) do
     55      if ValueExists(Name) then CompilerPath := ReadString(Name);
     56  finally
     57    Free;
     58  end;
     59end;
     60
     61procedure TCompilerList.SaveToRegistry(Root: HKEY; Key: string);
     62var
     63  I: Integer;
     64begin
     65  with TRegistryEx.Create do
     66  try
     67    RootKey := Root;
     68    OpenKey(Key + '\Compiler', True);
     69    for I := 0 to Count - 1 do
     70    with TBrainFuckCompiler(Items[I]) do
     71      if CompilerPath <> '' then WriteString(Name, CompilerPath)
     72        else DeleteValue(Name);
     73  finally
     74    Free;
     75  end;
     76end;
    3277
    3378{ TBrainFuckCompiler }
  • trunk/Compiler/UCompilerDelphi.pas

    r20 r25  
    2525  inherited Create;
    2626  Name := 'Delphi';
     27  SourceExtension := '.pas';
     28  CompiledExtension := '.exe';
    2729end;
    2830
     
    5355  AddLine('  Memory: array[0..30000] of Byte;');
    5456  AddLine('  Pos: Integer;');
     57  AddLine('  ReadChar: Char;');
    5558  AddLine('begin');
    5659  Inc(Indent);
     60  AddLine('Pos := 0;');
    5761  I := 1;
    5862  while (I <= Length(Source)) do begin
     
    7579      end;
    7680      '.': AddLine('Write(Chr(Memory[Pos]));');
    77       ',': AddLine('Read(Chr(Memory[Pos]));');
     81      ',': AddLine('Read(ReadChar); Memory[Pos] := Ord(ReadChar);');
    7882      '[': begin
    7983        AddLine('while Memory[Pos] <> 0 do begin');
  • trunk/Compiler/UCompilerPHP.pas

    r20 r25  
    2626  inherited Create;
    2727  Name := 'PHP';
     28  SourceExtension := '.php';
    2829end;
    2930
Note: See TracChangeset for help on using the changeset viewer.