From 294caaa35a19bf058aabd0db51c34f2e98d3685b Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 23 May 2023 16:34:35 -0400 Subject: [PATCH] tamer: asg::graph::object: Remove declare_local This was used for metavariable declaration before scoping was sorted out. That was just resolved, and so this is no longer needed (and is indeed not desirable, since it side-steps the scope index and so will not be found except by `lookup_local_linear`). DEV-13162 --- tamer/src/asg/graph/object.rs | 19 ------------------- tamer/src/asg/graph/object/meta.rs | 13 +------------ tamer/src/asg/graph/object/rel.rs | 18 +----------------- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/tamer/src/asg/graph/object.rs b/tamer/src/asg/graph/object.rs index ed60743d..011f443d 100644 --- a/tamer/src/asg/graph/object.rs +++ b/tamer/src/asg/graph/object.rs @@ -800,25 +800,6 @@ impl ObjectIndex { ObjectIndexRelTo::lookup_local_linear(self, asg, name) } - /// Declare a local identifier. - /// - /// See [`ObjectIndexRelTo::declare_local`]. - // - // TODO: This method exists here only as a fallback when Rust is unable - // to infer the proper type for [`ObjectIndexRelTo`]. - // It can be removed once that is resolved; - // delete this method and compile to see. - pub fn declare_local( - &self, - asg: &mut Asg, - name: SPair, - ) -> ObjectIndex - where - O: ObjectRelTo, - { - ObjectIndexRelTo::declare_local(self, asg, name) - } - /// Retrieve the identifier for this object, /// if any. /// diff --git a/tamer/src/asg/graph/object/meta.rs b/tamer/src/asg/graph/object/meta.rs index 07fc4b67..ebc5e9a8 100644 --- a/tamer/src/asg/graph/object/meta.rs +++ b/tamer/src/asg/graph/object/meta.rs @@ -24,7 +24,7 @@ //! have historically been a feature of the template system. //! The canonical metavariable is the template parameter. -use super::{prelude::*, Ident, Tpl}; +use super::{prelude::*, Ident}; use crate::{ diagnose::Annotate, diagnostic_todo, @@ -137,17 +137,6 @@ object_rel! { } impl ObjectIndex { - pub fn identify_as_tpl_param( - &self, - asg: &mut Asg, - oi_tpl: ObjectIndex, - name: SPair, - ) -> ObjectIndex { - oi_tpl - .declare_local(asg, name) - .add_edge_to(asg, *self, None) - } - pub fn assign_lexeme(self, asg: &mut Asg, lexeme: SPair) -> Self { self.map_obj(asg, |meta| meta.assign_lexeme(lexeme)) } diff --git a/tamer/src/asg/graph/object/rel.rs b/tamer/src/asg/graph/object/rel.rs index c8991dad..6a68fdf5 100644 --- a/tamer/src/asg/graph/object/rel.rs +++ b/tamer/src/asg/graph/object/rel.rs @@ -28,7 +28,6 @@ use super::{ use crate::{ asg::{graph::object::Tpl, Asg}, f::Functor, - parse::util::SPair, span::Span, }; use std::{fmt::Display, marker::PhantomData}; @@ -870,7 +869,7 @@ pub trait ObjectIndexRelTo: Sized + Clone + Copy { fn lookup_local_linear( &self, asg: &Asg, - name: SPair, + name: crate::parse::util::SPair, ) -> Option> where Self: ObjectIndexRelTo, @@ -879,21 +878,6 @@ pub trait ObjectIndexRelTo: Sized + Clone + Copy { ObjectIndexRelTo::::edges_rel_to(self, asg) .find(|oi| oi.resolve(asg).name().symbol() == name.symbol()) } - - /// Declare a local identifier. - /// - /// A local identifier is lexically scoped to `self`. - /// This operation is valid only for [`ObjectKind`]s that can contain - /// edges to [`Ident`]s. - /// - /// TODO: This allows for duplicate local identifiers! - fn declare_local(&self, asg: &mut Asg, name: SPair) -> ObjectIndex - where - Self: ObjectIndexRelTo, - { - asg.create(Ident::declare(name)) - .add_edge_from(asg, *self, None) - } } impl ObjectIndexRelTo