[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Jul 10 08:59:26 PDT 2013
sc/inc/formulagroup.hxx | 3 +++
sc/source/core/opencl/formulagroupcl.cxx | 8 +++++---
sc/source/core/tool/formulagroup.cxx | 13 ++++++++++---
3 files changed, 18 insertions(+), 6 deletions(-)
New commits:
commit 2f8d759e615355f6498ad8f95e162367745c3bb9
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jul 10 11:58:49 2013 -0400
Generate Reverse Polish token array (RPN) at the start.
Change-Id: Idcac01820fab536cebebcc437e206b6900511600
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index e645968..9963fc9 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -39,6 +39,9 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
protected:
FormulaGroupInterpreter() {}
virtual ~FormulaGroupInterpreter() {}
+
+ static void generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode);
+
public:
static FormulaGroupInterpreter *getStatic();
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 8bc0224..04a67d2 100755
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -65,6 +65,8 @@ ScMatrixRef FormulaGroupInterpreterOpenCL::inverseMatrix(const ScMatrix& /* rMat
bool FormulaGroupInterpreterOpenCL::interpret(ScDocument& rDoc, const ScAddress& rTopPos,
const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode)
{
+ generateRPNCode(rDoc, rTopPos, rCode);
+
size_t rowSize = xGroup->mnLength;
fprintf(stderr,"rowSize at begin is ...%ld.\n",(long)rowSize);
// The row quantity can be gotten from p2->GetArrayLength()
@@ -193,9 +195,7 @@ bool FormulaGroupInterpreterOpenCL::interpret(ScDocument& rDoc, const ScAddress&
if(!getenv("SC_GPU")||!ocl_calc.GetOpenclState())
{
fprintf(stderr,"ccCPU flow...\n\n");
- ScCompiler aComp(&rDoc, aTmpPos, aCode2);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
+ generateRPNCode(rDoc, aTmpPos, aCode2);
ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
aInterpreter.Interpret();
pDest->SetResultToken(aInterpreter.GetResultToken().get());
@@ -306,6 +306,8 @@ bool FormulaGroupInterpreterGroundwater::interpret(ScDocument& rDoc, const ScAdd
const ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode)
{
+ generateRPNCode(rDoc, rTopPos, rCode);
+
// Inputs: both of length xGroup->mnLength
OpCode eOp; // type of operation: ocAverage, ocMax, ocMin
const double *pArrayToSubtractOneElementFrom;
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 627c5f5..5a23511 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -96,9 +96,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
if (!pDest)
return false;
- ScCompiler aComp(&rDoc, aTmpPos, aCode2);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
+ generateRPNCode(rDoc, aTmpPos, aCode2);
ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
aInterpreter.Interpret();
aResults.push_back(aInterpreter.GetResultToken()->GetDouble());
@@ -190,6 +188,15 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
return msInstance;
}
+void FormulaGroupInterpreter::generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode)
+{
+ // First, generate an RPN (reverse polish notation) token array.
+ ScCompiler aComp(&rDoc, rPos, rCode);
+ aComp.SetGrammar(rDoc.GetGrammar());
+ aComp.CompileTokenArray(); // Create RPN token array.
+ // Now, calling FirstRPN() and NextRPN() will return tokens from the RPN token array.
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list