Pass tests
This commit is contained in:
parent
05c9e70d49
commit
3064a92e73
@ -14,6 +14,10 @@ pub enum Type {
|
||||
Boolean,
|
||||
Custom(Identifier),
|
||||
Float,
|
||||
Function {
|
||||
parameter_types: Vec<Type>,
|
||||
return_type: Box<Type>,
|
||||
},
|
||||
Integer,
|
||||
List,
|
||||
ListOf(Box<Type>),
|
||||
@ -131,6 +135,18 @@ impl Display for Type {
|
||||
Type::None => write!(f, "none"),
|
||||
Type::Range => write!(f, "range"),
|
||||
Type::String => write!(f, "string"),
|
||||
Type::Function {
|
||||
parameter_types,
|
||||
return_type,
|
||||
} => {
|
||||
write!(f, "(")?;
|
||||
|
||||
for r#type in parameter_types {
|
||||
write!(f, "{} ", r#type)?;
|
||||
}
|
||||
|
||||
write!(f, ") : {return_type}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,18 @@ impl AbstractTree for ValueNode {
|
||||
ValueNode::Range(_) => Type::Range,
|
||||
ValueNode::String(_) => Type::String,
|
||||
ValueNode::Enum(name, _) => Type::Custom(name.clone()),
|
||||
ValueNode::Function { .. } => todo!(),
|
||||
ValueNode::Function {
|
||||
parameters,
|
||||
return_type,
|
||||
..
|
||||
} => Type::Function {
|
||||
parameter_types: parameters
|
||||
.into_iter()
|
||||
.map(|(_, r#type)| r#type)
|
||||
.cloned()
|
||||
.collect(),
|
||||
return_type: Box::new(return_type.clone()),
|
||||
},
|
||||
};
|
||||
|
||||
Ok(r#type)
|
||||
|
Loading…
Reference in New Issue
Block a user