Commit 5e478e9f authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

scrap link_shallow

parent cdcf73e1
...@@ -117,6 +117,7 @@ fn bench_link(b: &mut Bencher, input: &BenchInput) { ...@@ -117,6 +117,7 @@ fn bench_link(b: &mut Bencher, input: &BenchInput) {
link( link(
&input.var_graph, &input.var_graph,
val.clone(), val.clone(),
&|v| v,
&early_visitor, &early_visitor,
&(|val| visitor(val, compile_time_info, ImportAttributes::empty_ref())), &(|val| visitor(val, compile_time_info, ImportAttributes::empty_ref())),
&Default::default(), &Default::default(),
......
...@@ -4199,6 +4199,7 @@ mod tests { ...@@ -4199,6 +4199,7 @@ mod tests {
link( link(
var_graph, var_graph,
val, val,
&|v| v,
&super::test_utils::early_visitor, &super::test_utils::early_visitor,
&(|val| { &(|val| {
Box::pin(super::test_utils::visitor( Box::pin(super::test_utils::visitor(
......
...@@ -136,7 +136,6 @@ use crate::{ ...@@ -136,7 +136,6 @@ use crate::{
builtin::early_replace_builtin, builtin::early_replace_builtin,
graph::{ConditionalKind, EffectArg, EvalContext, VarGraph}, graph::{ConditionalKind, EffectArg, EvalContext, VarGraph},
imports::{ImportAnnotations, ImportAttributes, ImportedSymbol, Reexport}, imports::{ImportAnnotations, ImportAttributes, ImportedSymbol, Reexport},
linker::link_shallow,
parse_require_context, parse_require_context,
top_level_await::has_top_level_await, top_level_await::has_top_level_await,
}, },
...@@ -450,6 +449,7 @@ impl AnalysisState<'_> { ...@@ -450,6 +449,7 @@ impl AnalysisState<'_> {
Ok(link( Ok(link(
self.var_graph, self.var_graph,
value, value,
&|v| v,
&early_value_visitor, &early_value_visitor,
&|value| { &|value| {
value_visitor( value_visitor(
...@@ -474,10 +474,12 @@ impl AnalysisState<'_> { ...@@ -474,10 +474,12 @@ impl AnalysisState<'_> {
&self, &self,
value: JsValue, value: JsValue,
attributes: &ImportAttributes, attributes: &ImportAttributes,
earliest_toplevel_visitor: &impl Fn(JsValue) -> JsValue,
) -> Result<JsValue> { ) -> Result<JsValue> {
link_shallow( link(
self.var_graph, self.var_graph,
value, value,
earliest_toplevel_visitor,
&early_value_visitor, &early_value_visitor,
&|value| { &|value| {
value_visitor( value_visitor(
...@@ -493,7 +495,8 @@ impl AnalysisState<'_> { ...@@ -493,7 +495,8 @@ impl AnalysisState<'_> {
&self.fun_args_values, &self.fun_args_values,
&self.var_cache, &self.var_cache,
) )
.await .await?
.0)
} }
async fn link_truthy(&self, value: JsValue, attributes: &ImportAttributes) -> Result<JsValue> { async fn link_truthy(&self, value: JsValue, attributes: &ImportAttributes) -> Result<JsValue> {
...@@ -508,7 +511,14 @@ impl AnalysisState<'_> { ...@@ -508,7 +511,14 @@ impl AnalysisState<'_> {
// We are only interested in well-known functions, the only JsValues that can evaluated to // We are only interested in well-known functions, the only JsValues that can evaluated to
// that are WellKnownFunction-s, and Variables that point to them. Anything else can be // that are WellKnownFunction-s, and Variables that point to them. Anything else can be
// short circuited. // short circuited.
let value = self.unsafe_link_value_shallow(value, attributes).await?; let value = self
.unsafe_link_value_shallow(value, attributes, &|v| match v {
JsValue::Alternatives { .. } | JsValue::FreeVar { .. } | JsValue::Member { .. } => {
v
}
_ => JsValue::unknown(v, false, "earliest visitor well known function"),
})
.await?;
Ok(match value { Ok(match value {
JsValue::WellKnownFunction(kind) => vec![kind], JsValue::WellKnownFunction(kind) => vec![kind],
JsValue::Alternatives { values, .. } => values JsValue::Alternatives { values, .. } => values
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment