Ignore:
Timestamp:
Apr 22, 2020, 10:23:31 PM (5 years ago)
Author:
chronos
Message:
  • Added: Transformation of Result variable assignment into Return statement.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2/USource.pas

    r212 r213  
    308308  end;
    309309
     310  { TReturn }
     311
     312  TReturn = class(TCommand)
     313  private
     314    function GetFieldsCount: Integer; override;
     315  public
     316    Expression: TExpression;
     317    procedure GetValue(Index: Integer; out Value); override;
     318    function GetField(Index: Integer): TField; override;
     319    procedure SetValue(Index: Integer; var Value); override;
     320    constructor Create;
     321    destructor Destroy; override;
     322  end;
     323
    310324  { TIfThenElse }
    311325
     
    437451  SYes = 'Yes';
    438452  SNo = 'No';
     453
     454{ TReturn }
     455
     456function TReturn.GetFieldsCount: Integer;
     457begin
     458  Result := 1;
     459end;
     460
     461procedure TReturn.GetValue(Index: Integer; out Value);
     462begin
     463  if Index = 0 then TExpression(Value) := Expression
     464  else inherited;
     465end;
     466
     467function TReturn.GetField(Index: Integer): TField;
     468begin
     469  if Index = 0 then Result := TField.Create(dtObject, 'Expression')
     470  else inherited;
     471end;
     472
     473procedure TReturn.SetValue(Index: Integer; var Value);
     474begin
     475  if Index = 0 then Expression := TExpression(Value)
     476  else inherited;
     477end;
     478
     479constructor TReturn.Create;
     480begin
     481  Expression := TExpression.Create;
     482end;
     483
     484destructor TReturn.Destroy;
     485begin
     486  Expression.Free;
     487  inherited Destroy;
     488end;
    439489
    440490{ TField }
Note: See TracChangeset for help on using the changeset viewer.