[Libreoffice-commits] core.git: 6 commits - formula/source include/formula sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed May 14 11:21:54 PDT 2014
formula/source/core/api/FormulaCompiler.cxx | 43 ++++++++++++++++------------
formula/source/ui/dlg/formula.cxx | 4 +-
include/formula/FormulaCompiler.hxx | 11 +++----
sc/inc/compiler.hxx | 8 ++---
sc/source/core/data/formulacell.cxx | 2 +
sc/source/core/data/grouptokenconverter.cxx | 4 --
sc/source/core/opencl/formulagroupcl.cxx | 14 ++++-----
sc/source/core/tool/compiler.cxx | 13 ++++++--
sc/source/core/tool/token.cxx | 9 ++++-
sc/source/ui/miscdlgs/anyrefdg.cxx | 3 +
sc/source/ui/unoobj/tokenuno.cxx | 4 +-
11 files changed, 68 insertions(+), 47 deletions(-)
New commits:
commit d459c3648c28981250809ae3e3cf02dde7157f51
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 13:12:21 2014 -0400
Enable vectorization for the "jump" function opcodes.
Change-Id: I24333db598943a0984fb1abb603e90b79d37d845
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0bc46f9..4f4cbf6 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1328,10 +1328,15 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION)
{
- // This is a function opcode. For now, we only support vectorization
- // for min, max, sum and average.
+ // We support vectorization for the following opcodes.
switch (eOp)
{
+ case ocIf:
+ case ocIfError:
+ case ocIfNA:
+ case ocChose:
+ // Jump commands are now supported.
+ break;
case ocAverage:
case ocMin:
case ocMinA:
commit 17774c46a470dbcd35c9efd2c730acb396dc6539
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 13:01:17 2014 -0400
Disable jump command reordering of RPN tokens for OpenCL interpreter.
Change-Id: I03e1e8a8cda1ff88b1d65876ffc27605090f1f4d
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 0c2755b..78c847e 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3678,6 +3678,8 @@ bool ScFormulaCell::InterpretFormulaGroup()
return false;
}
+ // The converted code does not have RPN tokens yet. The interpreter will
+ // generate them.
mxGroup->meCalcState = sc::GroupCalcRunning;
if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode))
{
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index 47585fd..a43efb0 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -226,10 +226,6 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
}
}
- ScCompiler aComp(&mrDoc, mrPos, mrGroupTokens);
- aComp.SetGrammar(mrDoc.GetGrammar());
- aComp.CompileTokenArray(); // Regenerate RPN tokens.
-
return true;
}
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index d4873b6..7066c4f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -3433,20 +3433,20 @@ CompiledFormula* FormulaGroupInterpreterOpenCL::createCompiledFormula(ScDocument
ScFormulaCellGroup& rGroup,
ScTokenArray& rCode)
{
- ScTokenArray aConvertedCode;
- ScGroupTokenConverter aConverter(aConvertedCode, rDoc, *rGroup.mpTopCell, rTopPos);
- if (!aConverter.convert(rCode) || aConvertedCode.GetLen() == 0)
- return NULL;
-
SymbolTable::nR = rGroup.mnLength;
-
- return DynamicKernel::create(rDoc, rTopPos, aConvertedCode);
+ return DynamicKernel::create(rDoc, rTopPos, rCode);
}
bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode )
{
+ ScCompiler aComp(&rDoc, rTopPos, rCode);
+ aComp.SetGrammar(rDoc.GetGrammar());
+ // Disable special ordering for jump commands for the OpenCL interpreter.
+ aComp.EnableJumpCommandReorder(false);
+ aComp.CompileTokenArray(); // Regenerate RPN tokens.
+
DynamicKernel *pKernel = NULL;
boost::scoped_ptr<DynamicKernel> pLocalKernel;
commit ffa18f56511a91294a3f45bdee9767595e8c03f5
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 11:45:30 2014 -0400
Update the method comment and add assertion per what the comment says.
Change-Id: I751e33a8bba732e3b7935fc41385ea5e1f8c8704
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 811028c..527ad76 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -392,8 +392,9 @@ public:
bool IsEnglishSymbol( const OUString& rName );
bool IsErrorConstant( const OUString& ) const;
- //! _either_ CompileForFAP _or_ AutoCorrection, _not_ both
- // #i101512# SetCompileForFAP is in formula::FormulaCompiler
+ /**
+ * When auto correction is set, the jump command reorder must be enabled.
+ */
void SetAutoCorrection( bool bVal );
void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; }
void SetRefConvention( const Convention *pConvP );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index be8780e..751b98b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3201,6 +3201,7 @@ bool ScCompiler::IsErrorConstant( const OUString& rName ) const
void ScCompiler::SetAutoCorrection( bool bVal )
{
+ assert(mbJumpCommandReorder);
bAutoCorrect = bVal;
mbStopOnError = !bVal;
}
commit a921d38ad4ee087355945b9a544d1957987f308f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 11:31:33 2014 -0400
No more SetCompileForFAP(). Use respective flag setting methods instead.
Change-Id: Ib2256ebac8a7e63e7e24fb35d13d47b811bd8e19
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 59839b4..2e066af 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -980,12 +980,15 @@ sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const
return nError;
}
-void FormulaCompiler::SetCompileForFAP( bool bVal )
+void FormulaCompiler::EnableJumpCommandReorder( bool bEnable )
{
- mbJumpCommandReorder = !bVal;
- mbStopOnError = !bVal;
+ mbJumpCommandReorder = bEnable;
}
+void FormulaCompiler::EnableStopOnError( bool bEnable )
+{
+ mbStopOnError = bEnable;
+}
void FormulaCompiler::AppendErrorConstant( OUStringBuffer& rBuffer, sal_uInt16 nError ) const
{
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 11d36cc..3247f2a 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -740,7 +740,9 @@ void FormulaDlg_Impl::UpdateTokenArray( const OUString& rStrExp)
} // if ( pTokens && nLen == m_aTokenList.getLength() )
FormulaCompiler aCompiler(*m_pTokenArray.get());
- aCompiler.SetCompileForFAP(true); // #i101512# special handling is needed
+ // #i101512# Disable special handling of jump commands.
+ aCompiler.EnableJumpCommandReorder(false);
+ aCompiler.EnableStopOnError(false);
aCompiler.CompileTokenArray();
}
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index ec1aba3..81277c9 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -227,7 +227,8 @@ public:
sal_uInt16 GetErrorConstant( const OUString& rName ) const;
- void SetCompileForFAP( bool bVal );
+ void EnableJumpCommandReorder( bool bEnable );
+ void EnableStopOnError( bool bEnable );
static bool IsOpCodeVolatile( OpCode eOp );
static bool IsOpCodeJumpCommand( OpCode eOp );
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 5b435f0..7e22636 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -323,7 +323,8 @@ void ScFormulaReferenceHelper::Init()
pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
pRefComp->SetGrammar( pDoc->GetGrammar() );
- pRefComp->SetCompileForFAP(true);
+ pRefComp->EnableJumpCommandReorder(false);
+ pRefComp->EnableStopOnError(false);
nRefTab = nTab;
}
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 1bde192..5cd4944 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -114,8 +114,8 @@ void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const
eConv = aConvMap[mnConv];
rCompiler.SetRefConvention( eConv );
-
- rCompiler.SetCompileForFAP(mbCompileFAP);
+ rCompiler.EnableJumpCommandReorder(!mbCompileFAP);
+ rCompiler.EnableStopOnError(!mbCompileFAP);
rCompiler.SetExternalLinks( maExternalLinks);
}
commit 69a7e7440cdafbaeddd344f61cc5dfe54750d509
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 11:17:13 2014 -0400
Use "stop on error" concept rather than "ignore error if true".
Just to keep the pattern of "true" -> "action", "false" -> "no action".
Change-Id: I6303bc779cd7048eef2fdc3c2abba8be8f15da6d
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 02c7a5e..59839b4 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -537,9 +537,9 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr )
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
bCorrected( false ),
- bIgnoreErrors( false ),
glSubTotal( false ),
- mbJumpCommandReorder(true)
+ mbJumpCommandReorder(true),
+ mbStopOnError(true)
{
}
@@ -555,9 +555,9 @@ FormulaCompiler::FormulaCompiler()
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
bCorrected( false ),
- bIgnoreErrors( false ),
glSubTotal( false ),
- mbJumpCommandReorder(true)
+ mbJumpCommandReorder(true),
+ mbStopOnError(true)
{
}
@@ -983,7 +983,7 @@ sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const
void FormulaCompiler::SetCompileForFAP( bool bVal )
{
mbJumpCommandReorder = !bVal;
- bIgnoreErrors = bVal;
+ mbStopOnError = !bVal;
}
@@ -1041,7 +1041,7 @@ bool FormulaCompiler::GetToken()
aCorrectedSymbol = "";
}
bool bStop = false;
- if( pArr->GetCodeError() && !bIgnoreErrors )
+ if (pArr->GetCodeError() && mbStopOnError)
bStop = true;
else
{
@@ -1119,7 +1119,7 @@ bool FormulaCompiler::GetToken()
// RPN creation by recursion
void FormulaCompiler::Factor()
{
- if ( pArr->GetCodeError() && !bIgnoreErrors )
+ if (pArr->GetCodeError() && mbStopOnError)
return;
CurrentFactor pFacToken( this );
@@ -1157,7 +1157,7 @@ void FormulaCompiler::Factor()
{
NextToken();
eOp = Expression();
- while ((eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors))
+ while ((eOp == ocSep) && (!pArr->GetCodeError() || !mbStopOnError))
{ // range list (A1;A2) converted to (A1~A2)
pFacToken = mpToken;
NextToken();
@@ -1292,7 +1292,7 @@ void FormulaCompiler::Factor()
if( !bNoParam )
{
nSepCount++;
- while ( (eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors) )
+ while ((eOp == ocSep) && (!pArr->GetCodeError() || !mbStopOnError))
{
nSepCount++;
NextToken();
@@ -1364,7 +1364,7 @@ void FormulaCompiler::Factor()
}
short nJumpCount = 0;
while ( (nJumpCount < (FORMULA_MAXJUMPCOUNT - 1)) && (eOp == ocSep)
- && (!pArr->GetCodeError() || bIgnoreErrors) )
+ && (!pArr->GetCodeError() || !mbStopOnError))
{
if ( ++nJumpCount <= nJumpMax )
pFacToken->GetJump()[nJumpCount] = pc-1;
@@ -1641,7 +1641,7 @@ bool FormulaCompiler::CompileTokenArray()
{
glSubTotal = false;
bCorrected = false;
- if( !pArr->GetCodeError() || bIgnoreErrors )
+ if (!pArr->GetCodeError() || !mbStopOnError)
{
if ( bAutoCorrect )
{
@@ -1684,7 +1684,7 @@ bool FormulaCompiler::CompileTokenArray()
if( !pArr->GetCodeError() && nErrorBeforePop )
pArr->SetCodeError( nErrorBeforePop);
- if( pArr->GetCodeError() && !bIgnoreErrors )
+ if (pArr->GetCodeError() && mbStopOnError)
{
pArr->DelRPN();
pArr->SetHyperLink( false);
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index 8d4627e..ec1aba3 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -337,11 +337,10 @@ protected:
bool bAutoCorrect; // whether to apply AutoCorrection
bool bCorrected; // AutoCorrection was applied
- bool bIgnoreErrors; // on AutoCorrect and CompileForFAP
- // ignore errors and create RPN nevertheless
bool glSubTotal; // if code contains one or more subtotal functions
bool mbJumpCommandReorder; /// Whether or not to reorder RPN for jump commands.
+ bool mbStopOnError; /// Whether to stop compilation on first encountered error.
private:
void InitSymbolsNative() const; /// only SymbolsNative, on first document creation
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 8ea5c77..811028c 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -394,8 +394,7 @@ public:
//! _either_ CompileForFAP _or_ AutoCorrection, _not_ both
// #i101512# SetCompileForFAP is in formula::FormulaCompiler
- void SetAutoCorrection( bool bVal )
- { bAutoCorrect = bVal; bIgnoreErrors = bVal; }
+ void SetAutoCorrection( bool bVal );
void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; }
void SetRefConvention( const Convention *pConvP );
void SetRefConvention( const formula::FormulaGrammar::AddressConvention eConv );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 9f5c51b..be8780e 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3199,6 +3199,12 @@ bool ScCompiler::IsErrorConstant( const OUString& rName ) const
return false;
}
+void ScCompiler::SetAutoCorrection( bool bVal )
+{
+ bAutoCorrect = bVal;
+ mbStopOnError = !bVal;
+}
+
void ScCompiler::AutoCorrectParsedSymbol()
{
sal_Int32 nPos = aCorrectedSymbol.getLength();
commit 5db9391c0640450f3e30dfa9d2c9b8ff9c79b958
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed May 14 11:02:27 2014 -0400
Introduce a new boolean flag and use it in lieu of bCompileForFAP.
To make it sound more general than "compile for FAP".
Change-Id: Ia6916b6f3579a290be7d5074f809666be2bd2473
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 7064e0f..02c7a5e 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -537,9 +537,9 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr )
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
bCorrected( false ),
- bCompileForFAP( false ),
bIgnoreErrors( false ),
- glSubTotal( false )
+ glSubTotal( false ),
+ mbJumpCommandReorder(true)
{
}
@@ -555,9 +555,9 @@ FormulaCompiler::FormulaCompiler()
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
bCorrected( false ),
- bCompileForFAP( false ),
bIgnoreErrors( false ),
- glSubTotal( false )
+ glSubTotal( false ),
+ mbJumpCommandReorder(true)
{
}
@@ -980,6 +980,12 @@ sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const
return nError;
}
+void FormulaCompiler::SetCompileForFAP( bool bVal )
+{
+ mbJumpCommandReorder = !bVal;
+ bIgnoreErrors = bVal;
+}
+
void FormulaCompiler::AppendErrorConstant( OUStringBuffer& rBuffer, sal_uInt16 nError ) const
{
@@ -1121,7 +1127,7 @@ void FormulaCompiler::Factor()
OpCode eOp = mpToken->GetOpCode();
if( eOp == ocPush || eOp == ocColRowNameAuto || eOp == ocMatRef ||
eOp == ocDBArea
- || (bCompileForFAP && ((eOp == ocName) || (eOp == ocDBArea)
+ || (!mbJumpCommandReorder && ((eOp == ocName) || (eOp == ocDBArea)
|| (eOp == ocColRowName) || (eOp == ocBad)))
)
{
@@ -1258,7 +1264,7 @@ void FormulaCompiler::Factor()
|| eOp == ocOr
|| eOp == ocBad
|| ( eOp >= ocInternalBegin && eOp <= ocInternalEnd )
- || (bCompileForFAP && IsOpCodeJumpCommand(eOp)))
+ || (!mbJumpCommandReorder && IsOpCodeJumpCommand(eOp)))
{
pFacToken = mpToken;
OpCode eMyLastOp = eOp;
@@ -1300,7 +1306,7 @@ void FormulaCompiler::Factor()
else
eOp = NextToken();
// Jumps are just normal functions for the FunctionAutoPilot tree view
- if ( bCompileForFAP && pFacToken->GetType() == svJump )
+ if (!mbJumpCommandReorder && pFacToken->GetType() == svJump)
pFacToken = new FormulaFAPToken( pFacToken->GetOpCode(), nSepCount, pFacToken );
else
pFacToken->SetByte( nSepCount );
@@ -2061,7 +2067,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p )
SetError( errCodeOverflow);
return;
}
- if( pArr->GetCodeError() && !bCompileForFAP )
+ if (pArr->GetCodeError() && mbJumpCommandReorder)
return;
ForceArrayOperator( p, pCurrentFactorToken);
p->IncRef();
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index 9df22ec..8d4627e 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -227,8 +227,7 @@ public:
sal_uInt16 GetErrorConstant( const OUString& rName ) const;
- void SetCompileForFAP( bool bVal )
- { bCompileForFAP = bVal; bIgnoreErrors = bVal; }
+ void SetCompileForFAP( bool bVal );
static bool IsOpCodeVolatile( OpCode eOp );
static bool IsOpCodeJumpCommand( OpCode eOp );
@@ -338,12 +337,12 @@ protected:
bool bAutoCorrect; // whether to apply AutoCorrection
bool bCorrected; // AutoCorrection was applied
- bool bCompileForFAP; //! not real RPN but names, for FunctionAutoPilot
- // will not be resolved
bool bIgnoreErrors; // on AutoCorrect and CompileForFAP
// ignore errors and create RPN nevertheless
bool glSubTotal; // if code contains one or more subtotal functions
+ bool mbJumpCommandReorder; /// Whether or not to reorder RPN for jump commands.
+
private:
void InitSymbolsNative() const; /// only SymbolsNative, on first document creation
void InitSymbolsEnglish() const; /// only SymbolsEnglish, maybe later
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 888f774..9f5c51b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3918,7 +3918,7 @@ bool ScCompiler::HandleRange()
sal_uInt16 nErr = pRangeData->GetErrCode();
if( nErr )
SetError( errNoName );
- else if ( !bCompileForFAP )
+ else if (mbJumpCommandReorder)
{
ScTokenArray* pNew;
// put named formula into parentheses.
@@ -4469,7 +4469,7 @@ bool ScCompiler::HandleSingleRef()
}
if ( !bFound )
SetError(errNoRef);
- else if ( !bCompileForFAP )
+ else if (mbJumpCommandReorder)
{
ScTokenArray* pNew = new ScTokenArray();
if ( bSingle )
@@ -4520,7 +4520,7 @@ bool ScCompiler::HandleDbData()
ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(mpToken->GetIndex());
if ( !pDBData )
SetError(errNoName);
- else if ( !bCompileForFAP )
+ else if (mbJumpCommandReorder)
{
ScComplexRefData aRefData;
aRefData.InitFlags();
More information about the Libreoffice-commits
mailing list