substitutions

Jim Dehnert dehnert at baalbek.engr.sgi.com
Wed Apr 19 01:08:20 UTC 2000


> From alainm at cup.hp.com  Tue Apr 18 15:12:22 2000
> > >
> > > Now, let's say that S<n2>_ is longuer than S<n1>_2C3, what should
> > > we do ?
> > 
> > Ah, I think I see your problem.  The entity that we're considering for
> > substitution is 2C12C3, _not_ S<n1>_2C3.  Earlier substitutions don't
> > come into play.
> 
> But we don't have the string 2C12C3 in the encoding, if C1::C2 already
> appear before, we need to reuse (let say that C1 is a long enough name)
> the C1 preffix, so we only have S<nc1>2C2 appearing in the encoding.
> And probably some map indicating that C1::C3 is encoded with that
> string.

But you need to behave as though you did have the string 2C12C3.
That's what you're substituting for.  As the document says:

  ...the substitution occurs only if "S<seq-id>_" (or "S_")
  is strictly shorter than the unsubstituted encoding,

to which I just added for more clarity:

  i.e. the encoding obtained if no substitution of its parts were done.

> > > Clearly, we can't write NS<n1>_2C3 instead of S<n2>_ because
> > > n1 does not reffers to the same entity at that point.
> > 
> > Right.  Our choices at this point are (with the above numbering)
> > 2C12C3 (no substitution), S2_2C3 (substitute for C1), or S0_
> > (substitute for C1::C3).  We wouldn't choose the second because it's
> > not shorter, and would choose the third unless <n> were > 3 digits.
> 
> Maybe my problem will be more clear with the following example:
> 
> struct C1xxxx {
>     struct C2 {};
>     struct C3 {
>         struct C4 {};
>     };
> }
> 
> template <class T12, class T13, class Tune, class T134>
> struct Temp : virtual something{};
> 
> And we need to encode the name:
> 
> Temp<C1xxxx::C2,C1xxxx::C3,int,C1xxxx::C3::C4>
> 
> (to encode it's vptr for example)
> 
> We have:
> 
> 4Temp 
>   I
>     N 6C1xxxx 2C2 E 
>     N S1_ 2C3 ES
>     i
>     N S2_ 2C4 E // S2_ -> S1_ 2C3, let's call S2_ S<C13n>_ instead.
>   E
> 
> Now imagine, instead of "int", we have something very 
> big that generate a 5 digit (or more) C13n (sure, it's 
> a big number, it won't append very often) so that 
> strlen( "S<C13n>_2C4" ) > strlen ("S1_ 2C3")

But is strlen( "S<C13n>_2C4" ) > strlen ("6C1xxxx2C3")?
That's the question that matters.

> At that point, I don't see what to write instead of "S<C13n>_2C4".

Is "S<C13n>_" shorter than "6C1xxxx2C3"?  If so, use it.
Otherwise, is "S<C1n>" shorter than "6C1xxxx"?  If so, use S<C1n>2C3.
Otherwise, use "6C1xxxx".

Jim

-	    Jim Dehnert		dehnert at sgi.com
				(650)933-4272




More information about the cxx-abi-dev mailing list