diff --git a/tamer/src/asg/graph.rs b/tamer/src/asg/graph.rs index ca849ef3..ed74b253 100644 --- a/tamer/src/asg/graph.rs +++ b/tamer/src/asg/graph.rs @@ -209,13 +209,13 @@ impl Asg { &mut self, from_oi: OA, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, ) -> Result<(), AsgError> { - from_oi.pre_add_edge(self, to_oi, ctx_span, |asg| { + from_oi.pre_add_edge(self, to_oi, ref_span, |asg| { asg.graph.add_edge( from_oi.widen().into(), to_oi.into(), - (from_oi.src_rel_ty(), OB::rel_ty(), ctx_span), + (from_oi.src_rel_ty(), OB::rel_ty(), ref_span), ); }) } @@ -333,14 +333,14 @@ impl Asg { oi: ObjectIndex, ) -> impl Iterator + 'a { self.graph.edges(oi.into()).map(move |edge| { - let (src_ty, target_ty, ctx_span) = edge.weight(); + let (src_ty, target_ty, ref_span) = edge.weight(); DynObjectRel::new( *src_ty, *target_ty, oi, ObjectIndex::::new(edge.target(), oi), - *ctx_span, + *ref_span, ) }) } @@ -542,7 +542,7 @@ impl AsgRelMut for OA { pub struct ProposedRel { from_oi: ObjectIndex, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, } #[cfg(test)] diff --git a/tamer/src/asg/graph/object/rel.rs b/tamer/src/asg/graph/object/rel.rs index 4a19b8f9..4c2390ed 100644 --- a/tamer/src/asg/graph/object/rel.rs +++ b/tamer/src/asg/graph/object/rel.rs @@ -198,7 +198,7 @@ macro_rules! object_rel { // on its own; // an edge only needs supplemental span information if there is // another context in which that object is referenced. - (@is_cross_edge dyn $rel:ident) => { $rel.ctx_span().is_some() }; + (@is_cross_edge dyn $rel:ident) => { $rel.ref_span().is_some() }; // Similar to above but providing _static_ information to the type // system. @@ -234,9 +234,9 @@ impl DynObjectRel { to_ty: ObjectRelTy, src: S, target: T, - ctx_span: Option, + ref_span: Option, ) -> Self { - Self((from_ty, to_ty), (src, target), ctx_span) + Self((from_ty, to_ty), (src, target), ref_span) } /// The type of the source edge. @@ -270,12 +270,16 @@ impl DynObjectRel { } } - /// A [`Span`] associated with the _relationship_ between the source and - /// target objects, - /// if any. - pub fn ctx_span(&self) -> Option { + /// A [`Span`] representing the reference location of a relationship. + /// + /// This value indicates that the edge represents a cross edge. + /// In this case, + /// a separate span is needed to provide information about the source + /// location of the reference, + /// rather than the object that has been referenced. + pub fn ref_span(&self) -> Option { match self { - Self(_, _, ctx_span) => *ctx_span, + Self(_, _, ref_span) => *ref_span, } } } @@ -486,7 +490,7 @@ impl Map<(S, T), (U, V)> for DynObjectRel { fn map(self, f: impl FnOnce((S, T)) -> (U, V)) -> Self::Target { match self { - Self(tys, x, ctx_span) => DynObjectRel(tys, f(x), ctx_span), + Self(tys, x, ref_span) => DynObjectRel(tys, f(x), ref_span), } } } @@ -863,7 +867,7 @@ pub trait ObjectIndexRelTo: Sized + Clone + Copy { &self, asg: &mut Asg, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, commit: impl FnOnce(&mut Asg), ) -> Result<(), AsgError>; @@ -947,7 +951,7 @@ where &self, asg: &mut Asg, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, commit: impl FnOnce(&mut Asg), ) -> Result<(), AsgError> { O::pre_add_edge( @@ -955,7 +959,7 @@ where ProposedRel { from_oi: self.widen().must_narrow_into::(), to_oi, - ctx_span, + ref_span, }, commit, ) @@ -977,7 +981,7 @@ impl ObjectIndexRelTo for ObjectIndexTo { &self, asg: &mut Asg, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, commit: impl FnOnce(&mut Asg), ) -> Result<(), AsgError> { macro_rules! pre_add_edge { @@ -987,7 +991,7 @@ impl ObjectIndexRelTo for ObjectIndexTo { ProposedRel { from_oi: self.widen().must_narrow_into::<$ty>(), to_oi, - ctx_span, + ref_span, }, commit, ) @@ -1023,11 +1027,11 @@ impl ObjectIndexRelTo for ObjectIndexToTree { &self, asg: &mut Asg, to_oi: ObjectIndex, - ctx_span: Option, + ref_span: Option, commit: impl FnOnce(&mut Asg), ) -> Result<(), AsgError> { match self { - Self(oito) => oito.pre_add_edge(asg, to_oi, ctx_span, commit), + Self(oito) => oito.pre_add_edge(asg, to_oi, ref_span, commit), } } } diff --git a/tamer/src/asg/graph/object/tpl.rs b/tamer/src/asg/graph/object/tpl.rs index 78f34580..f9eef9ed 100644 --- a/tamer/src/asg/graph/object/tpl.rs +++ b/tamer/src/asg/graph/object/tpl.rs @@ -266,7 +266,7 @@ object_rel! { ) -> Result<(), AsgError> { let tpl_name = rel.from_oi.name(asg); - match (rel.ctx_span, rel.to_oi.definition(asg)) { + match (rel.ref_span, rel.to_oi.definition(asg)) { // Missing definition results in shape uncertainty that // will have to be resolved when (if) a definition // becomes available. diff --git a/tamer/src/asg/graph/visit/ontree.rs b/tamer/src/asg/graph/visit/ontree.rs index e6d6517b..afa03608 100644 --- a/tamer/src/asg/graph/visit/ontree.rs +++ b/tamer/src/asg/graph/visit/ontree.rs @@ -313,10 +313,10 @@ impl Token for TreeWalkRel { /// while concrete spans are stored on the objects that those /// relationships reference. /// This will return a potentially-useful span only if the inner - /// [`DynObjectRel::ctx_span`] does. + /// [`DynObjectRel::ref_span`] does. fn span(&self) -> Span { match self { - Self(dyn_rel, _) => dyn_rel.ctx_span().unwrap_or(UNKNOWN_SPAN), + Self(dyn_rel, _) => dyn_rel.ref_span().unwrap_or(UNKNOWN_SPAN), } } }