Add some support for custom struct types in lib
This commit is contained in:
parent
1acaa29a12
commit
0ec427252f
@ -38,6 +38,7 @@ Currently missing relevant features (TODOs) are:
|
|||||||
- ~~Extern functions~~ (DONE)
|
- ~~Extern functions~~ (DONE)
|
||||||
- ~~Strings~~ (DONE)
|
- ~~Strings~~ (DONE)
|
||||||
- Loops
|
- Loops
|
||||||
|
- Debug Information
|
||||||
|
|
||||||
### Why "Reid"
|
### Why "Reid"
|
||||||
|
|
||||||
|
@ -5,12 +5,15 @@ use std::{cell::RefCell, rc::Rc};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
BlockData, ConstValue, FunctionData, Instr, InstructionData, ModuleData, TerminatorKind, Type,
|
BlockData, ConstValue, FunctionData, Instr, InstructionData, ModuleData, TerminatorKind, Type,
|
||||||
util::match_types,
|
TypeData, util::match_types,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Hash, Copy, PartialEq, Eq)]
|
#[derive(Clone, Hash, Copy, PartialEq, Eq)]
|
||||||
pub struct ModuleValue(pub(crate) usize);
|
pub struct ModuleValue(pub(crate) usize);
|
||||||
|
|
||||||
|
#[derive(Clone, Hash, Copy, PartialEq, Eq)]
|
||||||
|
pub struct TypeValue(pub(crate) ModuleValue, pub(crate) usize);
|
||||||
|
|
||||||
#[derive(Clone, Hash, Copy, PartialEq, Eq)]
|
#[derive(Clone, Hash, Copy, PartialEq, Eq)]
|
||||||
pub struct FunctionValue(pub(crate) ModuleValue, pub(crate) usize);
|
pub struct FunctionValue(pub(crate) ModuleValue, pub(crate) usize);
|
||||||
|
|
||||||
@ -25,6 +28,13 @@ pub struct ModuleHolder {
|
|||||||
pub(crate) value: ModuleValue,
|
pub(crate) value: ModuleValue,
|
||||||
pub(crate) data: ModuleData,
|
pub(crate) data: ModuleData,
|
||||||
pub(crate) functions: Vec<FunctionHolder>,
|
pub(crate) functions: Vec<FunctionHolder>,
|
||||||
|
pub(crate) types: Vec<TypeHolder>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct TypeHolder {
|
||||||
|
pub(crate) value: TypeValue,
|
||||||
|
pub(crate) data: TypeData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -65,6 +75,7 @@ impl Builder {
|
|||||||
value,
|
value,
|
||||||
data,
|
data,
|
||||||
functions: Vec::new(),
|
functions: Vec::new(),
|
||||||
|
types: Vec::new(),
|
||||||
});
|
});
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,10 @@ impl ModuleHolder {
|
|||||||
context.context_ref,
|
context.context_ref,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for _ty in &self.types {
|
||||||
|
todo!("Do something with types!");
|
||||||
|
}
|
||||||
|
|
||||||
// Compile the contents
|
// Compile the contents
|
||||||
|
|
||||||
let mut functions = HashMap::new();
|
let mut functions = HashMap::new();
|
||||||
|
@ -263,3 +263,14 @@ pub enum TerminatorKind {
|
|||||||
Br(BlockValue),
|
Br(BlockValue),
|
||||||
CondBr(InstructionValue, BlockValue, BlockValue),
|
CondBr(InstructionValue, BlockValue, BlockValue),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||||
|
pub struct TypeData {
|
||||||
|
name: String,
|
||||||
|
kind: CustomTypeKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||||
|
pub enum CustomTypeKind {
|
||||||
|
Struct(Vec<Type>),
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user