diff --git a/Nodes.hpp b/Nodes.hpp index 1260d37..601f75a 100644 --- a/Nodes.hpp +++ b/Nodes.hpp @@ -16,6 +16,10 @@ enum class Type { }; +template +using Pointer = std::unique_ptr; + + class Emittable { public: virtual void emit(std::ostream &stream, int indent = 0) = 0; @@ -95,7 +99,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr value; + Pointer value; }; @@ -135,7 +139,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr expression; + Pointer expression; }; @@ -145,8 +149,8 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr body; - std::unique_ptr condition; + Pointer body; + Pointer condition; }; @@ -157,9 +161,9 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr name; + Pointer name; bool point; - std::unique_ptr init; + Pointer init; Type type; }; @@ -170,8 +174,8 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr name; - std::unique_ptr value; + Pointer name; + Pointer value; }; @@ -181,7 +185,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr expression; + Pointer expression; }; @@ -191,7 +195,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr variable; + Pointer variable; }; @@ -207,7 +211,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr expression; + Pointer expression; }; @@ -217,8 +221,8 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr name; - std::unique_ptr args; + Pointer name; + Pointer args; }; @@ -229,8 +233,8 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr condition; - std::unique_ptr body; + Pointer condition; + Pointer body; }; @@ -244,9 +248,9 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr var; - std::unique_ptr cases; - std::unique_ptr els; + Pointer var; + Pointer cases; + Pointer els; }; @@ -256,7 +260,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr body; + Pointer body; }; @@ -269,9 +273,9 @@ public: virtual void emit(std::ostream &stream, int indent = 0); private: - std::unique_ptr name; - std::unique_ptr args; - std::unique_ptr body; + Pointer name; + Pointer args; + Pointer body; }; class Program: public Emittable { @@ -279,7 +283,7 @@ public: virtual void emit(std::ostream &stream, int indent = 0); void setMain(Main *m) { - main = std::unique_ptr
(m); + main = Pointer
(m); } void addFunction(Function *f) { @@ -287,7 +291,7 @@ public: } private: - std::unique_ptr
main; + Pointer
main; PointerList functions; }; @@ -301,8 +305,8 @@ protected: virtual std::string getSym() = 0; private: - std::unique_ptr left; - std::unique_ptr right; + Pointer left; + Pointer right; }; @@ -425,7 +429,7 @@ protected: virtual std::string getSym() = 0; private: - std::unique_ptr left; + Pointer left; };