# dmd.statement

Defines AST nodes for statements.

Specification: Statements

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: statement.d

Documentation: https://dlang.org/phobos/dmd_statement.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/statement.d

- `getThrowable`

  #### Declaration

  `TypeIdentifier `getThrowable`();`

  #### Return Value

  `TypeIdentifier` corresponding to `object.Throwable`

- `getException`

  #### Declaration

  `TypeIdentifier `getException`();`

  #### Return Value

  TypeIdentifier corresponding to `object.Exception`

- `Statement`

  #### Declaration

  `abstract class `Statement`: dmd.ast_node.ASTNode;`

  Specification: https://dlang.org/spec/statement.html

  - `arraySyntaxCopy`

    #### Declaration

    `static Statements* `arraySyntaxCopy`(Statements* `a`);`

    Do syntax copy of an array of Statement's.

  - `hasBreak`

    #### Declaration

    `const pure nothrow bool `hasBreak`();`

    Determine if an enclosed `break` would apply to this statement, such as if it is a loop or switch statement.

    #### Return Value

    `true` if it does

  - `hasContinue`

    #### Declaration

    `const pure nothrow bool `hasContinue`();`

    Determine if an enclosed `continue` would apply to this statement, such as if it is a loop statement.

    #### Return Value

    `true` if it does

  - `usesEH`

    #### Declaration

    `final bool `usesEH`();`

    #### Return Value

    `true` if statement uses exception handling

  - `comeFrom`

    #### Declaration

    `final bool `comeFrom`();`

    #### Return Value

    `true` if statement 'comes from' somewhere else, like a goto

  - `hasCode`

    #### Declaration

    `final bool `hasCode`();`

    #### Return Value

    `true` if statement has executable code.

  - `last`

    #### Declaration

    `inout pure nothrow inout(Statement) `last`();`

    Find `last` statement in a sequence of statements.

    #### Return Value

    the `last` statement, or `null` if there isn't one

  - `accept`

    #### Declaration

    `void `accept`(Visitor `v`);`

    Support Visitor Pattern

    #### Parameters

    `Visitor `v`` | visitor

  - `endsWithReturnStatement`

    #### Declaration

    `inout pure nothrow @nogc inout(ReturnStatement) `endsWithReturnStatement`();`

    Does this statement end with a return statement?

    #### Discussion

    I.e. is it a single return statement or some compound statement that unconditionally hits a return statement.

    #### Return Value

    return statement it ends with, otherwise `null`

  - `isErrorStatement`

    #### Declaration

    `final inout pure nothrow @nogc @safe inout(ErrorStatement) `isErrorStatement`();`

    A cheaper method of doing downcasting of Statements.

    #### Return Value

    the downcast statement if it can be downcasted, otherwise `null`

- `ErrorStatement`

  #### Declaration

  `class `ErrorStatement`: dmd.statement.Statement;`

  Any Statement that fails semantic() or has a component that is an ErrorExp or a TypeError should return an `ErrorStatement` from semantic().

- `PeelStatement`

  #### Declaration

  `class `PeelStatement`: dmd.statement.Statement;`

- `ExpStatement`

  #### Declaration

  `class `ExpStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#ExpressionStatement

- `DtorExpStatement`

  #### Declaration

  `class `DtorExpStatement`: dmd.statement.ExpStatement;`

- `CompileStatement`

  #### Declaration

  `class `CompileStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#mixin-statement

- `CompoundStatement`

  #### Declaration

  `class `CompoundStatement`: dmd.statement.Statement;`

  - `this`

    #### Declaration

    `final this(const ref Loc `loc`, Statements* `statements`);`

    Construct a `CompoundStatement` using an already existing array of `Statement`s

    #### Parameters

    `Loc `loc`` | Instantiation information
    `Statements* `statements`` | An array of `Statement`s, that will referenced by this class

  - `this`

    #### Declaration

    `final this(const ref Loc `loc`, Statement[] `sts`...);`

    Construct a `CompoundStatement` from an array of `Statement`s

    #### Parameters

    `Loc `loc`` | Instantiation information
    `Statement[] `sts`` | A variadic array of `Statement`s, that will copied in this class The entries themselves will not be copied.

