|
@@ -3,6 +3,8 @@
|
|
|
|
|
|
#include "Parser.h"
|
|
|
|
|
|
+#include <unordered_map>
|
|
|
+
|
|
|
namespace zp
|
|
|
{
|
|
|
// forward declarations
|
|
@@ -16,8 +18,14 @@ namespace zp
|
|
|
class AstVisitor;
|
|
|
|
|
|
struct BlockInstruction;
|
|
|
+ struct SimpleBlockInstruction;
|
|
|
+ struct LinearLoopInstruction;
|
|
|
+ struct LoopInstruction;
|
|
|
|
|
|
class Optimizer;
|
|
|
+
|
|
|
+ using Index = int;
|
|
|
+ using Cell = unsigned char;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -37,7 +45,29 @@ public:
|
|
|
|
|
|
struct zp::BlockInstruction
|
|
|
{
|
|
|
+ virtual ~BlockInstruction(void) = default;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+struct zp::SimpleBlockInstruction :
|
|
|
+ public BlockInstruction
|
|
|
+{
|
|
|
+ Index pointerMove;
|
|
|
+ std::unordered_map<Index, Cell> added;
|
|
|
+};
|
|
|
|
|
|
+
|
|
|
+struct zp::LinearLoopInstruction :
|
|
|
+ public BlockInstruction
|
|
|
+{
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+struct zp::LoopInstruction :
|
|
|
+ public BlockInstruction
|
|
|
+{
|
|
|
+ std::vector<std::unique_ptr<BlockInstruction>> content;
|
|
|
};
|
|
|
|
|
|
|