diff options
[IPL/T] Implemented initial structure with Integer data type
3 files changed, 42 insertions, 0 deletions
diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.cpp new file mode 100644 index 0000000..d7f70e3 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.cpp @@ -0,0 +1,12 @@ +#include "Integer.h" +#include "../LLVMVisitor/LLVMVisitor.h" + +std::string Integer::Visit(LLVMVisitor& visitor) const { + return visitor.Visit(*this); +} + +const int& Integer::get_value() const { + return this->value; +} + +Integer::Integer(int value) : value(value) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.h new file mode 100644 index 0000000..3859d1d --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Integer.h @@ -0,0 +1,16 @@ +#ifndef VALUE_INTEGER +#define VALUE_INTEGER + +#include "Value.h" + +class Integer : public Value { + int value; +public: + std::string Visit(LLVMVisitor& visitor) const override; + const int& get_value() const; + + Integer(int value); + ~Integer() override = default; +}; + +#endif diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Value.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Value.h new file mode 100644 index 0000000..8488262 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Value.h @@ -0,0 +1,14 @@ +#ifndef VALUE +#define VALUE + +#include <string> + +class LLVMVisitor; + +class Value { +public: + virtual std::string Visit(LLVMVisitor& visitor) const = 0; + virtual ~Value() {}; +}; + +#endif |
