private void BranchToLocation(FlowLocation location, FlowState state) { TState existingState; if (this.joinStates.TryGetValue(location, out existingState)) { this.joinStates = this.joinStates.SetItem(location, (TState)existingState.Join(this.lexicalState)); } else { this.joinStates = this.joinStates.SetItem(location, this.lexicalState); } }
public override void AfterConditional(SyntaxNode node, out FlowState trueState, out FlowState falseState) { trueState = this; falseState = this; var kind = node.Kind(); if (kind == SyntaxKind.EqualsExpression || kind == SyntaxKind.NotEqualsExpression) { var binop = (BinaryExpressionSyntax)node; ExpressionSyntax influencedExpr = null; if (binop.Right.IsKind(SyntaxKind.NullLiteralExpression)) { influencedExpr = this.GetVariableExpression(binop.Left); } else if (binop.Left.IsKind(SyntaxKind.NullLiteralExpression)) { influencedExpr = this.GetVariableExpression(binop.Right); } if (influencedExpr != null) { if (kind == SyntaxKind.EqualsExpression) { trueState = this.WithReferenceState(influencedExpr, NullState.Null); falseState = this.WithReferenceState(influencedExpr, NullState.NotNull); } else { trueState = this.WithReferenceState(influencedExpr, NullState.NotNull); falseState = this.WithReferenceState(influencedExpr, NullState.Null); } } } }
public override bool Equals(FlowState state) { var nfs = state as NullFlowState; return(nfs != null && nfs.variableStates == this.variableStates); }