Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
implement demangler for back references
Browse files Browse the repository at this point in the history
  • Loading branch information
rainers committed Jul 23, 2016
1 parent 980a9f6 commit 7502203
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions src/core/demangle.d
Expand Up @@ -470,7 +470,7 @@ private struct Demangle
/*
LName:
Number Name
Number %
Name:
Namestart
Namestart Namechars
Expand All @@ -493,19 +493,37 @@ private struct Demangle
debug(trace) scope(success) printf( "parseLName-\n" );

auto n = decodeNumber();

if( !n || n > buf.length || n > buf.length - pos )
error( "LName must be at least 1 character" );
if( '_' != front && !isAlpha( front ) )
error( "Invalid character in LName" );
foreach(char e; buf[pos + 1 .. pos + n] )
{
if( '_' != e && !isAlpha( e ) && !isDigit( e ) )
error( "Invalid character in LName" );
}

put( buf[pos .. pos + n] );
pos += n;
if( pos < buf.length && buf[pos] == '%' )
{
// back reference to LName
if( n >= pos )
error( "invalid LName back reference" );
size_t p = n;
n = 0;
while( isDigit( buf[p] ) )
{
n = n * 10 + buf[p] - '0';
p++;
}
if( n > pos - p )
error( "invalid LName length" );
put( buf[p .. p + n] );
pos++;
}
else
{
if( !n || n > buf.length || n > buf.length - pos )
error( "LName must be at least 1 character" );
if( '_' != front && !isAlpha( front ) )
error( "Invalid character in LName" );
foreach(char e; buf[pos + 1 .. pos + n] )
{
if( '_' != e && !isAlpha( e ) && !isDigit( e ) )
error( "Invalid character in LName" );
}
put( buf[pos .. pos + n] );
pos += n;
}
}


Expand Down Expand Up @@ -715,6 +733,14 @@ private struct Demangle

switch( t )
{
case '$':
popFront();
auto n = decodeNumber();
auto savePos = pos;
pos = n;
auto ret = parseType();
pos = savePos;
return ret;
case 'O': // Shared (O Type)
popFront();
put( "shared(" );
Expand Down

0 comments on commit 7502203

Please sign in to comment.