prefix pc field in FormulaCompiler

Change-Id: I2b7b78d6a9df1103084ac4a50d39e452645b4e5f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1392
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 431e8c9e9a6a7e476e8240c6c8781e2344b558ea)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205600
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Noel Grandin
2026-05-24 09:05:43 +02:00
committed by Julien Nabet
parent 3a57fe4450
commit e22c8988d2
2 changed files with 22 additions and 22 deletions
+21 -21
View File
@@ -774,7 +774,7 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr, bool bComputeII, bool
meLastOp( ocPush ),
mnRecursion( 0 ),
mnNumFmt( SvNumFormatType::UNDEFINED ),
pc( 0 ),
mnPC( 0 ),
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
mbAutoCorrect( false ),
mbCorrected( false ),
@@ -799,7 +799,7 @@ FormulaCompiler::FormulaCompiler(bool bComputeII, bool bMatrixFlag)
meLastOp( ocPush ),
mnRecursion(0),
mnNumFmt( SvNumFormatType::UNDEFINED ),
pc( 0 ),
mnPC( 0 ),
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
mbAutoCorrect( false ),
mbCorrected( false ),
@@ -1687,7 +1687,7 @@ void FormulaCompiler::Factor()
eOp = Expression();
// Do not ignore error here, regardless of mbStopOnError, to not
// change the formula expression in case of an unexpected state.
if (mpArr->GetCodeError() == FormulaError::NONE && pc >= 2)
if (mpArr->GetCodeError() == FormulaError::NONE && mnPC >= 2)
{
// Left and right operands must be reference or function
// returning reference to form a range list.
@@ -1843,7 +1843,7 @@ void FormulaCompiler::Factor()
// Current index is nSepPos+3 if expression stops, or
// nSepPos+4 if expression continues after the call because
// we just called NextToken() to move away from it.
if (pc >= 2 && (maArrIterator.GetIndex() == nSepPos + 3 || maArrIterator.GetIndex() == nSepPos + 4) &&
if (mnPC >= 2 && (maArrIterator.GetIndex() == nSepPos + 3 || maArrIterator.GetIndex() == nSepPos + 4) &&
mpArr->TokenAt(nSepPos+1)->GetType() == svDouble &&
static_cast<FormulaDoubleToken*>(mpArr->TokenAt(nSepPos+1))->GetDouble() != 1.0 &&
mpArr->TokenAt(nSepPos+2)->GetOpCode() == ocClose &&
@@ -1852,7 +1852,7 @@ void FormulaCompiler::Factor()
maArrIterator.AfterRemoveToken( nSepPos, 2);
// Remove the ocPush/svDouble just removed also from
// the compiler local RPN array.
--mpCode; --pc;
--mpCode; --mnPC;
(*mpCode)->DecRef(); // may be dead now
pFacToken->SetByte( nSepCount - 1 );
}
@@ -2041,7 +2041,7 @@ void FormulaCompiler::Factor()
case ocStop:
// May happen only if PutCode(pFacToken) ran into overflow.
nJumpMax = 0;
assert(pc == FORMULA_MAXTOKENS && mpArr->GetCodeError() != FormulaError::NONE);
assert(mnPC == FORMULA_MAXTOKENS && mpArr->GetCodeError() != FormulaError::NONE);
break;
default:
nJumpMax = 0;
@@ -2053,7 +2053,7 @@ void FormulaCompiler::Factor()
&& (mpArr->GetCodeError() == FormulaError::NONE || !mbStopOnError))
{
if ( ++nJumpCount <= nJumpMax )
static_cast<FormulaJumpToken*>(&*pFacToken)->GetJump()[nJumpCount] = pc-1;
static_cast<FormulaJumpToken*>(&*pFacToken)->GetJump()[nJumpCount] = mnPC-1;
NextToken();
CheckSetForceArrayParameter( mpToken, nJumpCount - 1);
eOp = Expression();
@@ -2067,7 +2067,7 @@ void FormulaCompiler::Factor()
NextToken();
// always limit to nJumpMax, no arbitrary overwrites
if ( ++nJumpCount <= nJumpMax )
static_cast<FormulaJumpToken*>(&*pFacToken)->GetJump()[ nJumpCount ] = pc-1;
static_cast<FormulaJumpToken*>(&*pFacToken)->GetJump()[ nJumpCount ] = mnPC-1;
eFacOpCode = pFacToken->GetOpCode();
bool bLimitOk;
switch (eFacOpCode)
@@ -2091,7 +2091,7 @@ void FormulaCompiler::Factor()
// error wasn't propagated so assert only the program
// counter.
bLimitOk = false;
assert(pc == FORMULA_MAXTOKENS);
assert(mnPC == FORMULA_MAXTOKENS);
break;
default:
bLimitOk = false;
@@ -2177,7 +2177,7 @@ void FormulaCompiler::IntersectionLine()
// functions (potentially returning references, if not then a space
// or no space would be a syntax error anyway), not other operators
// or operands. Else discard.
if (isAdjacentOrGapRpnEnd( pc, mpCode, pCode1, pCode2) && isIntersectable( pCode1, pCode2))
if (isAdjacentOrGapRpnEnd( mnPC, mpCode, pCode1, pCode2) && isIntersectable( pCode1, pCode2))
{
FormulaTokenRef pIntersect( new FormulaByteToken( ocIntersect));
// Replace ocSpaces with ocIntersect so that when switching
@@ -2381,7 +2381,7 @@ FormulaTokenRef FormulaCompiler::ExtendRangeReference( FormulaToken & /*rTok1*/,
bool FormulaCompiler::MergeRangeReference( FormulaToken * * const pCode1, FormulaToken * const * const pCode2 )
{
if (!isAdjacentRpnEnd( pc, mpCode, pCode1, pCode2))
if (!isAdjacentRpnEnd( mnPC, mpCode, pCode1, pCode2))
return false;
FormulaToken *p1 = *pCode1, *p2 = *pCode2;
@@ -2394,7 +2394,7 @@ bool FormulaCompiler::MergeRangeReference( FormulaToken * * const pCode1, Formul
p2->DecRef();
*pCode1 = p.get();
--mpCode;
--pc;
--mnPC;
return true;
}
@@ -2427,7 +2427,7 @@ bool FormulaCompiler::CompileTokenArray()
mpArr->ClearRecalcMode();
maArrIterator.Reset();
meLastOp = ocOpen;
pc = 0;
mnPC = 0;
NextToken();
OpCode eOp = Expression();
// Some trailing garbage that doesn't form an expression?
@@ -2439,9 +2439,9 @@ bool FormulaCompiler::CompileTokenArray()
while( mpStack )
PopTokenArray();
if( pc )
if( mnPC )
{
mpArr->CreateNewRPNArrayFromData( pData, pc );
mpArr->CreateNewRPNArrayFromData( pData, mnPC );
if( mbNeedsRPNTokenCheck )
mpArr->CheckAllRPNTokens();
}
@@ -3046,15 +3046,15 @@ OpCode FormulaCompiler::NextToken()
void FormulaCompiler::PutCode( FormulaTokenRef& p )
{
if( pc >= FORMULA_MAXTOKENS - 1 )
if( mnPC >= FORMULA_MAXTOKENS - 1 )
{
if ( pc == FORMULA_MAXTOKENS - 1 )
if ( mnPC == FORMULA_MAXTOKENS - 1 )
{
SAL_WARN("formula.core", "FormulaCompiler::PutCode - CodeOverflow with OpCode " << +p->GetOpCode());
p = new FormulaByteToken( ocStop );
p->IncRef();
*mpCode++ = p.get();
++pc;
++mnPC;
}
SetError( FormulaError::CodeOverflow);
return;
@@ -3064,7 +3064,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p )
ForceArrayOperator( p);
p->IncRef();
*mpCode++ = p.get();
pc++;
mnPC++;
}
@@ -3204,7 +3204,7 @@ void FormulaCompiler::ForceArrayOperator( FormulaTokenRef const & rCurr )
// below.
rCurr->SetInForceArray( ParamClass::ForceArray);
}
else if (pc >= 2 && SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP)
else if (mnPC >= 2 && SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP)
{
// Binary operators are not functions followed by arguments
// and need some peeking into RPN to inspect their operands.
@@ -3231,7 +3231,7 @@ void FormulaCompiler::ForceArrayOperator( FormulaTokenRef const & rCurr )
rCurr->SetInForceArray( eArrayReturn);
}
}
else if (pc >= 1 && SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP)
else if (mnPC >= 1 && SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP)
{
// Similar for unary operators.
if (mpCode[-1]->GetInForceArray() != ParamClass::Unknown || IsMatrixFunction(mpCode[-1]->GetOpCode()))
+1 -1
View File
@@ -410,7 +410,7 @@ protected:
OpCode meLastOp;
short mnRecursion; // GetToken() recursions
SvNumFormatType mnNumFmt; // set during CompileTokenArray()
sal_uInt16 pc; // program counter
sal_uInt16 mnPC; // program counter
FormulaGrammar::Grammar meGrammar; // The grammar used, language plus convention.