Ignore:
Timestamp:
Apr 9, 2009, 2:08:56 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Nástřel parsování funkcí.
  • Přidáno: Zobrazení stromu struktury programu.
  • Opraveno: Zobrazení chybových hlášení.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UCSource.pas

    r14 r19  
    55uses
    66  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    7   Dialogs, StdCtrls, UPascalSource;
     7  Dialogs, StdCtrls, UPascalSource, UCodeProducer;
    88
    99type
    10   TCSource = class
     10  TCProducer = class(TCodeProducer)
    1111    TextSource: TStringList;
    12     PascalSource: TStringList;
    13     procedure Generate;
     12    procedure Produce; override;
    1413    constructor Create;
    1514    destructor Destroy; override;
     15  private
     16    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
     17      LabelPrefix: string);
     18    procedure GenerateProgram(ProgramBlock: TProgram);
    1619  end;
    1720
    1821implementation
    1922
    20 { TCSource }
     23{ TCProducer }
    2124
    22 constructor TCSource.Create;
     25constructor TCProducer.Create;
    2326begin
    2427  TextSource := TStringList.Create;
    2528end;
    2629
    27 destructor TCSource.Destroy;
     30destructor TCProducer.Destroy;
    2831begin
    2932  TextSource.Free;
     
    3134end;
    3235
    33 procedure TCSource.Generate;
     36procedure TCProducer.Produce;
    3437begin
    35 
     38  inherited;
     39  GenerateProgram(ProgramCode);
    3640end;
    3741
     42procedure TCProducer.GenerateProgram(ProgramBlock: TProgram);
     43var
     44  I: Integer;
     45begin
     46  with ProgramBlock do
     47  for I := 0 to Modules.Count - 1 do
     48    GenerateCommonBlock(TModule(Modules[I]), '');
     49end;
     50
     51procedure TCProducer.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
     52var
     53  I: Integer;
     54  LabelName: string;
     55begin
     56  with CommonBlock do begin
     57    TextSource.Add('void ' + Name + '()');
     58    TextSource.Add('{');
     59
     60    TextSource.Add('}');
     61  end;
     62end;
     63
     64
     65
    3866end.
Note: See TracChangeset for help on using the changeset viewer.