Ignore:
Timestamp:
Nov 24, 2020, 6:19:17 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Resolved remaining memory leaks.
  • Modified: Generators moved to Generators subdirectory.
  • Modified: PascalParser moved to Parsers subdirectory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2/UExecutor.pas

    r214 r221  
    138138destructor TExecutorFunction.Destroy;
    139139begin
    140   Block.Free;
    141   inherited Destroy;
     140  FreeAndNil(Block);
     141  inherited;
    142142end;
    143143
     
    151151destructor TExecutorVariable.Destroy;
    152152begin
    153   Value.Free;
    154   inherited Destroy;
     153  FreeAndNil(Value);
     154  inherited;
    155155end;
    156156
     
    164164destructor TExecutorType.Destroy;
    165165begin
    166   Functions.Free;
    167   inherited Destroy;
     166  FreeAndNil(Functions);
     167  inherited;
    168168end;
    169169
     
    273273destructor TExecutorBlock.Destroy;
    274274begin
    275   Variables.Free;
    276   Functions.Free;
    277   Types.Free;
    278   inherited Destroy;
     275  FreeAndNil(Variables);
     276  FreeAndNil(Functions);
     277  FreeAndNil(Types);
     278  inherited;
    279279end;
    280280
     
    513513var
    514514  Value: TValue;
     515  BoolValue: Boolean;
    515516begin
    516517  while True do begin
    517518    Value := ExecuteExpression(Block, WhileDo.Expression);
    518519    if Value is TValueBoolean then begin
    519       if not TValueBoolean(Value).Value then Break;
     520      BoolValue := TValueBoolean(Value).Value;
     521      Value.Free;
     522      if not BoolValue then Break;
    520523      ExecuteCommand(Block, WhileDo.Command);
    521524      if WhileDo.DoContinue then begin
     
    528531      end;
    529532    end else raise Exception.Create('Expected boolean value.');
    530     Value.Free;
    531533  end;
    532534end;
     
    537539  Value: TValue;
    538540  I: Integer;
     541  BoolValue: Boolean;
    539542begin
    540543  while True do begin
     
    552555    Value := ExecuteExpression(Block, RepeatUntil.Expression);
    553556    if Value is TValueBoolean then begin
    554       if TValueBoolean(Value).Value then Break;
     557      BoolValue := TValueBoolean(Value).Value;
     558      Value.Free;
     559      if BoolValue then Break;
    555560    end else raise Exception.Create('Expected boolean value.');
    556     Value.Free;
    557561  end;
    558562end;
     
    654658      ExecuteBlock(Block, FunctionCall.FunctionDef.Block, ExecutorFunction.Block);
    655659      ExecutorVariable := ExecutorFunction.Block.Variables.SearchByVariable(TVariable(FunctionCall.FunctionDef.Block.Variables.SearchByName('Result')));
    656       Result := ExecutorVariable.Value;
     660      Result := ExecutorVariable.Value.Clone;
    657661    end;
    658662  end else raise Exception.Create('No executor for ' + FunctionCall.FunctionDef.Name + ' function.');
     
    706710    raise Exception.Create('Missing operator function ' + FuncName + ' for type ' + Expression.TypeRef.Name);
    707711
    708   Result := Expression.TypeRef.ValueClass.Create;
    709 
    710712  SetLength(Params, Expression.Items.Count);
    711713  for I := 0 to Expression.Items.Count - 1 do begin
Note: See TracChangeset for help on using the changeset viewer.