bool Why3Translator::visit(UnaryOperation const& _unaryOperation)
{
	try
	{
		toFormalType(*_unaryOperation.annotation().type);
	}
	catch (NoFormalType &err)
	{
		string const* typeNamePtr = boost::get_error_info<errinfo_noFormalTypeFrom>(err);
		error(_unaryOperation, "Type \"" + (typeNamePtr ? *typeNamePtr : "") + "\" supported in unary operation.");
	}

	switch (_unaryOperation.getOperator())
	{
	case Token::Not: // !
		add("(not ");
		break;
	default:
		error(_unaryOperation, "Operator not supported.");
		break;
	}

	_unaryOperation.subExpression().accept(*this);
	add(")");

	return false;
}
示例#2
0
bool ASTPrinter::visit(UnaryOperation const& _node)
{
	writeLine(string("UnaryOperation (") + (_node.isPrefixOperation() ? "prefix" : "postfix") +
			  ") " + Token::toString(_node.getOperator()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
ScalarUnaryExpression::ScalarUnaryExpression(const UnaryOperation &operation,
                                             Scalar *operand)
    : Scalar(*operation.resultTypeForArgumentType(operand->getType())),
      operation_(operation),
      operand_(operand) {
  initHelper(false);
}