- `CompoundDeclarationStatement`

  #### Declaration

  `class `CompoundDeclarationStatement`: dmd.statement.CompoundStatement;`

- `UnrolledLoopStatement`

  #### Declaration

  `class `UnrolledLoopStatement`: dmd.statement.Statement;`

  The purpose of this is so that continue will go to the next of the statements, and break will go to the end of the statements.

- `ScopeStatement`

  #### Declaration

  `class `ScopeStatement`: dmd.statement.Statement;`

- `ForwardingStatement`

  #### Declaration

  `class `ForwardingStatement`: dmd.statement.Statement;`

  Statement whose symbol table contains foreach index variables in a local scope and forwards other members to the parent scope. This wraps a statement.

  #### Discussion

  Also see: `dmd.attrib.ForwardingAttribDeclaration`

  - `sym`

    #### Declaration

    `ForwardingScopeDsymbol `sym`;`

    The symbol containing the `static foreach` variables.

  - `statement`

    #### Declaration

    `Statement `statement`;`

    The wrapped `statement`.

- `WhileStatement`

  #### Declaration

  `class `WhileStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#while-statement

- `DoStatement`

  #### Declaration

  `class `DoStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#do-statement

- `ForStatement`

  #### Declaration

  `class `ForStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#for-statement

- `ForeachStatement`

  #### Declaration

  `class `ForeachStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#foreach-statement

- `ForeachRangeStatement`

  #### Declaration

  `class `ForeachRangeStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#foreach-range-statement

- `IfStatement`

  #### Declaration

  `class `IfStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#if-statement

  - `isIfCtfeBlock`

    #### Declaration

    `bool `isIfCtfeBlock`();`

    #### Return Value

    `true` if `if (__ctfe)`

- `ConditionalStatement`

  #### Declaration

  `class `ConditionalStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/version.html#ConditionalStatement

- `StaticForeachStatement`

  #### Declaration

  `class `StaticForeachStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/version.html#StaticForeachStatement Static foreach statements, like: void main() { static foreach(i; 0 .. 10) { pragma(msg, i); } }

- `PragmaStatement`

  #### Declaration

  `class `PragmaStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#pragma-statement

- `StaticAssertStatement`

  #### Declaration

  `class `StaticAssertStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/version.html#StaticAssert

- `SwitchStatement`

  #### Declaration

  `class `SwitchStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#switch-statement

  - `condition`

    #### Declaration

    `Expression `condition`;`

    switch(`condition`)

  - `_body`

    #### Declaration

    `Statement `_body`;`

  - `isFinal`

    #### Declaration

    `bool `isFinal`;`

    https://dlang.org/spec/statement.html#final-switch-statement

  - `sdefault`

    #### Declaration

    `DefaultStatement `sdefault`;`

    default:

  - `tryBody`

    #### Declaration

    `Statement `tryBody`;`

    set to TryCatchStatement or TryFinallyStatement if in body portion

  - `tf`

    #### Declaration

    `TryFinallyStatement `tf`;`

    set if in the 'finally' block of a TryFinallyStatement

  - `gotoCases`

    #### Declaration

    `GotoCaseStatements `gotoCases`;`

    array of unresolved GotoCaseStatement's

  - `cases`

    #### Declaration

    `CaseStatements* `cases`;`

    array of CaseStatement's

  - `hasNoDefault`

    #### Declaration

    `int `hasNoDefault`;`

    !=0 if no default statement

  - `hasVars`

    #### Declaration

    `int `hasVars`;`

    !=0 if has variable case values

  - `lastVar`

    #### Declaration

    `VarDeclaration `lastVar`;`

    last observed variable declaration in this statement

  - `checkLabel`

    #### Declaration

    `bool `checkLabel`();`

    #### Return Value

    `true` if error

