exceptions
本頁內容尚未翻譯。
cpp.Exceptions.typeName
Section titled “cpp.Exceptions.typeName”def Exceptions.typeName (t : Ty Cpp.constructs) : StringA type’s name as a handler names it (and as an uncaught exception is reported).
cpp.Exceptions.typed
Section titled “cpp.Exceptions.typed”def Exceptions.typed (n : NodeId) (e : ExceptionStatement) : TypedStmt Cpp.constructsA statement of exceptions without operands.
cpp.CatchLabel.of
Section titled “cpp.CatchLabel.of”def CatchLabel.of (catches : Option String) (label : String) : CatchLabelA handler’s entry: what it catches and its label.
cpp.Exceptions.basesWithin
Section titled “cpp.Exceptions.basesWithin”def Exceptions.basesWithin (fuel : Nat) (known : List ClassMembers) (x : String) : List StringA class’s bases, and theirs (fuel bounds the depth).
cpp.TypedExpr.memberPath
Section titled “cpp.TypedExpr.memberPath”def TypedExpr.memberPath {L : Constructs} (e : TypedExpr L) : List NatThe members’ positions an lvalue reaches from its variable (a base subobject’s path).
cpp.Exceptions.catchable
Section titled “cpp.Exceptions.catchable”def Exceptions.catchable (types : TypeExtension Cpp.constructs) (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) : List CatchableThe names an exception of a type can be caught by: its own (the object itself), then, for a class, each of its bases’ that is one subobject reached through public bases (the base subobject, [except.handle]p3), and for a pointer to a class, each pointer to such a base (the path to the subobject it points to).
cpp.Exceptions.classOf
Section titled “cpp.Exceptions.classOf”def Exceptions.classOf (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) : Option ClassMembersThe class with constructors a type is, if any.
cpp.Exceptions.throwing
Section titled “cpp.Exceptions.throwing”def Exceptions.throwing (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (e : Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)throw e: the exception object initialized from e, with the names a handler catches it by. One of a class with
constructors is declared and constructed from e (copied, or the temporary itself, [except.throw]p3), then handed to
the exception; any other holds e’s value.
cpp.Exceptions.catches
Section titled “cpp.Exceptions.catches”def Exceptions.catches (k : Choosing) (g : Globals Cpp.constructs) (t : Option TypeSyntax) : Option StringThe name a handler’s written type catches by (a reference catches what it refers to), none for catch (...).
cpp.Declared
Section titled “cpp.Declared”def Declared : TypeStatements that declare, and the environment with what they declare.
cpp.Exceptions.declaring
Section titled “cpp.Exceptions.declaring”def Exceptions.declaring (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (byRef : Bool) (u : Ty Cpp.constructs) : CheckResult Cpp.constructs DeclaredA handler’s x declared from the exception (a pointer to the subobject it is caught as): bound to it by reference, else a copy, by the copy constructor for a class with constructors (through a reference to the exception).
cpp.Exceptions.handler
Section titled “cpp.Exceptions.handler”def Exceptions.handler (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (h : Handler) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A handler’s code: the exception adopted into its scope, x declared from it, the body, the handler finished.
cpp.Exceptions.tryStatement
Section titled “cpp.Exceptions.tryStatement”def Exceptions.tryStatement (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (body : Stmt) (handlers : List Handler) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)try { body } catch …: a block with the body run under the handlers’ frame, then a jump past the handlers, each
handler at its label (followed by the jump), and the end label.
cpp.Exceptions.statement
Section titled “cpp.Exceptions.statement”def Exceptions.statement (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))C++‘s statements of exceptions: throw, throw;, try, a function try block (a function’s body in a try; a
constructor’s is lowered with its members’ initializations, cpp.classes).
cpp.Exceptions.with
Section titled “cpp.Exceptions.with”def Exceptions.with (s : State Cpp.constructs) (e : CppState) : State Cpp.constructsA state with C++’s part changed.
cpp.Exceptions.forget
Section titled “cpp.Exceptions.forget”def Exceptions.forget (b : Nat) (scopes : List Scope) : List ScopeScopes without a block (an exception thrown again leaves the handler’s scope that adopted it).
cpp.CatchLabel.handles
Section titled “cpp.CatchLabel.handles”def CatchLabel.handles (t : Thrown) (h : CatchLabel) : Option (List Nat)Whether a handler catches an exception, with the path to the subobject it refers to: catch (...) (the object
itself), or one of the exception’s names.
cpp.CatchLabel.first
Section titled “cpp.CatchLabel.first”def CatchLabel.first (t : Thrown) (handlers : List CatchLabel) : Option (CatchLabel * List Nat)The first handler that catches an exception, and the path to the subobject it refers to.
cpp.Ahead
Section titled “cpp.Ahead”data AheadWhat an exception meets first on its way out: a handler that catches it, a noexcept function’s body (at a position in the frames), or nothing (it leaves main).
cpp.Exceptions.ahead
Section titled “cpp.Exceptions.ahead”def Exceptions.ahead (t : Thrown) (i : Nat) (k : List (Frame Cpp.constructs)) : AheadWhat an exception meets first in the frames from position i.
cpp.Exceptions.pastLastCall
Section titled “cpp.Exceptions.pastLastCall”def Exceptions.pastLastCall (i : Nat) (best : Nat) (k : List (Frame Cpp.constructs)) : NatHow many frames, from position i, reach past the last call in them (best so far: none is 0).
cpp.Outcome.state
Section titled “cpp.Outcome.state”def Outcome.state {L : Constructs} (o : Outcome L) : Option (State L)The state a configuration ended in, if it has one.
cpp.Exceptions.terminate
Section titled “cpp.Exceptions.terminate”def Exceptions.terminate (n : NodeId) (trial : List (Frame Cpp.constructs)) (actual : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsA termination after unwinding the actual frames: first a trial unwinding the frames of the other choice, and when its output differs, the divergence noted at the throw.
cpp.Exceptions.propagate
Section titled “cpp.Exceptions.propagate”def Exceptions.propagate (n : NodeId) (t : Thrown) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsAn exception on its way out (in the state), thrown as libc++abi does: when a handler catches it, the stack unwinds to it; else the run terminates, having unwound only the calls the noexcept function it meets made, or nothing ([except.terminate]p2 leaves it to the implementation; whether unwinding all of it, to the noexcept function’s body or out of main, would change the output is noted).
cpp.Exceptions.run
Section titled “cpp.Exceptions.run”def Exceptions.run (ev : Evaluator Cpp.constructs) (n : NodeId) (tag : ExceptionStatement) (types : List (Ty Cpp.constructs)) (es : List (TypedExpr Cpp.constructs)) (ss : List (TypedStmt Cpp.constructs)) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsRunning a statement of exceptions.
cpp.Exceptions.uncaught
Section titled “cpp.Exceptions.uncaught”def Exceptions.uncaught (s : State Cpp.constructs) : Configuration Cpp.constructsHow a run ends with an exception main let out: reported as uncaught, by its type.
cpp.Pointer.toSubobject
Section titled “cpp.Pointer.toSubobject”def Pointer.toSubobject (p : Pointer) (path : List Nat) : PointerA pointer to the subobject at a path in what it points to (null stays null).
cpp.Conversion
Section titled “cpp.Conversion”record ConversionWhat catching an exception at a path gives: the state, the block of a converted pointer (if any) and the path in the exception object the handler refers to.
cpp.Exceptions.convert
Section titled “cpp.Exceptions.convert”def Exceptions.convert (s : State Cpp.constructs) (b : Nat) (path : List Nat) : ConversionAn exception caught at a path: an object’s subobject (the path, for a handler’s pointer to it); a pointer caught as a pointer to a base, the pointer converted in a block of its own (and no path in it).
cpp.Exceptions.frame
Section titled “cpp.Exceptions.frame”def Exceptions.frame (f : CppFrame) (u : Leaving) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsHow leaving passes C++’s frames: at a try block’s, an exception a handler catches becomes the one being handled, and the run jumps to that handler; at a terminating one, an exception ends the run; anything else passes.
cpp.Exceptions.caught
Section titled “cpp.Exceptions.caught”def Exceptions.caught (s : State Cpp.constructs) : Evaluated Cpp.constructs ValueThe pointer to the exception being handled.
cpp.Exceptions.body
Section titled “cpp.Exceptions.body”def Exceptions.body (f : FunctionDefinition) (body : TypedStmt Cpp.constructs) : TypedStmt Cpp.constructsA function’s body as C++ runs it: a noexcept function’s under a frame an exception leaving it ends the run at ([except.spec]p5).