本文整理汇总了C++中ASTType::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTType::toString方法的具体用法?C++ ASTType::toString怎么用?C++ ASTType::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTType
的用法示例。
在下文中一共展示了ASTType::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void SymbolCheckVisitor::visit(ASTConcatenate& ast)
{
ast.getLeft().accept(*this);
ASTType lefttype = mCurrentType;
mCurrentType.clear();
ast.getRight().accept(*this);
switch ( ast.getMode() )
{
case ASTConcatenate::eMul:
case ASTConcatenate::eDiv:
case ASTConcatenate::eRem:
case ASTConcatenate::ePlus:
case ASTConcatenate::eMinus:
{
ASTType righttype = mCurrentType;
mCurrentType = ASTType::greaterType(lefttype, righttype);
if ( mCurrentType.isValid() )
{
// optionally add casts if necessary
if ( mCurrentType.isChar() && lefttype.isString() )
{
// add char is now allowed directly:
// str = str + char <- no casts
// str = char + str <- casts char to string
break;
}
if ( !lefttype.equals(mCurrentType) )
{
ASTCast* pcast = new ASTCast();
pcast->setType(mCurrentType.clone());
pcast->setNode(ast.useLeft());
ast.setLeft(pcast);
}
if ( !righttype.equals(mCurrentType) )
{
ASTCast* pcast = new ASTCast();
pcast->setType(mCurrentType.clone());
pcast->setNode(ast.useRight());
ast.setRight(pcast);
}
}
else
{
String op = UTEXT("+");
error(E0022, UTEXT("Can not execute operator ") + op + UTEXT(" on types ") + lefttype.toString() + UTEXT(" and ") + righttype.toString(), ast);
}
}
break;
case ASTConcatenate::eBitwiseOr:
case ASTConcatenate::eBitwiseXor:
case ASTConcatenate::eBitwiseAnd:
case ASTConcatenate::eShiftLeft:
case ASTConcatenate::eShiftRight:
{
ASTType righttype = mCurrentType;
if ( !lefttype.isInt() || !righttype.isInt() )
{
error(E0023, UTEXT("Bitwise operators only operate on int values."), ast);
}
}
break;
case ASTConcatenate::eAnd:
case ASTConcatenate::eOr:
{
if ( !lefttype.isBoolean() || !mCurrentType.isBoolean() )
{
String op = UTEXT("&&"); // add toString to Mode
error(E0024, UTEXT("Operator ") + op + UTEXT(" requires boolean expressions."), ast);
}
}
break;
case ASTConcatenate::eEquals:
case ASTConcatenate::eUnequals:
case ASTConcatenate::eSmallerEqual:
case ASTConcatenate::eSmaller:
case ASTConcatenate::eGreater:
case ASTConcatenate::eGreaterEqual:
{
ASTType comp = ASTType::greaterType(lefttype, mCurrentType);
if ( !comp.isValid() )
{
error(E0025, UTEXT("Can not compare ") + lefttype.toString() + UTEXT(" with ") + mCurrentType.toString(), ast);
}
else if ( ast.getMode() >= ASTConcatenate::eSmallerEqual )
{
if ( comp.isObject() || comp.isArray() || comp.isBoolean() )
{
//.........这里部分代码省略.........