@@ -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,23 @@ 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 ( CvQualifiers , Option < RefQualifier > , Option < ExplicitObjectParameter > , PrefixHandle ) ,
1954
1967
}
1955
1968
1956
1969
impl Parse for NestedName {
@@ -1963,19 +1976,28 @@ impl Parse for NestedName {
1963
1976
1964
1977
let tail = consume ( b"N" , input) ?;
1965
1978
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
- } ;
1979
+ let ( cv_qualifiers, ref_qualifier, explicit_obj_param, tail) = match tail. peek ( ) {
1980
+ Some ( b'H' ) => {
1981
+ let ( explicit_obj_param, tail) = ExplicitObjectParameter :: parse ( ctx, subs, tail) ?;
1982
+ ( Default :: default ( ) , None , Some ( explicit_obj_param) , tail)
1983
+ }
1984
+ _ => {
1985
+ let ( cv_qualifiers, tail) =
1986
+ if let Ok ( ( q, tail) ) = try_recurse ! ( CvQualifiers :: parse( ctx, subs, tail) ) {
1987
+ ( q, tail)
1988
+ } else {
1989
+ ( Default :: default ( ) , tail)
1990
+ } ;
1972
1991
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
- } ;
1992
+ let ( ref_qualifier, tail) =
1993
+ if let Ok ( ( r, tail) ) = try_recurse ! ( RefQualifier :: parse( ctx, subs, tail) ) {
1994
+ ( Some ( r) , tail)
1995
+ } else {
1996
+ ( None , tail)
1997
+ } ;
1998
+ ( cv_qualifiers, ref_qualifier, None , tail)
1999
+ }
2000
+ } ;
1979
2001
1980
2002
let ( prefix, tail) = PrefixHandle :: parse ( ctx, subs, tail) ?;
1981
2003
let tail = consume ( b"E" , tail) ?;
@@ -1988,11 +2010,11 @@ impl Parse for NestedName {
1988
2010
1989
2011
match substitutable {
1990
2012
Some ( & Substitutable :: Prefix ( Prefix :: Nested ( ref prefix, ref name) ) ) => Ok ( (
1991
- NestedName :: Unqualified ( cv_qualifiers, ref_qualifier, prefix. clone ( ) , name. clone ( ) ) ,
2013
+ NestedName :: Unqualified ( cv_qualifiers, ref_qualifier, explicit_obj_param , prefix. clone ( ) , name. clone ( ) ) ,
1992
2014
tail,
1993
2015
) ) ,
1994
2016
Some ( & Substitutable :: Prefix ( Prefix :: Template ( ..) ) ) => Ok ( (
1995
- NestedName :: Template ( cv_qualifiers, ref_qualifier, prefix) ,
2017
+ NestedName :: Template ( cv_qualifiers, ref_qualifier, explicit_obj_param , prefix) ,
1996
2018
tail,
1997
2019
) ) ,
1998
2020
_ => Err ( error:: Error :: UnexpectedText ) ,
@@ -2017,12 +2039,20 @@ impl NestedName {
2017
2039
}
2018
2040
}
2019
2041
2042
+ /// Get the ref-qualifier for this name, if one exists.
2043
+ pub fn has_explicit_obj_param ( & self ) -> bool {
2044
+ match * self {
2045
+ NestedName :: Unqualified ( _, _, Some ( ref _r) , ..)
2046
+ | NestedName :: Template ( _, _, Some ( ref _r) , ..) => true ,
2047
+ _ => false ,
2048
+ }
2049
+ }
2020
2050
// Not public because the prefix means different things for different
2021
2051
// variants, and for `::Template` it actually contains part of what
2022
2052
// conceptually belongs to `<nested-name>`.
2023
2053
fn prefix ( & self ) -> & PrefixHandle {
2024
2054
match * self {
2025
- NestedName :: Unqualified ( _, _, ref p, _) | NestedName :: Template ( _, _, ref p) => p,
2055
+ NestedName :: Unqualified ( _, _, _ , ref p, _) | NestedName :: Template ( _ , _, _, ref p) => p,
2026
2056
}
2027
2057
}
2028
2058
}
@@ -2039,7 +2069,7 @@ where
2039
2069
let ctx = try_begin_demangle ! ( self , ctx, scope) ;
2040
2070
2041
2071
match * self {
2042
- NestedName :: Unqualified ( _, _, ref p, ref name) => {
2072
+ NestedName :: Unqualified ( _, _, _ , ref p, ref name) => {
2043
2073
ctx. push_demangle_node ( DemangleNodeType :: NestedName ) ;
2044
2074
p. demangle ( ctx, scope) ?;
2045
2075
if name. accepts_double_colon ( ) {
@@ -2048,13 +2078,17 @@ where
2048
2078
name. demangle ( ctx, scope) ?;
2049
2079
ctx. pop_demangle_node ( ) ;
2050
2080
}
2051
- NestedName :: Template ( _, _, ref p) => {
2081
+ NestedName :: Template ( _, _, _ , ref p) => {
2052
2082
ctx. is_template_prefix_in_nested_name = true ;
2053
2083
p. demangle ( ctx, scope) ?;
2054
2084
ctx. is_template_prefix_in_nested_name = false ;
2055
2085
}
2056
2086
}
2057
2087
2088
+ if self . has_explicit_obj_param ( ) {
2089
+ ctx. is_explicit_obj_param = true ;
2090
+ }
2091
+
2058
2092
if let Some ( inner) = ctx. pop_inner ( ) {
2059
2093
inner. demangle_as_inner ( ctx, scope) ?;
2060
2094
}
@@ -2075,7 +2109,7 @@ where
2075
2109
impl GetTemplateArgs for NestedName {
2076
2110
fn get_template_args < ' a > ( & ' a self , subs : & ' a SubstitutionTable ) -> Option < & ' a TemplateArgs > {
2077
2111
match * self {
2078
- NestedName :: Template ( _, _, ref prefix) => prefix. get_template_args ( subs) ,
2112
+ NestedName :: Template ( _, _, _ , ref prefix) => prefix. get_template_args ( subs) ,
2079
2113
_ => None ,
2080
2114
}
2081
2115
}
@@ -2084,10 +2118,10 @@ impl GetTemplateArgs for NestedName {
2084
2118
impl < ' a > GetLeafName < ' a > for NestedName {
2085
2119
fn get_leaf_name ( & ' a self , subs : & ' a SubstitutionTable ) -> Option < LeafName < ' a > > {
2086
2120
match * self {
2087
- NestedName :: Unqualified ( _, _, ref prefix, ref name) => name
2121
+ NestedName :: Unqualified ( _, _, _ , ref prefix, ref name) => name
2088
2122
. get_leaf_name ( subs)
2089
2123
. or_else ( || prefix. get_leaf_name ( subs) ) ,
2090
- NestedName :: Template ( _, _, ref prefix) => prefix. get_leaf_name ( subs) ,
2124
+ NestedName :: Template ( _, _, _ , ref prefix) => prefix. get_leaf_name ( subs) ,
2091
2125
}
2092
2126
}
2093
2127
}
@@ -4018,6 +4052,19 @@ define_vocabulary! {
4018
4052
}
4019
4053
}
4020
4054
4055
+ define_vocabulary ! {
4056
+ /// A <ref-qualifier> production.
4057
+ ///
4058
+ /// ```text
4059
+ /// <ref-qualifier> ::= R # & ref-qualifier
4060
+ /// ::= O # && ref-qualifier
4061
+ /// ```
4062
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
4063
+ pub enum ExplicitObjectParameter {
4064
+ ExplicitObjectParameter ( b"H" , "this" )
4065
+ }
4066
+ }
4067
+
4021
4068
define_vocabulary ! {
4022
4069
/// A one of the standard variants of the <builtin-type> production.
4023
4070
///
@@ -8538,6 +8585,7 @@ mod tests {
8538
8585
Ok => {
8539
8586
b"NS0_3abcE..." => {
8540
8587
Name :: Nested ( NestedName :: Unqualified ( CvQualifiers :: default ( ) ,
8588
+ None ,
8541
8589
None ,
8542
8590
PrefixHandle :: BackReference ( 1 ) ,
8543
8591
UnqualifiedName :: Source ( SourceName ( Identifier {
@@ -8660,6 +8708,7 @@ mod tests {
8660
8708
const_: true ,
8661
8709
} ,
8662
8710
Some ( RefQualifier :: RValueRef ) ,
8711
+ None ,
8663
8712
PrefixHandle :: BackReference ( 0 ) ,
8664
8713
UnqualifiedName :: Source (
8665
8714
SourceName ( Identifier {
@@ -8677,6 +8726,7 @@ mod tests {
8677
8726
const_: false ,
8678
8727
} ,
8679
8728
Some ( RefQualifier :: RValueRef ) ,
8729
+ None ,
8680
8730
PrefixHandle :: BackReference ( 0 ) ,
8681
8731
UnqualifiedName :: Source (
8682
8732
SourceName ( Identifier {
@@ -8694,6 +8744,7 @@ mod tests {
8694
8744
const_: false ,
8695
8745
} ,
8696
8746
None ,
8747
+ None ,
8697
8748
PrefixHandle :: BackReference ( 0 ) ,
8698
8749
UnqualifiedName :: Source (
8699
8750
SourceName ( Identifier {
@@ -8711,6 +8762,7 @@ mod tests {
8711
8762
const_: true ,
8712
8763
} ,
8713
8764
Some ( RefQualifier :: RValueRef ) ,
8765
+ None ,
8714
8766
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8715
8767
b"..." ,
8716
8768
[
@@ -8732,6 +8784,7 @@ mod tests {
8732
8784
const_: false ,
8733
8785
} ,
8734
8786
Some ( RefQualifier :: RValueRef ) ,
8787
+ None ,
8735
8788
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8736
8789
b"..." ,
8737
8790
[
@@ -8753,6 +8806,7 @@ mod tests {
8753
8806
const_: false ,
8754
8807
} ,
8755
8808
None ,
8809
+ None ,
8756
8810
PrefixHandle :: NonSubstitution ( NonSubstitution ( 0 ) ) ) ,
8757
8811
b"..." ,
8758
8812
[
0 commit comments