alpha
Login
or
Join now
nandi.uk
/
gleam
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Fork of daniellemaywood.uk/gleam — Wasm codegen work
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Add more information to references
author
GearsDatapacks
committer
Louis Pilfold
date
1 year ago
(Mar 13, 2025, 2:53 PM UTC)
commit
d444962e
d444962e29b9d0fe8e27a016de79cb6052f408e7
parent
422b93a9
422b93a9474f229f72bdeb196d4dfc0459ea37b2
+710
-23
12 changed files
Expand all
Collapse all
Unified
Split
compiler-core
generated
schema_capnp.rs
schema.capnp
src
analyse
imports.rs
analyse.rs
language_server
rename.rs
metadata
module_decoder.rs
module_encoder.rs
tests.rs
reference.rs
type_
expression.rs
pattern.rs
type_.rs
+571
-6
compiler-core/generated/schema_capnp.rs
View file
Reviewed
···
1690
1690
!self.reader.get_pointer_field(1).is_null()
1691
1691
}
1692
1692
#[inline]
1693
1693
-
pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Reader<'a,crate::schema_capnp::src_span::Owned>> {
1693
1693
+
pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Reader<'a,crate::schema_capnp::reference::Owned>> {
1694
1694
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None)
1695
1695
}
1696
1696
#[inline]
···
1784
1784
!self.builder.is_pointer_field_null(1)
1785
1785
}
1786
1786
#[inline]
1787
1787
-
pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Builder<'a,crate::schema_capnp::src_span::Owned>> {
1787
1787
+
pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Builder<'a,crate::schema_capnp::reference::Owned>> {
1788
1788
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None)
1789
1789
}
1790
1790
#[inline]
1791
1791
-
pub fn set_references(&mut self, value: ::capnp::struct_list::Reader<'_,crate::schema_capnp::src_span::Owned>) -> ::capnp::Result<()> {
1791
1791
+
pub fn set_references(&mut self, value: ::capnp::struct_list::Reader<'_,crate::schema_capnp::reference::Owned>) -> ::capnp::Result<()> {
1792
1792
::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(2), value, false)
1793
1793
}
1794
1794
#[inline]
1795
1795
-
pub fn init_references(self, size: u32) -> ::capnp::struct_list::Builder<'a,crate::schema_capnp::src_span::Owned> {
1795
1795
+
pub fn init_references(self, size: u32) -> ::capnp::struct_list::Builder<'a,crate::schema_capnp::reference::Owned> {
1796
1796
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), size)
1797
1797
}
1798
1798
#[inline]
···
1873
1873
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
1874
1874
::capnp::word(0, 0, 0, 0, 3, 0, 1, 0),
1875
1875
::capnp::word(16, 0, 0, 0, 0, 0, 0, 0),
1876
1876
-
::capnp::word(176, 122, 119, 83, 72, 147, 59, 230),
1876
1876
+
::capnp::word(97, 111, 221, 187, 73, 147, 33, 194),
1877
1877
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
1878
1878
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
1879
1879
::capnp::word(14, 0, 0, 0, 0, 0, 0, 0),
···
1884
1884
match index {
1885
1885
0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(),
1886
1886
1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(),
1887
1887
-
2 => <::capnp::struct_list::Owned<crate::schema_capnp::src_span::Owned> as ::capnp::introspect::Introspect>::introspect(),
1887
1887
+
2 => <::capnp::struct_list::Owned<crate::schema_capnp::reference::Owned> as ::capnp::introspect::Introspect>::introspect(),
1888
1888
_ => panic!("invalid field index {}", index),
1889
1889
}
1890
1890
}
···
1902
1902
pub static MEMBERS_BY_NAME : &[u16] = &[0,1,2];
1903
1903
pub const TYPE_ID: u64 = 0xcd8d_a5aa_fa92_5d68;
1904
1904
}
1905
1905
+
}
1906
1906
+
1907
1907
+
pub mod reference {
1908
1908
+
#[derive(Copy, Clone)]
1909
1909
+
pub struct Owned(());
1910
1910
+
impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } }
1911
1911
+
impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }
1912
1912
+
impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }
1913
1913
+
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
1914
1914
+
1915
1915
+
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
1916
1916
+
impl <> ::core::marker::Copy for Reader<'_,> {}
1917
1917
+
impl <> ::core::clone::Clone for Reader<'_,> {
1918
1918
+
fn clone(&self) -> Self { *self }
1919
1919
+
}
1920
1920
+
1921
1921
+
impl <> ::capnp::traits::HasTypeId for Reader<'_,> {
1922
1922
+
const TYPE_ID: u64 = _private::TYPE_ID;
1923
1923
+
}
1924
1924
+
impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> {
1925
1925
+
fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self {
1926
1926
+
Self { reader, }
1927
1927
+
}
1928
1928
+
}
1929
1929
+
1930
1930
+
impl <'a,> ::core::convert::From<Reader<'a,>> for ::capnp::dynamic_value::Reader<'a> {
1931
1931
+
fn from(reader: Reader<'a,>) -> Self {
1932
1932
+
Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>})))
1933
1933
+
}
1934
1934
+
}
1935
1935
+
1936
1936
+
impl <> ::core::fmt::Debug for Reader<'_,> {
1937
1937
+
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> {
1938
1938
+
core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f)
1939
1939
+
}
1940
1940
+
}
1941
1941
+
1942
1942
+
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
1943
1943
+
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Self> {
1944
1944
+
::core::result::Result::Ok(reader.get_struct(default)?.into())
1945
1945
+
}
1946
1946
+
}
1947
1947
+
1948
1948
+
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
1949
1949
+
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
1950
1950
+
self.reader
1951
1951
+
}
1952
1952
+
}
1953
1953
+
1954
1954
+
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
1955
1955
+
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
1956
1956
+
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
1957
1957
+
}
1958
1958
+
}
1959
1959
+
1960
1960
+
impl <'a,> Reader<'a,> {
1961
1961
+
pub fn reborrow(&self) -> Reader<'_,> {
1962
1962
+
Self { .. *self }
1963
1963
+
}
1964
1964
+
1965
1965
+
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
1966
1966
+
self.reader.total_size()
1967
1967
+
}
1968
1968
+
#[inline]
1969
1969
+
pub fn get_location(self) -> ::capnp::Result<crate::schema_capnp::src_span::Reader<'a>> {
1970
1970
+
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
1971
1971
+
}
1972
1972
+
#[inline]
1973
1973
+
pub fn has_location(&self) -> bool {
1974
1974
+
!self.reader.get_pointer_field(0).is_null()
1975
1975
+
}
1976
1976
+
#[inline]
1977
1977
+
pub fn get_kind(self) -> ::capnp::Result<crate::schema_capnp::reference_kind::Reader<'a>> {
1978
1978
+
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None)
1979
1979
+
}
1980
1980
+
#[inline]
1981
1981
+
pub fn has_kind(&self) -> bool {
1982
1982
+
!self.reader.get_pointer_field(1).is_null()
1983
1983
+
}
1984
1984
+
}
1985
1985
+
1986
1986
+
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
1987
1987
+
impl <> ::capnp::traits::HasStructSize for Builder<'_,> {
1988
1988
+
const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 0, pointers: 2 };
1989
1989
+
}
1990
1990
+
impl <> ::capnp::traits::HasTypeId for Builder<'_,> {
1991
1991
+
const TYPE_ID: u64 = _private::TYPE_ID;
1992
1992
+
}
1993
1993
+
impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> {
1994
1994
+
fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self {
1995
1995
+
Self { builder, }
1996
1996
+
}
1997
1997
+
}
1998
1998
+
1999
1999
+
impl <'a,> ::core::convert::From<Builder<'a,>> for ::capnp::dynamic_value::Builder<'a> {
2000
2000
+
fn from(builder: Builder<'a,>) -> Self {
2001
2001
+
Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>})))
2002
2002
+
}
2003
2003
+
}
2004
2004
+
2005
2005
+
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
2006
2006
+
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
2007
2007
+
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
2008
2008
+
}
2009
2009
+
}
2010
2010
+
2011
2011
+
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
2012
2012
+
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self {
2013
2013
+
builder.init_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE).into()
2014
2014
+
}
2015
2015
+
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Self> {
2016
2016
+
::core::result::Result::Ok(builder.get_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE, default)?.into())
2017
2017
+
}
2018
2018
+
}
2019
2019
+
2020
2020
+
impl <> ::capnp::traits::SetterInput<Owned<>> for Reader<'_,> {
2021
2021
+
fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
2022
2022
+
}
2023
2023
+
2024
2024
+
impl <'a,> Builder<'a,> {
2025
2025
+
pub fn into_reader(self) -> Reader<'a,> {
2026
2026
+
self.builder.into_reader().into()
2027
2027
+
}
2028
2028
+
pub fn reborrow(&mut self) -> Builder<'_,> {
2029
2029
+
Builder { builder: self.builder.reborrow() }
2030
2030
+
}
2031
2031
+
pub fn reborrow_as_reader(&self) -> Reader<'_,> {
2032
2032
+
self.builder.as_reader().into()
2033
2033
+
}
2034
2034
+
2035
2035
+
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
2036
2036
+
self.builder.as_reader().total_size()
2037
2037
+
}
2038
2038
+
#[inline]
2039
2039
+
pub fn get_location(self) -> ::capnp::Result<crate::schema_capnp::src_span::Builder<'a>> {
2040
2040
+
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
2041
2041
+
}
2042
2042
+
#[inline]
2043
2043
+
pub fn set_location(&mut self, value: crate::schema_capnp::src_span::Reader<'_>) -> ::capnp::Result<()> {
2044
2044
+
::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(0), value, false)
2045
2045
+
}
2046
2046
+
#[inline]
2047
2047
+
pub fn init_location(self, ) -> crate::schema_capnp::src_span::Builder<'a> {
2048
2048
+
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0)
2049
2049
+
}
2050
2050
+
#[inline]
2051
2051
+
pub fn has_location(&self) -> bool {
2052
2052
+
!self.builder.is_pointer_field_null(0)
2053
2053
+
}
2054
2054
+
#[inline]
2055
2055
+
pub fn get_kind(self) -> ::capnp::Result<crate::schema_capnp::reference_kind::Builder<'a>> {
2056
2056
+
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None)
2057
2057
+
}
2058
2058
+
#[inline]
2059
2059
+
pub fn set_kind(&mut self, value: crate::schema_capnp::reference_kind::Reader<'_>) -> ::capnp::Result<()> {
2060
2060
+
::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(1), value, false)
2061
2061
+
}
2062
2062
+
#[inline]
2063
2063
+
pub fn init_kind(self, ) -> crate::schema_capnp::reference_kind::Builder<'a> {
2064
2064
+
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
2065
2065
+
}
2066
2066
+
#[inline]
2067
2067
+
pub fn has_kind(&self) -> bool {
2068
2068
+
!self.builder.is_pointer_field_null(1)
2069
2069
+
}
2070
2070
+
}
2071
2071
+
2072
2072
+
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
2073
2073
+
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
2074
2074
+
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self {
2075
2075
+
Self { _typeless: typeless, }
2076
2076
+
}
2077
2077
+
}
2078
2078
+
impl Pipeline {
2079
2079
+
pub fn get_location(&self) -> crate::schema_capnp::src_span::Pipeline {
2080
2080
+
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(0))
2081
2081
+
}
2082
2082
+
pub fn get_kind(&self) -> crate::schema_capnp::reference_kind::Pipeline {
2083
2083
+
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
2084
2084
+
}
2085
2085
+
}
2086
2086
+
mod _private {
2087
2087
+
pub static ENCODED_NODE: [::capnp::Word; 48] = [
2088
2088
+
::capnp::word(0, 0, 0, 0, 5, 0, 6, 0),
2089
2089
+
::capnp::word(97, 111, 221, 187, 73, 147, 33, 194),
2090
2090
+
::capnp::word(13, 0, 0, 0, 1, 0, 0, 0),
2091
2091
+
::capnp::word(190, 237, 188, 253, 156, 169, 51, 181),
2092
2092
+
::capnp::word(2, 0, 7, 0, 0, 0, 0, 0),
2093
2093
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2094
2094
+
::capnp::word(21, 0, 0, 0, 186, 0, 0, 0),
2095
2095
+
::capnp::word(29, 0, 0, 0, 7, 0, 0, 0),
2096
2096
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2097
2097
+
::capnp::word(25, 0, 0, 0, 119, 0, 0, 0),
2098
2098
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2099
2099
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2100
2100
+
::capnp::word(115, 99, 104, 101, 109, 97, 46, 99),
2101
2101
+
::capnp::word(97, 112, 110, 112, 58, 82, 101, 102),
2102
2102
+
::capnp::word(101, 114, 101, 110, 99, 101, 0, 0),
2103
2103
+
::capnp::word(0, 0, 0, 0, 1, 0, 1, 0),
2104
2104
+
::capnp::word(8, 0, 0, 0, 3, 0, 4, 0),
2105
2105
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2106
2106
+
::capnp::word(0, 0, 1, 0, 0, 0, 0, 0),
2107
2107
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2108
2108
+
::capnp::word(41, 0, 0, 0, 74, 0, 0, 0),
2109
2109
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2110
2110
+
::capnp::word(40, 0, 0, 0, 3, 0, 1, 0),
2111
2111
+
::capnp::word(52, 0, 0, 0, 2, 0, 1, 0),
2112
2112
+
::capnp::word(1, 0, 0, 0, 1, 0, 0, 0),
2113
2113
+
::capnp::word(0, 0, 1, 0, 1, 0, 0, 0),
2114
2114
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2115
2115
+
::capnp::word(49, 0, 0, 0, 42, 0, 0, 0),
2116
2116
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2117
2117
+
::capnp::word(44, 0, 0, 0, 3, 0, 1, 0),
2118
2118
+
::capnp::word(56, 0, 0, 0, 2, 0, 1, 0),
2119
2119
+
::capnp::word(108, 111, 99, 97, 116, 105, 111, 110),
2120
2120
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2121
2121
+
::capnp::word(16, 0, 0, 0, 0, 0, 0, 0),
2122
2122
+
::capnp::word(176, 122, 119, 83, 72, 147, 59, 230),
2123
2123
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2124
2124
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2125
2125
+
::capnp::word(16, 0, 0, 0, 0, 0, 0, 0),
2126
2126
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2127
2127
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2128
2128
+
::capnp::word(107, 105, 110, 100, 0, 0, 0, 0),
2129
2129
+
::capnp::word(16, 0, 0, 0, 0, 0, 0, 0),
2130
2130
+
::capnp::word(201, 38, 14, 81, 37, 76, 28, 166),
2131
2131
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2132
2132
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2133
2133
+
::capnp::word(16, 0, 0, 0, 0, 0, 0, 0),
2134
2134
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2135
2135
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2136
2136
+
];
2137
2137
+
pub fn get_field_types(index: u16) -> ::capnp::introspect::Type {
2138
2138
+
match index {
2139
2139
+
0 => <crate::schema_capnp::src_span::Owned as ::capnp::introspect::Introspect>::introspect(),
2140
2140
+
1 => <crate::schema_capnp::reference_kind::Owned as ::capnp::introspect::Introspect>::introspect(),
2141
2141
+
_ => panic!("invalid field index {}", index),
2142
2142
+
}
2143
2143
+
}
2144
2144
+
pub fn get_annotation_types(child_index: Option<u16>, index: u32) -> ::capnp::introspect::Type {
2145
2145
+
panic!("invalid annotation indices ({:?}, {}) ", child_index, index)
2146
2146
+
}
2147
2147
+
pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema {
2148
2148
+
encoded_node: &ENCODED_NODE,
2149
2149
+
nonunion_members: NONUNION_MEMBERS,
2150
2150
+
members_by_discriminant: MEMBERS_BY_DISCRIMINANT,
2151
2151
+
members_by_name: MEMBERS_BY_NAME,
2152
2152
+
};
2153
2153
+
pub static NONUNION_MEMBERS : &[u16] = &[0,1];
2154
2154
+
pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[];
2155
2155
+
pub static MEMBERS_BY_NAME : &[u16] = &[1,0];
2156
2156
+
pub const TYPE_ID: u64 = 0xc221_9349_bbdd_6f61;
2157
2157
+
}
2158
2158
+
}
2159
2159
+
2160
2160
+
pub mod reference_kind {
2161
2161
+
pub use self::Which::{Qualified,Unqualified,Import,Definition};
2162
2162
+
2163
2163
+
#[derive(Copy, Clone)]
2164
2164
+
pub struct Owned(());
2165
2165
+
impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } }
2166
2166
+
impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }
2167
2167
+
impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }
2168
2168
+
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
2169
2169
+
2170
2170
+
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
2171
2171
+
impl <> ::core::marker::Copy for Reader<'_,> {}
2172
2172
+
impl <> ::core::clone::Clone for Reader<'_,> {
2173
2173
+
fn clone(&self) -> Self { *self }
2174
2174
+
}
2175
2175
+
2176
2176
+
impl <> ::capnp::traits::HasTypeId for Reader<'_,> {
2177
2177
+
const TYPE_ID: u64 = _private::TYPE_ID;
2178
2178
+
}
2179
2179
+
impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> {
2180
2180
+
fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self {
2181
2181
+
Self { reader, }
2182
2182
+
}
2183
2183
+
}
2184
2184
+
2185
2185
+
impl <'a,> ::core::convert::From<Reader<'a,>> for ::capnp::dynamic_value::Reader<'a> {
2186
2186
+
fn from(reader: Reader<'a,>) -> Self {
2187
2187
+
Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>})))
2188
2188
+
}
2189
2189
+
}
2190
2190
+
2191
2191
+
impl <> ::core::fmt::Debug for Reader<'_,> {
2192
2192
+
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> {
2193
2193
+
core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f)
2194
2194
+
}
2195
2195
+
}
2196
2196
+
2197
2197
+
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
2198
2198
+
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Self> {
2199
2199
+
::core::result::Result::Ok(reader.get_struct(default)?.into())
2200
2200
+
}
2201
2201
+
}
2202
2202
+
2203
2203
+
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
2204
2204
+
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
2205
2205
+
self.reader
2206
2206
+
}
2207
2207
+
}
2208
2208
+
2209
2209
+
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
2210
2210
+
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
2211
2211
+
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
2212
2212
+
}
2213
2213
+
}
2214
2214
+
2215
2215
+
impl <> Reader<'_,> {
2216
2216
+
pub fn reborrow(&self) -> Reader<'_,> {
2217
2217
+
Self { .. *self }
2218
2218
+
}
2219
2219
+
2220
2220
+
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
2221
2221
+
self.reader.total_size()
2222
2222
+
}
2223
2223
+
#[inline]
2224
2224
+
pub fn which(self) -> ::core::result::Result<WhichReader, ::capnp::NotInSchema> {
2225
2225
+
match self.reader.get_data_field::<u16>(0) {
2226
2226
+
0 => {
2227
2227
+
::core::result::Result::Ok(Qualified(
2228
2228
+
()
2229
2229
+
))
2230
2230
+
}
2231
2231
+
1 => {
2232
2232
+
::core::result::Result::Ok(Unqualified(
2233
2233
+
()
2234
2234
+
))
2235
2235
+
}
2236
2236
+
2 => {
2237
2237
+
::core::result::Result::Ok(Import(
2238
2238
+
()
2239
2239
+
))
2240
2240
+
}
2241
2241
+
3 => {
2242
2242
+
::core::result::Result::Ok(Definition(
2243
2243
+
()
2244
2244
+
))
2245
2245
+
}
2246
2246
+
x => ::core::result::Result::Err(::capnp::NotInSchema(x))
2247
2247
+
}
2248
2248
+
}
2249
2249
+
}
2250
2250
+
2251
2251
+
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
2252
2252
+
impl <> ::capnp::traits::HasStructSize for Builder<'_,> {
2253
2253
+
const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 1, pointers: 0 };
2254
2254
+
}
2255
2255
+
impl <> ::capnp::traits::HasTypeId for Builder<'_,> {
2256
2256
+
const TYPE_ID: u64 = _private::TYPE_ID;
2257
2257
+
}
2258
2258
+
impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> {
2259
2259
+
fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self {
2260
2260
+
Self { builder, }
2261
2261
+
}
2262
2262
+
}
2263
2263
+
2264
2264
+
impl <'a,> ::core::convert::From<Builder<'a,>> for ::capnp::dynamic_value::Builder<'a> {
2265
2265
+
fn from(builder: Builder<'a,>) -> Self {
2266
2266
+
Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>})))
2267
2267
+
}
2268
2268
+
}
2269
2269
+
2270
2270
+
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
2271
2271
+
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
2272
2272
+
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
2273
2273
+
}
2274
2274
+
}
2275
2275
+
2276
2276
+
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
2277
2277
+
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self {
2278
2278
+
builder.init_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE).into()
2279
2279
+
}
2280
2280
+
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Self> {
2281
2281
+
::core::result::Result::Ok(builder.get_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE, default)?.into())
2282
2282
+
}
2283
2283
+
}
2284
2284
+
2285
2285
+
impl <> ::capnp::traits::SetterInput<Owned<>> for Reader<'_,> {
2286
2286
+
fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
2287
2287
+
}
2288
2288
+
2289
2289
+
impl <'a,> Builder<'a,> {
2290
2290
+
pub fn into_reader(self) -> Reader<'a,> {
2291
2291
+
self.builder.into_reader().into()
2292
2292
+
}
2293
2293
+
pub fn reborrow(&mut self) -> Builder<'_,> {
2294
2294
+
Builder { builder: self.builder.reborrow() }
2295
2295
+
}
2296
2296
+
pub fn reborrow_as_reader(&self) -> Reader<'_,> {
2297
2297
+
self.builder.as_reader().into()
2298
2298
+
}
2299
2299
+
2300
2300
+
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
2301
2301
+
self.builder.as_reader().total_size()
2302
2302
+
}
2303
2303
+
#[inline]
2304
2304
+
pub fn set_qualified(&mut self, _value: ()) {
2305
2305
+
self.builder.set_data_field::<u16>(0, 0);
2306
2306
+
}
2307
2307
+
#[inline]
2308
2308
+
pub fn set_unqualified(&mut self, _value: ()) {
2309
2309
+
self.builder.set_data_field::<u16>(0, 1);
2310
2310
+
}
2311
2311
+
#[inline]
2312
2312
+
pub fn set_import(&mut self, _value: ()) {
2313
2313
+
self.builder.set_data_field::<u16>(0, 2);
2314
2314
+
}
2315
2315
+
#[inline]
2316
2316
+
pub fn set_definition(&mut self, _value: ()) {
2317
2317
+
self.builder.set_data_field::<u16>(0, 3);
2318
2318
+
}
2319
2319
+
#[inline]
2320
2320
+
pub fn which(self) -> ::core::result::Result<WhichBuilder, ::capnp::NotInSchema> {
2321
2321
+
match self.builder.get_data_field::<u16>(0) {
2322
2322
+
0 => {
2323
2323
+
::core::result::Result::Ok(Qualified(
2324
2324
+
()
2325
2325
+
))
2326
2326
+
}
2327
2327
+
1 => {
2328
2328
+
::core::result::Result::Ok(Unqualified(
2329
2329
+
()
2330
2330
+
))
2331
2331
+
}
2332
2332
+
2 => {
2333
2333
+
::core::result::Result::Ok(Import(
2334
2334
+
()
2335
2335
+
))
2336
2336
+
}
2337
2337
+
3 => {
2338
2338
+
::core::result::Result::Ok(Definition(
2339
2339
+
()
2340
2340
+
))
2341
2341
+
}
2342
2342
+
x => ::core::result::Result::Err(::capnp::NotInSchema(x))
2343
2343
+
}
2344
2344
+
}
2345
2345
+
}
2346
2346
+
2347
2347
+
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
2348
2348
+
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
2349
2349
+
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self {
2350
2350
+
Self { _typeless: typeless, }
2351
2351
+
}
2352
2352
+
}
2353
2353
+
impl Pipeline {
2354
2354
+
}
2355
2355
+
mod _private {
2356
2356
+
pub static ENCODED_NODE: [::capnp::Word; 81] = [
2357
2357
+
::capnp::word(0, 0, 0, 0, 5, 0, 6, 0),
2358
2358
+
::capnp::word(201, 38, 14, 81, 37, 76, 28, 166),
2359
2359
+
::capnp::word(13, 0, 0, 0, 1, 0, 1, 0),
2360
2360
+
::capnp::word(190, 237, 188, 253, 156, 169, 51, 181),
2361
2361
+
::capnp::word(0, 0, 7, 0, 0, 0, 4, 0),
2362
2362
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2363
2363
+
::capnp::word(21, 0, 0, 0, 218, 0, 0, 0),
2364
2364
+
::capnp::word(33, 0, 0, 0, 7, 0, 0, 0),
2365
2365
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2366
2366
+
::capnp::word(29, 0, 0, 0, 231, 0, 0, 0),
2367
2367
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2368
2368
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2369
2369
+
::capnp::word(115, 99, 104, 101, 109, 97, 46, 99),
2370
2370
+
::capnp::word(97, 112, 110, 112, 58, 82, 101, 102),
2371
2371
+
::capnp::word(101, 114, 101, 110, 99, 101, 75, 105),
2372
2372
+
::capnp::word(110, 100, 0, 0, 0, 0, 0, 0),
2373
2373
+
::capnp::word(0, 0, 0, 0, 1, 0, 1, 0),
2374
2374
+
::capnp::word(16, 0, 0, 0, 3, 0, 4, 0),
2375
2375
+
::capnp::word(0, 0, 255, 255, 0, 0, 0, 0),
2376
2376
+
::capnp::word(0, 0, 1, 0, 0, 0, 0, 0),
2377
2377
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2378
2378
+
::capnp::word(97, 0, 0, 0, 82, 0, 0, 0),
2379
2379
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2380
2380
+
::capnp::word(96, 0, 0, 0, 3, 0, 1, 0),
2381
2381
+
::capnp::word(108, 0, 0, 0, 2, 0, 1, 0),
2382
2382
+
::capnp::word(1, 0, 254, 255, 0, 0, 0, 0),
2383
2383
+
::capnp::word(0, 0, 1, 0, 1, 0, 0, 0),
2384
2384
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2385
2385
+
::capnp::word(105, 0, 0, 0, 98, 0, 0, 0),
2386
2386
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2387
2387
+
::capnp::word(104, 0, 0, 0, 3, 0, 1, 0),
2388
2388
+
::capnp::word(116, 0, 0, 0, 2, 0, 1, 0),
2389
2389
+
::capnp::word(2, 0, 253, 255, 0, 0, 0, 0),
2390
2390
+
::capnp::word(0, 0, 1, 0, 2, 0, 0, 0),
2391
2391
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2392
2392
+
::capnp::word(113, 0, 0, 0, 58, 0, 0, 0),
2393
2393
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2394
2394
+
::capnp::word(108, 0, 0, 0, 3, 0, 1, 0),
2395
2395
+
::capnp::word(120, 0, 0, 0, 2, 0, 1, 0),
2396
2396
+
::capnp::word(3, 0, 252, 255, 0, 0, 0, 0),
2397
2397
+
::capnp::word(0, 0, 1, 0, 3, 0, 0, 0),
2398
2398
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2399
2399
+
::capnp::word(117, 0, 0, 0, 90, 0, 0, 0),
2400
2400
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2401
2401
+
::capnp::word(116, 0, 0, 0, 3, 0, 1, 0),
2402
2402
+
::capnp::word(128, 0, 0, 0, 2, 0, 1, 0),
2403
2403
+
::capnp::word(113, 117, 97, 108, 105, 102, 105, 101),
2404
2404
+
::capnp::word(100, 0, 0, 0, 0, 0, 0, 0),
2405
2405
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2406
2406
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2407
2407
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2408
2408
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2409
2409
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2410
2410
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2411
2411
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2412
2412
+
::capnp::word(117, 110, 113, 117, 97, 108, 105, 102),
2413
2413
+
::capnp::word(105, 101, 100, 0, 0, 0, 0, 0),
2414
2414
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2415
2415
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2416
2416
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2417
2417
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2418
2418
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2419
2419
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2420
2420
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2421
2421
+
::capnp::word(105, 109, 112, 111, 114, 116, 0, 0),
2422
2422
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2423
2423
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2424
2424
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2425
2425
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2426
2426
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2427
2427
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2428
2428
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2429
2429
+
::capnp::word(100, 101, 102, 105, 110, 105, 116, 105),
2430
2430
+
::capnp::word(111, 110, 0, 0, 0, 0, 0, 0),
2431
2431
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2432
2432
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2433
2433
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2434
2434
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2435
2435
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2436
2436
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2437
2437
+
::capnp::word(0, 0, 0, 0, 0, 0, 0, 0),
2438
2438
+
];
2439
2439
+
pub fn get_field_types(index: u16) -> ::capnp::introspect::Type {
2440
2440
+
match index {
2441
2441
+
0 => <() as ::capnp::introspect::Introspect>::introspect(),
2442
2442
+
1 => <() as ::capnp::introspect::Introspect>::introspect(),
2443
2443
+
2 => <() as ::capnp::introspect::Introspect>::introspect(),
2444
2444
+
3 => <() as ::capnp::introspect::Introspect>::introspect(),
2445
2445
+
_ => panic!("invalid field index {}", index),
2446
2446
+
}
2447
2447
+
}
2448
2448
+
pub fn get_annotation_types(child_index: Option<u16>, index: u32) -> ::capnp::introspect::Type {
2449
2449
+
panic!("invalid annotation indices ({:?}, {}) ", child_index, index)
2450
2450
+
}
2451
2451
+
pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema {
2452
2452
+
encoded_node: &ENCODED_NODE,
2453
2453
+
nonunion_members: NONUNION_MEMBERS,
2454
2454
+
members_by_discriminant: MEMBERS_BY_DISCRIMINANT,
2455
2455
+
members_by_name: MEMBERS_BY_NAME,
2456
2456
+
};
2457
2457
+
pub static NONUNION_MEMBERS : &[u16] = &[];
2458
2458
+
pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[0,1,2,3];
2459
2459
+
pub static MEMBERS_BY_NAME : &[u16] = &[3,2,0,1];
2460
2460
+
pub const TYPE_ID: u64 = 0xa61c_4c25_510e_26c9;
2461
2461
+
}
2462
2462
+
pub enum Which {
2463
2463
+
Qualified(()),
2464
2464
+
Unqualified(()),
2465
2465
+
Import(()),
2466
2466
+
Definition(()),
2467
2467
+
}
2468
2468
+
pub type WhichReader = Which;
2469
2469
+
pub type WhichBuilder = Which;
1905
2470
}
1906
2471
1907
2472
pub mod type_alias_constructor {
+15
-1
compiler-core/schema.capnp
View file
Reviewed
···
44
44
struct ValueReference {
45
45
module @0 :Text;
46
46
name @1 :Text;
47
47
-
references @2 :List(SrcSpan);
47
47
+
references @2 :List(Reference);
48
48
+
}
49
49
+
50
50
+
struct Reference {
51
51
+
location @0 :SrcSpan;
52
52
+
kind @1 :ReferenceKind;
53
53
+
}
54
54
+
55
55
+
struct ReferenceKind {
56
56
+
union {
57
57
+
qualified @0 :Void;
58
58
+
unqualified @1 :Void;
59
59
+
import @2 :Void;
60
60
+
definition @3 :Void;
61
61
+
}
48
62
}
49
63
50
64
struct TypeAliasConstructor {
+4
compiler-core/src/analyse.rs
View file
Reviewed
···
20
20
dep_tree,
21
21
line_numbers::LineNumbers,
22
22
parse::SpannedString,
23
23
+
reference::ReferenceKind,
23
24
type_::{
24
25
self, AccessorsMap, Deprecation, ModuleInterface, Opaque, PatternConstructor,
25
26
RecordAccessor, References, Type, TypeAliasConstructor, TypeConstructor,
···
430
431
environment.current_module.clone(),
431
432
name.clone(),
432
433
name_location,
434
434
+
ReferenceKind::Definition,
433
435
);
434
436
435
437
if publicity.is_private() {
···
653
655
environment.current_module.clone(),
654
656
name.clone(),
655
657
name_location,
658
658
+
ReferenceKind::Definition,
656
659
);
657
660
658
661
Definition::Function(Function {
···
1108
1111
environment.current_module.clone(),
1109
1112
constructor.name.clone(),
1110
1113
constructor.name_location,
1114
1114
+
ReferenceKind::Definition,
1111
1115
);
1112
1116
1113
1117
if value_constructor_publicity.is_private() {
+3
compiler-core/src/analyse/imports.rs
View file
Reviewed
···
3
3
use crate::{
4
4
ast::{SrcSpan, UnqualifiedImport, UntypedImport},
5
5
build::Origin,
6
6
+
reference::ReferenceKind,
6
7
type_::{
7
8
EntityKind, Environment, Error, ModuleInterface, Problems, UnusedModuleAlias,
8
9
ValueConstructorVariant,
···
175
176
module.clone(),
176
177
import_name.clone(),
177
178
import.imported_name_location,
179
179
+
ReferenceKind::Import,
178
180
);
179
181
}
180
182
ValueConstructorVariant::ModuleConstant { module, .. }
···
189
191
module.clone(),
190
192
import_name.clone(),
191
193
import.imported_name_location,
194
194
+
ReferenceKind::Import,
192
195
);
193
196
}
194
197
_ => self.environment.init_usage(
+1
-1
compiler-core/src/language_server/rename.rs
View file
Reviewed
···
131
131
132
132
references
133
133
.iter()
134
134
-
.for_each(|location| edits.replace(*location, new_name.clone()));
134
134
+
.for_each(|reference| edits.replace(reference.location, new_name.clone()));
135
135
136
136
let Some(uri) = url_from_path(source_information.path.as_str()) else {
137
137
return;
+20
-2
compiler-core/src/metadata/module_decoder.rs
View file
Reviewed
···
12
12
},
13
13
build::Origin,
14
14
line_numbers::LineNumbers,
15
15
+
reference::{Reference, ReferenceKind, ReferenceMap},
15
16
schema_capnp::{self as schema, *},
16
17
type_::{
17
18
self, AccessorsMap, Deprecation, FieldMap, ModuleInterface, Opaque, RecordAccessor,
···
127
128
fn value_references(
128
129
&self,
129
130
reader: capnp::struct_list::Reader<'_, value_reference::Owned>,
130
130
-
) -> Result<HashMap<(EcoString, EcoString), Vec<SrcSpan>>> {
131
131
+
) -> Result<ReferenceMap> {
131
132
let mut map = HashMap::with_capacity(reader.len() as usize);
132
133
for prop in reader.into_iter() {
133
134
let module = self.string(prop.get_module()?)?;
134
135
let name = self.string(prop.get_name()?)?;
135
135
-
let references = read_vec!(prop.get_references()?, self, src_span);
136
136
+
let references = read_vec!(prop.get_references()?, self, reference);
136
137
let _ = map.insert((module, name), references);
137
138
}
138
139
Ok(map)
140
140
+
}
141
141
+
142
142
+
fn reference(&self, reader: &reference::Reader<'_>) -> Result<Reference> {
143
143
+
Ok(Reference {
144
144
+
location: self.src_span(&reader.get_location()?)?,
145
145
+
kind: self.reference_kind(&reader.get_kind()?)?,
146
146
+
})
147
147
+
}
148
148
+
149
149
+
fn reference_kind(&self, reader: &reference_kind::Reader<'_>) -> Result<ReferenceKind> {
150
150
+
use reference_kind::Which;
151
151
+
Ok(match reader.which()? {
152
152
+
Which::Qualified(_) => ReferenceKind::Qualified,
153
153
+
Which::Unqualified(_) => ReferenceKind::Unqualified,
154
154
+
Which::Import(_) => ReferenceKind::Import,
155
155
+
Which::Definition(_) => ReferenceKind::Definition,
156
156
+
})
139
157
}
140
158
141
159
fn type_constructor(
+13
-1
compiler-core/src/metadata/module_encoder.rs
View file
Reviewed
···
5
5
Constant, Publicity, SrcSpan, TypedConstant, TypedConstantBitArraySegment,
6
6
TypedConstantBitArraySegmentOption,
7
7
},
8
8
+
reference::{Reference, ReferenceKind},
8
9
schema_capnp::{self as schema, *},
9
10
type_::{
10
11
self, AccessorsMap, Deprecation, FieldMap, Opaque, RecordAccessor, Type,
···
219
220
builder.reborrow().init_references(references.len() as u32);
220
221
for (i, reference) in references.iter().enumerate() {
221
222
let builder = references_builder.reborrow().get(i as u32);
222
222
-
self.build_src_span(builder, *reference);
223
223
+
self.build_reference(builder, reference);
223
224
}
224
225
}
226
226
+
}
227
227
+
228
228
+
fn build_reference(&mut self, mut builder: reference::Builder<'_>, reference: &Reference) {
229
229
+
let mut kind = builder.reborrow().init_kind();
230
230
+
match reference.kind {
231
231
+
ReferenceKind::Qualified => kind.set_qualified(()),
232
232
+
ReferenceKind::Unqualified => kind.set_unqualified(()),
233
233
+
ReferenceKind::Import => kind.set_import(()),
234
234
+
ReferenceKind::Definition => kind.set_definition(()),
235
235
+
}
236
236
+
self.build_src_span(builder.init_location(), reference.location);
225
237
}
226
238
227
239
fn set_version(&mut self, module: &mut module::Builder<'_>) {
+33
-5
compiler-core/src/metadata/tests.rs
View file
Reviewed
···
10
10
},
11
11
build::Origin,
12
12
line_numbers::LineNumbers,
13
13
+
reference::{Reference, ReferenceKind},
13
14
type_::{
14
15
self, Deprecation, ModuleInterface, Opaque, References, Type, TypeAliasConstructor,
15
16
TypeConstructor, TypeValueConstructor, TypeValueConstructorField, TypeVariantConstructors,
···
1858
1859
value_references: [
1859
1860
(
1860
1861
("some_module".into(), "some_function".into()),
1861
1861
-
vec![SrcSpan::new(1, 6), SrcSpan::new(7, 11)],
1862
1862
+
vec![
1863
1863
+
Reference {
1864
1864
+
location: SrcSpan::new(1, 6),
1865
1865
+
kind: ReferenceKind::Definition,
1866
1866
+
},
1867
1867
+
Reference {
1868
1868
+
location: SrcSpan::new(7, 11),
1869
1869
+
kind: ReferenceKind::Unqualified,
1870
1870
+
},
1871
1871
+
],
1862
1872
),
1863
1873
(
1864
1874
("some_other_module".into(), "some_constant".into()),
1865
1865
-
vec![SrcSpan::new(6, 9), SrcSpan::new(90, 108)],
1875
1875
+
vec![
1876
1876
+
Reference {
1877
1877
+
location: SrcSpan::new(6, 9),
1878
1878
+
kind: ReferenceKind::Import,
1879
1879
+
},
1880
1880
+
Reference {
1881
1881
+
location: SrcSpan::new(90, 108),
1882
1882
+
kind: ReferenceKind::Unqualified,
1883
1883
+
},
1884
1884
+
],
1866
1885
),
1867
1886
(
1868
1887
("some_other_module".into(), "SomeTypeVariant".into()),
1869
1888
vec![
1870
1870
-
SrcSpan::new(26, 35),
1871
1871
-
SrcSpan::new(152, 204),
1872
1872
-
SrcSpan::new(0, 8),
1889
1889
+
Reference {
1890
1890
+
location: SrcSpan::new(26, 35),
1891
1891
+
kind: ReferenceKind::Qualified,
1892
1892
+
},
1893
1893
+
Reference {
1894
1894
+
location: SrcSpan::new(152, 204),
1895
1895
+
kind: ReferenceKind::Qualified,
1896
1896
+
},
1897
1897
+
Reference {
1898
1898
+
location: SrcSpan::new(0, 8),
1899
1899
+
kind: ReferenceKind::Qualified,
1900
1900
+
},
1873
1901
],
1874
1902
),
1875
1903
]
+26
-4
compiler-core/src/reference.rs
View file
Reviewed
···
7
7
stable_graph::{NodeIndex, StableGraph},
8
8
};
9
9
10
10
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11
11
+
pub enum ReferenceKind {
12
12
+
Qualified,
13
13
+
Unqualified,
14
14
+
Import,
15
15
+
Definition,
16
16
+
}
17
17
+
18
18
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19
19
+
pub struct Reference {
20
20
+
pub location: SrcSpan,
21
21
+
pub kind: ReferenceKind,
22
22
+
}
23
23
+
24
24
+
pub type ReferenceMap = HashMap<(EcoString, EcoString), Vec<Reference>>;
25
25
+
10
26
#[derive(Debug, Default)]
11
27
pub struct ReferenceTracker {
12
28
/// A call-graph which tracks which values are referenced by which other value,
···
17
33
18
34
/// The locations of the references to each value in this module, used for
19
35
/// renaming and go-to reference.
20
20
-
reference_locations: HashMap<(EcoString, EcoString), Vec<SrcSpan>>,
36
36
+
reference_locations: ReferenceMap,
21
37
}
22
38
23
39
impl ReferenceTracker {
···
27
43
}
28
44
29
45
impl ReferenceTracker {
30
30
-
pub fn into_locations(self) -> HashMap<(EcoString, EcoString), Vec<SrcSpan>> {
46
46
+
pub fn into_locations(self) -> ReferenceMap {
31
47
self.reference_locations
32
48
}
33
49
···
47
63
self.current_function = self.get_or_create_node(module, name);
48
64
}
49
65
50
50
-
pub fn register_reference(&mut self, module: EcoString, name: EcoString, location: SrcSpan) {
66
66
+
pub fn register_reference(
67
67
+
&mut self,
68
68
+
module: EcoString,
69
69
+
name: EcoString,
70
70
+
location: SrcSpan,
71
71
+
kind: ReferenceKind,
72
72
+
) {
51
73
let target = self.get_or_create_node(module.clone(), name.clone());
52
74
self.reference_locations
53
75
.entry((module, name))
54
76
.or_default()
55
55
-
.push(location);
77
77
+
.push(Reference { location, kind });
56
78
57
79
_ = self.graph.add_edge(self.current_function, target, ());
58
80
}
+2
-1
compiler-core/src/type_.rs
View file
Reviewed
···
31
31
bit_array,
32
32
build::{Origin, Target},
33
33
line_numbers::LineNumbers,
34
34
+
reference::ReferenceMap,
34
35
type_::expression::Implementations,
35
36
};
36
37
use error::*;
···
903
904
#[derive(Debug, Clone, PartialEq, Eq, Default)]
904
905
pub struct References {
905
906
pub imported_modules: HashSet<EcoString>,
906
906
-
pub value_references: HashMap<(EcoString, EcoString), Vec<SrcSpan>>,
907
907
+
pub value_references: ReferenceMap,
907
908
}
908
909
909
910
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+16
-2
compiler-core/src/type_/expression.rs
View file
Reviewed
···
13
13
},
14
14
build::Target,
15
15
exhaustiveness::{self, Reachability},
16
16
+
reference::ReferenceKind,
16
17
};
17
18
use hexpm::version::Version;
18
19
use id_arena::Arena;
···
1078
1079
name,
1079
1080
&constructor.variant,
1080
1081
*location,
1082
1082
+
ReferenceKind::Unqualified,
1081
1083
)
1082
1084
}
1083
1085
}
···
1106
1108
module_name.clone(),
1107
1109
label.clone(),
1108
1110
SrcSpan::new(field_start, location.end),
1111
1111
+
ReferenceKind::Qualified,
1109
1112
);
1110
1113
TypedExpr::ModuleSelect {
1111
1114
location,
···
2335
2338
module_name.clone(),
2336
2339
label.clone(),
2337
2340
location,
2341
2341
+
ReferenceKind::Qualified,
2338
2342
);
2339
2343
2340
2344
Ok(ClauseGuard::ModuleSelect {
···
3009
3013
register_reference,
3010
3014
ReferenceRegistration::RegisterReferences
3011
3015
) {
3012
3012
-
self.register_value_constructor_reference(name, &variant, *location);
3016
3016
+
self.register_value_constructor_reference(
3017
3017
+
name,
3018
3018
+
&variant,
3019
3019
+
*location,
3020
3020
+
if module.is_some() {
3021
3021
+
ReferenceKind::Qualified
3022
3022
+
} else {
3023
3023
+
ReferenceKind::Unqualified
3024
3024
+
},
3025
3025
+
);
3013
3026
}
3014
3027
3015
3028
// Instantiate generic variables into unbound variables for this usage
···
3027
3040
referenced_name: &EcoString,
3028
3041
variant: &ValueConstructorVariant,
3029
3042
location: SrcSpan,
3043
3043
+
kind: ReferenceKind,
3030
3044
) {
3031
3045
match variant {
3032
3046
// If the referenced name is different to the name of the original
···
3046
3060
| ValueConstructorVariant::ModuleConstant { name, module, .. } => self
3047
3061
.environment
3048
3062
.references
3049
3049
-
.register_reference(module.clone(), name.clone(), location),
3063
3063
+
.register_reference(module.clone(), name.clone(), location, kind),
3050
3064
ValueConstructorVariant::LocalVariable { .. }
3051
3065
| ValueConstructorVariant::LocalConstant { .. } => {}
3052
3066
}
+6
compiler-core/src/type_/pattern.rs
View file
Reviewed
···
12
12
ast::{
13
13
AssignName, BitArrayOption, ImplicitCallArgOrigin, Layer, UntypedPatternBitArraySegment,
14
14
},
15
15
+
reference::ReferenceKind,
15
16
type_::expression::FunctionDefinition,
16
17
};
17
18
use std::sync::Arc;
···
821
822
constructor.module.clone(),
822
823
constructor.name.clone(),
823
824
name_location,
825
825
+
if module.is_some() {
826
826
+
ReferenceKind::Qualified
827
827
+
} else {
828
828
+
ReferenceKind::Unqualified
829
829
+
},
824
830
);
825
831
826
832
let instantiated_constructor_type =