跳到內容

generate

本頁內容尚未翻譯。

record PrintedLine

A printed line: its text and the nodes printed on it.

def PrintedLine.of (text : String) (nodes : List NodeId) : PrintedLine

A line with its nodes.

def PrintedLine.plain (text : String) : PrintedLine

A line with no nodes.

def Names : Type

Declaration nodes to source names.

def Names.of (ns : Names) (x : DeclId) : String

The source name of a declaration (its node when it has none).

def Print.indent (k : Nat) : String

k levels of indentation, two spaces each.

def Print.namedEscape (c : Nat) : Option String

The escape a control character has a name for (C11 6.4.4.4: a, b, t, n, v, f and r after a backslash), if it has one.

def Print.octalEscape (c : Nat) : String

A code as a three-digit octal escape (three digits, so a digit after it is not read as part of it).

def Print.escapeCode (c : Nat) (quote : Nat) : String

A character escaped for a quote: a control character by its name or in octal, backslash and the quote itself.

def Print.escapeString (s : String) : String

A string’s contents as in a C string literal.

def Print.escapeCharacter (c : Nat) : String

A character constant’s contents (‘\0’ for the null).

def Print.commas (xs : List String) : String

Texts separated by commas.

def Print.isEmpty (s : String) : Bool

Whether a string is empty.

def Print.hexDigits (fuel : Nat) (v : Nat) (acc : List Char) : List Char

The hexadecimal digits of a number put before acc (fuel bounds the digits).

def Print.hexLiteral (v : Int) : String

An integer constant written in hexadecimal (an octal one has the same type, C11 6.4.4.1p5).

def UnaryOp.symbol (op : UnaryOp) : String

A unary operator as written.

def Manipulator.name (m : Manipulator) : String

A stream manipulator’s name after std::.

def Param.text (p : Param) : String

A parameter as declared in a definition: int a[3].

def Param.list (texts : List String) : String

A parameter list: void for none.

def Param.names (ps : List Param) : Names

The parameters’ names.

def Capture.text (c : Capture) : String

A lambda’s capture as written.

def Expr.lambdaText (cs : List Capture) (ps : List Param) (r : Option TypeSyntax) (m : Bool) (lines : List PrintedLine) : String

A lambda on one line: its captures, parameters, mutable, result type, and its body’s lines (printed) joined.

def Print.lambdaKey (n : NodeId) : String

The key a lambda’s text is kept under in the names (its sLambda declares it for the statements after it).

def Expr.printTop (ns : Names) (e : Expr) : String

An expression at the top (a statement or a for step): no outer parentheses.

def Expr.nodesOption (m : Option Expr) : List NodeId

The nodes of an optional expression.

def Init.nodesOption (m : Option Init) : List NodeId

The nodes of an optional initializer.

def Print.declaration (ns : Names) (name : String) (t : TypeSyntax) (i : Option Init) : String

A declaration without its semicolon: int a[3] = {1, 2, 3}.

def Print.closing (k : Nat) : PrintedLine

A closing brace at k levels.

def PrintedLine.at (k : Nat) (text : String) (nodes : List NodeId) : PrintedLine

A line at k levels of indentation.

def Print.braced (k : Nat) (head : PrintedLine) (inside : List PrintedLine) : List PrintedLine

A head line, the lines inside, and the closing brace at k levels.

def Field.declarator (y : String) (t : TypeSyntax) : String

A member as declared: its type around the name, and a bit-field’s width after it.

def StructDefinition.lines (k : Nat) (keyword : String) (d : StructDefinition) : List PrintedLine

A struct’s or union’s definition at k levels of indentation.

def Print.unnamedDefinitions (items : List Item) : List (String * String)

The structs and unions whose names a front end made up (Tag.isUnnamed), each by its name with its definition written on one line (union { int i; double d; }): C cannot name them, so the definition is written where the type is used. A definition is written with the ones before it among items.

def Print.addUnnamed (known : List (String * String)) (it : Item) : List (String * String)

The made-up definitions known so far with the item it’s added, if it is one.

def Print.unnamedDefinition (known : List (String * String)) (keyword : String) (d : StructDefinition) : List (String * String)

The made-up definitions known so far with the struct’s or union’s d added (written after keyword), if its name is made up.

