@@ -556,6 +556,8 @@ where
556
556
// argument pack.
557
557
is_template_argument_pack : bool ,
558
558
559
+ is_explicit_obj_param : bool ,
560
+
559
561
// Whether to show function parameters.
560
562
// This must be set to true before calling `demangle` on `Encoding`
561
563
// unless that call is via the toplevel call to `MangledName::demangle`.
@@ -615,6 +617,7 @@ where
615
617
is_template_prefix : false ,
616
618
is_template_prefix_in_nested_name : false ,
617
619
is_template_argument_pack : false ,
620
+ is_explicit_obj_param : false ,
618
621
show_params : !options. no_params ,
619
622
show_return_type : !options. no_return_type ,
620
623
show_expression_literal_types : !options. hide_expression_literal_types ,
@@ -1037,6 +1040,12 @@ where
1037
1040
}
1038
1041
1039
1042
let mut need_comma = false ;
1043
+
1044
+ // Only the first param should have `this`.
1045
+ if ctx. is_explicit_obj_param {
1046
+ write ! ( ctx, "this " ) ?;
1047
+ }
1048
+
1040
1049
for arg in self . iter ( ) {
1041
1050
if need_comma {
1042
1051
write ! ( ctx, ", " ) ?;
@@ -1938,19 +1947,28 @@ impl<'a> GetLeafName<'a> for UnscopedTemplateName {
1938
1947
/// ```text
1939
1948
/// <nested-name> ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E
1940
1949
/// ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix> <template-args> E
1950
+ /// ::= N H <prefix> <unqualified-name> E
1951
+ /// ::= N H <template-prefix> <template-args> E
1952
+
1941
1953
/// ```
1942
1954
#[ derive( Clone , Debug , PartialEq , Eq ) ]
1943
1955
pub enum NestedName {
1944
1956
/// A nested name.
1945
1957
Unqualified (
1946
1958
CvQualifiers ,
1947
1959
Option < RefQualifier > ,
1960
+ Option < ExplicitObjectParameter > ,
1948
1961
PrefixHandle ,
1949
1962
UnqualifiedName ,
1950
1963
) ,
1951
1964
1952
1965
/// A nested template name. The `<template-args>` are part of the `PrefixHandle`.
1953
- Template ( CvQualifiers , Option < RefQualifier > , PrefixHandle ) ,
1966
+ Template (
1967
+ CvQualifiers ,
1968
+ Option < RefQualifier > ,
1969
+ Option < ExplicitObjectParameter > ,
1970
+ PrefixHandle ,
1971
+ ) ,
1954
1972
}
1955
1973
1956
1974
impl Parse for NestedName {
@@ -1963,19 +1981,28 @@ impl Parse for NestedName {
1963
1981
1964
1982
let tail = consume ( b"N" , input) ?;
1965
1983
1966
- let ( cv_qualifiers, tail) =
1967
- if let Ok ( ( q, tail) ) = try_recurse ! ( CvQualifiers :: parse( ctx, subs, tail) ) {
1968
- ( q, tail)
1969
- } else {
1970
- ( Default :: default ( ) , tail)
1971
- } ;
1984
+ let ( cv_qualifiers, ref_qualifier, explicit_obj_param, tail) = match tail. peek ( ) {
1985
+ Some ( b'H' ) => {
1986
+ let ( explicit_obj_param, tail) = ExplicitObjectParameter :: parse ( ctx, subs, tail) ?;
1987
+ ( Default :: default ( ) , None , Some ( explicit_obj_param) , tail)
1988
+ }
1989
+ _ => {
1990
+ let ( cv_qualifiers, tail) =
1991
+ if let Ok ( ( q, tail) ) = try_recurse ! ( CvQualifiers :: parse( ctx, subs, tail) ) {
1992
+ ( q, tail)
1993
+ } else {
1994
+ ( Default :: default ( ) , tail)
1995
+ } ;
1972
1996
1973
- let ( ref_qualifier, tail) =
1974
- if let Ok ( ( r, tail) ) = try_recurse ! ( RefQualifier :: parse( ctx, subs, tail) ) {
1975
- ( Some ( r) , tail)
1976
- } else {
1977
- ( None , tail)
1978
- } ;
1997
+ let ( ref_qualifier, tail) =
1998
+ if let Ok ( ( r, tail) ) = try_recurse ! ( RefQualifier :: parse( ctx, subs, tail) ) {
1999
+ ( Some ( r) , tail)
2000
+ } else {
2001
+ ( None , tail)
2002
+ } ;
2003
+ ( cv_qualifiers, ref_qualifier, None , tail)
2004
+ }
2005
+ } ;
1979
2006
1980
2007
let ( prefix, tail) = PrefixHandle :: parse ( ctx, subs, tail) ?;
1981
2008
let tail = consume ( b"E" , tail) ?;
@@ -1988,11 +2015,17 @@ impl Parse for NestedName {
1988
2015
1989
2016
match substitutable {
1990
2017
Some ( & Substitutable :: Prefix ( Prefix :: Nested ( ref prefix, ref name) ) ) => Ok ( (
1991
- NestedName :: Unqualified ( cv_qualifiers, ref_qualifier, prefix. clone ( ) , name. clone ( ) ) ,
2018
+ NestedName :: Unqualified (
2019
+ cv_qualifiers,
2020
+ ref_qualifier,
2021
+ explicit_obj_param,
2022
+ prefix. clone ( ) ,
2023
+ name. clone ( ) ,
2024
+ ) ,
1992
2025
tail,
1993
2026
) ) ,
1994
2027
Some ( & Substitutable :: Prefix ( Prefix :: Template ( ..) ) ) => Ok ( (
1995
- NestedName :: Template ( cv_qualifiers, ref_qualifier, prefix) ,
2028
+ NestedName :: Template ( cv_qualifiers, ref_qualifier, explicit_obj_param , prefix) ,
1996
2029
tail,
1997
2030
) ) ,
1998
2031
_ => Err ( error:: Error :: UnexpectedText ) ,
@@ -2017,12 +2050,20 @@ impl NestedName {
2017
2050
}
2018
2051
}
2019
2052
2053
+ /// Get the ref-qualifier for this name, if one exists.
2054
+ pub fn has_explicit_obj_param ( & self ) -> bool {
2055
+ match * self {
2056
+ NestedName :: Unqualified ( _, _, Some ( ref _r) , ..)
2057
+ | NestedName :: Template ( _, _, Some ( ref _r) , ..) => true ,
2058
+ _ => false ,
2059
+ }
2060
+ }
2020
2061
// Not public because the prefix means different things for different
2021
2062
// variants, and for `::Template` it actually contains part of what
2022
2063
// conceptually belongs to `<nested-name>`.
2023
2064
fn prefix ( & self ) -> & PrefixHandle {
2024
2065
match * self {
2025
- NestedName :: Unqualified ( _, _, ref p, _) | NestedName :: Template ( _, _, ref p) => p,
2066
+ NestedName :: Unqualified ( _, _, _ , ref p, _) | NestedName :: Template ( _ , _, _, ref p) => p,
2026
2067
}
2027
2068
}
2028
2069
}
@@ -2039,7 +2080,7 @@ where
2039
2080
let ctx = try_begin_demangle ! ( self , ctx, scope) ;
2040
2081
2041
2082
match * self {
2042
- NestedName :: Unqualified ( _, _, ref p, ref name) => {
2083
+ NestedName :: Unqualified ( _, _, _ , ref p, ref name) => {
2043
2084
ctx. push_demangle_node ( DemangleNodeType :: NestedName ) ;
2044
2085
p. demangle ( ctx, scope) ?;
2045
2086
if name. accepts_double_colon ( ) {
@@ -2048,13 +2089,17 @@ where
2048
2089
name. demangle ( ctx, scope) ?;
2049
2090
ctx. pop_demangle_node ( ) ;
2050
2091
}
2051
- NestedName :: Template ( _, _, ref p) => {
2092
+ NestedName :: Template ( _, _, _ , ref p) => {
2052
2093
ctx. is_template_prefix_in_nested_name = true ;
2053
2094
p. demangle ( ctx, scope) ?;
2054
2095
ctx. is_template_prefix_in_nested_name = false ;
2055
2096
}
2056
2097
}
2057
2098
2099
+ if self . has_explicit_obj_param ( ) {
2100
+ ctx. is_explicit_obj_param = true ;
2101
+ }
2102
+
2058
2103
if let Some ( inner) = ctx. pop_inner ( ) {
2059
2104
inner. demangle_as_inner ( ctx, scope) ?;
2060
2105
}
@@ -2075,7 +2120,7 @@ where
2075
2120
impl GetTemplateArgs for NestedName {
2076
2121
fn get_template_args < ' a > ( & ' a self , subs : & ' a SubstitutionTable ) -> Option < & ' a TemplateArgs > {
2077
2122
match * self {
2078
- NestedName :: Template ( _, _, ref prefix) => prefix. get_template_args ( subs) ,
2123
+ NestedName :: Template ( _, _, _ , ref prefix) => prefix. get_template_args ( subs) ,
2079
2124
_ => None ,
2080
2125
}
2081
2126
}
@@ -2084,10 +2129,10 @@ impl GetTemplateArgs for NestedName {
2084
2129
impl < ' a > GetLeafName < ' a > for NestedName {
2085
2130
fn get_leaf_name ( & ' a self , subs : & ' a SubstitutionTable ) -> Option < LeafName < ' a > > {
2086
2131
match * self {
2087
- NestedName :: Unqualified ( _, _, ref prefix, ref name) => name
2132
+ NestedName :: Unqualified ( _, _, _ , ref prefix, ref name) => name
2088
2133
. get_leaf_name ( subs)
2089
2134
. or_else ( || prefix. get_leaf_name ( subs) ) ,
2090
- NestedName :: Template ( _, _, ref prefix) => prefix. get_leaf_name ( subs) ,
2135
+ NestedName :: Template ( _, _, _ , ref prefix) => prefix. get_leaf_name ( subs) ,
2091
2136
}
2092
2137
}
2093
2138
}
@@ -4018,6 +4063,19 @@ define_vocabulary! {
4018
4063
}
4019
4064
}
4020
4065
4066
+ define_vocabulary ! {
4067
+ /// A <ref-qualifier> production.
4068
+ ///
4069
+ /// ```text
4070
+ /// <ref-qualifier> ::= R # & ref-qualifier
4071
+ /// ::= O # && ref-qualifier
4072
+ /// ```
4073
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
4074
+ pub enum ExplicitObjectParameter {
4075
+ ExplicitObjectParameter ( b"H" , "this" )
4076
+ }
4077
+ }
4078
+
4021
4079
define_vocabulary ! {
4022
4080
/// A one of the standard variants of the <builtin-type> production.
4023
4081
///
@@ -8538,6 +8596,7 @@ mod tests {
8538
8596
Ok => {
8539
8597
b"NS0_3abcE..." => {
8540
8598
Name :: Nested ( NestedName :: Unqualified ( CvQualifiers :: default ( ) ,
8599
+ None ,
8541
8600
None ,
8542
8601
PrefixHandle :: BackReference ( 1 ) ,
8543
8602
UnqualifiedName :: Source ( SourceName ( Identifier {
@@ -8660,6 +8719,7 @@ mod tests {
8660
8719
const_: true ,
8661
8720
} ,
8662
8721
Some ( RefQualifier :: RValueRef ) ,
8722
+ None ,
8663
8723
PrefixHandle :: BackReference ( 0 ) ,
8664
8724
UnqualifiedName :: Source (
8665
8725
SourceName ( Identifier {
@@ -8677,6 +8737,7 @@ mod tests {
8677
8737
const_: false ,
8678
8738
} ,
8679
8739
Some ( RefQualifier :: RValueRef ) ,
8740
+ None ,
8680
8741
PrefixHandle :: BackReference ( 0 ) ,
8681
8742
UnqualifiedName :: Source (
8682
8743
SourceName ( Identifier {
@@ -8694,6 +8755,7 @@ mod tests {
8694
8755
const_: false ,
8695
8756
} ,
8696
8757
None ,
8758
+ None ,
8697
8759
PrefixHandle :: BackReference ( 0 ) ,
8698
8760
UnqualifiedName :: Source (
8699
8761
SourceName ( Identifier {
@@ -8711,6 +8773,7 @@ mod tests {
8711
8773
const_: true ,
8712
8774
} ,
8713
8775
Some ( RefQualifier :: RValueRef ) ,
8776
+ None ,
8714
8777
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8715
8778
b"..." ,
8716
8779
[
@@ -8732,6 +8795,7 @@ mod tests {
8732
8795
const_: false ,
8733
8796
} ,
8734
8797
Some ( RefQualifier :: RValueRef ) ,
8798
+ None ,
8735
8799
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8736
8800
b"..." ,
8737
8801
[
@@ -8753,6 +8817,7 @@ mod tests {
8753
8817
const_: false ,
8754
8818
} ,
8755
8819
None ,
8820
+ None ,
8756
8821
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8757
8822
b"..." ,
8758
8823
[
0 commit comments