From 4d359b9c16b01847b26d6827e137f680c65969f2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 7 Feb 2023 20:06:31 +0200 Subject: [IPL/T] Overhauled how functions are handled, added list type --- .../src/Value/Function/BuiltInFunction.cpp | 14 -------------- .../Transpiler/src/Value/Function/BuiltInFunction.h | 13 ------------- .../Transpiler/src/Value/Function/Funcall.cpp | 16 ++++++++++++++++ .../Transpiler/src/Value/Function/Funcall.h | 11 +++++------ .../Transpiler/src/Value/Function/Function.cpp | 12 ------------ .../Transpiler/src/Value/Function/Function.h | 21 --------------------- .../Transpiler/src/Value/Function/UserFunction.cpp | 14 -------------- .../Transpiler/src/Value/Function/UserFunction.h | 16 ---------------- 8 files changed, 21 insertions(+), 96 deletions(-) delete mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp delete mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h delete mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp delete mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h delete mode 100644 Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.cpp delete 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 deleted file mode 100644 index 954c8da..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "BuiltInFunction.h" -#include "../../LLVMVisitor/LLVMVisitor.h" - -std::string BuiltInFunction::Visit(LLVMVisitor& visitor) const { - return visitor.Visit(*this); -} - -Value::T_Primitive BuiltInFunction::RetType() const { - if (args.empty()) - return T_void; - return args.front()->RetType(); -} - -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 deleted file mode 100644 index c4ea301..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef VALUE_ADDFUNCTION -#define VALUE_ADDFUNCTION - -#include "Function.h" - -class BuiltInFunction : public Function { -public: - std::string Visit(LLVMVisitor& visitor) const override; - T_Primitive RetType() const override; - BuiltInFunction(std::string name, std::deque args); -}; - -#endif diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.cpp index e69de29..df88001 100644 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.cpp +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.cpp @@ -0,0 +1,16 @@ +#include "Funcall.h" +#include "../../LLVMVisitor/LLVMVisitor.h" + +const std::string& Funcall::get_funname() const { + return funName; +} + +const std::vector& Funcall::get_args() const { + return args; +} + +LLVMRet Funcall::Visit(LLVMVisitor& visitor) const { + return visitor.Visit(*this); +} + +Funcall::Funcall(std::string funName, std::vector args) : funName(funName), args(args) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.h index 5afc51d..30dda60 100644 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.h +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.h @@ -1,20 +1,19 @@ #ifndef VALUE_FUNCALL #define VALUE_FUNCALL -#include +#include #include "../Value.h" class Funcall : public Value { std::string funName; - std::deque args; + std::vector args; public: const std::string& get_funname() const; - const std::deque& get_args() const; + const std::vector& get_args() const; - std::string Visit(LLVMVisitor& visitor) const override; - T_Primitive RetType() const override; + LLVMRet Visit(LLVMVisitor& visitor) const override; - Funcall(std::string funName, std::deque args); + Funcall(std::string funName, std::vector args); ~Funcall() override = default; }; 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 deleted file mode 100644 index 9e35eab..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#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 deleted file mode 100644 index 34e3ea1..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef VALUE_FUNCTION -#define VALUE_FUNCTION - -#include -#include -#include "../Value.h" - -class Function : public Value { -protected: - 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.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.cpp deleted file mode 100644 index a9841d3..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "UserFunction.h" -#include "../../LLVMVisitor/LLVMVisitor.h" - -std::string UserFunction::Visit(LLVMVisitor& visitor) const { - return visitor.Visit(*this); -} - -Value::T_Primitive UserFunction::RetType() const { - if (body.empty()) - return T_void; - return body.back()->RetType(); -} - -UserFunction::UserFunction(std::string name, std::deque args, std::deque body) : Function(name, args), body(body) {} 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 deleted file mode 100644 index 17cf931..0000000 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef VALUE_USERFUNCTION -#define VALUE_USERFUNCTION - -#include -#include "Function.h" - -class UserFunction : public Function { - std::deque body; - -public: - std::string Visit(LLVMVisitor& visitor) const override; - T_Primitive RetType() const override; - UserFunction(std::string name, std::deque args, std::deque body); -}; - -#endif -- cgit v1.3.1-26-gb76a