Skip to main content

luaur_compiler/functions/
predict_table_shapes.rs

1use luaur_ast::records::ast_expr_table::AstExprTable;
2use luaur_ast::records::ast_name::AstName;
3use luaur_ast::records::ast_node::AstNode;
4use luaur_common::records::dense_hash_map::DenseHashMap;
5use luaur_common::records::dense_hash_set::DenseHashSet;
6
7use crate::records::shape_visitor::ShapeVisitor;
8use crate::records::table_shape::TableShape;
9
10pub fn predict_table_shapes(
11    shapes: &mut DenseHashMap<*mut AstExprTable, TableShape>,
12    root: *mut AstNode,
13) {
14    let mut visitor = ShapeVisitor {
15        shapes,
16        tables: DenseHashMap::new(core::ptr::null_mut()),
17        fields: DenseHashSet::new((core::ptr::null_mut(), AstName::default())),
18        loops: DenseHashMap::new(core::ptr::null_mut()),
19    };
20
21    unsafe {
22        luaur_ast::visit::ast_node_visit(root, &mut visitor);
23    }
24}