本文整理汇总了C++中IValue::IsVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ IValue::IsVariable方法的具体用法?C++ IValue::IsVariable怎么用?C++ IValue::IsVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValue
的用法示例。
在下文中一共展示了IValue::IsVariable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParserError
//---------------------------------------------------------------------------
const IValue& ParserXBase::ParseFromRPN() const
{
ptr_val_type *pStack = &m_vStackBuffer[0];
if (m_rpn.GetSize()==0)
{
// Passiert bei leeren strings oder solchen, die nur Leerzeichen enthalten
ErrorContext err;
err.Expr = m_pTokenReader->GetExpr();
err.Errc = ecUNEXPECTED_EOF;
err.Pos = 0;
throw ParserError(err);
}
const ptr_tok_type *pRPN = &(m_rpn.GetData()[0]);
int sidx = -1;
std::size_t lenRPN = m_rpn.GetSize();
for (std::size_t i=0; i<lenRPN; ++i)
{
IToken *pTok = pRPN[i].Get();
ECmdCode eCode = pTok->GetCode();
switch (eCode)
{
case cmSCRIPT_NEWLINE:
sidx = -1;
continue;
case cmVAL:
{
IValue *pVal = static_cast<IValue*>(pTok);
sidx++;
assert(sidx<(int)m_vStackBuffer.size());
if (pVal->IsVariable())
{
pStack[sidx].Reset(pVal);
}
else
{
ptr_val_type &val = pStack[sidx];
if (val->IsVariable())
val.Reset(m_cache.CreateFromCache());
*val = *(static_cast<IValue*>(pTok));
}
}
continue;
case cmIC:
{
IOprtIndex *pIdxOprt = static_cast<IOprtIndex*>(pTok);
int nArgs = pIdxOprt->GetArgsPresent();
sidx -= nArgs - 1;
assert(sidx>=0);
ptr_val_type &idx = pStack[sidx]; // Pointer to the first index
ptr_val_type &val = pStack[--sidx]; // Pointer to the variable or value beeing indexed
pIdxOprt->At(val, &idx, nArgs);
}
continue;
case cmOPRT_POSTFIX:
case cmFUNC:
case cmOPRT_BIN:
case cmOPRT_INFIX:
{
ICallback *pFun = static_cast<ICallback*>(pTok);
int nArgs = pFun->GetArgsPresent();
sidx -= nArgs - 1;
assert(sidx>=0);
ptr_val_type &val = pStack[sidx];
try
{
if (val->IsVariable())
{
ptr_val_type buf(m_cache.CreateFromCache());
pFun->Eval(buf, &val, nArgs);
val = buf;
}
else
pFun->Eval(val, &val, nArgs);
}
catch(ParserError &exc)
{
// <ibg 20130131> Not too happy about that:
// Multiarg functions may throw specific error codes when evaluating.
// These codes would be converted to ecEVAL here. I omit the conversion
// for certain handpicked errors. (The reason this catch block exists is
// that not all exceptions contain proper metadata when thrown out of
// a function.)
if (exc.GetCode()==ecTOO_FEW_PARAMS || exc.GetCode()==ecDOMAIN_ERROR || exc.GetCode()==ecOVERFLOW)
throw;
// </ibg>
ErrorContext err;
err.Expr = m_pTokenReader->GetExpr();
err.Ident = pFun->GetIdent();
//.........这里部分代码省略.........