Ignore:
Timestamp:
Aug 10, 2010, 7:57:46 AM (14 years ago)
Author:
george
Message:

Visual TreeView reprezentation moved into target code producer set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Produce/UProducerC.pas

    r51 r52  
    77uses
    88  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, StdCtrls, USourceCode, UCodeProducer, StrUtils;
     9  Dialogs, StdCtrls, USourceCode, UProducer, StrUtils;
    1010
    1111type
    1212
    13   { TCProducer }
    14 
    15   TCProducer = class(TCodeProducer)
     13  { TProducerC }
     14
     15  TProducerC = class(TProducer)
    1616  private
    1717    function TranslateType(Name: string): string;
     
    4242implementation
    4343
    44 { TCProducer }
    45 
    46 constructor TCProducer.Create;
     44{ TProducerC }
     45
     46constructor TProducerC.Create;
    4747begin
    4848  TextSource := TStringList.Create;
     
    5050end;
    5151
    52 destructor TCProducer.Destroy;
     52destructor TProducerC.Destroy;
    5353begin
    5454  TextSource.Free;
     
    5656end;
    5757
    58 function TCProducer.TranslateType(Name: string): string;
     58function TProducerC.TranslateType(Name: string): string;
    5959begin
    6060  if Name = 'Byte' then Result := 'uint8'
     
    6767end;
    6868
    69 function TCProducer.TranslateOperator(Name: string): string;
     69function TProducerC.TranslateOperator(Name: string): string;
    7070begin
    7171  if Name = '=' then Result := '=='
     
    8282end;
    8383
    84 procedure TCProducer.Emit(Text: string);
     84procedure TProducerC.Emit(Text: string);
    8585begin
    8686  TextSource.Add(DupeString(' ', IndentationLength * Indetation) + Text);
    8787end;
    8888
    89 procedure TCProducer.GenerateUses(UsedModules: TUsedModuleList);
     89procedure TProducerC.GenerateUses(UsedModules: TUsedModuleList);
    9090var
    9191  I: Integer;
     
    9696end;
    9797
    98 procedure TCProducer.GenerateModule(Module: TModule);
     98procedure TProducerC.GenerateModule(Module: TModule);
    9999begin
    100100  Emit('#define int8 char');
     
    109109end;
    110110
    111 procedure TCProducer.Produce;
     111procedure TProducerC.Produce;
    112112begin
    113113  inherited;
     
    116116end;
    117117
    118 procedure TCProducer.GenerateProgram(ProgramBlock: TProgram);
     118procedure TProducerC.GenerateProgram(ProgramBlock: TProgram);
    119119var
    120120  I: Integer;
     
    126126end;
    127127
    128 procedure TCProducer.GenerateFunctions(Functions: TFunctionList);
     128procedure TProducerC.GenerateFunctions(Functions: TFunctionList);
    129129var
    130130  I: Integer;
     
    152152end;
    153153
    154 procedure TCProducer.GenerateBeginEnd(BeginEnd: TBeginEnd);
     154procedure TProducerC.GenerateBeginEnd(BeginEnd: TBeginEnd);
    155155var
    156156  I: Integer;
     
    176176end;
    177177
    178 procedure TCProducer.GenerateCommand(Command: TCommand);
     178procedure TProducerC.GenerateCommand(Command: TCommand);
    179179begin
    180180  if Command is TBeginEnd then GenerateBeginEnd(TBeginEnd(Command))
     
    185185end;
    186186
    187 procedure TCProducer.GenerateWhileDo(WhileDo: TWhileDo);
     187procedure TProducerC.GenerateWhileDo(WhileDo: TWhileDo);
    188188begin
    189189  Emit('while (' + GenerateExpression(WhileDo.Condition) + ')');
     
    191191end;
    192192
    193 procedure TCProducer.GenerateIfThenElse(IfThenElse: TIfThenElse);
     193procedure TProducerC.GenerateIfThenElse(IfThenElse: TIfThenElse);
    194194begin
    195195  Emit('if(' + GenerateExpression(IfThenElse.Condition) + ')');
     
    201201end;
    202202
    203 procedure TCProducer.GenerateAssignment(Assignment: TAssignment);
     203procedure TProducerC.GenerateAssignment(Assignment: TAssignment);
    204204begin
    205205  if Assignment.Target.Name = 'Result' then Emit('return(' + GenerateExpression(Assignment.Source) + ');')
     
    207207end;
    208208
    209 procedure TCProducer.GenerateFunctionCall(FunctionCall: TFunctionCall);
     209procedure TProducerC.GenerateFunctionCall(FunctionCall: TFunctionCall);
    210210var
    211211  Line: string;
     
    225225end;
    226226
    227 function TCProducer.GenerateExpression(Expression: TExpression): string;
     227function TProducerC.GenerateExpression(Expression: TExpression): string;
    228228begin
    229229  case Expression.NodeType of
     
    240240end;
    241241
    242 procedure TCProducer.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
     242procedure TProducerC.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
    243243var
    244244  I: Integer;
Note: See TracChangeset for help on using the changeset viewer.