Changeset 52 for branches/DelphiToC/Produce/UProducerC.pas
- Timestamp:
- Aug 10, 2010, 7:57:46 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Produce/UProducerC.pas
r51 r52 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls, USourceCode, U CodeProducer, StrUtils;9 Dialogs, StdCtrls, USourceCode, UProducer, StrUtils; 10 10 11 11 type 12 12 13 { T CProducer}14 15 T CProducer = class(TCodeProducer)13 { TProducerC } 14 15 TProducerC = class(TProducer) 16 16 private 17 17 function TranslateType(Name: string): string; … … 42 42 implementation 43 43 44 { T CProducer}45 46 constructor T CProducer.Create;44 { TProducerC } 45 46 constructor TProducerC.Create; 47 47 begin 48 48 TextSource := TStringList.Create; … … 50 50 end; 51 51 52 destructor T CProducer.Destroy;52 destructor TProducerC.Destroy; 53 53 begin 54 54 TextSource.Free; … … 56 56 end; 57 57 58 function T CProducer.TranslateType(Name: string): string;58 function TProducerC.TranslateType(Name: string): string; 59 59 begin 60 60 if Name = 'Byte' then Result := 'uint8' … … 67 67 end; 68 68 69 function T CProducer.TranslateOperator(Name: string): string;69 function TProducerC.TranslateOperator(Name: string): string; 70 70 begin 71 71 if Name = '=' then Result := '==' … … 82 82 end; 83 83 84 procedure T CProducer.Emit(Text: string);84 procedure TProducerC.Emit(Text: string); 85 85 begin 86 86 TextSource.Add(DupeString(' ', IndentationLength * Indetation) + Text); 87 87 end; 88 88 89 procedure T CProducer.GenerateUses(UsedModules: TUsedModuleList);89 procedure TProducerC.GenerateUses(UsedModules: TUsedModuleList); 90 90 var 91 91 I: Integer; … … 96 96 end; 97 97 98 procedure T CProducer.GenerateModule(Module: TModule);98 procedure TProducerC.GenerateModule(Module: TModule); 99 99 begin 100 100 Emit('#define int8 char'); … … 109 109 end; 110 110 111 procedure T CProducer.Produce;111 procedure TProducerC.Produce; 112 112 begin 113 113 inherited; … … 116 116 end; 117 117 118 procedure T CProducer.GenerateProgram(ProgramBlock: TProgram);118 procedure TProducerC.GenerateProgram(ProgramBlock: TProgram); 119 119 var 120 120 I: Integer; … … 126 126 end; 127 127 128 procedure T CProducer.GenerateFunctions(Functions: TFunctionList);128 procedure TProducerC.GenerateFunctions(Functions: TFunctionList); 129 129 var 130 130 I: Integer; … … 152 152 end; 153 153 154 procedure T CProducer.GenerateBeginEnd(BeginEnd: TBeginEnd);154 procedure TProducerC.GenerateBeginEnd(BeginEnd: TBeginEnd); 155 155 var 156 156 I: Integer; … … 176 176 end; 177 177 178 procedure T CProducer.GenerateCommand(Command: TCommand);178 procedure TProducerC.GenerateCommand(Command: TCommand); 179 179 begin 180 180 if Command is TBeginEnd then GenerateBeginEnd(TBeginEnd(Command)) … … 185 185 end; 186 186 187 procedure T CProducer.GenerateWhileDo(WhileDo: TWhileDo);187 procedure TProducerC.GenerateWhileDo(WhileDo: TWhileDo); 188 188 begin 189 189 Emit('while (' + GenerateExpression(WhileDo.Condition) + ')'); … … 191 191 end; 192 192 193 procedure T CProducer.GenerateIfThenElse(IfThenElse: TIfThenElse);193 procedure TProducerC.GenerateIfThenElse(IfThenElse: TIfThenElse); 194 194 begin 195 195 Emit('if(' + GenerateExpression(IfThenElse.Condition) + ')'); … … 201 201 end; 202 202 203 procedure T CProducer.GenerateAssignment(Assignment: TAssignment);203 procedure TProducerC.GenerateAssignment(Assignment: TAssignment); 204 204 begin 205 205 if Assignment.Target.Name = 'Result' then Emit('return(' + GenerateExpression(Assignment.Source) + ');') … … 207 207 end; 208 208 209 procedure T CProducer.GenerateFunctionCall(FunctionCall: TFunctionCall);209 procedure TProducerC.GenerateFunctionCall(FunctionCall: TFunctionCall); 210 210 var 211 211 Line: string; … … 225 225 end; 226 226 227 function T CProducer.GenerateExpression(Expression: TExpression): string;227 function TProducerC.GenerateExpression(Expression: TExpression): string; 228 228 begin 229 229 case Expression.NodeType of … … 240 240 end; 241 241 242 procedure T CProducer.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);242 procedure TProducerC.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string); 243 243 var 244 244 I: Integer;
Note:
See TracChangeset
for help on using the changeset viewer.