56 lines
1.1 KiB
Rust
56 lines
1.1 KiB
Rust
use crate::ir::{Atom, OwnedAtom};
|
|
pub(crate) mod parser;
|
|
|
|
#[derive(PartialEq, Debug)]
|
|
pub(crate) struct Module {
|
|
pub(crate) objs: Vec<(String, Region)>,
|
|
pub(crate) opts: Options,
|
|
}
|
|
|
|
/// Module options (endianess etc.)
|
|
/// To be defined :(
|
|
#[derive(PartialEq, Debug)]
|
|
pub(crate) struct Options(pub(crate) Vec<String>);
|
|
|
|
/// A region of memory.
|
|
/// Either a structured field list or an atomic type.
|
|
#[derive(PartialEq, Debug)]
|
|
pub(crate) enum Region {
|
|
Fields(Vec<(Range, FieldRegion)>),
|
|
Atom { ty: Type },
|
|
}
|
|
|
|
/// Content of a field.
|
|
/// Can be a region or a constant.
|
|
#[derive(PartialEq, Debug)]
|
|
pub(crate) enum FieldRegion {
|
|
Subfield { name: String, content: Region },
|
|
Const { name: String, value: OwnedAtom },
|
|
}
|
|
|
|
#[derive(PartialEq, Debug)]
|
|
pub(crate) enum Type {
|
|
Bool,
|
|
// unsigned numbers
|
|
U8,
|
|
U16,
|
|
U32,
|
|
U64,
|
|
U128,
|
|
UX(usize),
|
|
// signed numbers
|
|
I8,
|
|
I16,
|
|
I32,
|
|
I64,
|
|
I128,
|
|
IX(usize),
|
|
// float
|
|
F32,
|
|
F64,
|
|
// strings
|
|
Utf8,
|
|
}
|
|
|
|
/// position of field relative to parent
|
|
type Range = (usize, usize);
|