// e.g. (Int)a or (int)(a + b) public override bool Visit(UnifiedCast element, VisitorArgument arg) { Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); element.Expression.TryAccept(this, arg.Set(Paren)); return false; }
// e.g. (Int)a or (int)(a + b) public override bool Visit(UnifiedCast element, VisitorArgument arg) { Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); element.Expression.TryAccept(this, arg.Set(Paren)); return(false); }
public UnifiedElement VisitCastExpression( CastExpression expr, object data) { var type = LookupType(expr.Type); var elem = expr.Expression.TryAcceptForExpression(this); return(UnifiedCast.Create(type, elem)); }
//キャスト式 public override bool Visit(UnifiedCast element, VisitorArgument arg) { Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); //TODO ここのarg.Set(Paren)が不要な気がするので、後ではずしてテストしてみる element.Expression.TryAccept(this, arg.Set(Paren)); return true; }
//キャスト式 public override bool Visit(UnifiedCast element, VisitorArgument arg) { Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); //TODO ここのarg.Set(Paren)が不要な気がするので、後ではずしてテストしてみる element.Expression.TryAccept(this, arg.Set(Paren)); return(true); }
// e.g. (Int)a or (int)(a + b) public override bool Visit(UnifiedCast element, VisitorArgument arg) { // ((TestCase)(test)).setName(name); などに対応するため括弧を出力 Writer.Write("("); Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); element.Expression.TryAccept(this, arg.Set(Paren)); Writer.Write(")"); return(true); }
// e.g. (Int)a or (int)(a + b) public override bool Visit(UnifiedCast element, VisitorArgument arg) { // ((TestCase)(test)).setName(name); などに対応するため括弧を出力 Writer.Write("("); Writer.Write("("); element.Type.TryAccept(this, arg); Writer.Write(")"); element.Expression.TryAccept(this, arg.Set(Paren)); Writer.Write(")"); return true; }
public static UnifiedExpression CreateCastExpression(XElement node) { Contract.Requires(node != null); Contract.Requires(node.Name() == "cast_expression"); /* * cast_expression * : '(' type_name ')' cast_expression | unary_expression */ if (node.Element("cast_expression") != null) { return(UnifiedCast.Create( CreateTypeName(node.Element("type_name")), CreateCastExpression(node.Element("cast_expression")))); } if (node.Element("unary_expression") != null) { return(CreateUnaryExpression(node.Element("unary_expression"))); } throw new InvalidOperationException(); }