@@ -238,104 +238,11 @@ function MakePascalCase(const aString:String):String;
238
238
Result := Result + aString[I];
239
239
240
240
for I := Length(Result) downto 1 do
241
- // if Result[I]=' ' then
242
241
if CharInSet(Result[I],Chars) then
243
242
Delete(Result,I,1 );
244
243
end ;
245
244
246
245
247
-
248
-
249
-
250
- procedure FixMultilineStatements (var sl: TStringList);
251
- var
252
- i,j,c: Integer;
253
- ch:char;s:String;
254
- cPos: Integer;
255
- const
256
- DUMMY=' nnnnn' ;
257
- begin
258
- // get rid of multi-line statements
259
- {
260
- for i := 0 to sl.Count - 1 do
261
- begin
262
- if sl[i].EndsWith(',') then sl[i] := sl[i] + DUMMY;
263
- if sl[i].EndsWith('+') then sl[i] := sl[i] + DUMMY;
264
- if sl[i].EndsWith('-') then sl[i] := sl[i] + DUMMY;
265
- if sl[i].EndsWith('*') then sl[i] := sl[i] + DUMMY;
266
- if sl[i].EndsWith('/') then sl[i] := sl[i] + DUMMY;
267
- if sl[i].EndsWith('(') then sl[i] := sl[i] + DUMMY;
268
- end;
269
- sl.Text := sl.Text.Replace(DUMMY + sLineBreak, DUMMY, [rfReplaceAll]);
270
- sl.Text := sl.Text.Replace(DUMMY, sLineBreak, [rfReplaceAll]);
271
- }
272
-
273
- sl.Text := Sl.Text.Replace(#10 ,' ' );
274
- sl.Text := Sl.Text.Replace(#13 ,sLineBreak);
275
-
276
-
277
- for ch in [' ,' ,' +' ,' -' ,' *' ,' /' ] do
278
- sl.Text := sl.Text.Replace(ch+sLineBreak,ch+' ' ,[rfReplaceAll]);
279
-
280
- // sl.Text := sl.Text.Replace('){' + sLineBreak, ')' + sLineBreak + '{', [rfReplaceAll]);
281
- sl.Text := sl.Text.Replace(' {' , sLineBreak + ' {' +sLineBreak, [rfReplaceAll]);
282
- sl.Text := sl.Text.Replace(' }' , sLineBreak + ' }' +sLineBreak, [rfReplaceAll]);
283
- sl.Text := sl.Text.Replace(' ;' , ' ;' +' <LINEBREAK> ' , [rfReplaceAll]);
284
-
285
- for i := 0 to sl.Count-1 do
286
- if sl[I].Trim.StartsWith(' for' ) then
287
- sl[I] := sl[I].Replace(' <LINEBREAK> ' ,' ' );
288
-
289
- sl.Text := sl.Text.Replace(' <LINEBREAK>' , sLineBreak, [rfReplaceAll]);
290
-
291
- sl.Text := sl.Text.Replace( sLineBreak + sLineBreak + sLineBreak, sLineBreak + sLineBreak, [rfReplaceAll]);
292
-
293
- c := 0 ;
294
- for i := 0 to sl.Count-1 do
295
- begin
296
- s := sl[i];
297
- if s.Trim.ToLower.StartsWith(' if' ) then
298
- for j := 1 to length(s) do
299
- begin
300
- if s[j]=' (' then
301
- inc(c);
302
- if s[j]=' )' then
303
- begin
304
- dec(c);
305
- if c=0 then
306
- insert(' @@LINEBREAK@@ ' ,s,j+1 );
307
- sl[i] := s;
308
- end ;
309
- end ;
310
- end ;
311
-
312
- for i := 0 to sl.Count-1 do
313
- begin
314
- s := sl[i].Trim;
315
- cPos := s.IndexOf(' {' );
316
- if (cPos>0 ) and (cPos<s.Length) then
317
- begin
318
- insert(' @@LINEBREAK@@' ,s,cPos+1 );
319
- sl[i] := s;
320
- end ;
321
- end ;
322
-
323
-
324
- for i := 0 to sl.Count-1 do
325
- begin
326
- s := sl[i].Trim;
327
- cPos := s.IndexOf(' }' );
328
- if cPos>0 then
329
- begin
330
- insert(' @@LINEBREAK@@' ,s,cPos+2 );
331
- sl[i] := s;
332
- end ;
333
- end ;
334
-
335
- sl.Text := sl.Text.Replace(' @@LINEBREAK@@' ,sLineBreak, [rfReplaceAll]);
336
- end ;
337
-
338
-
339
246
constructor TVariable.Create;
340
247
begin
341
248
@@ -420,7 +327,7 @@ function TVariableList.getLongestName: integer;
420
327
end ;
421
328
422
329
function TVariableList.ToPascal (indent:Boolean): String;
423
- var longest,i:integer;// v:TVariable;
330
+ var longest,i:integer;
424
331
align:boolean;
425
332
begin
426
333
Result := ' ' ;
@@ -456,11 +363,6 @@ function TVariableList.ToPascal(indent:Boolean): String;
456
363
or (Items[I - 1 ].Dir <> Items[I].Dir)
457
364
or (Items[I - 1 ].&Type <> Items[I].&Type ) then
458
365
begin
459
- // if Items[I].Dir <> TDir.none then
460
- // if Indent then
461
- // if Result.Trim <> '' then
462
- // Result := Result + sLineBreak;
463
-
464
366
if Indent then
465
367
if I = 0 then
466
368
if Items[I].Dir = TDir.none then
@@ -539,8 +441,6 @@ function TVariableList.ToPascal(indent:Boolean): String;
539
441
540
442
if Indent then
541
443
begin
542
- // if not (Result.StartsWith('var') or Result.StartsWith('const')) then
543
- // Result := 'var'+sLineBreak+' '+Result;
544
444
if not Result.Trim.EndsWith(' ;' ) then
545
445
Result := Result.Trim + ' ;' ;
546
446
@@ -614,14 +514,10 @@ function TRoutine.ToDeclarationPascal: String;
614
514
if sl.ToString.Trim<>' ;' then
615
515
sl.Append(' ;' );
616
516
617
- if &Override then
618
- sl.Append(' override;' );
619
- if &Overload then
620
- sl.Append(' overload;' );
621
- if &Inline then
622
- sl.Append(' inline;' );
623
- if &Static then
624
- sl.Append(' static;' );
517
+ if &Override then sl.Append(' override;' );
518
+ if &Overload then sl.Append(' overload;' );
519
+ if &Inline then sl.Append(' inline;' );
520
+ if &Static then sl.Append(' static;' );
625
521
626
522
Result := sl.ToString;
627
523
sl.Free;
@@ -647,16 +543,12 @@ function TRoutine.ToImplementationPascal(aClassName: string): String;
647
543
sl.Append(' :' +Self.ReturnType);
648
544
649
545
sl.AppendLine(' ;' );
650
- // sl.Remove(sl.Length-1,1);
651
546
if self.LocalVars.Count>0 then
652
547
sl.Append( LocalVars.ToPascal(true) );
653
548
654
549
sl.AppendLine( ' begin' );
655
550
Code.Cleanup;
656
551
657
- // for c in Code.Lines do
658
- // sl.AppendLine( c );
659
-
660
552
sl.AppendLine(code.ToPascal);
661
553
662
554
sl.AppendLine( ' end;' );
@@ -747,11 +639,9 @@ sl.Add(Esc(Name) + ' = record');
747
639
end ;
748
640
sl.Add( vars.ToPascal(true).TrimRight );
749
641
end ;
642
+
750
643
for m in Methods do
751
- begin
752
644
sl.Add(m.ToDeclarationPascal);
753
- // sl.Add('');
754
- end ;
755
645
756
646
757
647
if self.Kind <> &unit then
@@ -865,7 +755,6 @@ procedure TCode.Cleanup;
865
755
end ;
866
756
end ;
867
757
Setlength(lines,J);
868
- // Align;
869
758
end ;
870
759
871
760
constructor TCode.Create(c: TArray<string>);
@@ -975,7 +864,6 @@ function TPascalUnit.toPascal: string;
975
864
976
865
sl.Add(usesListIntf.ToPascal);
977
866
978
- // sl.Add('type');
979
867
for e in enums do
980
868
sl.Add( e.ToPascal );
981
869
0 commit comments