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 --- .../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 5 files changed, 52 insertions(+) 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/Function') 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