diff --git a/asn-compiler/src/parser/asn/structs/types/mod.rs b/asn-compiler/src/parser/asn/structs/types/mod.rs index 5c68ea5..8965686 100644 --- a/asn-compiler/src/parser/asn/structs/types/mod.rs +++ b/asn-compiler/src/parser/asn/structs/types/mod.rs @@ -146,8 +146,9 @@ pub(crate) enum Asn1TagMode { Implicit, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub(crate) enum Asn1TagClass { + #[default] Universal, Application, ContextSpecific, diff --git a/asn-compiler/src/resolver/asn/structs/types/base.rs b/asn-compiler/src/resolver/asn/structs/types/base.rs index b433a3f..f095de8 100644 --- a/asn-compiler/src/resolver/asn/structs/types/base.rs +++ b/asn-compiler/src/resolver/asn/structs/types/base.rs @@ -1,7 +1,7 @@ //! Structs for the resolved Base Types use std::collections::{BTreeSet, HashMap}; -use crate::resolver::asn::structs::types::constraints::Asn1ConstraintValueSet; +use crate::resolver::asn::structs::types::{constraints::Asn1ConstraintValueSet, Asn1ResolvedTag}; #[derive(Debug, Clone)] pub(crate) enum ResolvedBaseType { @@ -25,6 +25,7 @@ pub(crate) struct Asn1ResolvedInteger { pub(crate) signed: bool, pub(crate) resolved_constraints: Option, pub(crate) named_values: Option>, + pub(crate) tag: Option, } impl Default for Asn1ResolvedInteger { @@ -34,6 +35,7 @@ impl Default for Asn1ResolvedInteger { signed: true, named_values: None, resolved_constraints: None, + tag: None, } } } @@ -48,6 +50,7 @@ pub(crate) struct Asn1ResolvedEnumerated { pub(crate) excepts: Option>, pub(crate) named_root_values: Vec<(String, i128)>, pub(crate) named_ext_values: Vec<(String, i128)>, + pub(crate) tag: Option, } impl Default for Asn1ResolvedEnumerated { @@ -61,6 +64,7 @@ impl Default for Asn1ResolvedEnumerated { excepts: None, named_root_values: vec![], named_ext_values: vec![], + tag: None, } } } @@ -73,21 +77,28 @@ pub(crate) struct Asn1ResolvedBitString { // We support only up to 128 named bits, if more than that is required, change this to appropriate. value pub(crate) named_values: HashMap, + + pub(crate) tag: Option, } // Just an empty structure for Resolved `BOOLEAN` type. #[derive(Debug, Default, Clone)] -pub(crate) struct Asn1ResolvedBoolean; +pub(crate) struct Asn1ResolvedBoolean { + pub(crate) tag: Option, +} // Just an empty structure for Resolved `NULL` type. #[derive(Debug, Default, Clone)] -pub(crate) struct Asn1ResolvedNull; +pub(crate) struct Asn1ResolvedNull { + pub(crate) tag: Option, +} // A structure representing a Resolved `OCTET STRING`. `SIZE` Constraint is resolved as well. The // `CONTAINING` Constraint is not resolved. #[derive(Debug, Default, Clone)] pub(crate) struct Asn1ResolvedOctetString { pub(crate) size: Option, + pub(crate) tag: Option, } // A structure representing a Resolved `CharacterString`. `SIZE` Constraint is resolved as well. The @@ -95,7 +106,10 @@ pub(crate) struct Asn1ResolvedOctetString { pub(crate) struct Asn1ResolvedCharacterString { pub(crate) str_type: String, pub(crate) size: Option, + pub(crate) tag: Option, } #[derive(Debug, Default, Clone)] -pub(crate) struct Asn1ResolvedObjectIdentifier; +pub(crate) struct Asn1ResolvedObjectIdentifier { + pub(crate) tag: Asn1ResolvedTag, +} diff --git a/asn-compiler/src/resolver/asn/structs/types/mod.rs b/asn-compiler/src/resolver/asn/structs/types/mod.rs index de7898d..0072be5 100644 --- a/asn-compiler/src/resolver/asn/structs/types/mod.rs +++ b/asn-compiler/src/resolver/asn/structs/types/mod.rs @@ -1,5 +1,7 @@ use std::collections::BTreeMap; +use crate::parser::asn::structs::types::Asn1TagClass; + pub(crate) mod constructed; use constructed::ResolvedConstructedType; @@ -32,3 +34,11 @@ pub(crate) enum Asn1ResolvedType { // A Set of Resolved Types. This is true if the type is obtained from Object Sets or Value Sets Set(ResolvedSetType), } + +// When tags are to be supported, an instance of this class will be available for each of the +// 'resolved' type. +#[derive(Debug, Clone, Default)] +pub(crate) struct Asn1ResolvedTag { + num: u32, + class: Asn1TagClass, +}