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
main
Mike Gerwitz 2023-05-23 16:34:35 -04:00
parent 19a5ec1e0f
commit 294caaa35a
3 changed files with 2 additions and 48 deletions

View File

@ -800,25 +800,6 @@ impl<O: ObjectKind> ObjectIndex<O> {
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<Ident>
where
O: ObjectRelTo<Ident>,
{
ObjectIndexRelTo::declare_local(self, asg, name)
}
/// Retrieve the identifier for this object,
/// if any.
///

View File

@ -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<Meta> {
pub fn identify_as_tpl_param(
&self,
asg: &mut Asg,
oi_tpl: ObjectIndex<Tpl>,
name: SPair,
) -> ObjectIndex<Ident> {
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))
}

View File

@ -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<OB: ObjectRelatable>: Sized + Clone + Copy {
fn lookup_local_linear(
&self,
asg: &Asg,
name: SPair,
name: crate::parse::util::SPair,
) -> Option<ObjectIndex<Ident>>
where
Self: ObjectIndexRelTo<Ident>,
@ -879,21 +878,6 @@ pub trait ObjectIndexRelTo<OB: ObjectRelatable>: Sized + Clone + Copy {
ObjectIndexRelTo::<Ident>::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<Ident>
where
Self: ObjectIndexRelTo<Ident>,
{
asg.create(Ident::declare(name))
.add_edge_from(asg, *self, None)
}
}
impl<O: ObjectRelatable, OB: ObjectRelatable> ObjectIndexRelTo<OB>