- `CaseStatement`

  #### Declaration

  `class `CaseStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#CaseStatement

- `CaseRangeStatement`

  #### Declaration

  `class `CaseRangeStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#CaseRangeStatement

- `DefaultStatement`

  #### Declaration

  `class `DefaultStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#DefaultStatement

- `GotoDefaultStatement`

  #### Declaration

  `class `GotoDefaultStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#GotoStatement

- `GotoCaseStatement`

  #### Declaration

  `class `GotoCaseStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#GotoStatement

- `SwitchErrorStatement`

  #### Declaration

  `class `SwitchErrorStatement`: dmd.statement.Statement;`

- `ReturnStatement`

  #### Declaration

  `class `ReturnStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#return-statement

- `BreakStatement`

  #### Declaration

  `class `BreakStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#break-statement

- `ContinueStatement`

  #### Declaration

  `class `ContinueStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#continue-statement

- `SynchronizedStatement`

  #### Declaration

  `class `SynchronizedStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#SynchronizedStatement

- `WithStatement`

  #### Declaration

  `class `WithStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#with-statement

- `TryCatchStatement`

  #### Declaration

  `class `TryCatchStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#try-statement

  - `tryBody`

    #### Declaration

    `Statement `tryBody`;`

    set to enclosing TryCatchStatement or TryFinallyStatement if in body portion

- `Catch`

  #### Declaration

  `class `Catch`: dmd.root.rootobject.RootObject;`

  https://dlang.org/spec/statement.html#Catch

- `TryFinallyStatement`

  #### Declaration

  `class `TryFinallyStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#try-statement

  - `tryBody`

    #### Declaration

    `Statement `tryBody`;`

    set to enclosing TryCatchStatement or TryFinallyStatement if in body portion

  - `bodyFallsThru`

    #### Declaration

    `bool `bodyFallsThru`;`

    `true` if body falls through to finally

- `ScopeGuardStatement`

  #### Declaration

  `class `ScopeGuardStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#scope-guard-statement

- `ThrowStatement`

  #### Declaration

  `class `ThrowStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#throw-statement

- `DebugStatement`

  #### Declaration

  `class `DebugStatement`: dmd.statement.Statement;`

- `GotoStatement`

  #### Declaration

  `class `GotoStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#goto-statement

  - `tryBody`

    #### Declaration

    `Statement `tryBody`;`

    set to TryCatchStatement or TryFinallyStatement if in body portion

  - `inCtfeBlock`

    #### Declaration

    `bool `inCtfeBlock`;`

    set if goto is inside an `if (__ctfe)` block

  - `checkLabel`

    #### Declaration

    `bool `checkLabel`();`

    #### Return Value

    `true` for error

- `LabelStatement`

  #### Declaration

  `class `LabelStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#LabeledStatement

  - `tryBody`

    #### Declaration

    `Statement `tryBody`;`

    set to TryCatchStatement or TryFinallyStatement if in body portion

- `LabelDsymbol`

  #### Declaration

  `class `LabelDsymbol`: dmd.dsymbol.Dsymbol;`

- `AsmStatement`

  #### Declaration

  `class `AsmStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/statement.html#asm

- `InlineAsmStatement`

  #### Declaration

  `class `InlineAsmStatement`: dmd.statement.AsmStatement;`

  https://dlang.org/spec/iasm.html

- `GccAsmStatement`

  #### Declaration

  `class `GccAsmStatement`: dmd.statement.AsmStatement;`

  https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html Assembler instructions with D expression operands.

- `CompoundAsmStatement`

  #### Declaration

  `class `CompoundAsmStatement`: dmd.statement.CompoundStatement;`

  a complete asm {} block

- `ImportStatement`

  #### Declaration

  `class `ImportStatement`: dmd.statement.Statement;`

  https://dlang.org/spec/module.html#ImportDeclaration