From 089b151286a07e625d9c5c99fef490691f0f4528 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Mon, 29 Jan 2024 12:48:30 -0500 Subject: [PATCH] Add better tracking to property fetches --- .../fetch/atomic_property_fetch_analyzer.rs | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs b/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs index 87ba4e97..42bd06f8 100644 --- a/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs @@ -186,6 +186,7 @@ pub(crate) fn analyze( class_property_type, in_assignment, &property_id, + declaring_property_class, lhs_var_id, var_id, ); @@ -333,20 +334,14 @@ pub(crate) fn localize_property_type( template_types .entry(*calling_param_name) .or_insert_with(FxHashMap::default) - .insert( - property_class_storage.name, - lhs_param_type.clone(), - ); + .insert(property_class_storage.name, lhs_param_type.clone()); break; } } } } - let template_type_keys = template_types - .iter() - .map(|(k, _)| *k) - .collect::>(); + let template_type_keys = template_types.iter().map(|(k, _)| *k).collect::>(); for type_name in template_type_keys { if let Some(mapped_type) = extended_types @@ -395,10 +390,11 @@ fn add_property_dataflow( stmt_type: TUnion, in_assignment: bool, property_id: &(StrId, StrId), + declaring_property_class: &StrId, lhs_var_id: &Option, expr_id: &Option, ) -> TUnion { - if classlike_storage.specialize_instance { + let mut stmt_type = if classlike_storage.specialize_instance { if let Some(lhs_var_id) = lhs_var_id { let var_type = analysis_data .expr_types @@ -443,14 +439,12 @@ fn add_property_dataflow( let mut stmt_type = stmt_type.clone(); stmt_type.parent_nodes.insert(property_node.clone()); - - return stmt_type; } } stmt_type } else { - let stmt_type = add_unspecialized_property_fetch_dataflow( + add_unspecialized_property_fetch_dataflow( expr_id, property_id, statements_analyzer.get_hpos(pos), @@ -458,10 +452,27 @@ fn add_property_dataflow( in_assignment, stmt_type, statements_analyzer.get_interner(), - ); + ) + }; - stmt_type - } + let localized_property_node = DataFlowNode::get_for_assignment( + format!( + "{}::${}", + statements_analyzer.get_interner().lookup(&declaring_property_class), + statements_analyzer.get_interner().lookup(&property_id.1) + ), + statements_analyzer.get_hpos(pos), + ); + + analysis_data + .data_flow_graph + .add_node(localized_property_node.clone()); + + stmt_type + .parent_nodes + .insert(localized_property_node.clone()); + + stmt_type } pub(crate) fn add_unspecialized_property_fetch_dataflow(