Skip to content
Snippets Groups Projects
Commit 371e5540 authored by Russel Arbore's avatar Russel Arbore
Browse files

some type progress

parent bac82af6
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ pub struct Function { ...@@ -17,7 +17,7 @@ pub struct Function {
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Type { pub enum Type {
Control(u64), Control(ConstantID),
Integer8, Integer8,
Integer16, Integer16,
Integer32, Integer32,
...@@ -28,6 +28,8 @@ pub enum Type { ...@@ -28,6 +28,8 @@ pub enum Type {
UnsignedInteger64, UnsignedInteger64,
Float32, Float32,
Float64, Float64,
Product(Box<[TypeID]>),
Summation(Box<[TypeID]>),
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
...@@ -56,11 +58,11 @@ pub enum Node { ...@@ -56,11 +58,11 @@ pub enum Node {
}, },
Fork { Fork {
control: NodeID, control: NodeID,
factor: usize, factor: ConstantID,
}, },
Join { Join {
control: NodeID, control: NodeID,
factor: usize, factor: ConstantID,
}, },
Phi { Phi {
control: NodeID, control: NodeID,
......
...@@ -77,7 +77,7 @@ fn parse_module<'a>(ir_text: &'a str, mut context: Context<'a>) -> nom::IResult< ...@@ -77,7 +77,7 @@ fn parse_module<'a>(ir_text: &'a str, mut context: Context<'a>) -> nom::IResult<
let function_id = context.function_ids.remove(function_name.as_str()).unwrap(); let function_id = context.function_ids.remove(function_name.as_str()).unwrap();
fixed_functions[function_id.idx()] = function; fixed_functions[function_id.idx()] = function;
} }
let mut types = vec![Type::Control(0); context.interned_types.len()]; let mut types = vec![Type::Control(ConstantID::new(0)); context.interned_types.len()];
for (ty, id) in context.interned_types { for (ty, id) in context.interned_types {
types[id.idx()] = ty; types[id.idx()] = ty;
} }
...@@ -276,8 +276,23 @@ fn parse_type_id<'a>(ir_text: &'a str, context: &mut Context<'a>) -> nom::IResul ...@@ -276,8 +276,23 @@ fn parse_type_id<'a>(ir_text: &'a str, context: &mut Context<'a>) -> nom::IResul
fn parse_type<'a>(ir_text: &'a str) -> nom::IResult<&'a str, Type> { fn parse_type<'a>(ir_text: &'a str) -> nom::IResult<&'a str, Type> {
let ir_text = nom::character::complete::multispace0(ir_text)?.0; let ir_text = nom::character::complete::multispace0(ir_text)?.0;
let (ir_text, ty) = nom::branch::alt(( let (ir_text, ty) = nom::branch::alt((
//nom::sequence::tuple((nom::bytes::complete::tag(""))),
nom::combinator::map(nom::bytes::complete::tag("i8"), |_| Type::Integer8), nom::combinator::map(nom::bytes::complete::tag("i8"), |_| Type::Integer8),
nom::combinator::map(nom::bytes::complete::tag("i16"), |_| Type::Integer16),
nom::combinator::map(nom::bytes::complete::tag("i32"), |_| Type::Integer32), nom::combinator::map(nom::bytes::complete::tag("i32"), |_| Type::Integer32),
nom::combinator::map(nom::bytes::complete::tag("i64"), |_| Type::Integer64),
nom::combinator::map(nom::bytes::complete::tag("u8"), |_| Type::UnsignedInteger8),
nom::combinator::map(nom::bytes::complete::tag("u16"), |_| {
Type::UnsignedInteger16
}),
nom::combinator::map(nom::bytes::complete::tag("u32"), |_| {
Type::UnsignedInteger32
}),
nom::combinator::map(nom::bytes::complete::tag("u64"), |_| {
Type::UnsignedInteger64
}),
nom::combinator::map(nom::bytes::complete::tag("f32"), |_| Type::Float32),
nom::combinator::map(nom::bytes::complete::tag("f64"), |_| Type::Float64),
))(ir_text)?; ))(ir_text)?;
Ok((ir_text, ty)) Ok((ir_text, ty))
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment