streams
cpp.Streams.kindOf
Section titled “cpp.Streams.kindOf”def Streams.kindOf (n : NodeId) (t : Ty Cpp.constructs) : CheckResult Cpp.constructs OutputKindWhat an operand of std::cout writes, by its type; none for a type std::cout does not write (a pointer other than a char pointer prints an address, which differs from run to run).
cpp.Streams.typed
Section titled “cpp.Streams.typed”def Streams.typed (m : NodeId) (t : StreamStatement) (operands : List (TypedExpr Cpp.constructs)) : TypedStmt Cpp.constructsA statement of the streams, as C++’s extension statement with its operands.
cpp.Streams.formatArgument
Section titled “cpp.Streams.formatArgument”def Streams.formatArgument (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (m : NodeId) (a : Expr) (change : FormatChange) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))A manipulator’s operand (setw, setprecision, setfill): an integer, as long.
cpp.Streams.item
Section titled “cpp.Streams.item”def Streams.item (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))An operand of std::cout: std::endl, a manipulator, or a value to write.
cpp.Streams.items
Section titled “cpp.Streams.items”def Streams.items (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (es : List Expr) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))The operands of std::cout in order.
cpp.Streams.statement
Section titled “cpp.Streams.statement”def Streams.statement (p : Platform) (checker : Checker Cpp.constructs) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))C++’s statements about streams, s checked by checker and statements in the context c with the variables in
scope env (p the platform): std::cout << ..., std::cin.ignore(...), and a call of Streams.cFormatted).
cpp.Streams.cFormatted
Section titled “cpp.Streams.cFormatted”def Streams.cFormatted (n : NodeId) (e : Expr) : Option Stmtprintf("...", args) or scanf("...", args) (with std:: or not, from e of its own at
the node n: the C library’s formatted output or input with that format (C11 7.21.6.3, 7.21.6.4, as C’s statement
sPrintf/sScanf). None for another call, or a format that is not a string literal.
cpp.Streams.Checked
Section titled “cpp.Streams.Checked”def Streams.Checked : TypeThe statements a check of streams gives, or why it does not.
cpp.Streams.ignoring
Section titled “cpp.Streams.ignoring”def Streams.ignoring (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option Streams.Checkedstd::cin.ignore(), std::cin.ignore(count), std::cin.ignore(count, delimiter) (the expression e, checked by
checker with the globals g and the variables in scope env): the operands, then the input that drops characters
(count 1 and delimiter EOF by default, [istream.unformatted]p25); none for another expression.
cpp.Streams.extracted
Section titled “cpp.Streams.extracted”def Streams.extracted (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))Reading into an object of a class: the call std::cin >> x, its operator>> found as an operator’s (the
library’s of std::string, [string.io]); the stream it returns is dropped.
cpp.Streams.inputItem
Section titled “cpp.Streams.inputItem”def Streams.inputItem (types : TypeExtension Cpp.constructs) (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))An operand of std::cin (>>): a base manipulator, else an lvalue to read into, by its type: a number (an integer,
a character, a floating value), a character array (a word, through its first element), an object of a class (its
operator>>, Streams.extracted).
cpp.Streams.inputItems
Section titled “cpp.Streams.inputItems”def Streams.inputItems (types : TypeExtension Cpp.constructs) (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (es : List Expr) : CheckResult Cpp.constructs (List (TypedStmt Cpp.constructs))The operands of std::cin in order.
cpp.Streams.expression
Section titled “cpp.Streams.expression”def Streams.expression (types : TypeExtension Cpp.constructs) (p : Platform) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))C++’s expressions about streams: std::cin >> a >> b and std::getline(std::cin, s), each input before, the
value whether std::cin has not failed (an int).
cpp.Streams.endLineNode
Section titled “cpp.Streams.endLineNode”def Streams.endLineNode (e : Expr) : Option NodeIdThe node of e where it is std::endl, else none. One match with a default: a match on the second operand nested
under the default of a match on the first would be compiled once per constructor of Expr, a function of several
hundred kilobytes in the WasmGC build that every expression’s check calls (Streams.manipulatorOperand).
cpp.Streams.manipulatorOperand
Section titled “cpp.Streams.manipulatorOperand”def Streams.manipulatorOperand (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))std::endl as an operand of a binary operator e outside an output ("Hello!" << endl, the first << written as
< in cout < "Hello!" << endl, which binds as cout < ("Hello!" << endl)): a function template with no type to deduce
its arguments from ([over.over]p1), so clang’s error at it, after an error in the left operand (checked by checker
with the globals g in the scope env), which clang reports first. None for any other expression.
cpp.StreamFormat.manipulate
Section titled “cpp.StreamFormat.manipulate”def StreamFormat.manipulate (f : StreamFormat) (m : Manipulator) : StreamFormatA format with a manipulator applied.
cpp.StreamFormat.change
Section titled “cpp.StreamFormat.change”def StreamFormat.change (f : StreamFormat) (c : FormatChange) (v : Int) : StreamFormatA format changed with an operand (a negative width is 0; the fill is a character).
cpp.StreamFormat.pad
Section titled “cpp.StreamFormat.pad”def StreamFormat.pad (f : StreamFormat) (text : String) : StringText padded to the width with the fill: on the left, or on the right when left aligned.
cpp.StreamFormat.integerText
Section titled “cpp.StreamFormat.integerText”def StreamFormat.integerText (f : StreamFormat) (t : IntegerType) (v : Int) : StringAn integer of a type as written: in decimal with its sign (+ with showpos for a signed type or bool); in octal or hexadecimal as the unsigned value of its width, with the base’s prefix for showbase except for zero.
cpp.StreamFormat.flags
Section titled “cpp.StreamFormat.flags”def StreamFormat.flags (f : StreamFormat) : Flagsprintf’s flags for a floating output: + with showpos.
cpp.FloatNotation.style
Section titled “cpp.FloatNotation.style”def FloatNotation.style (n : FloatNotation) : FloatStyleprintf’s style for the notation.
cpp.StreamFormat.floatText
Section titled “cpp.StreamFormat.floatText”def StreamFormat.floatText (f : StreamFormat) (v : Float) : StringA floating value as written: %g, %f or %e with the precision, 6 when it is negative (upper case with uppercase).
cpp.StreamFormat.isWord
Section titled “cpp.StreamFormat.isWord”def StreamFormat.isWord (f : StreamFormat) (t : IntegerType) : BoolWhether an output is bool written as a word: inserted as is (no padding, the width kept).
cpp.StreamFormat.valueText
Section titled “cpp.StreamFormat.valueText”def StreamFormat.valueText (f : StreamFormat) (t : IntegerType) (v : Int) : StringAn integer output’s text: a character type’s character, bool as a word with boolalpha, else the number.
cpp.Streams.write
Section titled “cpp.Streams.write”def Streams.write (s : State Cpp.constructs) (text : String) (usesWidth : Bool) : State Cpp.constructsThe state after writing text to std::cout; a formatted output uses the width up.
cpp.Streams.output
Section titled “cpp.Streams.output”def Streams.output (n : NodeId) (kind : OutputKind) (v : Value) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsRuns an output of a value in the stream’s format.
cpp.Streams.skipped
Section titled “cpp.Streams.skipped”def Streams.skipped (c : Console) : List CharThe input after the whitespace std::cin skips.
cpp.Streams.consumed
Section titled “cpp.Streams.consumed”def Streams.consumed (c : Console) (rest : List Char) (failed : Bool) : ConsoleThe console after an input that stopped before rest: at the end (eofbit) when nothing is left, failed (failbit) as the read says.
cpp.Streams.integerRead
Section titled “cpp.Streams.integerRead”def Streams.integerRead (t : IntegerType) (negative : Bool) (magnitude : Nat) : Int * BoolThe value num_get stores for an integer of a type: in range as it is; out of range the type’s maximum (or minimum), with failbit ([facet.num.get.virtuals]p3); an unsigned type takes a negative value modulo 2^width (as strtoull).
cpp.Streams.scanKind
Section titled “cpp.Streams.scanKind”def Streams.scanKind (base : Nat) : ScanKindHow an integer is scanned in std::cin’s base (std::dec, std::hex with an optional 0x, std::oct).
cpp.Streams.ready
Section titled “cpp.Streams.ready”def Streams.ready (c : Console) : BoolWhether std::cin can read: it has not failed and is not at the end (else the sentry sets failbit, [istream]p4).
cpp.Streams.number
Section titled “cpp.Streams.number”def Streams.number (t : Ty Cpp.constructs) (a : Address) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsA number read into the object at an address, after the whitespace: a character type’s one character; an integer as num_get reads it (no digits: 0 and failbit); a floating value as strtod (none: 0 and failbit); no input left sets failbit and eofbit and leaves the value.
cpp.Streams.word
Section titled “cpp.Streams.word”def Streams.word (xs : List Char) : List CharA word (to whitespace) after the whitespace, and the rest.
cpp.Streams.intoArray
Section titled “cpp.Streams.intoArray”def Streams.intoArray (platform : Platform) (n : NodeId) (p : Pointer) (k : List (Frame Cpp.constructs)) (s : State Cpp.constructs) : Configuration Cpp.constructsA word read into a character array (through its first element) with its null; one that does not fit is out of bounds.
cpp.Streams.text
Section titled “cpp.Streams.text”def Streams.text (line : Bool) (c : Console) : Option (List Char * List Char)What std::string gets: a word after the whitespace (none: failbit and eofbit), or a line (to a newline, which is read and not kept; none at the end: failbit and eofbit), and the rest.
cpp.Streams.setString
Section titled “cpp.Streams.setString”def Streams.setString (p : Platform) (s : State Cpp.constructs) (old : Value) (dataAt : Address) (sizeAt : Address) (capacityAt : Address) (text : List Char) : State Cpp.constructsA std::string set to text: its old block released, a block of the text and its null made (as new[]), its size and capacity the text’s length.
cpp.Streams.isSpace
Section titled “cpp.Streams.isSpace”def Streams.isSpace (c : Char) : BoolWhether a character code is whitespace (as std::isspace in the C locale).
cpp.Streams.isNewline
Section titled “cpp.Streams.isNewline”def Streams.isNewline (c : Char) : BoolWhether a character is a newline.
cpp.Streams.ignored
Section titled “cpp.Streams.ignored”def Streams.ignored (count : Int) (delimiter : Int) (input : List Char) : List CharThe input left after std::cin.ignore(count, delimiter) drops characters from input: up to count of them, or
through the first that is delimiter (dropped too); EOF (a negative delimiter) is none ([istream.unformatted]p25).
A loop: the input may be long.
cpp.Streams.needsInput
Section titled “cpp.Streams.needsInput”def Streams.needsInput (p : Platform) (tag : CppStatement) (es : List (TypedExpr Cpp.constructs)) (s : State Cpp.constructs) : BoolWhether an input from std::cin may read differently with more input than given so far (the debugger then waits for it): a character needs one after the whitespace; a number or a word needs one after the whitespace that is followed by whitespace (more could extend it); a line needs a newline. A stream that has failed reads nothing.
cpp.Streams.run
Section titled “cpp.Streams.run”def Streams.run (ev : Evaluator Cpp.constructs) (n : NodeId) (tag : StreamStatement) (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.constructsRuns C++’s statements about streams.