Skip to content

Commit

Permalink
Add better tracking to property fetches
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 29, 2024
1 parent 6f33969 commit 089b151
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub(crate) fn analyze(
class_property_type,
in_assignment,
&property_id,
declaring_property_class,
lhs_var_id,
var_id,
);
Expand Down Expand Up @@ -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::<Vec<_>>();
let template_type_keys = template_types.iter().map(|(k, _)| *k).collect::<Vec<_>>();

for type_name in template_type_keys {
if let Some(mapped_type) = extended_types
Expand Down Expand Up @@ -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<String>,
expr_id: &Option<String>,
) -> 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
Expand Down Expand Up @@ -443,25 +439,40 @@ 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),
analysis_data,
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(
Expand Down

0 comments on commit 089b151

Please sign in to comment.