当前位置: 首页>>代码示例>>C++>>正文


C++ PrintContext::out方法代码示例

本文整理汇总了C++中PrintContext::out方法的典型用法代码示例。如果您正苦于以下问题:C++ PrintContext::out方法的具体用法?C++ PrintContext::out怎么用?C++ PrintContext::out使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PrintContext的用法示例。


在下文中一共展示了PrintContext::out方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doPrint

void MemberAccessOperator::doPrint(PrintContext &context) const {
    bool braces = compound()->is<UnaryOperator>() ||
                  compound()->is<BinaryOperator>() ||
                  compound()->is<Typecast>();

    if (braces) {
        context.out() << "(";
    }
    compound_->print(context);
    if (braces) {
        context.out() << ")";
    }

    switch (accessKind()) {
        case ARROW:
            context.out() << "->";
            break;
        case DOT:
            context.out() << '.';
            break;
        default:
            unreachable();
            break;
    }
    
    context.out() << member_->identifier();
}
开发者ID:453483289,项目名称:smartdec,代码行数:27,代码来源:MemberAccessOperator.cpp

示例2: doPrint

void IntegerConstant::doPrint(PrintContext &context) const {
    SignedConstantValue val = value().size() > 1 ? value().signedValue() : value().value();

    if ((0 <= val && val <= 100) || (-100 <= val && val < 0 && !type()->isUnsigned())) {
        context.out() << val;
    } else {
        context.out() << hex << "0x" << value().value() << dec;
    }
}
开发者ID:yarec,项目名称:snowman,代码行数:9,代码来源:IntegerConstant.cpp

示例3: doPrint

void Typecast::doPrint(PrintContext &context) const {
    context.out() << '(' << *type() << ')';
    bool braces = operand()->is<BinaryOperator>();
    if (braces) {
        context.out() << '(';
    }
    operand()->print(context);
    if (braces) {
        context.out() << ')';
    }
}
开发者ID:453483289,项目名称:smartdec,代码行数:11,代码来源:Typecast.cpp

示例4: doPrint

void UnaryOperator::doPrint(PrintContext &context) const {
    switch (operatorKind()) {
        case DEREFERENCE:
            context.out() << '*';
            break;
        case REFERENCE:
            context.out() << '&';
            break;
        case BITWISE_NOT:
            context.out() << '~';
            break;
        case LOGICAL_NOT:
            context.out() << '!';
            break;
        case NEGATION:
            context.out() << '-';
            break;
        case PREFIX_INCREMENT:
            context.out() << "++";
            break;
        case PREFIX_DECREMENT:
            context.out() << "--";
            break;
        default:
            unreachable();
            break;
    }

    int precedence = this->precedence();
    int operandPrecedence = operand()->precedence();

    int absPrecedence = abs(precedence);
    int absOperandPrecedence = abs(operandPrecedence);

    bool operandInBraces = absOperandPrecedence > absPrecedence;

    /* Avoid too many minuses in a row. */
    if (operatorKind() == NEGATION || operatorKind() == PREFIX_DECREMENT) {
        if (auto unary = operand()->as<UnaryOperator>()) {
            if (unary->operatorKind() == NEGATION || unary->operatorKind() == PREFIX_DECREMENT) {
                operandInBraces = true;
            }
        }
    }

    if (operandInBraces) {
        context.out() << '(';
    }
    operand()->print(context);
    if (operandInBraces) {
        context.out() << ')';
    }
}
开发者ID:453483289,项目名称:smartdec,代码行数:53,代码来源:UnaryOperator.cpp

示例5: printSignature

void FunctionDeclaration::printSignature(PrintContext &context) const {
    context.out() << *type()->returnType() << ' ';
    functionIdentifier()->print(context);
    context.out() << '(';

    bool comma = false;
    foreach (const auto &argument, arguments_) {
        if (comma) {
            context.out() << ", ";
        } else {
            comma = true;
        }
        argument->print(context);
    }

    if (type()->variadic()) {
        if (comma) {
            context.out() << ", ";
        }
        context.out() << "...";
    }
    
    context.out() << ')';
}
开发者ID:AGeekyDevil,项目名称:snowman,代码行数:24,代码来源:FunctionDeclaration.cpp

示例6: doPrint

void While::doPrint(PrintContext &context) const {
    context.out() << "while (";
    condition()->print(context);
    context.out() << ") ";
    printNestedStatement(body(), context);
}
开发者ID:uxmal,项目名称:snowman,代码行数:6,代码来源:While.cpp

示例7: doPrint

void Switch::doPrint(PrintContext &context) const {
    context.out() << "switch (";
    expression()->print(context);
    context.out() << ") ";
    printNestedStatement(body(), context);
}
开发者ID:yarec,项目名称:snowman,代码行数:6,代码来源:Switch.cpp

示例8: doPrint

void InlineAssembly::doPrint(PrintContext &context) const {
    context.out() << "__asm__(\"" << code() << "\")";
}
开发者ID:453483289,项目名称:smartdec,代码行数:3,代码来源:InlineAssembly.cpp

示例9: doPrint

void ExpressionStatement::doPrint(PrintContext &context) const {
    expression_->print(context);
    context.out() << ';';
}
开发者ID:yarec,项目名称:snowman,代码行数:4,代码来源:ExpressionStatement.cpp

示例10: doPrint

void FunctionDeclaration::doPrint(PrintContext &context) const {
    printComment(context);
    printSignature(context);
    context.out() << ';';
}
开发者ID:AGeekyDevil,项目名称:snowman,代码行数:5,代码来源:FunctionDeclaration.cpp

示例11: doPrint

void LabelIdentifier::doPrint(PrintContext &context) const {
    context.out() << declaration_->identifier();
}
开发者ID:d4nnyk,项目名称:snowman,代码行数:3,代码来源:LabelIdentifier.cpp

示例12: doPrint

void Goto::doPrint(PrintContext &context) const {
    context.out() << "goto ";
    destination_->print(context);
    context.out() << ';';
}
开发者ID:AGeekyDevil,项目名称:snowman,代码行数:5,代码来源:Goto.cpp


注:本文中的PrintContext::out方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。