def TypeSyntax.unnamedPrinted (known : List (String * String)) (t : TypeSyntax) : TypeSyntax

A struct or union type t whose name is made up and whose definition is in known written as that definition (a tName, printed as written).

def StructDefinition.isUnnamed (d : StructDefinition) : Bool

Whether the name of the struct or union d is made up (it is written where it is used, Print.unnamedDefinitions).

def Enumerator.names (cs : List Enumerator) : Names

The enumerators’ names.

def Enumerator.qualifiedNames (x : String) (cs : List Enumerator) : Names

The names of the enumerators cs outside the scoped enumeration x (C++’s enum class): x::name ([dcl.enum]p11).

def Enumerator.scopedHead (x : String) (base : Option TypeSyntax) : String

A scoped enumeration’s head: enum class x, with : base where it has one.

def Enumerator.scopedLine (ns : Names) (n : NodeId) (x : String) (base : Option TypeSyntax) (cs : List Enumerator) : PrintedLine

The line of the scoped enumeration x with the base and the enumerators cs at the node n, with the names ns around it: its values see its enumerators unqualified (what comes after it names them qualified, Item.names).

def Enumerator.textOf (ns : Names) (c : Enumerator) : String

An enumerator: a, or b = 2.

def Enumerator.text (ns : Names) (cs : List Enumerator) : String

The enumerators separated by commas.

def Enumerator.nodes (cs : List Enumerator) : List NodeId

The nodes of the enumerators’ values.

def TypeDefinition.lines (ns : Names) (k : Nat) (d : TypeDefinition) : List PrintedLine

A type defined in a block, at k levels of indentation (an enum’s values with its enumerators in scope).

def Binder.printAll (xs : List Binder) : String

A structured binding’s names as written: [a, b].

def Binder.names (xs : List Binder) : Names

A structured binding’s names, each its label and name.

def Stmt.namesAfter (ns : Names) (s : Stmt) : Names

The names a statement brings into scope for the statements after it.

def Stmt.namesAfterAll (ns : Names) (ss : List Stmt) : Names

The names after statements in order.

def Stmt.namesAfterOption (ns : Names) (m : Option Stmt) : Names

The names after an optional statement (a for’s init).

def Stmt.forInit (ns : Names) (m : Option Stmt) : String

A for’s init on its line: a declaration or an expression, without the semicolon.

def Stmt.forInitNodes (m : Option Stmt) : List NodeId

The nodes of a for’s init.

def Expr.printOption (ns : Names) (m : Option Expr) : String

An optional expression’s text, empty when absent.

def Stmt.printSimple (ns : Names) (k : Nat) (s : Stmt) : List PrintedLine

A statement with no statements inside it, on one line (the lowering’s copies print nothing).

def Print.member (ns : Names) (x : String) : String

A member of the object a member function runs on, named as it is written: alone, or after this-> where a local or a parameter of the same name hides it.

def Stmt.braceNodes (s : Stmt) : List NodeId

The node of a block whose braces a construct prints as its own (recorded on the construct’s line).

def Param.declared (ns : Names) (p : Param) : String

A parameter as declared in a prototype or a class: with its default value (the names in scope, the globals’).

def FunctionDefinition.isConversion (name : String) : Bool

A conversion function (operator T) has no result type written.

def FunctionDefinition.conversionName (name : String) (r : Option TypeSyntax) : String

A conversion function’s name as declared: its class’s part, then operator and the type as written (a pointer to member (spelled with ::*) by its typedef, operator Helper: the type’s own spelling is not a declarator there, [class.conv.fct]p1).

def FunctionDefinition.head (ns : Names) (withDefaults : Bool) (f : FunctionDefinition) : String

A function’s head: the result type, name and parameters, with the defaults or without.

def Print.noexcept (nx : Bool) : String

“ noexcept” when a constructor or function is.

def FunctionDefinition.noexcept (f : FunctionDefinition) : String

“ noexcept” when the function is.

def FunctionDefinition.renamed (x : String) (f : FunctionDefinition) : FunctionDefinition

The function with another name.

def Print.prototypes (ns : Names) (early : List String) (fs : List FunctionDefinition) : List PrintedLine

