Skip to main content

rajac_types/
field_signature.rs

1use crate::TypeId;
2use rajac_base::shared_string::SharedString;
3
4/// Field modifiers used during type checking and resolution.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct FieldModifiers(pub u32);
7
8impl FieldModifiers {
9    /// Field is visible to all.
10    pub const PUBLIC: u32 = 0x0001;
11    /// Field is only visible within the declaring class.
12    pub const PRIVATE: u32 = 0x0002;
13    /// Field is visible to subclasses and same-package types.
14    pub const PROTECTED: u32 = 0x0004;
15    /// Field is declared as static.
16    pub const STATIC: u32 = 0x0008;
17    /// Field is declared as final.
18    pub const FINAL: u32 = 0x0010;
19    /// Field is declared as volatile.
20    pub const VOLATILE: u32 = 0x0040;
21    /// Field is declared as transient.
22    pub const TRANSIENT: u32 = 0x0080;
23}
24
25/// Type-level field signature for resolution.
26#[derive(Debug, Clone, PartialEq)]
27pub struct FieldSignature {
28    /// Field name.
29    pub name: SharedString,
30    /// Field type.
31    pub ty: TypeId,
32    /// Visibility and behavior modifiers.
33    pub modifiers: FieldModifiers,
34}
35
36impl FieldSignature {
37    pub fn new(name: SharedString, ty: TypeId, modifiers: FieldModifiers) -> Self {
38        Self {
39            name,
40            ty,
41            modifiers,
42        }
43    }
44}