Kaydet (Commit) 43a61b3d authored tarafından I-Jui (Ray) Sung's avatar I-Jui (Ray) Sung Kaydeden (comit) Kohei Yoshida

Include a message for unhandled-token in OCL group interpreter.

Also added sanity checks for unhandled cases; i.e. mixed string/numeric
in SingleVectorRefs

Change-Id: I448536f45ec6cf9bc870671646c5ed4ee83ac9f8
üst b3aadaa5
...@@ -807,14 +807,19 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s, ...@@ -807,14 +807,19 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
const formula::SingleVectorRefToken* pSVR = const formula::SingleVectorRefToken* pSVR =
dynamic_cast< const formula::SingleVectorRefToken* >(pChild); dynamic_cast< const formula::SingleVectorRefToken* >(pChild);
assert(pSVR); assert(pSVR);
if (pSVR->GetArray().mpNumericArray) if (pSVR->GetArray().mpNumericArray &&
!pSVR->GetArray().mpStringArray)
mvSubArguments.push_back( mvSubArguments.push_back(
SubArgument(new DynamicKernelArgument(ts, SubArgument(new DynamicKernelArgument(ts,
ft->Children[i]))); ft->Children[i])));
else else if (!pSVR->GetArray().mpNumericArray &&
pSVR->GetArray().mpStringArray)
mvSubArguments.push_back( mvSubArguments.push_back(
SubArgument(new DynamicKernelStringArgument( SubArgument(new DynamicKernelStringArgument(
ts, ft->Children[i]))); ts, ft->Children[i])));
else
throw UnhandledToken(pChild,
"Got both numeric and string vector");
} else if (pChild->GetType() == formula::svDouble) { } else if (pChild->GetType() == formula::svDouble) {
mvSubArguments.push_back( mvSubArguments.push_back(
SubArgument(new DynamicKernelConstantArgument(ts, SubArgument(new DynamicKernelConstantArgument(ts,
...@@ -824,7 +829,7 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s, ...@@ -824,7 +829,7 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
SubArgument(new ConstStringArgument(ts, SubArgument(new ConstStringArgument(ts,
ft->Children[i]))); ft->Children[i])));
} else { } else {
throw UnhandledToken(pChild); throw UnhandledToken(pChild, "unknown operand for ocPush");
} }
break; break;
case ocDiv: case ocDiv:
...@@ -1095,7 +1100,7 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s, ...@@ -1095,7 +1100,7 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
} }
break; break;
default: default:
throw UnhandledToken(pChild); throw UnhandledToken(pChild, "unhandled opcode");
}; };
} }
} }
...@@ -1414,8 +1419,9 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, ...@@ -1414,8 +1419,9 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
return true; return true;
} }
#undef NO_FALLBACK_TO_SWINTERP /* undef this for non-TDD runs */ #undef NO_FALLBACK_TO_SWINTERP /* undef this for non-TDD runs */
catch (const UnhandledToken&) { catch (const UnhandledToken &ut) {
std::cerr << "Dynamic formual compiler: unhandled token\n"; std::cerr << "\nDynamic formual compiler: unhandled token: ";
std::cerr << ut.mMessage << "\n";
#ifdef NO_FALLBACK_TO_SWINTERP #ifdef NO_FALLBACK_TO_SWINTERP
assert(false); assert(false);
#else #else
......
...@@ -25,8 +25,10 @@ namespace sc { namespace opencl { ...@@ -25,8 +25,10 @@ namespace sc { namespace opencl {
class UnhandledToken class UnhandledToken
{ {
public: public:
UnhandledToken(formula::FormulaToken *t): mToken(t) {} UnhandledToken(formula::FormulaToken *t,
const char *const m): mToken(t), mMessage(m) {}
formula::FormulaToken *mToken; formula::FormulaToken *mToken;
std::string mMessage;
}; };
/// Failed in marshaling /// Failed in marshaling
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment