Stan_math_backend.CppA set of data types representing the C++ we generate
val identifier_of_sexp : Sexplib0.Sexp.t -> identifierval sexp_of_identifier : identifier -> Sexplib0.Sexp.ttype type_ = | Auto| Void| Int| Double| Complex of type_| TemplateType of identifier| StdVector of type_A std::vector. For Eigen Vectors, use Matrix with a row or column size of 1
| Array of type_ * int| Tuple of type_ list| TypeLiteral of identifierUsed for things like Eigen::Index
*)| NonTypeTemplateInt of int| Matrix of type_ * int * int * Middle.Mem_pattern.t| Ref of type_| Const of type_| Pointer of type_| TypeTrait of identifier * type_ liste.g. stan::promote_scalar, stan:base_type
*)C++ types
val type__of_sexp : Sexplib0.Sexp.t -> type_val sexp_of_type_ : type_ -> Sexplib0.Sexp.tmodule Types : sig ... endHelpers for constructing types
val operator_of_sexp : Sexplib0.Sexp.t -> operatorval sexp_of_operator : operator -> Sexplib0.Sexp.ttype expr = | Literal of stringprinted as-is
*)| Var of identifier| VarRef of identifier| Parens of expr| FunCall of identifier * type_ list * expr list| MethodCall of expr * identifier * type_ list * expr list| StaticMethodCall of type_ * identifier * type_ list * expr list| Constructor of type_ * expr listprinted as type(expr1, expr2, ...)
| InitializerExpr of type_ * expr listprinted as type{expr1, expr2, ...}
| ArrayLiteral of expr list| TernaryIf of expr * expr * expr| Cast of type_ * expr| Subscript of expr * expr| Deref of expr| AllocNew of type_ * expr list| OperatorNew of identifier * type_ * expr list| Assign of expr * exprNB: Not all exprs are valid lvalues!
*)| StreamInsertion of expr * expr listCorresponds to operator<<
| BinOp of expr * operator * expr| PMinus of expr| Increment of exprval expr_of_sexp : Sexplib0.Sexp.t -> exprval sexp_of_expr : expr -> Sexplib0.Sexp.tmodule Exprs : sig ... endSome helper values and functions
val init_of_sexp : Sexplib0.Sexp.t -> initval sexp_of_init : init -> Sexplib0.Sexp.tval make_variable_defn :
?static:bool ->
?constexpr:bool ->
type_:type_ ->
name:identifier ->
?init:init ->
unit ->
variable_defnval variable_defn_of_sexp : Sexplib0.Sexp.t -> variable_defnval sexp_of_variable_defn : variable_defn -> Sexplib0.Sexp.ttype stmt = | Expression of expr| VariableDefn of variable_defn| For of variable_defn * expr * expr * stmt| ForEach of type_ * identifier * expr * stmt| While of expr * stmt| IfElse of expr * stmt * stmt option| TryCatch of stmt list * type_ * identifier * stmt list| Block of stmt list| Return of expr option| Throw of expr| Break| Continue| Using of string * type_ option| Comment of stringval stmt_of_sexp : Sexplib0.Sexp.t -> stmtval sexp_of_stmt : stmt -> Sexplib0.Sexp.tmodule Stmts : sig ... endHelpers for common statement constructs
module Decls : sig ... endDeclarations which get re-used often in the generated model
type template_parameter = | Typename of stringA typename, e.g. template <typename Foo>
| Bool of stringA named boolean non-type template parameter
*)| Require of string * string listA straightforward require_...<...> template.
| RequireAllCondition of string * type_ listA C++ type trait (e.g. is_arithmetic) and the template types which need to satisfy that. These are collated into one require_all_t<...>.
val template_parameter_of_sexp : Sexplib0.Sexp.t -> template_parameterval sexp_of_template_parameter : template_parameter -> Sexplib0.Sexp.tval cv_qualifiers_of_sexp : Sexplib0.Sexp.t -> cv_qualifiersval sexp_of_cv_qualifiers : cv_qualifiers -> Sexplib0.Sexp.ttype fun_defn = {templates_init : template_parameter list list * bool;Double list since some functions (mainly reduce_sum functors) need two sets of templates
*)inline : bool;return_type : type_;name : identifier;args : (type_ * string) list;cv_qualifiers : cv_qualifiers list;body : stmt list option;}val make_fun_defn :
?templates_init:(template_parameter list list * bool) ->
?inline:bool ->
return_type:type_ ->
name:identifier ->
?args:(type_ * string) list ->
?cv_qualifiers:cv_qualifiers list ->
?body:stmt list ->
unit ->
fun_defnval fun_defn_of_sexp : Sexplib0.Sexp.t -> fun_defnval sexp_of_fun_defn : fun_defn -> Sexplib0.Sexp.ttype constructor = {args : (type_ * string) list;init_list : (identifier * expr list) list;body : stmt list;}val make_constructor :
?args:(type_ * string) list ->
?init_list:(identifier * expr list) list ->
?body:stmt list ->
unit ->
constructorval constructor_of_sexp : Sexplib0.Sexp.t -> constructorval sexp_of_constructor : constructor -> Sexplib0.Sexp.ttype directive = | Include of string| IfNDef of string * defn list| MacroApply of string * string listIncomplete list of C++ preprocessor directives
and class_defn = {class_name : identifier;final : bool;public_base : type_;private_members : defn list;public_members : defn list;constructor : constructor;destructor_body : stmt list;}The Stan model class always has a non-default constructor and destructor
and defn = | FunDef of fun_defn| Class of class_defn| Struct of struct_defn| GlobalVariableDefn of variable_defn| GlobalComment of string| GlobalUsing of string * type_ option| Namespace of identifier * defn list| Preprocessor of directiveval directive_of_sexp : Sexplib0.Sexp.t -> directiveval class_defn_of_sexp : Sexplib0.Sexp.t -> class_defnval struct_defn_of_sexp : Sexplib0.Sexp.t -> struct_defnval defn_of_sexp : Sexplib0.Sexp.t -> defnval sexp_of_directive : directive -> Sexplib0.Sexp.tval sexp_of_class_defn : class_defn -> Sexplib0.Sexp.tval sexp_of_struct_defn : struct_defn -> Sexplib0.Sexp.tval sexp_of_defn : defn -> Sexplib0.Sexp.tval make_class_defn :
name:identifier ->
public_base:type_ ->
?final:bool ->
private_members:defn list ->
public_members:defn list ->
constructor:constructor ->
?destructor_body:stmt list ->
unit ->
class_defnval make_struct_defn :
param:template_parameter option ->
name:identifier ->
body:defn list ->
unit ->
struct_defnmodule DSL : sig ... endA set of operators and helpers to make the OCaml code look more like the resultant C++
val (!//) : string -> defnShorthand for a C++ comment. This one is rather harmless, so it isn't in its own module
type program = defn listMuch like in C++, we define a translation unit as a list of definitions
val program_of_sexp : Sexplib0.Sexp.t -> programval sexp_of_program : program -> Sexplib0.Sexp.tmodule Printing : sig ... endPretty-printing of the C++ type
module Tests : sig ... end