Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Transpiler / src / Value / Function
diff options
context:
space:
mode:
Commitab1d1ecba4f2562a8b81d887d08370d5fcf0921d (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-01-29 20:58:52 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-01-29 20:58:52 +0200
Files636468df6e0f973fa3066db6492251c8027890d6 /Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function
uni-projects-ab1d1ecba4f2562a8b81d887d08370d5fcf0921d.tar
uni-projects-ab1d1ecba4f2562a8b81d887d08370d5fcf0921d.tar.gz
uni-projects-ab1d1ecba4f2562a8b81d887d08370d5fcf0921d.zip
Parentd8eb50a7960edd35c74885d0ba7897f35c1b1eed (diff)
[IPL/T] Added current progress of implementing functions
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
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.cpp
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
new file mode 100644
index 0000000..5afc51d
--- /dev/null
+++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Funcall.h
@@ -0,0 +1,21 @@
+#ifndef VALUE_FUNCALL
+#define VALUE_FUNCALL
+
+#include <deque>
+#include "../Value.h"
+
+class Funcall : public Value {
+ std::string funName;
+ std::deque<Value*> args;
+public:
+ const std::string& get_funname() const;
+ const std::deque<Value*>& get_args() const;
+
+ std::string Visit(LLVMVisitor& visitor) const override;
+ T_Primitive RetType() const override;
+
+ Funcall(std::string funName, std::deque<Value*> args);
+ ~Funcall() 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
new file mode 100644
index 0000000..a9841d3
--- /dev/null
+++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/UserFunction.cpp
@@ -0,0 +1,14 @@
+#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
index e69de29..17cf931 100644
--- 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
@@ -0,0 +1,16 @@
+#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