X hits on this document

1421 views

0 shares

0 downloads

0 comments

101 / 396

C# LANGUAGE SPECIFICATION

5.3.3.1 General rules for statements

v is not definitely assigned at the beginning of a function member body.

v is definitely assigned at the beginning of any unreachable statement.

The definite assignment state of v at the beginning of any other statement is determined by checking the definite assignment state of v on all control flow transfers that target the beginning of that statement. If (and only if) v is definitely assigned on all such control flow transfers, then v is definitely assigned at the beginning of the statement. The set of possible control flow transfers is determined in the same way as for checking statement reachability (§‎8.1).

The definite assignment state of v at the end point of a block, checked, unchecked, if, while, do, for, foreach, lock, using, or switch statement is determined by checking the definite assignment state of v on all control flow transfers that target the end point of that statement. If v is definitely assigned on all such control flow transfers, then v is definitely assigned at the end point of the statement. Otherwise; v is not definitely assigned at the end point of the statement. The set of possible control flow transfers is determined in the same way as for checking statement reachability (§‎8.1).

5.3.3.2 Block statements, checked, and unchecked statements

The definite assignment state of v on the control transfer to the first statement of the statement list in the block (or to the end point of the block, if the statement list is empty) is the same as the definite assignment statement of v before the block, checked, or unchecked statement.

5.3.3.3 Expression statements

For an expression statement stmt that consists of the expression expr:

v has the same definite assignment state at the beginning of expr as at the beginning of stmt.

If v if definitely assigned at the end of expr, it is definitely assigned at the end point of stmt; otherwise; it is not definitely assigned at the end point of stmt.

5.3.3.4 Declaration statements

If stmt is a declaration statement without initializers, then v has the same definite assignment state at the end point of stmt as at the beginning of stmt.

If stmt is a declaration statement with initializers, then the definite assignment state for v is determined as if stmt were a statement list, with one assignment statement for each declaration with an initializer (in the order of declaration).

5.3.3.5 If statements

For an if statement stmt of the form:

if ( expr ) then-stmt else else-stmt

v has the same definite assignment state at the beginning of expr as at the beginning of stmt.

If v is definitely assigned at the end of expr, then it is definitely assigned on the control flow transfer to then-stmt and to either else-stmt or to the end-point of stmt if there is no else clause.

If v has the state “definitely assigned after true expression” at the end of expr, then it is definitely assigned on the control flow transfer to then-stmt, and not definitely assigned on the control flow transfer to either else-stmt or to the end-point of stmt if there is no else clause.

If v has the state “definitely assigned after false expression” at the end of expr, then it is definitely assigned on the control flow transfer to else-stmt, and not definitely assigned on the control flow transfer to then-stmt. It is definitely assigned at the end-point of stmt if and only if it is definitely assigned at the end-point of then-stmt.

88Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views1421
Page views1421
Page last viewedMon Jan 23 13:30:35 UTC 2017
Pages396
Paragraphs9401
Words133190

Comments