local names

Jim Dehnert dehnert at baalbek.engr.sgi.com
Fri Sep 1 20:52:06 UTC 2000


OK, now I think I understand the issue at least.  But I interpret what
we have differently.  Consider the examples that have come up:

    void foo () {
      class C {
        class D {};
      };
    }

To mangle D here, I would use:

  <encoding> ::- <name>
	     ::- <local-name>
	     ::- Z <function encoding> E <entity name>
where:
  <function encoding> ::- <name> <bare-function-type>
		      ::- 3foo i
  <entity name> ::- <nested-name>
		...
		::- N <component> <component> E
		::- N 1C 1D E
so the final result is:  Z 3foo i E N 1C 1D E

The key difference from the original "problem" is, I think, that I do
not think that the base function name should be considered part of the
entity name.  Even if the latter is a compound name within the function,
the entity name doesn't have foo as a compound component.


The next example is analogous:

    class C {
      void foo (int) {
        class D {};
      }
    };

To mangle D here, <encoding> starts off the same, but
  <function encoding> ::- <name> <bare-function-type>
		      ::- <nested-name> <bare-function-type>
		      ...
		      ::- N <component> <component> E <bare-function-type>
		      ::- N 1C 3foo E i
  <entity name> ::- <name>
		::- 1D
so the final result is:  Z N 1C 3foo E i E 1D


Finally, Mark's original example, which has two <local-name> levels:

  void foo () {
    struct C {
      void bar () {
	struct D {
	  void baz() { }
	}
      }
    }
  }

To mangle baz here, I would use:

  <encoding> ::- <name>
	     ::- <local-name>
	     ::- Z <function encoding> E <entity name>
where:
  <function encoding> ::- <name> <bare-function-type>	 (bar)
		      ::- <local-name> v
		      ::- Z <function encoding> E <entity name> v
		      ::- Z <name> <bare-function-type> E <nested-name> v
		      ...
		      ::- Z 3foo v E N 1C 3bar E v
  <entity name> ::- <function name>
		::- <function name> <bare-function-type>
		::- <nested-name> <bare-function-type>
		...
		::- N <component> <component> E <bare-function-type>
		::- N 1D 3baz E v
yielding the final result:
	Z Z 3foo v E N 1C 3bar E v E N 1D 3baz E v


I think this works, using the current definitions and just
understanding that the <entity name> in a <local-name> is always
relative to the immediately enclosing function.  And there's no
duplication here.  Although it might be slightly more efficient trying
to integrate the function names into the <nested-name> component list,
I'd be worried about conflicts with non-local names, and I'd rather not
deal with the complications just to save some (presumably rare) nested
Z-E pairs.

Am I confused?  Or confusing?

Jim

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




More information about the cxx-abi-dev mailing list