Заглавная страница Избранные статьи Случайная статья Познавательные статьи Новые добавления Обратная связь FAQ Написать работу КАТЕГОРИИ: АрхеологияБиология Генетика География Информатика История Логика Маркетинг Математика Менеджмент Механика Педагогика Религия Социология Технологии Физика Философия Финансы Химия Экология ТОП 10 на сайте Приготовление дезинфицирующих растворов различной концентрацииТехника нижней прямой подачи мяча. Франко-прусская война (причины и последствия) Организация работы процедурного кабинета Смысловое и механическое запоминание, их место и роль в усвоении знаний Коммуникативные барьеры и пути их преодоления Обработка изделий медицинского назначения многократного применения Образцы текста публицистического стиля Четыре типа изменения баланса Задачи с ответами для Всероссийской олимпиады по праву Мы поможем в написании ваших работ! ЗНАЕТЕ ЛИ ВЫ?
Влияние общества на человека
Приготовление дезинфицирующих растворов различной концентрации Практические работы по географии для 6 класса Организация работы процедурного кабинета Изменения в неживой природе осенью Уборка процедурного кабинета Сольфеджио. Все правила по сольфеджио Балочные системы. Определение реакций опор и моментов защемления |
Break, continue, and goto statementsСодержание книги
Поиск на нашем сайте
The definite assignment state of v on the control flow transfer caused by a break, continue, or goto statement is the same as the definite assignment state of v at the beginning of the statement. Throw statements For a statement stmt of the form throw expr; The definite assignment state of v at the beginning of expr is the same as the definite assignment state of v at the beginning of stmt. Return statements For a statement stmt of the form return expr; · The definite assignment state of v at the beginning of expr is the same as the definite assignment state of v at the beginning of stmt. · If v is an output parameter, then it must be definitely assigned either: o after expr o or at the end of the finally block of a try-finally or try-catch-finally that encloses the return statement. For a statement stmt of the form: return; · If v is an output parameter, then it must be definitely assigned either: o before stmt o or at the end of the finally block of a try-finally or try-catch-finally that encloses the return statement. Try-catch statements For a statement stmt of the form: try try-block · The definite assignment state of v at the beginning of try-block is the same as the definite assignment state of v at the beginning of stmt. · The definite assignment state of v at the beginning of catch-block-i (for any i) is the same as the definite assignment state of v at the beginning of stmt. · The definite assignment state of v at the end-point of stmt is definitely assigned if (and only if) v is definitely assigned at the end-point of try-block and every catch-block-i (for every i from 1 to n). Try-finally statements For a try statement stmt of the form: try try-block finally finally-block · The definite assignment state of v at the beginning of try-block is the same as the definite assignment state of v at the beginning of stmt. · The definite assignment state of v at the beginning of finally-block is the same as the definite assignment state of v at the beginning of stmt. · The definite assignment state of v at the end-point of stmt is definitely assigned if (and only if) at least one of the following is true: o v is definitely assigned at the end-point of try-block o v is definitely assigned at the end-point of finally-block If a control flow transfer (for example, a goto statement) is made that begins within try-block, and ends outside of try-block, then v is also considered definitely assigned on that control flow transfer if v is definitely assigned at the end-point of finally-block. (This is not an only if—if v is definitely assigned for another reason on this control flow transfer, then it is still considered definitely assigned.) Try-catch-finally statements Definite assignment analysis for a try-catch-finally statement of the form: try try-block is done as if the statement were a try-finally statement enclosing a try-catch statement: try { The following example demonstrates how the different blocks of a try statement (§8.10) affect definite assignment. class A catch { finally { } Foreach statements For a foreach statement stmt of the form: foreach (type identifier in expr) embedded-statement · The definite assignment state of v at the beginning of expr is the same as the state of v at the beginning of stmt. · The definite assignment state of v on the control flow transfer to embedded-statement or to the end point of stmt is the same as the state of v at the end of expr. Using statements For a using statement stmt of the form: using (resource-acquisition) embedded-statement · The definite assignment state of v at the beginning of resource-acquisition is the same as the state of v at the beginning of stmt. · The definite assignment state of v on the control flow transfer to embedded-statement is the same as the state of v at the end of resource-acquisition. Lock statements For a lock statement stmt of the form: lock (expr) embedded-statement · The definite assignment state of v at the beginning of expr is the same as the state of v at the beginning of stmt. · The definite assignment state of v on the control flow transfer to embedded-statement is the same as the state of v at the end of expr. Yield statements For a yield return statement stmt of the form: yield return expr; · The definite assignment state of v at the beginning of expr is the same as the state of v at the beginning of stmt. · The definite assignment state of v at the end of stmt is the same as the state of v at the end of expr. A yield break statement has no effect on the definite assignment state. General rules for simple expressions The following rule applies to these kinds of expressions: literals (§7.6.1), simple names (§7.6.2), member access expressions (§7.6.4), non-indexed base access expressions (§7.6.8), typeof expressions (§7.6.11), and default value expressions (§7.6.13). · The definite assignment state of v at the end of such an expression is the same as the definite assignment state of v at the beginning of the expression. General rules for expressions with embedded expressions The following rules apply to these kinds of expressions: parenthesized expressions (§7.6.3), element access expressions (§7.6.6), base access expressions with indexing (§7.6.8), increment and decrement expressions (§7.6.9, §7.7.5), cast expressions (§7.7.6), unary +, -, ~, * expressions, binary +, -, *, /, %, <<, >>, <, <=, >, >=, ==,!=, is, as, &, |, ^ expressions (§7.8, §7.9, §7.10, §7.11), compound assignment expressions (§7.17.2), checked and unchecked expressions (§7.6.12), plus array and delegate creation expressions (§7.6.10). Each of these expressions has one or more sub-expressions that are unconditionally evaluated in a fixed order. For example, the binary % operator evaluates the left hand side of the operator, then the right hand side. An indexing operation evaluates the indexed expression, and then evaluates each of the index expressions, in order from left to right. For an expression expr, which has sub-expressions expr1, expr2,..., exprn, evaluated in that order: · The definite assignment state of v at the beginning of expr1 is the same as the definite assignment state at the beginning of expr. · The definite assignment state of v at the beginning of expri (i greater than one) is the same as the definite assignment state at the end of expri-1. · The definite assignment state of v at the end of expr is the same as the definite assignment state at the end of exprn. Invocation expressions and object creation expressions For an invocation expression expr of the form: primary-expression (arg1, arg2, …, argn) or an object creation expression of the form: new type (arg1, arg2, …, argn) · For an invocation expression, the definite assignment state of v before primary-expression is the same as the state of v before expr. · For an invocation expression, the definite assignment state of v before arg1 is the same as the state of v after primary-expression. · For an object creation expression, the definite assignment state of v before arg1 is the same as the state of v before expr. · For each argument argi, the definite assignment state of v after argi is determined by the normal expression rules, ignoring any ref or out modifiers. · For each argument argi for any i greater than one, the definite assignment state of v before argi is the same as the state of v after argi-1. · If the variable v is passed as an out argument (i.e., an argument of the form “out v”) in any of the arguments, then the state of v after expr is definitely assigned. Otherwise; the state of v after expr is the same as the state of v after argn. · For array initializers (§7.6.10.4), object initializers (§7.6.10.2), collection initializers (§7.6.10.3) and anonymous object initializers (§7.6.10.6), the definite assignment state is determined by the expansion that these constructs are defined in terms of.
|
||||
Последнее изменение этой страницы: 2016-08-10; просмотров: 279; Нарушение авторского права страницы; Мы поможем в написании вашей работы! infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 3.138.204.195 (0.009 с.) |