Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Transpiler / src / Value / Function
diff options
context:
space:
mode:
Commit4d359b9c16b01847b26d6827e137f680c65969f2 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-02-07 20:06:31 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-02-07 20:06:31 +0200
Files2af4cf7c92237f1a55550cd8866e8bcb0b51b87c /Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function
uni-projects-4d359b9c16b01847b26d6827e137f680c65969f2.tar
uni-projects-4d359b9c16b01847b26d6827e137f680c65969f2.tar.gz
uni-projects-4d359b9c16b01847b26d6827e137f680c65969f2.zip
Parent38c4a1355cb573d47c3e26f83ca8e916b62c80d1 (diff)
[IPL/T] Overhauled how functions are handled, added list type
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<Value*> 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<Value*> 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<Value*>& Funcall::get_args() const {
+ return args;
+}
+
+LLVMRet Funcall::Visit(LLVMVisitor& visitor) const {
+ return visitor.Visit(*this);
+}
+
+Funcall::Funcall(std::string funName, std::vector<Value*> 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 <deque>
+#include <vector>
#include "../Value.h"
class Funcall : public Value {
std::string funName;
- std::deque<Value*> args;
+ std::vector<Value*> args;
public:
const std::string& get_funname() const;
- const std::deque<Value*>& get_args() const;
+ const std::vector<Value*>& 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<Value*> args);
+ Funcall(std::string funName, std::vector<Value*> 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<Value*> Function::get_args() const {
- return args;
-}
-
-Function::Function(std::string name, std::deque<Value*> 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 <string>
-#include <deque>
-#include "../Value.h"
-
-class Function : public Value {
-protected:
- std::string name;
- std::deque<Value*> args;
-
-public:
- const std::string& get_name() const;
- const std::deque<Value*> get_args() const;
-
- Function(std::string name, std::deque<Value*> 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<Value*> args, std::deque<Function*> 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 <deque>
-#include "Function.h"
-
-class UserFunction : public Function {
- std::deque<Function*> body;
-
-public:
- std::string Visit(LLVMVisitor& visitor) const override;
- T_Primitive RetType() const override;
- UserFunction(std::string name, std::deque<Value*> args, std::deque<Function*> body);
-};
-
-#endif