MetaData #
The Imperative dialect has a mechanism to store metadata in each of its constructs. Metadata can be used to track both syntactic facts obtained during translation from the source program to this dialect (e.g., line and column numbers), or semantic facts derived during analyses (e.g., global variables implicitly modified by a language construct).
A metadata field, which can be either a variable or an arbitrary string label.
For now, we only track the variables modified by a construct, but we will expand this in the future.
- var
{P : PureExpr}
(v : P.Ident)
: Field P
Metadata indexed by a Strata variable.
- label
{P : PureExpr}
(l : String)
: Field P
Metadata indexed by an arbitrary label.
Instances For
Equations
- (Imperative.MetaDataElem.Field.var v1).beq (Imperative.MetaDataElem.Field.var v2) = (v1 == v2)
- (Imperative.MetaDataElem.Field.label l1).beq (Imperative.MetaDataElem.Field.label l2) = (l1 == l2)
- f1.beq f2 = false
Instances For
Equations
- Imperative.instBEqField = { beq := fun (f1 f2 : Imperative.MetaDataElem.Field P) => f1.beq f2 }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
A metadata value, which can be either an expression, a message, or a fileRange
- expr
{P : PureExpr}
(e : P.Expr)
: Value P
Metadata value in the form of a structured expression.
- msg
{P : PureExpr}
(s : String)
: Value P
Metadata value in the form of an arbitrary string.
- fileRange
{P : PureExpr}
(r : Strata.FileRange)
: Value P
Metadata value in the form of a fileRange.
- switch
{P : PureExpr}
(b : Bool)
: Value P
Metadata value in the form of a boolean switch.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- (Imperative.MetaDataElem.Value.expr e1).beq (Imperative.MetaDataElem.Value.expr e2) = (e1 == e2)
- (Imperative.MetaDataElem.Value.msg m1).beq (Imperative.MetaDataElem.Value.msg m2) = (m1 == m2)
- (Imperative.MetaDataElem.Value.fileRange r1).beq (Imperative.MetaDataElem.Value.fileRange r2) = (r1 == r2)
- (Imperative.MetaDataElem.Value.switch b1).beq (Imperative.MetaDataElem.Value.switch b2) = (b1 == b2)
- v1.beq v2 = false
Instances For
Equations
- Imperative.instBEqValue = { beq := fun (v1 v2 : Imperative.MetaDataElem.Value P) => v1.beq v2 }
Metadata is an array of tagged elements.
Equations
Instances For
Equations
Instances For
Push a new metadata element.
Equations
- md.pushElem fld value = Array.push md { fld := fld, value := value }
Instances For
Remove the first metadata element with tag fld.
Equations
- md.eraseElem fld = Array.eraseP md fun (e : Imperative.MetaDataElem P) => e.fld == fld
Instances For
Retrieve the first metadata element with tag fld.
Equations
- md.findElem fld = Array.find? (fun (e : Imperative.MetaDataElem P) => e.fld == fld) md
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Imperative.instToFormatMetaDataOfMetaDataElem = { format := fun (md : Imperative.MetaData P) => if Array.isEmpty md = true then Std.format "" else Std.format md ++ Std.format " " }
Equations
- One or more equations did not get rendered due to their size.
Common metadata fields #
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Imperative.MetaData.validityCheck = Imperative.MetaDataElem.Field.label "validityCheck"
Instances For
Equations
- Imperative.MetaData.satisfiabilityCheck = Imperative.MetaDataElem.Field.label "satisfiabilityCheck"
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create a DiagnosticModel from metadata and a message. Uses the file range from metadata if available, otherwise uses a default location.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create a DiagnosticModel from metadata and a Format message.
Equations
- md.toDiagnosticF msg type = md.toDiagnostic (toString msg) type
Instances For
Get the file range from metadata as a DiagnosticModel (for formatting). This is a compatibility function that formats the file range using byte offsets. For proper line/column display, use toDiagnostic and format with a FileMap at the top level.
Equations
- md.formatFileRangeD fileMap includeEnd? = match Imperative.getFileRange md with | some fr => fr.format fileMap includeEnd? | none => Std.format ""
Instances For
Get all related file ranges from metadata, in order. The returned array's order is determined by the call stack: the innermost (most deeply inlined) call comes first.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Remove all metadata elements with the given field.
Equations
- md.eraseAllElems fld = Array.filter (fun (e : Imperative.MetaDataElem P) => !e.fld == fld) md
Instances For
Replace the primary file range with a new one, shifting existing related file ranges and prepending the old primary range.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Metadata field for property type classification (e.g., "divisionByZero").
Equations
- Imperative.MetaData.propertyType = Imperative.MetaDataElem.Field.label "propertyType"
Instances For
Metadata value for division-by-zero property type classification.
Equations
- Imperative.MetaData.divisionByZero = "divisionByZero"
Instances For
Metadata field for property summaries attached to assert/requires/ensures clauses.
Equations
- Imperative.MetaData.propertySummary = Imperative.MetaDataElem.Field.label "propertySummary"
Instances For
Push a property summary into metadata.