@@ -312,7 +312,9 @@ class Comparator {
312
312
Self *self () { return reinterpret_cast <Self *>(this ); }
313
313
314
314
public:
315
- bool compareByCase (const SExpr *E1 , const SExpr* E2 ) {
315
+ bool compare (const SExpr *E1 , const SExpr *E2 ) {
316
+ if (E1 ->opcode () != E2 ->opcode ())
317
+ return false ;
316
318
switch (E1 ->opcode ()) {
317
319
#define TIL_OPCODE_DEF (X ) \
318
320
case COP_##X: \
@@ -338,12 +340,6 @@ class EqualsComparator : public Comparator<EqualsComparator> {
338
340
bool compareStrings (StringRef s, StringRef r) { return s == r; }
339
341
bool comparePointers (const void * P, const void * Q) { return P == Q; }
340
342
341
- bool compare (const SExpr *E1 , const SExpr* E2 ) {
342
- if (E1 ->opcode () != E2 ->opcode ())
343
- return false ;
344
- return compareByCase (E1 , E2 );
345
- }
346
-
347
343
// TODO -- handle alpha-renaming of variables
348
344
void enterScope (const Variable *V1, const Variable *V2) {}
349
345
void leaveScope () {}
@@ -377,9 +373,7 @@ class MatchComparator : public Comparator<MatchComparator> {
377
373
if (E1 ->opcode () == COP_Wildcard || E2 ->opcode () == COP_Wildcard)
378
374
return true ;
379
375
// otherwise normal equality.
380
- if (E1 ->opcode () != E2 ->opcode ())
381
- return false ;
382
- return compareByCase (E1 , E2 );
376
+ return Comparator::compare (E1 , E2 );
383
377
}
384
378
385
379
// TODO -- handle alpha-renaming of variables
0 commit comments