Skip to main content

def_type

Attribute Macro def_type 

Source
#[def_type]
Expand description

#[def_type(...)]: Annotate a Rust struct as a new IR type.

Note: It is suggested to use the pliron_type macro instead of using this macro directly. The documention here is useful though, because pliron_type’s name field expands to this macro.

The argument to the macro is the fully qualified name of the type in the form of "dialect.type_name".

The macro will leave the struct definition unchanged, but it will generate an implementation of the pliron::Type trait and implements other internal traits and types resources required to use the IR type.

Note: pre-requisite traits for Type must already be implemented. Additionaly, Hash and Eq must be implemented by the rust type.

Usage:

use pliron::derive::{def_type, format_type, verify_succ};
#[verify_succ]
#[def_type("my_dialect.unit")]
#[format_type]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnitType;