use crate::dsl::ast::BindingModifier;
use crate::node::PortType;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImportClassification {
CompileConst,
Extern,
Shared,
IterationExtern,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExportClassification {
Local,
Final,
Shared,
Coordinate,
Volatile,
}
#[derive(Debug, Clone)]
pub struct ImportSpec {
pub name: String,
pub port_type: PortType,
pub classification: ImportClassification,
}
impl ImportSpec {
pub fn extern_(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
classification: ImportClassification::Extern,
}
}
pub fn final_(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
classification: ImportClassification::CompileConst,
}
}
pub fn shared(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
classification: ImportClassification::Shared,
}
}
pub fn iter_var(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
classification: ImportClassification::IterationExtern,
}
}
}
#[derive(Debug, Clone)]
pub struct ExportSpec {
pub name: String,
pub port_type: PortType,
pub modifier: BindingModifier,
pub classification: ExportClassification,
}
impl ExportSpec {
pub fn local(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
modifier: BindingModifier::NONE,
classification: ExportClassification::Local,
}
}
pub fn final_(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
modifier: BindingModifier::CONST,
classification: ExportClassification::Final,
}
}
pub fn shared(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
modifier: BindingModifier::SHARED,
classification: ExportClassification::Shared,
}
}
pub fn iter_var(name: impl Into<String>, port_type: PortType) -> Self {
Self {
name: name.into(),
port_type,
modifier: BindingModifier::NONE,
classification: ExportClassification::Coordinate,
}
}
}