more fixes
This commit is contained in:
parent
8b3789d7b0
commit
486a634ea1
|
@ -1041,7 +1041,7 @@ impl<'a> AstVisitorTrait<&'a mut Ast> for PlacenessSolver {
|
||||||
let func = ast.convert_to_value_expr(func);
|
let func = ast.convert_to_value_expr(func);
|
||||||
let arguments = self.visit_argument_list(ast, arguments)?;
|
let arguments = self.visit_argument_list(ast, arguments)?;
|
||||||
|
|
||||||
ast.datas[idx] = Data::two_indices(func, arguments);
|
ast.datas[idx] = Data::two_indices(func, arguments.into_index());
|
||||||
|
|
||||||
Ok(PlaceOrValue::Value(idx))
|
Ok(PlaceOrValue::Value(idx))
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1085,8 @@ impl<'a> AstVisitorTrait<&'a mut Ast> for PlacenessSolver {
|
||||||
|
|
||||||
fn visit_any(&mut self, ast: &'a mut Ast, idx: Index) -> Result<Self::Value, Self::Error> {
|
fn visit_any(&mut self, ast: &'a mut Ast, idx: Index) -> Result<Self::Value, Self::Error> {
|
||||||
let tag = ast.tags[idx];
|
let tag = ast.tags[idx];
|
||||||
match tag {
|
|
||||||
|
let idx = match tag {
|
||||||
Tag::Parameter => self.visit_parameter(ast, idx)?,
|
Tag::Parameter => self.visit_parameter(ast, idx)?,
|
||||||
Tag::VarDecl | Tag::MutVarDecl | Tag::VarDeclAssignment | Tag::MutVarDeclAssignment => {
|
Tag::VarDecl | Tag::MutVarDecl | Tag::VarDeclAssignment | Tag::MutVarDeclAssignment => {
|
||||||
self.visit_var_decl_common(ast, idx)?
|
self.visit_var_decl_common(ast, idx)?
|
||||||
|
@ -1142,10 +1143,14 @@ impl<'a> AstVisitorTrait<&'a mut Ast> for PlacenessSolver {
|
||||||
Tag::ArrayType => todo!(),
|
Tag::ArrayType => todo!(),
|
||||||
Tag::Error => todo!(),
|
Tag::Error => todo!(),
|
||||||
Tag::Undefined => todo!(),
|
Tag::Undefined => todo!(),
|
||||||
|
Tag::FunctionProto => todo!(),
|
||||||
|
Tag::FunctionProtoInterned => todo!(),
|
||||||
|
Tag::StructDeclInterned => todo!(),
|
||||||
|
Tag::ParameterList => todo!(),
|
||||||
};
|
};
|
||||||
//_ => Err(())?,
|
//_ => Err(())?,
|
||||||
|
|
||||||
Ok(todo!())
|
Ok(idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ pub enum Tag {
|
||||||
File,
|
File,
|
||||||
/// `data` is an intern to a name, and an index into extra of [index: return_type, index: ParameterList]
|
/// `data` is an intern to a name, and an index into extra of [index: return_type, index: ParameterList]
|
||||||
FunctionProto,
|
FunctionProto,
|
||||||
|
/// `data` is an intern to a name, and an intern to the function type
|
||||||
|
FunctionProtoInterned,
|
||||||
/// `data` is an index to a FunctionProto and an index to a Block
|
/// `data` is an index to a FunctionProto and an index to a Block
|
||||||
FunctionDecl,
|
FunctionDecl,
|
||||||
/// `data` is a range from a..b into extra of indices to parameters
|
/// `data` is a range from a..b into extra of indices to parameters
|
||||||
|
@ -57,6 +59,8 @@ pub enum Tag {
|
||||||
GlobalDecl,
|
GlobalDecl,
|
||||||
/// `data` is an intern to a name, and an offset into extra of `[flags, type0 ,..., typeN ,name0 ,..., nameN]`
|
/// `data` is an intern to a name, and an offset into extra of `[flags, type0 ,..., typeN ,name0 ,..., nameN]`
|
||||||
StructDecl,
|
StructDecl,
|
||||||
|
/// `data` is an intern to a name, and an intern to the type of the struct
|
||||||
|
StructDeclInterned,
|
||||||
/// `data` is an index to a type, and an intern to a name
|
/// `data` is an index to a type, and an intern to a name
|
||||||
FieldDecl,
|
FieldDecl,
|
||||||
/// `data` is an index to a VarDecl, GlobalDecl or FunctionDecl, and an opaque DeclKind
|
/// `data` is an index to a VarDecl, GlobalDecl or FunctionDecl, and an opaque DeclKind
|
||||||
|
@ -131,6 +135,7 @@ impl Tag {
|
||||||
| Tag::PointerType
|
| Tag::PointerType
|
||||||
| Tag::InternedType
|
| Tag::InternedType
|
||||||
| Tag::ArrayType
|
| Tag::ArrayType
|
||||||
|
| Tag::StructDeclInterned
|
||||||
| Tag::StructDecl => true,
|
| Tag::StructDecl => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -165,6 +170,8 @@ impl Tag {
|
||||||
| Tag::SubscriptExpr
|
| Tag::SubscriptExpr
|
||||||
| Tag::IfExpr
|
| Tag::IfExpr
|
||||||
| Tag::IfElseExpr
|
| Tag::IfElseExpr
|
||||||
|
| Tag::PlaceToValueConversion
|
||||||
|
| Tag::ValueToPlaceConversion
|
||||||
| Tag::Block
|
| Tag::Block
|
||||||
| &Tag::BlockTrailingExpr => true,
|
| &Tag::BlockTrailingExpr => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -368,6 +375,7 @@ impl From<(Tag, Data)> for ExpandedData {
|
||||||
| Tag::CallExpr
|
| Tag::CallExpr
|
||||||
| Tag::ArrayType
|
| Tag::ArrayType
|
||||||
| Tag::FunctionDecl => Self::from_two_indices(data),
|
| Tag::FunctionDecl => Self::from_two_indices(data),
|
||||||
|
Tag::StructDeclInterned | Tag::FunctionProtoInterned => Self::from_two_interns(data),
|
||||||
Tag::ReturnExprStmt
|
Tag::ReturnExprStmt
|
||||||
| Tag::DeclRef
|
| Tag::DeclRef
|
||||||
| Tag::TypeDeclRef
|
| Tag::TypeDeclRef
|
||||||
|
@ -489,7 +497,7 @@ impl Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
enum PlaceOrValue {
|
pub enum PlaceOrValue {
|
||||||
Value(index::Index),
|
Value(index::Index),
|
||||||
Place(index::Index),
|
Place(index::Index),
|
||||||
}
|
}
|
||||||
|
@ -1415,6 +1423,11 @@ impl Ast {
|
||||||
|
|
||||||
ip.as_mut().get_function_type(return_type, parameters)
|
ip.as_mut().get_function_type(return_type, parameters)
|
||||||
}
|
}
|
||||||
|
Tag::FunctionProtoInterned | Tag::StructDeclInterned => {
|
||||||
|
let (_, ty) = data.as_two_interns();
|
||||||
|
|
||||||
|
ty
|
||||||
|
}
|
||||||
Tag::BlockTrailingExpr => {
|
Tag::BlockTrailingExpr => {
|
||||||
let (_a, b) = data.as_extra_range();
|
let (_a, b) = data.as_extra_range();
|
||||||
self.get_type_of_node(ip, cache, Index::from_u32(self.extra[b - 1]).unwrap())
|
self.get_type_of_node(ip, cache, Index::from_u32(self.extra[b - 1]).unwrap())
|
||||||
|
@ -1491,6 +1504,7 @@ impl Ast {
|
||||||
// TODO: find out of the expression is const, volatile for flags
|
// TODO: find out of the expression is const, volatile for flags
|
||||||
|
|
||||||
// ip.try_get_pointer_type(ty, None).unwrap()
|
// ip.try_get_pointer_type(ty, None).unwrap()
|
||||||
|
|
||||||
// note: because of value-to-place and place-to-value,
|
// note: because of value-to-place and place-to-value,
|
||||||
// this is actually the same type.
|
// this is actually the same type.
|
||||||
ty
|
ty
|
||||||
|
@ -1585,6 +1599,9 @@ impl Ast {
|
||||||
.map(|&i| Index::from_u32(i).unwrap())
|
.map(|&i| Index::from_u32(i).unwrap())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
Tag::FunctionProtoInterned => {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
Tag::FunctionDecl => {
|
Tag::FunctionDecl => {
|
||||||
let (a, b) = data.as_two_indices();
|
let (a, b) = data.as_two_indices();
|
||||||
vec![a, b]
|
vec![a, b]
|
||||||
|
@ -1684,6 +1701,7 @@ impl Ast {
|
||||||
let (a, _) = data.as_index_and_extra_offset();
|
let (a, _) = data.as_index_and_extra_offset();
|
||||||
vec![a]
|
vec![a]
|
||||||
}
|
}
|
||||||
|
Tag::StructDeclInterned => vec![],
|
||||||
Tag::StructDecl => {
|
Tag::StructDecl => {
|
||||||
let (_a, offset) = data.as_intern_and_extra_offset();
|
let (_a, offset) = data.as_intern_and_extra_offset();
|
||||||
let flags = StructFlags::unpack(self.extra[offset]);
|
let flags = StructFlags::unpack(self.extra[offset]);
|
||||||
|
@ -1731,15 +1749,16 @@ impl Ast {
|
||||||
let is_comptime = match tag {
|
let is_comptime = match tag {
|
||||||
Tag::Parameter => false,
|
Tag::Parameter => false,
|
||||||
// TODO: figure out if there are function protos that arent const
|
// TODO: figure out if there are function protos that arent const
|
||||||
// Tag::FunctionProto | Tag::FunctionDecl | Tag::Block | Tag::BlockTrailingExpr => {
|
Tag::FunctionProto | Tag::FunctionProtoInterned| Tag::FunctionDecl | Tag::Block | Tag::BlockTrailingExpr => {
|
||||||
// are_children_comptime(self, cache)
|
//are_children_comptime(self, cache)
|
||||||
// }
|
false
|
||||||
|
}
|
||||||
Tag::Constant => true,
|
Tag::Constant => true,
|
||||||
Tag::ReturnStmt => true,
|
Tag::ReturnStmt => true,
|
||||||
Tag::ReturnExprStmt => are_children_comptime(self, cache),
|
Tag::ReturnExprStmt => are_children_comptime(self, cache),
|
||||||
Tag::MutVarDecl | Tag::MutVarDeclAssignment => false,
|
Tag::MutVarDecl | Tag::MutVarDeclAssignment => false,
|
||||||
// Tag::VarDecl => true,
|
Tag::VarDecl => false,
|
||||||
// Tag::ValueToPlaceConversion => false,
|
Tag::ValueToPlaceConversion => false,
|
||||||
Tag::PlaceToValueConversion | Tag::VarDeclAssignment => {
|
Tag::PlaceToValueConversion | Tag::VarDeclAssignment => {
|
||||||
are_children_comptime(self, cache)
|
are_children_comptime(self, cache)
|
||||||
}
|
}
|
||||||
|
@ -1748,12 +1767,13 @@ impl Ast {
|
||||||
Tag::FieldDecl => true,
|
Tag::FieldDecl => true,
|
||||||
Tag::DeclRef => self.tags[data.as_index()] == Tag::GlobalDecl,
|
Tag::DeclRef => self.tags[data.as_index()] == Tag::GlobalDecl,
|
||||||
Tag::InternedType | Tag::PointerType | Tag::ArrayType | Tag::TypeDeclRef => true,
|
Tag::InternedType | Tag::PointerType | Tag::ArrayType | Tag::TypeDeclRef => true,
|
||||||
// Tag::CallExpr => are_children_comptime(self, cache),
|
Tag::CallExpr => false, // are_children_comptime(self, cache),
|
||||||
// Tag::FieldAccess => {
|
Tag::FieldAccess => {
|
||||||
// let parent = data.as_index_intern().0;
|
// let parent = data.as_index_intern().0;
|
||||||
// cache.mark_as_dominated_by(index, parent);
|
// cache.mark_as_dominated_by(index, parent);
|
||||||
// self.is_node_comptime_evaluable(cache, parent)
|
// self.is_node_comptime_evaluable(cache, parent)
|
||||||
// }
|
false
|
||||||
|
}
|
||||||
Tag::ArgumentList => are_children_comptime(self, cache),
|
Tag::ArgumentList => are_children_comptime(self, cache),
|
||||||
Tag::Argument => self.is_node_comptime_evaluable(cache, data.as_index()),
|
Tag::Argument => self.is_node_comptime_evaluable(cache, data.as_index()),
|
||||||
Tag::NamedArgument => {
|
Tag::NamedArgument => {
|
||||||
|
@ -1789,7 +1809,7 @@ impl Ast {
|
||||||
cache.mark_as_dominated_by(index, left);
|
cache.mark_as_dominated_by(index, left);
|
||||||
are_children_comptime(self, cache)
|
are_children_comptime(self, cache)
|
||||||
}
|
}
|
||||||
// Tag::IfExpr | Tag::IfElseExpr => are_children_comptime(self, cache),
|
Tag::IfExpr | Tag::IfElseExpr => false, // are_children_comptime(self, cache),
|
||||||
Tag::Root
|
Tag::Root
|
||||||
| Tag::File
|
| Tag::File
|
||||||
| Tag::ParameterList
|
| Tag::ParameterList
|
||||||
|
|
|
@ -517,6 +517,8 @@ pub trait AstVisitorTrait<Ast: AstExt> {
|
||||||
Tag::MutVarDeclAssignment => self.visit_mut_var_assign_decl(ast, idx),
|
Tag::MutVarDeclAssignment => self.visit_mut_var_assign_decl(ast, idx),
|
||||||
Tag::GlobalDecl => self.visit_global_decl(ast, idx),
|
Tag::GlobalDecl => self.visit_global_decl(ast, idx),
|
||||||
Tag::StructDecl => todo!(),
|
Tag::StructDecl => todo!(),
|
||||||
|
Tag::StructDeclInterned => todo!(),
|
||||||
|
Tag::FunctionProtoInterned => todo!(),
|
||||||
Tag::FieldDecl => todo!(),
|
Tag::FieldDecl => todo!(),
|
||||||
Tag::DeclRef => self.visit_decl_ref(ast, idx),
|
Tag::DeclRef => self.visit_decl_ref(ast, idx),
|
||||||
Tag::DeclRefUnresolved => todo!(),
|
Tag::DeclRefUnresolved => todo!(),
|
||||||
|
|
Loading…
Reference in a new issue