跳到內容

lambdas

本頁內容尚未翻譯。

record Variable

A variable a function declares: its declaration, its name and its written type.

record Captured

A variable a lambda captures: its declaration, its written type, and whether by reference.

def Lambdas.className (f : String) (n : NodeId) : String

The name of the class a lambda (its node) in a function is an object of.

def Lambdas.member (x : DeclId) : String

The member of its lambda’s class a captured variable is kept in.

def Lambdas.deducing (c : String) : String

The typedef marking that a lambda’s class has its result deduced.

def Lambdas.returning (c : String) : String

The typedef keeping the result type deduced for a lambda’s class.

def Lambdas.parameters (ps : List Param) : List Variable

The variables parameters declare.

def Lambdas.caught (h : Handler) : List Variable

The variable a handler declares (its exception object; none for catch (...)).

def Lambdas.declarations (s : Stmt) : List Variable

The variables a statement and the statements inside it declare (its lambdas’ parameters and bodies too).

def Lambdas.used (body : Stmt) : List DeclId

The variables a body uses (its lambdas’ uses too), in order, each once.

def Lambdas.declares (ds : List Variable) (x : DeclId) : Bool

Whether a variable is among the declared ones.

def Lambdas.find (ds : List Variable) (x : DeclId) : Option Variable

A declared variable, if it is among them.

def Capture.isDefault (c : Capture) : Bool

Whether a capture is a default one, and whether that captures by reference.

def Lambdas.outer (env : List Variable) (ps : List Param) (body : Stmt) : List Variable

The variables a lambda’s body (its own lambdas’ too) uses from the enclosing function (env) that it does not declare itself, in order.

def Lambdas.captured (env : List Variable) (cs : List Capture) (ps : List Param) (body : Stmt) : List Captured

What 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.

def Lambdas.uncaptured (env : List Variable) (cs : List Capture) (ps : List Param) (body : Stmt) : Option Variable

A variable of the enclosing function a lambda uses without capturing it (it has no default capture), if one.

def Lambdas.usesThis (body : Stmt) : Bool

Whether a body uses the object a member function is called on: this or a member of it.

def Lambdas.capturesThis (self : Option TypeSyntax) (cs : List Capture) (body : Stmt) : Bool

Whether a lambda captures this: in a member function (self is the type this points to), named, or by a default capture its body uses.

def Lambdas.thisMember : String

The member a lambda’s class keeps the captured this in.

def Lambdas.invoker (c : String) : String

The 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).

def Lambdas.referred (t : TypeSyntax) : TypeSyntax

What a reference refers to, else the type.

def Captured.memberType (c : Captured) : TypeSyntax

The type of the member a captured variable is kept in: a reference to what it refers to, or (by copy) that type.

def Captured.parameterType (c : Captured) : TypeSyntax

The class’s constructor’s parameter for a captured variable: a reference to it (const, by copy).

def Captured.argument (c : Captured) : DeclId

The constructor’s parameter (its declaration) for a captured variable.

record Closure

A lambda’s declaration of its closure type.

def Lambdas.closures (body : Stmt) : List Closure

The closure types a function’s body declares (its lambdas’ bodies’ too).

def Lambdas.replacing (f : String) (env : List Variable) (self : Option TypeSyntax) (cs : List Closure) : SyntaxMap

Each 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.

def Lambdas.rewritten (cs : List Captured) (object : Bool) : SyntaxMap

In 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.

def Lambdas.closure (f : String) (self : Option TypeSyntax) (returns : String -> Option TypeSyntax) (c : Closure) (captured : List Captured) (object : Bool) (b : Stmt) : List Item

A 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.

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.

def Expr.isLambda (e : Expr) : Bool

Whether an expression is a lambda.

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.

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.

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.

def Lambdas.deduced (items : List Item) (x : String) : Option TypeSyntax

The result type deduced for lambdas’ classes: the typedefs C::#returns among the items.

def Lambdas.prepare (p : Program) : CheckResult Cpp.constructs Program

A program with its lambdas lowered (a function template’s definition keeps its own: its instances’ are lowered).

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.

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.

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.

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).

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.