operators
cpp.Operators.classOf
Section titled “cpp.Operators.classOf”def Operators.classOf (g : Globals Cpp.constructs) (l : Lifted Cpp.constructs) : Option ClassMembersThe class of a checked expression’s type (through a reference), if it is one.
cpp.Operators.hasFunction
Section titled “cpp.Operators.hasFunction”def Operators.hasFunction (g : Globals Cpp.constructs) (f : String) : BoolWhether the program has a function of a name (overloaded or not).
cpp.Operators.hasMember
Section titled “cpp.Operators.hasMember”def Operators.hasMember (g : Globals Cpp.constructs) (c : ClassMembers) (f : String) : BoolWhether a class (or a base) has a member of a name.
cpp.Operators.declared
Section titled “cpp.Operators.declared”def Operators.declared (g : Globals Cpp.constructs) (name : String) : BoolWhether the program has an operator function of a name at all: a function, or a member of some class (when it has none, an operator is not a call, and its operands need no checking here: checking them at every level of a nested expression costs as much as the expression’s size times its depth).
cpp.Operators.lastQualifier
Section titled “cpp.Operators.lastQualifier”def Operators.lastQualifier (depth : Nat) (at : Nat) (last : Option Nat) (cs : List Char) : Option NatWhere the last :: outside template arguments starts in the characters (depth: the arguments open, at: where
the characters start).
cpp.Operators.namespaceOf
Section titled “cpp.Operators.namespaceOf”def Operators.namespaceOf (x : String) : StringThe namespace a class’s name is in, with its :: (empty for none): up to the last :: outside template arguments
(std::vector<std::string> is in std::).
cpp.Operators.candidates
Section titled “cpp.Operators.candidates”def Operators.candidates (g : Globals Cpp.constructs) (name : String) (classes : List ClassMembers) : List StringThe names an operator’s function is looked up by: its own (the program’s), then in the namespaces of the operands’ classes (argument-dependent lookup, [basic.lookup.argdep]), those the program has, each once.
cpp.Operators.chosen
Section titled “cpp.Operators.chosen”def Operators.chosen (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (operands : List Expr) (candidates : List String) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An operator’s call of a function among the candidates: the one whose call checks (the first one’s failure when none does).
cpp.Operators.mayBeClass
Section titled “cpp.Operators.mayBeClass”def Operators.mayBeClass (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : BoolWhether an expression may be an object of a class, checking only what can be: a literal is not, a built-in operator’s result on operands that are not is not, and a cast is one when its type is; anything else is checked. Checking each operand whole at every level of a nested expression (once here, once more when the operator is the core’s) costs twice per level: exponential in the depth.
cpp.Operators.keptLeft
Section titled “cpp.Operators.keptLeft”def Operators.keptLeft (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (name : String) (rest : List Expr) (first : Option Kept.Checked) : Option KeptThe left operand of an operator name at the node n written as a call of the program’s function (o << x as
operator<<(o, x)), checked as first (with the globals g in the scope env), kept before the rest
(Classes.kept) when the built-in operator’s left operand goes first ([over.match.oper]p2, Classes.objectFirst) and it
has statements of its own; else none (the operands as written, unsequenced as a call’s arguments).
cpp.Operators.call
Section titled “cpp.Operators.call”def Operators.call (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (name : String) (operands : List Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))The call an operator with operands is, when one of them is an object of a class: the left one’s member, else the program’s function or one in the namespace of an operand’s class.
cpp.Operators.index
Section titled “cpp.Operators.index”def Operators.index (pick : Picking) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) (asLvalue : Bool) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))v[i] on an object of a class with operator[]: the call v.operator[](i).
cpp.Operators.unmodeledStream
Section titled “cpp.Operators.unmodeledStream”def Operators.unmodeledStream (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (op : BinaryOp) (a : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))The operator op at the node n whose left operand a (checked by checker with the globals g in the scope
env) is an object of the model’s std::istream or std::ostream class with no function for it: unknown, not the core’s
rejection. Those classes are empty in the model (their reading and writing are the stream statements, in >> x
through an istream & is not provided yet), while the standard library has the operators ([istream.formatted]).
cpp.Operators.streamOperand
Section titled “cpp.Operators.streamOperand”def Operators.streamOperand (env : Env Cpp.constructs) (e : Expr) : Option StringThe class of a standard stream an operand e is, read from how it is written (checking an operand twice doubles the
work at each level of a nested expression): cout or cerr (std::ostream’s) and cin (std::istream’s) by their names
(Classes.standardStream; whether or not the model has their objects), or a variable of the class in the scope env.
cpp.Operators.streamText
Section titled “cpp.Operators.streamText”def Operators.streamText (x : String) : String * StringA standard stream’s class x as clang writes it: the typedef and the class template’s instance it stands for.
cpp.Operators.operandText
Section titled “cpp.Operators.operandText”def Operators.operandText (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (stream : Option String) (x : Expr) : CheckResult Cpp.constructs StringAn operand x of a binary operator as clang writes its type: a standard stream’s (stream, its class) by
Operators.streamText, else the operand’s type before it decays, written by types (the operand checked by checker
with the globals g in the scope env, so an error in it comes first).
cpp.Operators.streamMismatch
Section titled “cpp.Operators.streamMismatch”def Operators.streamMismatch (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))A binary operator e with a standard stream for an operand (Operators.streamOperand) that neither std::ostream
nor std::istream has (cout < "Hello!", cin < x, x == cin; [ostream] and [istream] declare <<, >> and the
conversion to bool that && and || use): clang’s error, the operands’ types as written (Refusal.operandTypes, a
stream’s with what it stands for, Operators.operandText by types), after an error in an operand, which clang reports
first (checked by checker with the globals g in the scope env). A program declaring the operator’s function may
have one for a stream (Operators.call), looked up only once an operand is a stream: every binary operator comes here,
and resolving its function for an operand that is not a stream checks the operands once more at each level of a nested
expression. None for any other expression.
cpp.Operators.expression
Section titled “cpp.Operators.expression”def Operators.expression (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))C++’s operators on objects: binary and unary operators, increments and decrements as calls, a call of an object as
its operator().
cpp.Operators.memberLvalue
Section titled “cpp.Operators.memberLvalue”def Operators.memberLvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (name : String) (a : Expr) (rest : List Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An operator’s member call as an lvalue: the operand’s class declares the operator.
cpp.Operators.functionLvalue
Section titled “cpp.Operators.functionLvalue”def Operators.functionLvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (name : String) (operands : List Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An operator name at the node n on the operands as a function’s call, as an lvalue: the call of the candidate (a
function of the program, or one in the namespace of an operand’s class) whose call checks, by checker with the globals
g and the variables in scope env; its result of class type is materialized (References.callLvalue). None when no
operand is an object of a class or no candidate’s call checks.
cpp.Operators.operatorLvalue
Section titled “cpp.Operators.operatorLvalue”def Operators.operatorLvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (name : String) (a : Expr) (rest : List Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An operator name at the node n on a (and rest) as an lvalue, checked by checker with the globals g and
the variables in scope env: the left operand’s member call when its class declares the operator, else a function’s
call (Operators.functionLvalue).
cpp.Operators.lvalue
Section titled “cpp.Operators.lvalue”def Operators.lvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))C++’s operators on objects as lvalues: *a, ++a and --a as the operand’s member calls ((*it).f()); a unary
or binary operator as the operand’s member call or a function’s call ((~b).to_ulong(), (b & c).count()), whose
result of class type is materialized so a member function can be called on it (*(it + 1), [class.temporary]p2).
cpp.Operators.streamClass
Section titled “cpp.Operators.streamClass”def Operators.streamClass : StringThe name of std::ostream’s class and of its one object (standard output).
cpp.Operators.standardOutput
Section titled “cpp.Operators.standardOutput”def Operators.standardOutput : DeclIdThe variable standard output’s object is.
cpp.Operators.isStream
Section titled “cpp.Operators.isStream”def Operators.isStream (t : TypeSyntax) : BoolWhether a type is std::ostream.
cpp.Operators.inputClass
Section titled “cpp.Operators.inputClass”def Operators.inputClass : StringThe name of std::istream’s class and of its one object (standard input).
cpp.Operators.standardInput
Section titled “cpp.Operators.standardInput”def Operators.standardInput : DeclIdThe variable standard input’s object is.
cpp.Operators.namedStream
Section titled “cpp.Operators.namedStream”def Operators.namedStream (e : Expr) : Option (NodeId * String)The standard stream an operand e names, at its node: cout, cin or cerr, with or without std::, written as a
name the environment declares (eConst; what a name the front end leaves to Cella resolves to as an operand,
Resolving.streamObject). In C++ these are std::ostream’s and std::istream’s objects ([iostream.objects]); the
console’s streams as operands (eStdin) are C’s FILE * (fgets(line, n, stdin)).
cpp.Operators.standardStream
Section titled “cpp.Operators.standardStream”def Operators.standardStream (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (asLvalue : Bool) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))A standard stream as an operand (std::ostream_iterator<int>(std::cout, " "), an argument bound to std::ostream &,
Operators.namedStream): cout is the one object of std::ostream’s class (standard output’s) and cin of std::istream’s
(standard input’s) when the program has the class (Operators.prepare); otherwise, and for cerr (the model writes to
it only in an output statement), unknown: the model has no object for it, and the stream is not a FILE *. None for
any other expression (cpp.names takes the environment’s constants). The expression e, checked by checker in the
globals g and the scope env, as an lvalue when asLvalue.
cpp.Operators.reads
Section titled “cpp.Operators.reads”def Operators.reads (e : Expr) : List BoolWhether an expression reads standard input (std::cin >> ..., std::getline(std::cin, s)).
cpp.Operators.isInput
Section titled “cpp.Operators.isInput”def Operators.isInput (t : TypeSyntax) : BoolWhether a written type is std::istream.
cpp.Operators.prepare
Section titled “cpp.Operators.prepare”def Operators.prepare (p : Program) : ProgramA program using std::ostream with its class and its one object first, the type written as the class; one reading
standard input or naming std::istream (the library’s operator>> of strings) with std::istream’s class and object.
cpp.Operators.outputs
Section titled “cpp.Operators.outputs”def Operators.outputs (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (es : List Expr) : List StmtAn output’s items split at the objects of classes: the runs of the others written as before, each object passed to
operator<< with standard output.
cpp.Operators.statement
Section titled “cpp.Operators.statement”def Operators.statement (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 output of objects of classes through operator<<, and an operator<<’s output to the stream it is given.