From 06006fc601ab5f7bffa095b7279a61070e38ba54 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 19 Jan 2023 11:27:31 +0200 Subject: [IPL/T] Implemented Float type and added basic function structure as well as added addition function for two arguments --- .../Transpiler/src/Value/Casting.h | 0 .../Transpiler/src/Value/Float.cpp | 12 ++++++++++++ .../Transpiler/src/Value/Float.h | 16 ++++++++++++++++ .../src/Value/Function/BuiltInFunction.cpp | 8 ++++++++ .../Transpiler/src/Value/Function/BuiltInFunction.h | 12 ++++++++++++ .../Transpiler/src/Value/Function/Function.cpp | 12 ++++++++++++ .../Transpiler/src/Value/Function/Function.h | 20 ++++++++++++++++++++ .../Transpiler/src/Value/Function/UserFunction.h | 0 8 files changed, 80 insertions(+) create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Casting.h create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.cpp create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.h create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h create mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.h (limited to 'Year 2/Implementation of Programming Languages/Transpiler/src/Value') diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Casting.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Casting.h new file mode 100644 index 0000000..e69de29 diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.cpp new file mode 100644 index 0000000..a286fa2 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.cpp @@ -0,0 +1,12 @@ +#include "Float.h" +#include "../LLVMVisitor/LLVMVisitor.h" + +std::string Float::Visit(LLVMVisitor& visitor) const { + return visitor.Visit(*this); +} + +const double& Float::get_value() const { + return this->value; +} + +Float::Float(double value) : value(value) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.h new file mode 100644 index 0000000..22cd721 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Float.h @@ -0,0 +1,16 @@ +#ifndef VALUE_FLOAT +#define VALUE_FLOAT + +#include "Value.h" + +class Float : public Value { + double value; +public: + std::string Visit(LLVMVisitor& visitor) const override; + const double& get_value() const; + + Float(double value); + ~Float() override = default; +}; + +#endif diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp new file mode 100644 index 0000000..6d38aad --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp @@ -0,0 +1,8 @@ +#include "BuiltInFunction.h" +#include "../../LLVMVisitor/LLVMVisitor.h" + +std::string BuiltInFunction::Visit(LLVMVisitor& visitor) const { + return visitor.Visit(*this); +} + +BuiltInFunction::BuiltInFunction(std::string name, std::deque args) : Function(name, args) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h new file mode 100644 index 0000000..26fba3f --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h @@ -0,0 +1,12 @@ +#ifndef VALUE_ADDFUNCTION +#define VALUE_ADDFUNCTION + +#include "Function.h" + +class BuiltInFunction : public Function { +public: + std::string Visit(LLVMVisitor& visitor) const override; + BuiltInFunction(std::string name, std::deque args); +}; + +#endif diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp new file mode 100644 index 0000000..9e35eab --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp @@ -0,0 +1,12 @@ +#include "Function.h" +#include "../../LLVMVisitor/LLVMVisitor.h" + +const std::string& Function::get_name() const { + return name; +} + +const std::deque Function::get_args() const { + return args; +} + +Function::Function(std::string name, std::deque args) : name(name), args(args) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h new file mode 100644 index 0000000..549d15e --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h @@ -0,0 +1,20 @@ +#ifndef VALUE_FUNCTION +#define VALUE_FUNCTION + +#include +#include +#include "../Value.h" + +class Function : public Value { + std::string name; + std::deque args; + +public: + const std::string& get_name() const; + const std::deque get_args() const; + + Function(std::string name, std::deque args); + ~Function() override = default; +}; + +#endif diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.h new file mode 100644 index 0000000..e69de29 -- cgit v1.3.1-26-gb76a