Skip to content

Commit ae6f7b4

Browse files
committed
GP-4303 Collapse STARTSYM, ENDSYM, NEXT2SYM, etc. into single token type
1 parent d1dc485 commit ae6f7b4

File tree

12 files changed

+2360
-3095
lines changed

12 files changed

+2360
-3095
lines changed

Ghidra/Features/Decompiler/src/decompile/cpp/pcodeparse.cc

+888-1,033
Large diffs are not rendered by default.

Ghidra/Features/Decompiler/src/decompile/cpp/pcodeparse.y

+8-19
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ extern int pcodeerror(const char *str );
3838
SpaceSymbol *spacesym;
3939
UserOpSymbol *useropsym;
4040
LabelSymbol *labelsym;
41-
StartSymbol *startsym;
42-
EndSymbol *endsym;
43-
Next2Symbol *next2sym;
4441
OperandSymbol *operandsym;
4542
VarnodeSymbol *varsym;
4643
SpecificSymbol *specsym;
@@ -77,9 +74,7 @@ extern int pcodeerror(const char *str );
7774
%token <useropsym> USEROPSYM
7875
%token <varsym> VARSYM
7976
%token <operandsym> OPERANDSYM
80-
%token <startsym> STARTSYM
81-
%token <endsym> ENDSYM
82-
%token <next2sym> NEXT2SYM
77+
%token <specsym> JUMPSYM
8378
%token <labelsym> LABELSYM
8479

8580
%type <param> paramlist
@@ -197,9 +192,7 @@ sizedstar: '*' '[' SPACESYM ']' ':' INTEGER { $$ = new StarQuality; $$->size = *
197192
| '*' ':' INTEGER { $$ = new StarQuality; $$->size = *$3; delete $3; $$->id=ConstTpl(pcode->getDefaultSpace()); }
198193
| '*' { $$ = new StarQuality; $$->size = 0; $$->id=ConstTpl(pcode->getDefaultSpace()); }
199194
;
200-
jumpdest: STARTSYM { VarnodeTpl *sym = $1->getVarnode(); $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),sym->getOffset(),ConstTpl(ConstTpl::j_curspace_size)); delete sym; }
201-
| ENDSYM { VarnodeTpl *sym = $1->getVarnode(); $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),sym->getOffset(),ConstTpl(ConstTpl::j_curspace_size)); delete sym; }
202-
| NEXT2SYM { VarnodeTpl *sym = $1->getVarnode(); $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),sym->getOffset(),ConstTpl(ConstTpl::j_curspace_size)); delete sym; }
195+
jumpdest: JUMPSYM { VarnodeTpl *sym = $1->getVarnode(); $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),sym->getOffset(),ConstTpl(ConstTpl::j_curspace_size)); delete sym; }
203196
| INTEGER { $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),ConstTpl(ConstTpl::real,*$1),ConstTpl(ConstTpl::j_curspace_size)); delete $1; }
204197
| BADINTEGER { $$ = new VarnodeTpl(ConstTpl(ConstTpl::j_curspace),ConstTpl(ConstTpl::real,0),ConstTpl(ConstTpl::j_curspace_size)); yyerror("Parsed integer is too big (overflow)"); }
205198
| INTEGER '[' SPACESYM ']' { AddrSpace *spc = $3->getSpace(); $$ = new VarnodeTpl(ConstTpl(spc),ConstTpl(ConstTpl::real,*$1),ConstTpl(ConstTpl::real,spc->getAddrSize())); delete $1; }
@@ -224,9 +217,7 @@ label: '<' LABELSYM '>' { $$ = $2; }
224217
;
225218
specificsymbol: VARSYM { $$ = $1; }
226219
| OPERANDSYM { $$ = $1; }
227-
| STARTSYM { $$ = $1; }
228-
| ENDSYM { $$ = $1; }
229-
| NEXT2SYM { $$ = $1; }
220+
| JUMPSYM { $$ = $1; }
230221
;
231222
paramlist: /* EMPTY */ { $$ = new vector<ExprTree *>; }
232223
| expr { $$ = new vector<ExprTree *>; $$->push_back($1); }
@@ -750,14 +741,12 @@ int4 PcodeSnippet::lex(void)
750741
yylval.operandsym = (OperandSymbol *)sym;
751742
return OPERANDSYM;
752743
case SleighSymbol::start_symbol:
753-
yylval.startsym = (StartSymbol *)sym;
754-
return STARTSYM;
755744
case SleighSymbol::end_symbol:
756-
yylval.endsym = (EndSymbol *)sym;
757-
return ENDSYM;
758-
case SleighSymbol::next2_symbol:
759-
yylval.next2sym = (Next2Symbol *)sym;
760-
return NEXT2SYM;
745+
case SleighSymbol::next2_symbol:
746+
case SleighSymbol::flowdest_symbol:
747+
case SleighSymbol::flowref_symbol:
748+
yylval.specsym = (SpecificSymbol *)sym;
749+
return JUMPSYM;
761750
case SleighSymbol::label_symbol:
762751
yylval.labelsym = (LabelSymbol *)sym;
763752
return LABELSYM;

0 commit comments

Comments
 (0)