diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-10-09 11:57:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-10-09 11:57:58 (GMT) |
commit | 0b6e87de0d4313f8ef31907bc48ce4d7f7749738 (patch) | |
tree | f268e98efa733379b275d8834864f13cff6fa9ac /src/format/mangling | |
parent | 3628caa2311ee89ad0d2a0aa2438d7e85b497da4 (diff) |
Loaded all Dex pool items using several threads.
Diffstat (limited to 'src/format/mangling')
-rw-r--r-- | src/format/mangling/dex/type_gram.y | 32 | ||||
-rw-r--r-- | src/format/mangling/dex/type_tok.l | 32 |
2 files changed, 40 insertions, 24 deletions
diff --git a/src/format/mangling/dex/type_gram.y b/src/format/mangling/dex/type_gram.y index d5c3f26..506eb9b 100644 --- a/src/format/mangling/dex/type_gram.y +++ b/src/format/mangling/dex/type_gram.y @@ -7,10 +7,10 @@ #include "context.h" #include "../context-int.h" - +typedef void *yyscan_t; /* Affiche un message d'erreur concernant l'analyse. */ -static int type_error(GDexDemangler *, char *); +static int type_error(GDexDemangler *, yyscan_t, char *); /* Procède au décodage d'une chaîne de caractères. */ bool demangle_dex_type(GDexDemangler *, const char *); @@ -36,7 +36,11 @@ bool demangle_dex_type(GDexDemangler *, const char *); } -%parse-param { GDexDemangler *demangler } + +%define api.pure full +%parse-param { GDexDemangler *demangler } { yyscan_t scanner } +%lex-param { yyscan_t scanner } + %token V Z B S C I J F D %token ARRAY @@ -55,9 +59,11 @@ bool demangle_dex_type(GDexDemangler *, const char *); typedef struct yy_buffer_state *YY_BUFFER_STATE; -extern YY_BUFFER_STATE type__scan_string(const char *); -extern void type__delete_buffer(YY_BUFFER_STATE); -extern int type_lex(void); +extern int type_lex_init(yyscan_t *scanner); +extern YY_BUFFER_STATE type__scan_string(const char *, yyscan_t); +extern void type__delete_buffer(YY_BUFFER_STATE, yyscan_t); +extern int type_lex(YYSTYPE *, yyscan_t); +extern int type_lex_destroy(yyscan_t); %} @@ -104,6 +110,7 @@ simple_name: /****************************************************************************** * * * Paramètres : demangler = contexte associé à la procédure de décodage. * +* scanner = données internes aux analyseurs. * * msg = indications humaines sur l'événement. * * * * Description : Affiche un message d'erreur concernant l'analyse. * @@ -113,7 +120,7 @@ simple_name: * Remarques : - * * * ******************************************************************************/ -static int type_error(GDexDemangler *demangler, char *msg) +static int type_error(GDexDemangler *demangler, yyscan_t scanner, char *msg) { return -1; @@ -135,12 +142,17 @@ static int type_error(GDexDemangler *demangler, char *msg) bool demangle_dex_type(GDexDemangler *demangler, const char *desc) { + yyscan_t scanner; /* Données internes */ YY_BUFFER_STATE buffer; /* Tampon pour bison */ int ret; /* Bilan de l'appel */ - buffer = type__scan_string(desc); - ret = yyparse(demangler); - type__delete_buffer(buffer); + type_lex_init(&scanner); + + buffer = type__scan_string(desc, scanner); + ret = yyparse(demangler, scanner); + type__delete_buffer(buffer, scanner); + + type_lex_destroy(scanner); return (ret == 0); diff --git a/src/format/mangling/dex/type_tok.l b/src/format/mangling/dex/type_tok.l index 9c24085..918846a 100644 --- a/src/format/mangling/dex/type_tok.l +++ b/src/format/mangling/dex/type_tok.l @@ -4,13 +4,17 @@ #include "context.h" #include "libformatmanglingdextype_la-type_gram.h" +/* See lemoda.net/c/reentrant-parser */ + %} %option noyywrap %option yylineno %option nounput - /*%option noinput*/ +/*%option noinput*/ +%option reentrant +%option bison-bridge %x string @@ -29,11 +33,11 @@ SIMPLE {ASCII}|"$"|"-"|"_" "F" { return F; } "D" { return D; } "L" { BEGIN(string); return L; } -"["* { type_lval.adeep = strlen(yytext); return ARRAY; } +"["* { yylval->adeep = strlen(yytext); return ARRAY; } <string>"/" { return SLASH; } <string>";" { BEGIN(INITIAL); return SEMICOLON; } -<string>{SIMPLE}* { type_lval.text = yytext; return TEXT; } +<string>{SIMPLE}* { yylval->text = yytext; return TEXT; } <string>. { unsigned char next; @@ -44,7 +48,7 @@ SIMPLE {ASCII}|"$"|"-"|"_" /* U+00a1 ... U+1fff */ case 0x00 ... 0x1f: - next = input(); + next = input(yyscanner); if (yytext[0] == 0x00 && next < 0xa1) { @@ -57,7 +61,7 @@ SIMPLE {ASCII}|"$"|"-"|"_" mutf8[1] = next; mutf8[2] = '\0'; - strcpy(type_lval.text, mutf8); return TEXT; + strcpy(yylval->text, mutf8); return TEXT; } @@ -66,7 +70,7 @@ SIMPLE {ASCII}|"$"|"-"|"_" /* U+2010 ... U+2027 / U+2030 ... U+d7ff */ case 0x20: - next = input(); + next = input(yyscanner); switch (next) { @@ -77,7 +81,7 @@ SIMPLE {ASCII}|"$"|"-"|"_" mutf8[1] = next; mutf8[2] = '\0'; - strcpy(type_lval.text, mutf8); return TEXT; + strcpy(yylval->text, mutf8); return TEXT; break; default: @@ -91,19 +95,19 @@ SIMPLE {ASCII}|"$"|"-"|"_" /* ~ U+2030 ... U+d7ff */ case 0x21 ... 0xd7: - next = input(); + next = input(yyscanner); mutf8[0] = yytext[0]; mutf8[1] = next; mutf8[2] = '\0'; - strcpy(type_lval.text, mutf8); return TEXT; + strcpy(yylval->text, mutf8); return TEXT; break; /* U+e000 ... U+ffef */ case 0xe0 ... 0xff: - next = input(); + next = input(yyscanner); if (yytext[0] == 0xff && next > 0xef) { @@ -116,7 +120,7 @@ SIMPLE {ASCII}|"$"|"-"|"_" mutf8[1] = next; mutf8[2] = '\0'; - strcpy(type_lval.text, mutf8); return TEXT; + strcpy(yylval->text, mutf8); return TEXT; } @@ -127,11 +131,11 @@ SIMPLE {ASCII}|"$"|"-"|"_" case 0x10: mutf8[0] = yytext[0]; - mutf8[1] = input(); - mutf8[2] = input(); + mutf8[1] = input(yyscanner); + mutf8[2] = input(yyscanner); mutf8[3] = '\0'; - strcpy(type_lval.text, mutf8); return TEXT; + strcpy(yylval->text, mutf8); return TEXT; break; */ |