Ignore:
Timestamp:
Jun 27, 2023, 10:09:21 AM (17 months ago)
Author:
chronos
Message:
  • Modified: Improved function var parameter handling.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Generators/GeneratorPascal.pas

    r234 r235  
    102102  Indent := Indent + 1;
    103103  for I := 0 to RepeatUntil.Commands.Count - 1 do begin
    104     GenerateCommand(Block, TCommand(RepeatUntil.Commands[I]));
     104    GenerateCommand(Block, RepeatUntil.Commands[I]);
    105105    AddTextLine(';');
    106106  end;
     
    119119    AddText('(');
    120120    for I := 0 to FunctionCall.Params.Count - 1 do
    121       GenerateExpression(Block, TExpression(FunctionCall.Params[I]));
     121      GenerateExpression(Block, FunctionCall.Params[I]);
    122122    AddText(')');
    123123  end;
     
    133133    AddText('(');
    134134    for I := 0 to ProcedureCall.Params.Count - 1 do
    135       GenerateExpression(Block, TExpression(ProcedureCall.Params[I]));
     135      GenerateExpression(Block, ProcedureCall.Params[I]);
    136136    AddText(')');
    137137  end;
     
    169169      AddText(' ');
    170170    end;
    171     GenerateExpression(Block, TExpression(Expression.Items[I]));
     171    GenerateExpression(Block, Expression.Items[I]);
    172172  end;
    173173end;
     
    217217  if Prog.Name <> '' then AddTextLine('program ' + Prog.Name + ';');
    218218  AddTextLine('{$mode delphi}');
     219  AddTextLine('');
    219220  AddTextLine('uses SysUtils;');
    220221  GenerateBlock(Block, Prog.Block);
     
    231232    AddText('(');
    232233    for I := 0 to FunctionDef.Params.Count - 1 do begin
    233       AddText(TFunctionParameter(FunctionDef.Params[I]).Name);
     234      AddText(FunctionDef.Params[I].Name);
    234235      AddText(': ');
    235       AddText(TFunctionParameter(FunctionDef.Params[I]).TypeRef.Name);
     236      AddText(FunctionDef.Params[I].TypeRef.Name);
    236237      if I > 0 then AddText(', ');
    237238    end;
     
    267268    AddText('(');
    268269    for I := 0 to ProcedureDef.Params.Count - 1 do begin
    269       AddText(TFunctionParameter(ProcedureDef.Params[I]).Name);
     270      AddText(ProcedureDef.Params[I].Name);
    270271      AddText(': ');
    271       AddText(TFunctionParameter(ProcedureDef.Params[I]).TypeRef.Name);
     272      AddText(ProcedureDef.Params[I].TypeRef.Name);
    272273      if I > 0 then AddText(', ');
    273274    end;
     
    307308  VarCount := 0;
    308309  for I := 0 to Block.Variables.Count - 1 do
    309     if not TVariable(Block.Variables[I]).Internal then Inc(VarCount);
     310    if not Block.Variables[I].Internal then Inc(VarCount);
    310311
    311312  if VarCount > 0 then begin
     
    313314    Indent := Indent + 1;
    314315    for I := 0 to Block.Variables.Count - 1 do
    315     if not TVariable(Block.Variables[I]).Internal then begin
    316       Variable := TVariable(Block.Variables[I]);
     316    if not Block.Variables[I].Internal then begin
     317      Variable := Block.Variables[I];
    317318      AddTextLine(Variable.Name + ': ' + Variable.TypeRef.Name + ';');
    318319    end;
     
    331332    Indent := Indent + 1;
    332333    for I := 0 to Block.Constants.Count - 1 do begin
    333       Constant := TConstant(Block.Constants[I]);
     334      Constant := Block.Constants[I];
    334335      AddText(Constant.Name + ': ' + Constant.TypeRef.Name + ' = ');
    335336      GenerateValue(Constant.Value);
     
    348349  Indent := Indent + 1;
    349350  for I := 0 to BeginEnd.Commands.Count - 1 do begin
    350     GenerateCommand(Block, TCommand(BeginEnd.Commands[I]));
     351    GenerateCommand(Block, BeginEnd.Commands[I]);
    351352    AddTextLine(';');
    352353  end;
     
    361362begin
    362363  for I := 0 to Block.Functions.Count - 1 do begin
    363     GenerateFunction(ParentBlock, TFunction(Block.Functions[I]));
     364    GenerateFunction(ParentBlock, Block.Functions[I]);
    364365    AddTextLine;
    365366  end;
     
    372373begin
    373374  for I := 0 to Block.Procedures.Count - 1 do begin
    374     GenerateProcedure(ParentBlock, TProcedure(Block.Procedures[I]));
     375    GenerateProcedure(ParentBlock, Block.Procedures[I]);
    375376    AddTextLine;
    376377  end;
Note: See TracChangeset for help on using the changeset viewer.