Changeset 236 for branches/xpascal/Generators/GeneratorPascal.pas
- Timestamp:
- Jun 29, 2023, 1:47:58 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/xpascal/Generators/GeneratorPascal.pas
r235 r236 14 14 procedure GenerateProgram(Block: TBlock; Prog:TProgram); 15 15 procedure GenerateFunction(ParentBlock: TBlock; FunctionDef: TFunction); 16 procedure GenerateFunctionParams(ParentBlock: TBlock; Params: TFunctionParameters); 16 17 procedure GenerateProcedure(ParentBlock: TBlock; ProcedureDef: TProcedure); 17 18 procedure GenerateBlock(ParentBlock: TBlock; Block: TBlock); … … 218 219 AddTextLine('{$mode delphi}'); 219 220 AddTextLine(''); 220 AddTextLine('uses SysUtils;'); 221 AddTextLine('uses'); 222 AddTextLine(' SysUtils;'); 223 AddTextLine(''); 221 224 GenerateBlock(Block, Prog.Block); 222 225 AddTextLine('.'); … … 225 228 procedure TGeneratorPascal.GenerateFunction(ParentBlock: TBlock; 226 229 FunctionDef: TFunction); 227 var228 I: Integer;229 230 begin 230 231 AddText('function ' + FunctionDef.Name); 231 if FunctionDef.Params.Count > 0 then begin 232 AddText('('); 233 for I := 0 to FunctionDef.Params.Count - 1 do begin 234 AddText(FunctionDef.Params[I].Name); 235 AddText(': '); 236 AddText(FunctionDef.Params[I].TypeRef.Name); 237 if I > 0 then AddText(', '); 238 end; 239 AddText(')'); 240 end; 232 GenerateFunctionParams(ParentBlock, FunctionDef.Params); 241 233 if Assigned(FunctionDef.ResultType) then begin 242 234 AddText(': '); … … 259 251 end; 260 252 261 procedure TGeneratorPascal.GenerateProcedure(ParentBlock: TBlock; 262 ProcedureDef: TProcedure); 263 var 264 I: Integer; 265 begin 266 AddText('procedure ' + ProcedureDef.Name); 267 if ProcedureDef.Params.Count > 0 then begin 253 procedure TGeneratorPascal.GenerateFunctionParams(ParentBlock: TBlock; 254 Params: TFunctionParameters); 255 var 256 I: Integer; 257 begin 258 if Params.Count > 0 then begin 268 259 AddText('('); 269 for I := 0 to ProcedureDef.Params.Count - 1 do begin 270 AddText(ProcedureDef.Params[I].Name); 260 for I := 0 to Params.Count - 1 do begin 261 if Params[I].Kind = pkVar then AddText('var '); 262 if Params[I].Kind = pkConst then AddText('const '); 263 AddText(Params[I].Name); 271 264 AddText(': '); 272 AddText(P rocedureDef.Params[I].TypeRef.Name);265 AddText(Params[I].TypeRef.Name); 273 266 if I > 0 then AddText(', '); 274 267 end; 275 268 AddText(')'); 276 269 end; 270 end; 271 272 procedure TGeneratorPascal.GenerateProcedure(ParentBlock: TBlock; 273 ProcedureDef: TProcedure); 274 begin 275 AddText('procedure ' + ProcedureDef.Name); 276 GenerateFunctionParams(ParentBlock, ProcedureDef.Params); 277 277 AddTextLine(';'); 278 278 if ProcedureDef.InternalName <> '' then begin
Note:
See TracChangeset
for help on using the changeset viewer.