fixed refactoring bugs
This commit is contained in:
75
include/idioms/arith_idioms.h
Normal file
75
include/idioms/arith_idioms.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
|
||||
struct Idiom5 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
public:
|
||||
virtual ~Idiom5() {}
|
||||
Idiom5(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom6 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
public:
|
||||
virtual ~Idiom6() {}
|
||||
Idiom6(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom18 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[4];
|
||||
bool m_is_dec;
|
||||
public:
|
||||
Idiom18(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 4;}
|
||||
bool match(iICODE picode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom19 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
bool m_is_dec;
|
||||
public:
|
||||
Idiom19(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE picode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom20 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[4];
|
||||
bool m_is_dec;
|
||||
public:
|
||||
Idiom20(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 4;}
|
||||
bool match(iICODE picode);
|
||||
int action();
|
||||
};
|
||||
42
include/idioms/call_idioms.h
Normal file
42
include/idioms/call_idioms.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
struct CallIdiom : public Idiom
|
||||
{
|
||||
protected:
|
||||
int m_param_count;
|
||||
public:
|
||||
virtual ~CallIdiom() {}
|
||||
CallIdiom(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
struct Idiom3 : public CallIdiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
public:
|
||||
virtual ~Idiom3() {}
|
||||
Idiom3(Function *f) : CallIdiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
struct Idiom17 : public CallIdiom
|
||||
{
|
||||
protected:
|
||||
std::vector<iICODE> m_icodes;
|
||||
public:
|
||||
virtual ~Idiom17() {}
|
||||
Idiom17(Function *f) : CallIdiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
39
include/idioms/epilogue_idioms.h
Normal file
39
include/idioms/epilogue_idioms.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
struct EpilogIdiom : public Idiom
|
||||
{
|
||||
protected:
|
||||
std::deque<iICODE> m_icodes; // deque to push_front optional icodes from popStkVars
|
||||
void popStkVars (iICODE pIcode);
|
||||
public:
|
||||
virtual ~EpilogIdiom() {}
|
||||
EpilogIdiom(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
struct Idiom2 : public EpilogIdiom
|
||||
{
|
||||
virtual ~Idiom2() {}
|
||||
Idiom2(Function *f) : EpilogIdiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 3;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
struct Idiom4 : public EpilogIdiom
|
||||
{
|
||||
protected:
|
||||
int m_param_count;
|
||||
public:
|
||||
virtual ~Idiom4() {}
|
||||
Idiom4(Function *f) : EpilogIdiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 1;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
22
include/idioms/idiom.h
Normal file
22
include/idioms/idiom.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "icode.h"
|
||||
#include "Procedure.h"
|
||||
struct Idiom
|
||||
{
|
||||
protected:
|
||||
Function *m_func;
|
||||
iICODE m_end;
|
||||
public:
|
||||
Idiom(Function *f) : m_func(f),m_end(f->Icode.end())
|
||||
{
|
||||
}
|
||||
virtual uint8_t minimum_match_length()=0;
|
||||
virtual bool match(iICODE at)=0;
|
||||
virtual int action()=0;
|
||||
int operator ()(iICODE at)
|
||||
{
|
||||
if(match(at))
|
||||
return action();
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
17
include/idioms/idiom1.h
Normal file
17
include/idioms/idiom1.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "idiom.h"
|
||||
struct Idiom1 : public Idiom
|
||||
{
|
||||
protected:
|
||||
std::vector<iICODE> m_icodes;
|
||||
int m_min_off;
|
||||
Int checkStkVars (iICODE pIcode);
|
||||
public:
|
||||
Idiom1(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 1;}
|
||||
bool match(iICODE picode);
|
||||
int action();
|
||||
size_t match_length() {return m_icodes.size();}
|
||||
};
|
||||
36
include/idioms/mov_idioms.h
Normal file
36
include/idioms/mov_idioms.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
|
||||
struct Idiom14 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
byte m_regL;
|
||||
byte m_regH;
|
||||
public:
|
||||
virtual ~Idiom14() {}
|
||||
Idiom14(Function *f) : Idiom(f),m_regL(0),m_regH(0)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom13 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
byte m_loaded_reg;
|
||||
public:
|
||||
virtual ~Idiom13() {}
|
||||
Idiom13(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
33
include/idioms/neg_idioms.h
Normal file
33
include/idioms/neg_idioms.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
|
||||
struct Idiom11 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[3];
|
||||
public:
|
||||
virtual ~Idiom11() {}
|
||||
Idiom11(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 3;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom16 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[3];
|
||||
public:
|
||||
virtual ~Idiom16() {}
|
||||
Idiom16(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 3;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
66
include/idioms/shift_idioms.h
Normal file
66
include/idioms/shift_idioms.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
|
||||
struct Idiom8 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
byte m_loaded_reg;
|
||||
public:
|
||||
virtual ~Idiom8() {}
|
||||
Idiom8(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom15 : public Idiom
|
||||
{
|
||||
protected:
|
||||
std::vector<iICODE> m_icodes;
|
||||
public:
|
||||
virtual ~Idiom15() {}
|
||||
Idiom15(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom12 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
byte m_loaded_reg;
|
||||
public:
|
||||
virtual ~Idiom12() {}
|
||||
Idiom12(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
|
||||
struct Idiom9 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
byte m_loaded_reg;
|
||||
public:
|
||||
virtual ~Idiom9() {}
|
||||
Idiom9(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
46
include/idioms/xor_idioms.h
Normal file
46
include/idioms/xor_idioms.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "idiom.h"
|
||||
#include "icode.h"
|
||||
#include <deque>
|
||||
|
||||
struct Idiom21 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
public:
|
||||
virtual ~Idiom21() {}
|
||||
Idiom21(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
|
||||
struct Idiom7 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icode;
|
||||
public:
|
||||
virtual ~Idiom7() {}
|
||||
Idiom7(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 1;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
struct Idiom10 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
public:
|
||||
virtual ~Idiom10() {}
|
||||
Idiom10(Function *f) : Idiom(f)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 1;}
|
||||
bool match(iICODE pIcode);
|
||||
int action();
|
||||
};
|
||||
Reference in New Issue
Block a user