private static ConditionalBlockExpression ToConditionalBlockExpression(ConditionalEx e) { return(new ConditionalBlockExpression( new BaseIfExpression [] { new IfExpression(condition: Parse(e.CondExpr), body: Parse(e.TrueExpr)) }.ToImmutableArray(), new ElseExpression(Parse(e.FalseExpr)) )); }
public override void VisitConditionalEx(ConditionalEx x) { VisitElement(x.CondExpr); ConsumeToken(Tokens.T_QUESTION, "?"); VisitElement(x.TrueExpr); // can be null ConsumeToken(Tokens.T_COLON, ":"); VisitElement(x.FalseExpr); }
/// <summary> /// Initializes a new instance of the <see cref="BinaryExPoint" /> class. /// </summary> /// <param name="expression">Conditional expression</param> /// <param name="condition">Condition determining whether true or false, or merge will be used</param> /// <param name="trueAssume">Assume point for true binary operand </param> /// <param name="falseAssume">Assume point for false binary operand </param> /// <param name="trueOperand">True operand</param> /// <param name="falseOperand">False operand</param> internal ConditionalExPoint(ConditionalEx expression, ValuePoint condition, AssumePoint trueAssume, AssumePoint falseAssume, ValuePoint trueOperand, ValuePoint falseOperand) { Expression = expression; Condition = condition; TrueAssume = trueAssume; FalseAssume = falseAssume; TrueOperand = trueOperand; FalseOperand = falseOperand; }
/// <inheritdoc /> override public void VisitConditionalEx(ConditionalEx x) { VisitElement(x.CondExpr); var condExpr = result; VisitElement(x.TrueExpr); var trueExpr = result; VisitElement(x.FalseExpr); var falseExpr = result; result = new ConditionalEx((Expression)condExpr, (Expression)trueExpr, (Expression)falseExpr); }
override public void VisitConditionalEx(ConditionalEx x) { _serializer.StartSerialize(typeof(ConditionalEx).Name, SerializeSpan(x.Span)); _serializer.StartSerialize("CondExpr"); VisitElement(x.CondExpr); _serializer.EndSerialize(); _serializer.StartSerialize("TrueExpr"); VisitElement(x.TrueExpr); _serializer.EndSerialize(); _serializer.StartSerialize("FalseExpr"); VisitElement(x.FalseExpr); _serializer.EndSerialize(); _serializer.EndSerialize(); }
public override void VisitConditionalEx(ConditionalEx x) { /* Points are created in current ordering * 1. conditionExpr, * 2. trueAssume, * 3. trueExpr, * 4. falseAssume, * 5. falseExpr, */ //1. // starts branching var conditionExpr = CreateRValue(x.CondExpr); //create true branch var trueAssumeCond = new AssumptionCondition(ConditionForm.All, x.CondExpr); var trueAssume = new AssumePoint(trueAssumeCond, new[] { conditionExpr }); //2. AppendToChain(trueAssume); //3. var trueExpr = CreateRValue(x.TrueExpr); //create false branch var falseAssumeCond = new AssumptionCondition(ConditionForm.None, x.CondExpr); var falseAssume = new AssumePoint(falseAssumeCond, new[] { conditionExpr }); //4. AppendToChain(falseAssume); //5. var falseExpr = CreateRValue(x.FalseExpr); //connect condition - true assume will be connected via chaining conditionExpr.AddFlowChild(falseAssume); //create result var expression = new ConditionalExPoint(x, conditionExpr, trueAssume, falseAssume, trueExpr, falseExpr); //false expr is added when processing substitution PreventChainEdge(trueExpr); trueExpr.AddFlowChild(expression); // Both branches must be processed before the expression conditionExpr.CreateWorklistSegment(expression); Result(expression); }
/// <summary> /// Visit conditions. /// </summary> /// <param name="x"></param> virtual public void VisitConditionalEx(ConditionalEx x) { VisitElement(x.CondExpr); VisitElement(x.TrueExpr); VisitElement(x.FalseExpr); }
/// <inheritdoc /> public override void VisitConditionalEx(ConditionalEx x) { RValueResult(x); }