lambdas
本頁內容尚未翻譯。
cpp.Variable
Section titled “cpp.Variable”record VariableA variable a function declares: its declaration, its name and its written type.
cpp.Captured
Section titled “cpp.Captured”record CapturedA variable a lambda captures: its declaration, its written type, and whether by reference.
cpp.Lambdas.className
Section titled “cpp.Lambdas.className”def Lambdas.className (f : String) (n : NodeId) : StringThe name of the class a lambda (its node) in a function is an object of.
cpp.Lambdas.member
Section titled “cpp.Lambdas.member”def Lambdas.member (x : DeclId) : StringThe member of its lambda’s class a captured variable is kept in.
cpp.Lambdas.deducing
Section titled “cpp.Lambdas.deducing”def Lambdas.deducing (c : String) : StringThe typedef marking that a lambda’s class has its result deduced.
cpp.Lambdas.returning
Section titled “cpp.Lambdas.returning”def Lambdas.returning (c : String) : StringThe typedef keeping the result type deduced for a lambda’s class.
cpp.Lambdas.parameters
Section titled “cpp.Lambdas.parameters”def Lambdas.parameters (ps : List Param) : List VariableThe variables parameters declare.
cpp.Lambdas.caught
Section titled “cpp.Lambdas.caught”def Lambdas.caught (h : Handler) : List VariableThe variable a handler declares (its exception object; none for catch (...)).
cpp.Lambdas.declarations
Section titled “cpp.Lambdas.declarations”def Lambdas.declarations (s : Stmt) : List VariableThe variables a statement and the statements inside it declare (its lambdas’ parameters and bodies too).
cpp.Lambdas.used
Section titled “cpp.Lambdas.used”def Lambdas.used (body : Stmt) : List DeclIdThe variables a body uses (its lambdas’ uses too), in order, each once.
cpp.Lambdas.declares
Section titled “cpp.Lambdas.declares”def Lambdas.declares (ds : List Variable) (x : DeclId) : BoolWhether a variable is among the declared ones.
cpp.Lambdas.find
Section titled “cpp.Lambdas.find”def Lambdas.find (ds : List Variable) (x : DeclId) : Option VariableA declared variable, if it is among them.
cpp.Capture.isDefault
Section titled “cpp.Capture.isDefault”def Capture.isDefault (c : Capture) : BoolWhether a capture is a default one, and whether that captures by reference.
cpp.Lambdas.outer
Section titled “cpp.Lambdas.outer”def Lambdas.outer (env : List Variable) (ps : List Param) (body : Stmt) : List VariableThe variables a lambda’s body (its own lambdas’ too) uses from the enclosing function (env) that it does not declare itself, in order.
cpp.Lambdas.captured
Section titled “cpp.Lambdas.captured”def Lambdas.captured (env : List Variable) (cs : List Capture) (ps : List Param) (body : Stmt) : List CapturedWhat a lambda captures: the variables it names (as named), then with a default every other variable of the enclosing function it uses (by the default’s way); a named one the function does not declare (a global) is not.
cpp.Lambdas.uncaptured
Section titled “cpp.Lambdas.uncaptured”def Lambdas.uncaptured (env : List Variable) (cs : List Capture) (ps : List Param) (body : Stmt) : Option VariableA variable of the enclosing function a lambda uses without capturing it (it has no default capture), if one.
cpp.Lambdas.usesThis
Section titled “cpp.Lambdas.usesThis”def Lambdas.usesThis (body : Stmt) : BoolWhether a body uses the object a member function is called on: this or a member of it.
cpp.Lambdas.capturesThis
Section titled “cpp.Lambdas.capturesThis”def Lambdas.capturesThis (self : Option TypeSyntax) (cs : List Capture) (body : Stmt) : BoolWhether a lambda captures this: in a member function (self is the type this points to), named, or by a default
capture its body uses.
cpp.Lambdas.thisMember
Section titled “cpp.Lambdas.thisMember”def Lambdas.thisMember : StringThe member a lambda’s class keeps the captured this in.
cpp.Lambdas.invoker
Section titled “cpp.Lambdas.invoker”def Lambdas.invoker (c : String) : StringThe function a lambda’s class without captures comes with, doing what its operator() does (the target of its
conversion to a pointer to a function).
cpp.Lambdas.referred
Section titled “cpp.Lambdas.referred”def Lambdas.referred (t : TypeSyntax) : TypeSyntaxWhat a reference refers to, else the type.
cpp.Captured.memberType
Section titled “cpp.Captured.memberType”def Captured.memberType (c : Captured) : TypeSyntaxThe type of the member a captured variable is kept in: a reference to what it refers to, or (by copy) that type.
cpp.Captured.parameterType
Section titled “cpp.Captured.parameterType”def Captured.parameterType (c : Captured) : TypeSyntaxThe class’s constructor’s parameter for a captured variable: a reference to it (const, by copy).
cpp.Captured.argument
Section titled “cpp.Captured.argument”def Captured.argument (c : Captured) : DeclIdThe constructor’s parameter (its declaration) for a captured variable.
cpp.Closure
Section titled “cpp.Closure”record ClosureA lambda’s declaration of its closure type.
cpp.Lambdas.closures
Section titled “cpp.Lambdas.closures”def Lambdas.closures (body : Stmt) : List ClosureThe closure types a function’s body declares (its lambdas’ bodies’ too).
cpp.Lambdas.replacing
Section titled “cpp.Lambdas.replacing”def Lambdas.replacing (f : String) (env : List Variable) (self : Option TypeSyntax) (cs : List Closure) : SyntaxMapEach lambda expression in a function an object of its class: a temporary constructed from what it captures
(this last). One whose closure type the function does not declare is left as it is.
cpp.Lambdas.rewritten
Section titled “cpp.Lambdas.rewritten”def Lambdas.rewritten (cs : List Captured) (object : Bool) : SyntaxMapIn a lambda’s body, each captured variable its class’s member; with this captured, this the member keeping
it and a member of the enclosing class reached through it.
cpp.Lambdas.closure
Section titled “cpp.Lambdas.closure”def Lambdas.closure (f : String) (self : Option TypeSyntax) (returns : String -> Option TypeSyntax) (c : Closure) (captured : List Captured) (object : Bool) (b : Stmt) : List ItemA lambda’s class (given what it captures, whether it captures this, and its body with its own lambda expressions
already objects): the captured variables’ members, the constructor taking them, operator() (its result written,
else the deduced one, else void while it is deduced), and the marker of a deduced result.
cpp.Lambdas.inFunction
Section titled “cpp.Lambdas.inFunction”def Lambdas.inFunction (returns : String -> Option TypeSyntax) (self : Option TypeSyntax) (f : String) (ps : List Param) (body : Stmt) : CheckResult Cpp.constructs (List Item * Stmt)A function’s lambdas lowered: the classes they are objects of, and the body with each lambda expression an object of its class; a variable used without being captured, or a lambda expression whose closure type the function does not declare, is an error.
cpp.Expr.isLambda
Section titled “cpp.Expr.isLambda”def Expr.isLambda (e : Expr) : BoolWhether an expression is a lambda.
cpp.Lambdas.inDefinition
Section titled “cpp.Lambdas.inDefinition”def Lambdas.inDefinition (returns : String -> Option TypeSyntax) (self : Option TypeSyntax) (lowered : String) (fd : FunctionDefinition) : CheckResult Cpp.constructs (List Item * FunctionDefinition)A function definition (of the name it is lowered to) with its lambdas lowered: their classes, and the definition.
cpp.Lambdas.inMembers
Section titled “cpp.Lambdas.inMembers”def Lambdas.inMembers (returns : String -> Option TypeSyntax) (x : String) (ms : List Member) : CheckResult Cpp.constructs (List Item * List Member)A class’s members with the lambdas in their member functions’ bodies lowered: the lambdas’ classes, and the members.
cpp.Lambdas.inItem
Section titled “cpp.Lambdas.inItem”def Lambdas.inItem (returns : String -> Option TypeSyntax) (it : Item) : CheckResult Cpp.constructs (List Item)An item with its lambdas lowered: their classes first, then the item.
cpp.Lambdas.deduced
Section titled “cpp.Lambdas.deduced”def Lambdas.deduced (items : List Item) (x : String) : Option TypeSyntaxThe result type deduced for lambdas’ classes: the typedefs C::#returns among the items.
cpp.Lambdas.prepare
Section titled “cpp.Lambdas.prepare”def Lambdas.prepare (p : Program) : CheckResult Cpp.constructs ProgramA program with its lambdas lowered (a function template’s definition keeps its own: its instances’ are lowered).
cpp.Lambdas.deducedReturn
Section titled “cpp.Lambdas.deducedReturn”def Lambdas.deducedReturn (checker : Checker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : Expr) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))A return of a value in a lambda’s operator() whose result is deduced: the first asks for the value’s type
(lambdaResult); after that, a value of another type is an error. None in any other function.
cpp.Lambdas.returnStatement
Section titled “cpp.Lambdas.returnStatement”def Lambdas.returnStatement (checker : Checker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))A return with a value in the operator() of a lambda’s class whose result is deduced: the first asks for the
value’s type (lambdaResult); after that, a value of another type is an error. None for any other return.
cpp.Lambdas.conversion
Section titled “cpp.Lambdas.conversion”def Lambdas.conversion (g : Globals Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An object of a lambda’s class without captures converted to a pointer to a function of its parameters and result: the address of the function it comes with. None for any other conversion.
cpp.Lambdas.statement
Section titled “cpp.Lambdas.statement”def Lambdas.statement (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))The declaration of a lambda’s closure type, as a statement of the function it is in: nothing to run (its class is lowered before checking).
cpp.Lambdas.answer
Section titled “cpp.Lambdas.answer”def Lambdas.answer (closure : String) (written : List TypeSyntax) (items : List Item) : Option (List Item)The answer to a lambda’s class asking for its result type: the type kept as its typedef C::#returns.