Prototypes of the functions other than main, so they may call each other in any order; a function in early has had its defaults written already and is declared without them (a default is given once, C++ [dcl.fct.default]p4).

def Print.functionWith (ns : Names) (withDefaults : Bool) (f : FunctionDefinition) : List PrintedLine

A function’s definition: its head and its body, with the parameters in scope; the default arguments written when it is the only declaration (a function template has no prototype before it, so without them its defaults were lost).

def Print.function (ns : Names) (f : FunctionDefinition) : List PrintedLine

A function’s definition after its prototype (which has the default arguments).

def Print.isIdentifierCode (c : Nat) : Bool

Whether a character can be part of an identifier.

def Print.wordAt (w : List Nat) (cs : List Nat) : Bool

Whether a word starts the characters and ends there as an identifier.

def Print.hasWordIn (ws : List (List Nat)) (cs : List Nat) (afterIdentifier : Bool) : Bool

Whether one of the words occurs as a whole identifier in the characters.

def Print.hasWord (ws : List String) (text : String) : Bool

Whether one of the words occurs as a whole identifier in a text.

def Print.named (fs : List FunctionDefinition) (text : String) : List FunctionDefinition

The functions whose names occur in a text.

def Member.defaults (ms : List Member) : List Expr

The expressions in a class that may call functions: members’ defaults and parameters’ defaults.

def ClassDefinition.defaultsText (d : ClassDefinition) : String

A class’s defaults as text, to find the functions they call.

def Item.early (fs : List FunctionDefinition) (items : List Item) : List String

The functions whose prototypes are printed early with their defaults: those a global’s initializer or a class’s defaults call (C++ dynamic initialization).

def TemplateParam.name (p : TemplateParam) : String

A template parameter’s name.

def TemplateParam.text (withDefaults : Bool) (ps : List TemplateParam) : String

Template parameters: typename T = int, int N; the defaults only in the first declaration.

def TemplateParam.header (withDefaults : Bool) (n : NodeId) (ps : List TemplateParam) : PrintedLine

The template header: template .

def Access.word (a : Access) : String

An access as written.

def Access.same (a : Access) (b : Access) : Bool

Whether two accesses are the same.

def Access.label (current : Access) (next : Access) : List PrintedLine

An access label when the access changes.

def Base.textOf (b : Base) : String

A base: virtual public A.

def Base.text (bs : List Base) : String

The bases: “ : public A, virtual private B”.

def Virtuality.before (v : Virtuality) : String

virtual before a method’s declaration.

def Virtuality.after (v : Virtuality) : String

override or = 0 after a method’s declaration.

def Member.enumeratorNames (ms : List Member) : Names

The enumerators the members define, those of nested classes too.

def Member.qualifiedEnumeratorNames (x : String) (ms : List Member) : Names

The enumerators a class’s members define (those of nested classes too), qualified by the class (C::E, which names the enumerator anywhere: outside the class the bare name is not in scope).

def Member.staticNames (x : String) (ms : List Member) : Names

The names of a class’s static data members, qualified by the class (C::n, which names the member anywhere).

def Member.constructorLine (ns : Names) (x : String) (header : String) (ex : Bool) (ctorNoexc : Bool) (ps : List Param) : PrintedLine

A constructor’s declaration in its class x (with the names ns): its template header (empty for none), explicit or not (ex), its parameters ps, noexcept or not (ctorNoexc).

def Member.lines (ns : Names) (x : String) (current : Access) (ms : List Member) : List PrintedLine

The members declared in a class (access labels only where the access changes); x is the class’s name.

def ClassDefinition.lines (ns : Names) (d : ClassDefinition) : List PrintedLine

A class’s definition with its members’ declarations; the members’ definitions are printed after it.

def ClassDefinition.instance (args : List TypeSyntax) (d : ClassDefinition) : ClassDefinition

The class named as an instance: class C.

def MemberInit.textOf (ns : Names) (y : MemberInit) : String

A constructor’s initializer: a(x), or a{x} with a braced list.

def MemberInit.text (ns : Names) (xs : List MemberInit) : String

A constructor’s initializers: “ : a(x), b(y)“.

def MemberInit.nodes (xs : List MemberInit) : List NodeId

The nodes of a constructor’s initializers.

