package herdtools7

  1. Overview
  2. Docs
val desugar_setter : AST.call AST.annotated -> AST.identifier list -> AST.expr -> AST.stmt_desc

Desugar a setter call, in particular:

Setter(args) = rhs;               -->     Setter(rhs, args);
Setter(args).fld = rhs;           -->     var temp = Getter(args);
                                          temp.fld = rhs;
                                          Setter(temp, args);
Setter(args).[fld1,fld2] = rhs;   -->     var temp = Getter(args);
                                          temp.[fld1,fld2] = rhs;
                                          Setter(temp, args);

Desugar an elided parameter, in particular:

let x : bits(e) = MyFunc{}(args)     --> ... = MyFunc{e}(args)
let x : bits(e) = MyFunc{,e1}(args)  --> ... = MyFunc{e,e1}(args)

Similarly for var and constant.

type lhs_field = AST.identifier AST.annotated
type lhs_access = {
  1. base : AST.identifier AST.annotated;
  2. index : AST.expr option;
  3. fields : lhs_field list;
    (*

    empty means no fields

    *)
  4. slices : AST.slice list AST.annotated;
    (*

    empty means no slices

    *)
}

An access has a base variable, optionally followed by an array index, nested field accesses fields, and slices: base[[index]].field1.field2[slices]

val desugar_lhs_access : lhs_access -> AST.lexpr

Desugar an lhs_access to an lexpr.

val desugar_lhs_tuple : lhs_access option list AST.annotated -> AST.lexpr

Desugar a list of lhs_access options to an LE_Destructuring. The None entries turn in to LE_Discard, and the Some entries are desugared using desugar_lhs_access. Also check that none of the entries share a base variable, i.e. none of them attempt to write the the same variable.

val desugar_lhs_fields_tuple : AST.identifier AST.annotated -> lhs_field option list -> AST.lexpr_desc

desugar_lhs_fields_tuple x flds desugars a left-hand side of the form x.(fld1, ..., fldk) to (x.fld1, ..., x.fldk), ensuring that the flds are unique.

desugar_case_stmt e0 cases otherwise desugars a case statement for the discriminant expression e0, case alternatives cases, and otherwise statement otherwise. The result is a conditional statement, possibly preceded by an assignment of the condition e0 to a fresh variable).

OCaml

Innovation. Community. Security.