Commit 779ba03b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Store _unDName function parameter backreferences in parsed_symbol structure.

parent 852c4d0a
...@@ -1324,6 +1324,12 @@ static void test_demangle(void) ...@@ -1324,6 +1324,12 @@ static void test_demangle(void)
"void __cdecl <CrtImplementationDetails>::RegisterModuleUninitializer(class System::EventHandler ^)"}, "void __cdecl <CrtImplementationDetails>::RegisterModuleUninitializer(class System::EventHandler ^)"},
/* 151 */ {"?RegisterModuleUninitializer@<CrtImplementationDetails>@@YAXBE$AAVEventHandler@System@@@Z", /* 151 */ {"?RegisterModuleUninitializer@<CrtImplementationDetails>@@YAXBE$AAVEventHandler@System@@@Z",
"void __cdecl <CrtImplementationDetails>::RegisterModuleUninitializer(class System::EventHandler % __ptr64 volatile)"}, "void __cdecl <CrtImplementationDetails>::RegisterModuleUninitializer(class System::EventHandler % __ptr64 volatile)"},
/* 152 */ {"??$forward@AEAUFFIValue@?1??call@FFIFunctionBinder@@CAHPEAUlua_State@@@Z@@std@@YAAEAUFFIValue@?1??call@"
"FFIFunctionBinder@@CAHPEAUxlua_State@@@Z@AEAU1?1??23@CAH0@Z@@Z",
"struct `private: static int __cdecl FFIFunctionBinder::call(struct xlua_State * __ptr64)'::`2'::FFIValue & "
"__ptr64 __cdecl std::forward<struct `private: static int __cdecl FFIFunctionBinder::call(struct lua_State "
"* __ptr64)'::`2'::FFIValue & __ptr64>(struct `private: static int __cdecl FFIFunctionBinder::call(struct "
"xlua_State * __ptr64)'::`2'::FFIValue & __ptr64)"},
}; };
int i, num_test = ARRAY_SIZE(test); int i, num_test = ARRAY_SIZE(test);
char* name; char* name;
......
...@@ -70,6 +70,7 @@ struct parsed_symbol ...@@ -70,6 +70,7 @@ struct parsed_symbol
char* result; /* demangled string */ char* result; /* demangled string */
struct array names; /* array of names for back reference */ struct array names; /* array of names for back reference */
struct array args; /* array of arguments for back reference */
struct array stack; /* stack of parsed strings */ struct array stack; /* stack of parsed strings */
void* alloc_list; /* linked list of allocated blocks */ void* alloc_list; /* linked list of allocated blocks */
...@@ -362,12 +363,15 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t ...@@ -362,12 +363,15 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t
char* args_str = NULL; char* args_str = NULL;
char* last; char* last;
unsigned int i; unsigned int i;
const char *p;
str_array_init(&arg_collect); str_array_init(&arg_collect);
/* Now come the function arguments */ /* Now come the function arguments */
while (*sym->current) while (*sym->current)
{ {
p = sym->current;
/* Decode each data type and append it to the argument list */ /* Decode each data type and append it to the argument list */
if (*sym->current == '@') if (*sym->current == '@')
{ {
...@@ -382,14 +386,20 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t ...@@ -382,14 +386,20 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t
&arg_collect)) &arg_collect))
return NULL; return NULL;
if (!strcmp(ct.left, "...")) break; if (!strcmp(ct.left, "...")) break;
if (z_term && sym->current - p > 1 && sym->args.num < 20)
{
if (!str_array_push(sym, ct.left ? ct.left : "", -1, &sym->args) ||
!str_array_push(sym, ct.right ? ct.right : "", -1, &sym->args))
return NULL;
}
} }
/* Functions are always terminated by 'Z'. If we made it this far and /* Functions are always terminated by 'Z'. If we made it this far and
* don't find it, we have incorrectly identified a data type. * don't find it, we have incorrectly identified a data type.
*/ */
if (z_term && *sym->current++ != 'Z') return NULL; if (z_term && *sym->current++ != 'Z') return NULL;
if (arg_collect.num == 0 || if (arg_collect.num == 0 ||
(arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void"))) (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void")))
return str_printf(sym, "%cvoid%c", open_char, close_char); return str_printf(sym, "%cvoid%c", open_char, close_char);
for (i = 1; i < arg_collect.num; i++) for (i = 1; i < arg_collect.num; i++)
{ {
...@@ -398,12 +408,12 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t ...@@ -398,12 +408,12 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t
last = args_str ? args_str : arg_collect.elts[0]; last = args_str ? args_str : arg_collect.elts[0];
if (close_char == '>' && last[strlen(last) - 1] == '>') if (close_char == '>' && last[strlen(last) - 1] == '>')
args_str = str_printf(sym, "%c%s%s %c", args_str = str_printf(sym, "%c%s%s %c",
open_char, arg_collect.elts[0], args_str, close_char); open_char, arg_collect.elts[0], args_str, close_char);
else else
args_str = str_printf(sym, "%c%s%s%c", args_str = str_printf(sym, "%c%s%s%c",
open_char, arg_collect.elts[0], args_str, close_char); open_char, arg_collect.elts[0], args_str, close_char);
return args_str; return args_str;
} }
...@@ -642,6 +652,7 @@ static char* get_template_name(struct parsed_symbol* sym) ...@@ -642,6 +652,7 @@ static char* get_template_name(struct parsed_symbol* sym)
unsigned num_mark = sym->names.num; unsigned num_mark = sym->names.num;
unsigned start_mark = sym->names.start; unsigned start_mark = sym->names.start;
unsigned stack_mark = sym->stack.num; unsigned stack_mark = sym->stack.num;
unsigned args_mark = sym->args.num;
struct array array_pmt; struct array array_pmt;
sym->names.start = sym->names.num; sym->names.start = sym->names.num;
...@@ -656,6 +667,7 @@ static char* get_template_name(struct parsed_symbol* sym) ...@@ -656,6 +667,7 @@ static char* get_template_name(struct parsed_symbol* sym)
sym->names.num = num_mark; sym->names.num = num_mark;
sym->names.start = start_mark; sym->names.start = start_mark;
sym->stack.num = stack_mark; sym->stack.num = stack_mark;
sym->args.num = args_mark;
return name; return name;
} }
...@@ -1043,9 +1055,8 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, ...@@ -1043,9 +1055,8 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
/* Referring back to previously parsed type */ /* Referring back to previously parsed type */
/* left and right are pushed as two separate strings */ /* left and right are pushed as two separate strings */
if (!pmt_ref) goto done; ct->left = str_array_get_ref(&sym->args, (dt - '0') * 2);
ct->left = str_array_get_ref(pmt_ref, (dt - '0') * 2); ct->right = str_array_get_ref(&sym->args, (dt - '0') * 2 + 1);
ct->right = str_array_get_ref(pmt_ref, (dt - '0') * 2 + 1);
if (!ct->left) goto done; if (!ct->left) goto done;
add_pmt = FALSE; add_pmt = FALSE;
break; break;
...@@ -1636,12 +1647,14 @@ static BOOL symbol_demangle(struct parsed_symbol* sym) ...@@ -1636,12 +1647,14 @@ static BOOL symbol_demangle(struct parsed_symbol* sym)
sym->current++; sym->current++;
if (in_template) if (in_template)
{ {
unsigned args_mark = sym->args.num;
const char *args; const char *args;
struct array array_pmt; struct array array_pmt;
str_array_init(&array_pmt); str_array_init(&array_pmt);
args = get_args(sym, &array_pmt, FALSE, '<', '>'); args = get_args(sym, &array_pmt, FALSE, '<', '>');
if (args) function_name = function_name ? str_printf(sym, "%s%s", function_name, args) : args; if (args) function_name = function_name ? str_printf(sym, "%s%s", function_name, args) : args;
sym->args.num = args_mark;
sym->names.num = 0; sym->names.num = 0;
} }
if (!str_array_push(sym, function_name, -1, &sym->stack)) if (!str_array_push(sym, function_name, -1, &sym->stack))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment