本文整理汇总了C++中AST_Expression::getAsBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ AST_Expression::getAsBoolean方法的具体用法?C++ AST_Expression::getAsBoolean怎么用?C++ AST_Expression::getAsBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST_Expression
的用法示例。
在下文中一共展示了AST_Expression::getAsBoolean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
int
MMO_EvalInitExp_::foldTraverseElement (AST_Expression exp)
{
int ret = 0;
switch (exp->expressionType ())
{
case EXPCOMPREF:
{
AST_Expression_ComponentReference cr = exp->getAsComponentReference ();
VarInfo vi = _vt->lookup (cr->name ());
if (vi == NULL)
{
Error::getInstance ()->add (exp->lineNum (),
EM_IR | EM_VARIABLE_NOT_FOUND,
ER_Error, "%s", cr->name ().c_str ());
return (ret);
}
if (!vi->isConstant ())
{
Error::getInstance ()->add (
exp->lineNum (), EM_IR | EM_INIT_EXP, ER_Error,
"Only constants allowed inside initial expressions. %s",
cr->name ().c_str ());
return (ret);
}
return (vi->value ());
}
case EXPBOOLEAN:
{
AST_Expression_Boolean eb = exp->getAsBoolean ();
if (eb->value ())
{
return (1);
}
else
{
return (0);
}
}
case EXPBOOLEANNOT:
{
AST_Expression_BooleanNot ebn = exp->getAsBooleanNot ();
int res = foldTraverse (ebn->exp ());
if (res == 0)
{
return (1);
}
else
{
return (0);
}
}
case EXPREAL:
Error::getInstance ()->add (
0, EM_IR | EM_INIT_EXP, ER_Warning,
"Implicit conversion from Real to Integer, in initial expression.");
return (exp->getAsReal ()->val ());
case EXPINTEGER:
return (exp->getAsInteger ()->val ());
default:
Error::getInstance ()->add (
0,
EM_IR | EM_INIT_EXP,
ER_Warning,
"Initial expression not recognized, returning zero as default value.");
break;
}
return (ret);
}