Skip to content

Commit 7a1b97a

Browse files
committed
codetools: PreInc/PostInc/PreDec/PostDec completion
1 parent 40b29f9 commit 7a1b97a

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

components/codetools/identcompletiontool.pas

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,13 @@ procedure TIdentCompletionTool.GatherPredefinedIdentifiers(CleanPos: integer;
19411941
AddCompilerProcedure('WriteLn','Args:Arguments');
19421942
AddCompilerProcedure('WriteStr','var S:String;Args:Arguments');
19431943
AddCompilerProcedure('SwapValues','var A,B:T');
1944+
if cmsPrepostIncDec in Scanner.CompilerModeSwitches then begin
1945+
// value-returning inc/dec: Pre yields the value after the update, Post the one before
1946+
AddCompilerFunction('PreInc','var N:T;X:Integer=1','T');
1947+
AddCompilerFunction('PostInc','var N:T;X:Integer=1','T');
1948+
AddCompilerFunction('PreDec','var N:T;X:Integer=1','T');
1949+
AddCompilerFunction('PostDec','var N:T;X:Integer=1','T');
1950+
end;
19441951
if (cmsParallelFor in Scanner.CompilerModeSwitches)
19451952
and ContextInImplicitStatementScope(Context.Node,CleanPos,issParallelForBody) then begin
19461953
// implicit worker-locals of `for parallel` bodies only

components/codetools/linkscanner.pas

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ TSourceChangeStep = record
248248
cmsInterpolatedStrings,{ Unleashed: $'text {expr} text' interpolated string literals }
249249
cmsAutoProperties, { Unleashed: accessor-less property synthesizes a backing field }
250250
cmsParallelFor, { Unleashed: `for parallel` worker-pool loop, WorkerIndex/WorkerCount in the body }
251-
cmsOutVar { Unleashed: `var x` declares an inline variable at an out-argument, `_` discards it }
251+
cmsOutVar, { Unleashed: `var x` declares an inline variable at an out-argument, `_` discards it }
252+
cmsPrepostIncDec { Unleashed: PreInc/PostInc/PreDec/PostDec value-returning inc/dec }
252253
);
253254
TCompilerModeSwitches = set of TCompilerModeSwitch;
254255
const
@@ -298,7 +299,7 @@ TSourceChangeStep = record
298299
cmsStatementExpressions,cmsArrayEquality,cmsInlineVars,cmsTuples,
299300
cmsComposableRecords,cmsMultiLineStrings,cmsStaticSection,cmsInlineStatic,
300301
cmsThreadStatic,cmsInterpolatedStrings,cmsLock,cmsAsyncAwait,cmsAutoProperties,
301-
cmsParallelFor,cmsOutVar]
302+
cmsParallelFor,cmsOutVar,cmsPrepostIncDec]
302303
);
303304
cmAllModesWithGeneric = [cmDELPHI,cmDELPHIUNICODE,cmOBJFPC,cmUnleashed];
304305
Pas2jsFixedModeswitches = [cmsArray2dynarray,cmsArrayOperators,
@@ -369,7 +370,8 @@ TSourceChangeStep = record
369370
'INTERPOLATEDSTRINGS',
370371
'AUTOPROPERTIES',
371372
'PARALLELFOR',
372-
'OUTVAR'
373+
'OUTVAR',
374+
'PREPOSTINCDEC'
373375
);
374376
375377
type

0 commit comments

Comments
 (0)