public int TransformTernOp(TernOp expr) { ExtractCILIndex(expr); XILInstr xi; switch (expr.Operation) { case TernOp.Kind.Conditional: xi = ISet.Select(); expr.Children[1].Accept(this); expr.Children[2].Accept(this); expr.Children[0].Accept(this); break; case TernOp.Kind.Slice: xi = ISet.Slice(); expr.Children[0].Accept(this); expr.Children[1].Accept(this); expr.Children[2].Accept(this); break; default: throw new NotImplementedException(); } Emit(xi, expr, 3, expr.ResultType); return(0); }
public Expression TransformTernOp(TernOp x) { switch (x.Operation) { case TernOp.Kind.Conditional: { Expression d1 = der(x.Operands[1]).Simplify(); Expression d2 = der(x.Operands[2]).Simplify(); if (d1.Equals(d2)) { return(d1); } else { return(Expression.Conditional( x.Operands[0], d1, d2)); } } case TernOp.Kind.Slice: throw new NotImplementedException(); default: throw new NotImplementedException(); } }
public Expression TransformTernOp(TernOp expr) { if (expr.IsConst()) { object result = expr.Eval(new DefaultEvaluator()); return(LiteralReference.CreateConstant(result)); } else { return(expr); } }
/// <summary> /// Transforms a ternary expression. The default implementation clones it. /// </summary> /// <param name="expr">ternary expression</param> /// <returns>transformation result</returns> public virtual Expression TransformTernOp(TernOp expr) { return(expr.CloneThis(expr.Children.Select(e => e.Transform(this)).ToArray())); }
public bool TransformTernOp(TernOp expr) { return(expr.Operands[0].Accept(this) && expr.Operands[1].Accept(this) && expr.Operands[2].Accept(this)); }
public NotateFunc GetNotation(TernOp.Kind op) { switch (op) { case TernOp.Kind.Conditional: return (string[] args) => args[1] + " when " + args[0] + " else " + args[2]; case TernOp.Kind.Slice: return (string[] args) => args[0] + "(" + args[1] + " downto " + args[2] + ")"; default: throw new NotImplementedException(); } }
public EOperatorAssociativity GetOperatorAssociativity(TernOp.Kind op) { return EOperatorAssociativity.RightAssociative; }
public int GetOperatorOrder(TernOp.Kind op) { switch (op) { case TernOp.Kind.Conditional: return -1; case TernOp.Kind.Slice: return -1; default: throw new NotImplementedException(); } }
/// <summary> /// Transforms a ternary expression. The default implementation clones it. /// </summary> /// <param name="expr">ternary expression</param> /// <returns>transformation result</returns> public virtual Expression TransformTernOp(TernOp expr) { return expr.CloneThis(expr.Children.Select(e => e.Transform(this)).ToArray()); }