Ignore:
Timestamp:
Nov 24, 2020, 6:19:17 PM (4 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/USource.pas

    r213 r221  
    154154    function GetField(Index: Integer): TField; override;
    155155    procedure SetValue(Index: Integer; var Value); override;
     156    destructor Destroy; override;
    156157  end;
    157158
     
    484485destructor TReturn.Destroy;
    485486begin
    486   Expression.Free;
    487   inherited Destroy;
     487  FreeAndNil(Expression);
     488  inherited;
    488489end;
    489490
     
    530531destructor TSourceNodes.Destroy;
    531532begin
    532   List.Free;
    533   inherited Destroy;
     533  FreeAndNil(List);
     534  inherited;
    534535end;
    535536
     
    588589  else if Index = 1 then TypeRef := TType(Value)
    589590  else inherited;
     591end;
     592
     593destructor TConstant.Destroy;
     594begin
     595  FreeAndNil(Value);
     596  inherited;
    590597end;
    591598
     
    722729destructor TRepeatUntil.Destroy;
    723730begin
    724   Expression.Free;
    725   Commands.Free;
    726   inherited Destroy;
     731  FreeAndNil(Expression);
     732  FreeAndNil(Commands);
     733  inherited;
    727734end;
    728735
     
    801808destructor TForToDo.Destroy;
    802809begin
    803   Command.Free;
    804   ExpressionTo.Free;
    805   ExpressionFrom.Free;
    806   inherited Destroy;
     810  FreeAndNil(Command);
     811  FreeAndNil(ExpressionTo);
     812  FreeAndNil(ExpressionFrom);
     813  inherited;
    807814end;
    808815
     
    868875destructor TExpressionOperand.Destroy;
    869876begin
    870   if Assigned(ConstantDirect) then ConstantDirect.Free;
     877  if Assigned(ConstantDirect) then FreeAndNil(ConstantDirect);
     878  if Assigned(FunctionCall) then FreeAndNil(FunctionCall);
    871879end;
    872880
     
    933941destructor TFunction.Destroy;
    934942begin
    935   Block.Free;
    936   Params.Free;
    937   inherited Destroy;
     943  FreeAndNil(Block);
     944  FreeAndNil(Params);
     945  inherited;
    938946end;
    939947
     
    971979destructor TType.Destroy;
    972980begin
    973   Functions.Free;
    974   inherited Destroy;
     981  FreeAndNil(Functions);
     982  inherited;
    975983end;
    976984
     
    10331041destructor TExpressionOperation.Destroy;
    10341042begin
    1035   Items.Free;
    1036   inherited Destroy;
     1043  FreeAndNil(Items);
     1044  inherited;
    10371045end;
    10381046
     
    10791087begin
    10801088  Variable := nil;
    1081   Expression.Free;
    1082   inherited Destroy;
     1089  FreeAndNil(Expression);
     1090  inherited;
    10831091end;
    10841092
     
    11231131destructor TIfThenElse.Destroy;
    11241132begin
    1125   Expression.Free;
    1126   CommandThen.Free;
    1127   CommandElse.Free;
    1128   inherited Destroy;
     1133  FreeAndNil(Expression);
     1134  FreeAndNil(CommandThen);
     1135  FreeAndNil(CommandElse);
     1136  inherited;
    11291137end;
    11301138
     
    11651173destructor TWhileDo.Destroy;
    11661174begin
    1167   Expression.Free;
    1168   Command.Free;
    1169   inherited Destroy;
     1175  FreeAndNil(Expression);
     1176  FreeAndNil(Command);
     1177  inherited;
    11701178end;
    11711179
     
    12051213destructor TFunctionCall.Destroy;
    12061214begin
    1207   Params.Free;
    1208   inherited Destroy;
     1215  FreeAndNil(Params);
     1216  inherited;
    12091217end;
    12101218
     
    13491357destructor TBlock.Destroy;
    13501358begin
    1351   BeginEnd.Free;
    1352   Types.Free;
    1353   Variables.Free;
    1354   Constants.Free;
    1355   Functions.Free;
    1356   inherited Destroy;
     1359  FreeAndNil(BeginEnd);
     1360  FreeAndNil(Types);
     1361  FreeAndNil(Variables);
     1362  FreeAndNil(Constants);
     1363  FreeAndNil(Functions);
     1364  inherited;
    13571365end;
    13581366
     
    13941402destructor TBeginEnd.Destroy;
    13951403begin
    1396   Commands.Free;
    1397   inherited Destroy;
     1404  FreeAndNil(Commands);
     1405  inherited;
    13981406end;
    13991407
     
    14391447destructor TProgram.Destroy;
    14401448begin
    1441   Block.Free;
    1442   SystemBlock.Free;
    1443   inherited Destroy;
     1449  FreeAndNil(Block);
     1450  FreeAndNil(SystemBlock);
     1451  inherited;
    14441452end;
    14451453
Note: See TracChangeset for help on using the changeset viewer.