Skip to main content

Model

Struct Model 

Source
pub struct Model { /* private fields */ }
Expand description

Everything the rules are allowed to say, and what each of it means.

Implementations§

Source§

impl Model

Source

pub fn open(path: &Path) -> Result<Model, Vec<Error>>

Read a model from a file, and every model it is written on top of.

An include names a file from the root of the repository, which is the first directory above the including one whose Cargo.toml says it is a workspace. Naming it that way rather than relative to whoever wrote the include is what makes the path in an include read the same as the path in the prose beside it, since everything else in this repository names a file from the root.

A file included twice is read once. That is the normal case rather than a mistake, since two rule sets over the same IR are two models including one file, and it is also what stops a cycle.

§Errors

Everything Model::read refuses, plus a file that is not there, a repository root that cannot be found, and a head that two of the files give a meaning to.

Source

pub fn read(path: &str, text: &str) -> Result<Model, Vec<Error>>

Read a model from text.

What the text includes is remembered rather than followed, because following it means reading files and this takes text. Model::open is the one that reads files.

§Errors

Anything that is not a well formed (semantics (head params) body) form or a well formed (include path) form, and any head given a meaning twice.

Source

pub fn knows(&self, head: &str) -> bool

Whether this model gives a head a meaning.

What a rule needs is Model::write, which expands a whole term. This is for anything asking about one head on its own, which is a test and a message about a head with no entry anywhere.

Source

pub fn write( &self, path: &str, term: &Term, widths: &Widths, ) -> Result<(String, Sort), Error>

Write one term out as SMT-LIB, expanding everything the model defines, and say how wide what it computes is.

§Errors

A head that is neither a builtin nor in the model, since that is a term nobody has said the meaning of, an application of the wrong number of arguments, and anything whose widths do not fit together.

Source

pub fn touches_memory(&self, term: &Term) -> bool

Whether reading this term reaches memory, following every head the model defines.

A rule that reads memory needs a solver told about arrays and a constant to stand for the memory it starts from, and neither is worth putting in a query that does not. Nothing in a rule says (mem) directly: a load says load.i32, and it is the model entry for that head which reaches memory, so this expands what the model says rather than reading the surface.

Source

pub fn touches_floats(&self, term: &Term) -> bool

Whether reading this term reaches a float, following every head the model defines.

A rule that does needs a solver told about floats, and a solver told about floats is slower at every rule that has none, so the question is worth asking rather than answering yes for the whole file. A head is a float either by its own suffix, as fadd.f32 is, or by what the model says it means.

Trait Implementations§

Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Model

Source§

fn default() -> Model

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.