Changeset 222 for branches/interpreter2/Generators/UGeneratorCSharp.pas
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/Generators/UGeneratorCSharp.pas
r221 r222 31 31 procedure GenerateExpressionOperation(Block: TBlock; Expression: TExpressionOperation); 32 32 procedure GenerateExpressionOperand(Block: TBlock; Expression: TExpressionOperand); 33 procedure GenerateExpressionBrackets(Block: TBlock; Expression: TExpressionBrackets); 33 34 procedure GenerateBreak(Block: TBlock; BreakCmd: TBreak); 34 35 procedure GenerateContinue(Block: TBlock; ContinueCmd: TContinue); … … 37 38 procedure GenerateValue(Value: TValue); 38 39 public 39 Prog: TProgram;40 40 procedure Generate; override; 41 end; 41 constructor Create; override; 42 end; 43 42 44 43 45 implementation 46 47 const 48 ExpressionOperatorTextCSharp: array[TExpressionOperator] of string = ('', '+', 49 '-', '*', '/', '/', '%', '&', '^', '|', '<<', 50 '>>', '==', '!=', '<', '>', '<=','>=', '!'); 44 51 45 52 { TGeneratorCSharp } … … 144 151 if Expression is TExpressionOperand then 145 152 GenerateExpressionOperand(Block, TExpressionOperand(Expression)) 153 else 154 if Expression is TExpressionBrackets then 155 GenerateExpressionBrackets(Block, TExpressionBrackets(Expression)) 146 156 else raise Exception.Create('Unknown expression class.'); 147 157 end; … … 154 164 for I := 0 to Expression.Items.Count - 1 do begin 155 165 if I > 0 then begin 156 if Expression.Operation = eoAdd then AddText(' + ') 157 else if Expression.Operation = eoSub then AddText(' - ') 158 else if Expression.Operation = eoEqual then AddText(' == ') 159 else if Expression.Operation = eoNotEqual then AddText(' != '); 166 AddText(' ' + ExpressionOperatorTextCSharp[Expression.Operation] + ' '); 160 167 end; 161 168 GenerateExpression(Block, TExpression(Expression.Items[I])); … … 173 180 else raise Exception.Create('Unsupported exception operand type.'); 174 181 end; 182 end; 183 184 procedure TGeneratorCSharp.GenerateExpressionBrackets(Block: TBlock; 185 Expression: TExpressionBrackets); 186 begin 187 AddText('('); 188 GenerateExpression(Block, Expression.Expression); 189 AddText(')'); 175 190 end; 176 191 … … 233 248 234 249 procedure TGeneratorCSharp.GenerateBlock(ParentBlock: TBlock; Block: TBlock); 235 var236 I: Integer;237 250 begin 238 251 if Block.BeginEnd.Commands.Count > 0 then begin … … 353 366 end; 354 367 368 constructor TGeneratorCSharp.Create; 369 begin 370 inherited; 371 Name := 'CSharp'; 372 FileExt := '.cs'; 373 end; 374 355 375 end. 356 376
Note:
See TracChangeset
for help on using the changeset viewer.