/// <summary> /// 二項演算を構築 /// </summary> /// <param name="pos">ファイル位置</param> /// <param name="op_type">二項演算の種類</param> /// <param name="lhs">左辺式</param> /// <param name="rhs">右辺式</param> public MBinOpExpr(string pos, BinOpType op_type, MExpr lhs, MExpr rhs) : base(pos) { OpType = op_type; Lhs = lhs; Rhs = rhs; }
public BinOpExpr(ParserRuleContext sourceLocation, BinOpType operation, IPExpr lhs, IPExpr rhs) { SourceLocation = sourceLocation; Operation = operation; Lhs = lhs; Rhs = rhs; if (IsArithmetic(operation)) { Debug.Assert(Lhs.Type.IsSameTypeAs(Rhs.Type)); Type = Lhs.Type; } else { Type = PrimitiveType.Bool; } }
private string WriteBinOp(BinOpType operation) { switch (operation) { case BinOpType.Add: return("+"); case BinOpType.Sub: return("-"); case BinOpType.Mul: return("*"); case BinOpType.Div: return("/"); case BinOpType.Eq: return("=="); case BinOpType.Neq: return("!="); case BinOpType.Lt: return("<"); case BinOpType.Le: return("<="); case BinOpType.Gt: return(">"); case BinOpType.Ge: return(">="); case BinOpType.And: return("&&"); case BinOpType.Or: return("||"); default: throw new ArgumentOutOfRangeException(nameof(operation), operation, null); } }
public static string ToFriendlyString(this BinOpType me) { switch (me) { case BinOpType.Or: return("|"); case BinOpType.And: return("&"); case BinOpType.Plus: return("+"); case BinOpType.Minus: return("-"); case BinOpType.Prod: return("*"); case BinOpType.Div: return("/"); case BinOpType.Less: return("<"); case BinOpType.LessOrEqual: return("<="); case BinOpType.Greater: return(">"); case BinOpType.GreaterOrEqual: return(">="); case BinOpType.Equal: return("=="); case BinOpType.NotEqual: return("!="); default: return("ErrorBinOpType"); } }
public BinExprNode(ExprNode left, ExprNode right, BinOpType type) { Left = left; Right = right; OpType = type; }
public BinOp(BinOpType op, Exp lhs, Exp rhs) { Operator = op; Lhs = lhs; Rhs = rhs; }
public SetOp(Pos tp, BinOpType _op) : base(tp) { type = _op; }
private static bool IsArithmetic(BinOpType operation) { return(operation == BinOpType.Add || operation == BinOpType.Sub || operation == BinOpType.Mul || operation == BinOpType.Div); }
public BinOpNode(ExprNode left, ExprNode right, BinOpType operation) { Left = left; Right = right; Op = operation; }