跳到內容

statics

本頁內容尚未翻譯。

def Statics.globalName (f : String) (x : DeclId) : DeclId

The global a static declaration of a function is lifted to: f::x.

def Statics.lifted (f : String) (d : Stmt) : Option Item

The global a static declaration of a function is, when it is initialized before the program starts (without an initializer, or with a constant one); none for any other.

def Statics.nameOf (d : Stmt) : Option DeclId

The declaration a static one is: sDecl or sDeclC, its name.

def Statics.renamedIn (f : String) (d : Stmt) : Stmt

A static declaration of a function declaring its global’s name (C++’s, initialized when first reached).

def Statics.declared (f : String) (body : Stmt) : List (DeclId * Option Item)

The static declarations in a statement, anywhere inside it: each name, and the global it is lifted to when it is initialized before the program starts.

def Statics.renamed (f : String) (xs : List DeclId) (e : Expr) : Expr

A use of a lifted declaration as its global’s.

def Statics.ofFunction (it : Item) (f : String) (body : Stmt) : List Item

A function’s items: the globals of its lifted static declarations, then the function using them.

def Statics.prepare (items : List Item) : List Item

The items with every function’s static declarations named as their globals (f::x), the ones initialized before the program starts lifted to globals.

def Linkage.unwrapped (it : Item) : Item

An item without its file-scope static: the program is one translation unit, so internal linkage changes nothing (C11 6.2.2p3).

def Linkage.definitionOf (name : String) (items : List Item) : Option DeclId

The label of the file-scope definition of a variable of a name, if the program has one.

def Linkage.renamed (from : DeclId) (to : DeclId) : SyntaxMap

Uses of one variable’s label made uses of another’s.

def Linkage.uses (x : DeclId) (it : Item) : Bool

Whether an item uses a variable’s label.

def Linkage.prepare (items : List Item) : List Item

The program’s items with file-scope static and extern settled: a static item is the item itself; an extern declaration declares the variable’s definition (its uses are uses of the definition’s label, and it stays where it is written, so what comes between it and a later definition sees the variable). One with no definition stays when something uses it (the checker rejects it: C11 6.9p5), and goes when nothing does.

def BlockTypes.Renames : Type

The block’s types defined so far: each name (and whether it is a tag) and its new name.

def BlockTypes.key (d : TypeDefinition) : String * Bool

A type defined in a block: its name, and whether it is a tag (struct, union and enum tags share one name space; a typedef’s name is an ordinary identifier, C11 6.2.3).

def BlockTypes.named (to : String) (d : TypeDefinition) : TypeDefinition

A type defined in a block under another name.

def BlockTypes.retyped (key : String * Bool) (to : String) (t : TypeSyntax) : TypeSyntax

A written type naming a block’s type by its old name, named by the new one.

def BlockTypes.nameFor (defined : BlockTypes.Renames) (n : NodeId) (key : String * Bool) : String

The name a block’s type gets at file scope: its own and its node (P#n); a second definition in the same block gets the first one’s, so that it is a redefinition at file scope too (6.7.2.3p1, 6.7p3).

def BlockTypes.retypedAll (defined : BlockTypes.Renames) (t : TypeSyntax) : TypeSyntax

A written type with the block’s types defined so far named by their new names.

def BlockTypes.renaming (defined : BlockTypes.Renames) : SyntaxMap

Renaming the block’s types defined so far.

def BlockTypes.inSequenceWith (defined : BlockTypes.Renames) (xs : List Stmt) : BlockTypes.Renames * List Stmt

A block’s statements in order with the types defined so far renamed: a type defined among them gets its new name, and the statements after it use it (a tag’s scope starts at its tag, so a struct’s members may point to it; a typedef’s at the end of its declarator, C11 6.2.1p7). Also the types defined so far, with the block’s own.

def BlockTypes.inSequence (defined : BlockTypes.Renames) (xs : List Stmt) : List Stmt

A block’s statements with its types named.

def BlockTypes.inClauses (defined : BlockTypes.Renames) (cs : List Clause) : List Clause

A switch’s clauses as one block (its body is one, C11 6.8.4.2): a type defined in one clause is in scope in the clauses after it.

def BlockTypes.defines (s : Stmt) : Bool

Whether a statement defines a type.

def BlockTypes.item (d : TypeDefinition) : Item

The file-scope item a block’s type becomes.

def BlockTypes.left (s : Stmt) : Stmt

A block’s type, once moved to file scope, does nothing where it is written.

def BlockTypes.ofFunction (it : Item) (d : FunctionDefinition) : List Item

The types a function defines in its blocks, renamed, as file-scope items before it (in the order written); none for a function that defines none.

def BlockTypes.prepare (items : List Item) : List Item

The items with the types each function defines in its blocks moved to file scope before it, named after their nodes (P#n): a name’s scope is its block, so the innermost definition before a use is the one it names.

def Bindings.hidden (n : NodeId) : DeclId

The object a structured binding decomposes: #bound: and its node.

def Bindings.parts (n : NodeId) (whole : Expr) (count : Nat) (k : Nat) (names : List Binder) : List Stmt

Each name of a structured binding as a reference to its part of the object, from the k-th on.

def Bindings.expanded (s : Stmt) : List Stmt

A structured binding as the declarations it is: the object (auto copies it, auto & refers to it; shown as a name so it is not a temporary), then each name a reference to its part ([dcl.struct.bind]p1, p3). A range for over one declares them first in its body.

def Bindings.prepare (items : List Item) : List Item

The items with each function’s structured bindings expanded in its blocks.

def Compounds.name (n : NodeId) : DeclId

The object a compound literal is: #c: and its node.

def Compounds.in (e : Expr) : List (NodeId * (TypeSyntax * Init))

The compound literals in an expression, outside in: each node, type and initializer.

def Compounds.literal (e : Expr) : Bool

Whether an expression is a compound literal.

def Compounds.has (e : Expr) : Bool

Whether an expression has a compound literal.

def Compounds.effect (e : Expr) : Bool

Whether an expression may change something or read input (calls, assignments, increments, C++’s new and input).

def Compounds.sequenced (e : Expr) : Bool

Whether an operand of a sequencing operator (,, &&, ||, ?:) has a compound literal: declared before the statement, its initializer would be evaluated before the operands that come first.

def Compounds.movable (es : List Expr) : Bool

Whether the compound literals of a statement’s expressions may be declared before it: their initializers have no effects (so their values depend only on the state before the statement; an unsequenced read and write in one full expression is undefined anyway, C11 6.5p2) and none is an operand a sequencing operator may evaluate later.

def Compounds.named : SyntaxMap

A compound literal’s uses as its object’s.

def Compounds.declarations (es : List Expr) : List Stmt

The declarations of the compound literals of expressions, the inner ones first (an outer one’s initializer uses them; their order is otherwise unobservable, as their initializers have no effects).

def Compounds.inStatement (s : Stmt) : List Stmt

A statement of a block with its compound literals declared before it (each lives to the end of the block, C11 6.5.2.5p5); a selection statement, and a for, is a block of its own (6.8.4p3, 6.8.5p5), so it is put in a block with them. One whose compound literals cannot move is left as it is.

def Compounds.prepare (items : List Item) : List Item

The items with each function’s compound literals declared before their statements; a file-scope variable’s initializer’s as file-scope objects before it (static storage, 6.5.2.5p5).

def Statics.isLifted (d : Stmt) : Bool

Whether a static declaration was lifted (its block’s statement does nothing).