def Member.constructorDefinition (ns : Names) (q : String) (x : String) (k : NodeId) (ctorNoexc : Bool) (ps : List Param) (inits : List MemberInit) (body : Stmt) : List PrintedLine

A constructor’s definition outside its class (q the qualified class name, x its own; with the names ns): its node k, noexcept or not (ctorNoexc), parameters ps, initializers inits and body (a function try block’s try goes before the initializers).

def Member.typesOf (dependent : Bool) (q : String) (ms : List Member) : List (String * String)

The types a class defines (nested classes, unions, enumerations, member typedefs), each by its name and its name qualified by the class (typename C<T>::y in a template, where the class is dependent).

def FunctionDefinition.outsideOf (scope : List (String * String)) (f : FunctionDefinition) : FunctionDefinition

A member function with its result type written outside the class (a conversion function’s result is part of its name, after the class’s qualifier, so in the class’s scope already).

def Item.methods (ns : Names) (items : List Item) : List PrintedLine

The member definitions of the items’ classes, in order (a full specialization’s members are ordinary members).

def Item.templates (ns : Names) (items : List Item) : List PrintedLine

The function templates and their specializations, after the prototypes.

def Item.names (items : List Item) : Names

The names the items declare: globals, enumerators (a class’s too), and those inside namespaces.

def Item.classes (items : List Item) : List (String * Bool)

The classes the items define, with whether each is declared with class.

def Print.forwards (later : List (String * Bool)) (lines : List PrintedLine) : List PrintedLine

Forward declarations of the later classes the lines name: a type has to be declared before it is written.

def Item.withoutStatic (it : Item) : Item

An item without its file-scope static.

def Expr.calls (fs : List String) (e : Expr) : Bool

Whether an expression calls one of the functions by name.

def Item.calls (fs : List String) (items : List Item) : Bool

Whether the items call one of the functions anywhere: functions, templates, classes, globals’ initializers and namespaces.

def PrintedLine.hasWord (ws : List String) (ls : List PrintedLine) : Bool

Whether a line has one of the words as an identifier.

def PrintedLine.contains (texts : List String) (ls : List PrintedLine) : Bool

Whether a line contains one of the texts (std::max( and the like).

def Print.header (needed : Bool) (h : String) : List PrintedLine

A header when it is needed.

def Print.mathNames : List String

The <math.h> functions the model has (<cmath>’s under std::).

def Print.mathCalls : List String

How a call of a <cmath> function starts in the printed C++ (std::sqrt(, and C++’s own std::abs().

def Print.headers (lang : Language) (items : List Item) (body : List PrintedLine) : List PrintedLine

The headers chosen by what the program uses: stdio always; for C, stdbool when it writes bool; for C++, the streams, strings, containers and exceptions it names; and the C library headers of the functions it calls.

def Item.includes (items : List Item) : List PrintedLine

The program’s own includes, in order.

def Item.allNames (items : List Item) : Names

The names of every declaration in the items’ functions (their parameters and locals) and at file scope: what an array’s length written as an expression is printed with.

def TypeSyntax.lengthPrinted (ns : Names) (t : TypeSyntax) : TypeSyntax

A written type with each array length written as an expression printed as it is written (tArrP, whose length is printed as its text).

def Program.generatedLines (p : Program) : List PrintedLine

The printed lines with the nodes on each: the headers (the program’s own when it writes any), then the body.

def Program.generate (p : Program) : String

A program as C or C++ source, one statement per line.

def PrintedLine.find (ls : List PrintedLine) (k : Nat) (n : NodeId) : Nat

The line (counting from k) a node is printed on, or 0 when it is not printed.

def NodeId.origin (n : NodeId) : Option NodeId

A node without its last :part, if it has one: a node the checker makes for part of a construct (n:element of a range-based for, n:list of a braced list) is the construct’s node and a suffix.

def PrintedLine.findOrigin (ls : List PrintedLine) (fuel : Nat) (n : NodeId) : Nat

The line a node or the construct it was made for is printed on, trying the node without its suffixes in turn.

def Program.generatedLineOf (p : Program) (n : NodeId) : Nat

The line (counting from 1) a node is printed on, or 0 when it is not printed; a node made for part of a construct is found by the construct’s node.