public override void EmitCpp(CppEmitContext cec) { var leftParens = cec.NeedParens(this, Left); var rightParens = cec.NeedParens(this, Right); if (leftParens) { cec.Buf.Write("(", Location); } Left.EmitCpp(cec); if (leftParens) { cec.Buf.Write(")"); } cec.Buf.Write(" " + this.OperName(oper) + " "); if (rightParens) { cec.Buf.Write("(", Location); } Right.EmitCpp(cec); if (rightParens) { cec.Buf.Write(")"); } }
public override void EmitCpp(CppEmitContext cec) { bool test_parens = cec.NeedParens(this, expr); bool true_parens = cec.NeedParens(this, true_expr); bool false_parens = cec.NeedParens(this, false_expr); if (test_parens) { cec.Buf.Write("("); expr.EmitCpp(cec); cec.Buf.Write(") ? "); } else { expr.EmitCpp(cec); cec.Buf.Write(" ? "); } if (true_parens) { cec.Buf.Write("("); true_expr.EmitCpp(cec); cec.Buf.Write(") : "); } else { true_expr.EmitCpp(cec); cec.Buf.Write(" : "); } if (false_parens) { cec.Buf.Write("("); false_expr.EmitCpp(cec); cec.Buf.Write(")"); } else { false_expr.EmitCpp(cec); } }
public override void EmitCpp(CppEmitContext cec) { bool needsParen = cec.NeedParens(this, Expr); cec.Buf.Write(OperName(Oper), Location); if (needsParen) { cec.Buf.Write("("); } Expr.EmitCpp(cec); if (needsParen) { cec.Buf.Write(")"); } }