Moved handling of MissingArgEval into IF() or CHOOSE() for non-optimised (eager argument evaluation) case
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@884389 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bf6c8f8dc
commit
823c6c6424
@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula.functions;
|
package org.apache.poi.hssf.record.formula.functions;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.BlankEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
|
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
|
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
||||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||||
|
|
||||||
@ -37,7 +39,11 @@ public final class Choose implements Function {
|
|||||||
if (ix < 1 || ix >= args.length) {
|
if (ix < 1 || ix >= args.length) {
|
||||||
return ErrorEval.VALUE_INVALID;
|
return ErrorEval.VALUE_INVALID;
|
||||||
}
|
}
|
||||||
return OperandResolver.getSingleValue(args[ix], srcRowIndex, srcColumnIndex);
|
ValueEval result = OperandResolver.getSingleValue(args[ix], srcRowIndex, srcColumnIndex);
|
||||||
|
if (result == MissingArgEval.instance) {
|
||||||
|
return BlankEval.INSTANCE;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return e.getErrorEval();
|
return e.getErrorEval();
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record.formula.functions;
|
package org.apache.poi.hssf.record.formula.functions;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.BlankEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.BoolEval;
|
import org.apache.poi.hssf.record.formula.eval.BoolEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
|
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
|
||||||
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
||||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||||
|
|
||||||
@ -34,7 +36,13 @@ public final class If extends Var2or3ArgFunction {
|
|||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return e.getErrorEval();
|
return e.getErrorEval();
|
||||||
}
|
}
|
||||||
return b ? arg1 : BoolEval.FALSE;
|
if (b) {
|
||||||
|
if (arg1 == MissingArgEval.instance) {
|
||||||
|
return BlankEval.INSTANCE;
|
||||||
|
}
|
||||||
|
return arg1;
|
||||||
|
}
|
||||||
|
return BoolEval.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
|
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
|
||||||
@ -45,7 +53,16 @@ public final class If extends Var2or3ArgFunction {
|
|||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return e.getErrorEval();
|
return e.getErrorEval();
|
||||||
}
|
}
|
||||||
return b ? arg1 : arg2;
|
if (b) {
|
||||||
|
if (arg1 == MissingArgEval.instance) {
|
||||||
|
return BlankEval.INSTANCE;
|
||||||
|
}
|
||||||
|
return arg1;
|
||||||
|
}
|
||||||
|
if (arg2 == MissingArgEval.instance) {
|
||||||
|
return BlankEval.INSTANCE;
|
||||||
|
}
|
||||||
|
return arg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean evaluateFirstArg(ValueEval arg, int srcCellRow, int srcCellCol)
|
public static boolean evaluateFirstArg(ValueEval arg, int srcCellRow, int srcCellCol)
|
||||||
|
@ -435,9 +435,6 @@ public final class WorkbookEvaluator {
|
|||||||
}
|
}
|
||||||
// logDebug("invoke " + operation + " (nAgs=" + numops + ")");
|
// logDebug("invoke " + operation + " (nAgs=" + numops + ")");
|
||||||
opResult = OperationEvaluatorFactory.evaluate(optg, ops, ec);
|
opResult = OperationEvaluatorFactory.evaluate(optg, ops, ec);
|
||||||
if (opResult == MissingArgEval.instance) {
|
|
||||||
opResult = BlankEval.INSTANCE;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
opResult = getEvalForPtg(ptg, ec);
|
opResult = getEvalForPtg(ptg, ec);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user