/// <summary> /// Visit a boolean condition expression, where we will be wanting AssignedWhenTrue and /// AssignedWhenFalse. /// </summary> /// <param name="node"></param> protected void VisitCondition(BoundExpression node) { Debug.Assert(!this.state.Assigned.IsNull); Visit(node); // We implement the foundational rules missing from the language specification: // v is "definitely assigned when true" after a constant expression whose value is false. // v is "definitely assigned when false" after a constant expression whose value is true. // These rules are to be added to the language specification. // It was the lack of these foundational rules that led to the invention of the concept // of "unreachable expression" in the native compiler. if (IsConstantTrue(node)) { state.Merge(); this.state = new FlowAnalysisLocalState(this.state.Reachable, this.state.Assigned, BitArray.AllSet(nextVariableSlot)); } else if (IsConstantFalse(node)) { state.Merge(); this.state = new FlowAnalysisLocalState(this.state.Reachable, BitArray.AllSet(nextVariableSlot), this.state.Assigned); } else { state.Split(); } }
// when two control points merge. Returns true if this state changed. public bool Join(FlowAnalysisLocalState other) { this.Merge(); other.Merge(); this.Reachable |= other.Reachable; return(this.Assigned.IntersectWith(other.Assigned)); }
// when two control points merge. Returns true if this state changed. public bool Join(FlowAnalysisLocalState other) { this.Merge(); other.Merge(); this.Reachable |= other.Reachable; return this.Assigned.IntersectWith(other.Assigned); }