place and value expression conversion in ast

This commit is contained in:
Janis 2025-03-05 15:48:46 +01:00
parent 1a20acd763
commit 028c74753e

View file

@ -86,6 +86,8 @@ pub enum Tag {
AddressOf,
Not,
Negate,
PlaceToValueConversion,
ValueToPlaceConversion,
/// data is two indices for `lhs` and `rhs`
Or,
And,
@ -370,6 +372,8 @@ impl From<(Tag, Data)> for ExpandedData {
| Tag::AddressOf
| Tag::Not
| Tag::Negate
| Tag::PlaceToValueConversion
| Tag::ValueToPlaceConversion
| Tag::ExprStmt => Self::from_index(data),
Tag::FieldAccess
| Tag::DeclRefUnresolved
@ -1370,7 +1374,9 @@ impl Ast {
// TODO: find out of the expression is const, volatile for flags
ip.try_get_pointer_type(ty, None).unwrap()
}
Tag::Not | Tag::Negate => self.get_type_of_node(ip, cache, data.as_index()),
Tag::ValueToPlaceConversion | Tag::PlaceToValueConversion | Tag::Not | Tag::Negate => {
self.get_type_of_node(ip, cache, data.as_index())
}
Tag::Or
| Tag::And
| Tag::BitOr
@ -1494,7 +1500,12 @@ impl Ast {
let (a, _) = data.as_index_intern();
vec![a]
}
Tag::Deref | Tag::AddressOf | Tag::Not | Tag::Negate => {
Tag::ValueToPlaceConversion
| Tag::PlaceToValueConversion
| Tag::Deref
| Tag::AddressOf
| Tag::Not
| Tag::Negate => {
let a = data.as_index();
vec![a]
}
@ -4471,10 +4482,6 @@ pub trait AstVisitorTrait {
_ = (ast, idx);
Err(Self::UNIMPL)
}
fn visit_return_expr(&mut self, ast: &mut Ast, idx: Index) -> Result<Self::Value, Self::Error> {
_ = (ast, idx);
Err(Self::UNIMPL)
}
fn visit_global_decl(&mut self, ast: &mut Ast, idx: Index) -> Result<Self::Value, Self::Error> {
_ = (ast, idx);
Err(Self::UNIMPL)
@ -5501,6 +5508,8 @@ pub mod irgen {
Tag::IfElseExpr => todo!(),
Tag::Error => todo!(),
Tag::Undefined => todo!(),
Tag::PlaceToValueConversion => todo!(),
Tag::ValueToPlaceConversion => todo!(),
}
},
|ast, scopes, i, tag, data| {
@ -5569,6 +5578,8 @@ pub mod irgen {
Tag::IfElseExpr => todo!(),
Tag::Error => todo!(),
Tag::Undefined => todo!(),
Tag::PlaceToValueConversion => todo!(),
Tag::ValueToPlaceConversion => todo!(),
}
},
);