Co-authored-by: Nilton Constantino <nilton.constantino@visma.com>
Reviewed-on: #8
This commit is contained in:
2026-03-24 13:40:22 +00:00
co-authored by Nilton Constantino
parent 05838d10b0
commit f9120e740b
128 changed files with 19414 additions and 4567 deletions
@@ -0,0 +1,40 @@
use crate::frontends::pbs::symbols::{SymbolKind, Visibility};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum ExportSurfaceKind {
Service,
DeclareType, // struct, storage struct, type alias
}
impl ExportSurfaceKind {
pub fn from_symbol_kind(kind: SymbolKind) -> Option<Self> {
match kind {
SymbolKind::Service => Some(ExportSurfaceKind::Service),
SymbolKind::Struct | SymbolKind::Contract | SymbolKind::ErrorType => {
Some(ExportSurfaceKind::DeclareType)
}
SymbolKind::Function | SymbolKind::Local => None,
}
}
pub fn validate_visibility(kind: SymbolKind, vis: Visibility) -> Result<(), String> {
if vis == Visibility::Pub {
if Self::from_symbol_kind(kind).is_none() {
let kind_str = match kind {
SymbolKind::Function => "Functions",
_ => "This declaration",
};
return Err(format!("{} are not exportable in this version.", kind_str));
}
}
Ok(())
}
pub fn namespace(&self) -> crate::frontends::pbs::symbols::Namespace {
match self {
ExportSurfaceKind::Service => crate::frontends::pbs::symbols::Namespace::Type,
ExportSurfaceKind::DeclareType => crate::frontends::pbs::symbols::Namespace::Type,
}
}
}
@@ -0,0 +1 @@
pub mod export_surface;