本文整理汇总了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();
}
示例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;
}
}
示例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() << ')';
}
}
示例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() << ')';
}
}
示例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() << ')';
}
示例6: doPrint
void While::doPrint(PrintContext &context) const {
context.out() << "while (";
condition()->print(context);
context.out() << ") ";
printNestedStatement(body(), context);
}
示例7: doPrint
void Switch::doPrint(PrintContext &context) const {
context.out() << "switch (";
expression()->print(context);
context.out() << ") ";
printNestedStatement(body(), context);
}
示例8: doPrint
void InlineAssembly::doPrint(PrintContext &context) const {
context.out() << "__asm__(\"" << code() << "\")";
}
示例9: doPrint
void ExpressionStatement::doPrint(PrintContext &context) const {
expression_->print(context);
context.out() << ';';
}
示例10: doPrint
void FunctionDeclaration::doPrint(PrintContext &context) const {
printComment(context);
printSignature(context);
context.out() << ';';
}
示例11: doPrint
void LabelIdentifier::doPrint(PrintContext &context) const {
context.out() << declaration_->identifier();
}
示例12: doPrint
void Goto::doPrint(PrintContext &context) const {
context.out() << "goto ";
destination_->print(context);
context.out() << ';';
}