use proc_macro2::Ident;
use syn::{Attribute, ItemMod, Signature, Type, Visibility};
pub struct Defs {
pub module: ItemMod,
pub microcode_type: MicrocodeTypeDef,
pub allowed_types: AllowedTypes,
}
pub struct MicrocodeTypeDef {
pub name: Ident,
pub vis: Visibility,
pub docs: Vec<Attribute>,
pub ops: Vec<MicrocodeOp>,
pub descriptor_name: Ident,
}
pub struct MicrocodeOp {
pub name: Ident,
pub func_name: Ident,
pub docs: Vec<Attribute>,
pub args: Vec<MicrocodeArg>,
pub returns: Vec<MicrocodeRes>,
pub subtype: MicrocodeSubtype,
pub sig: Signature,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum MicrocodeSubtype {
Extern,
Function,
}
pub enum ArgSource {
Stack(StackInfo),
Field(FieldInfo),
}
pub struct MicrocodeArg {
pub ty: Type,
pub source: ArgSource,
}
pub struct StackInfo {
pub name: Option<Ident>,
}
pub struct FieldInfo {
pub name: Ident,
pub docs: Vec<Attribute>,
}
pub struct MicrocodeRes {
pub ty: Type,
}
pub struct AllowedTypes {
pub docs: Vec<Attribute>,
pub name: Ident,
pub vis: Visibility,
pub types: Vec<AllowedType>,
}
pub struct AllowedType {
pub docs: Vec<Attribute>,
pub ty: Ident,
pub name: Ident,
}