Line data Source code
1 : #include "../../../inc/visitors/monomorphize/monomorphize.h"
2 : #include "../../../inc/parsingAnalysis/ast/functions/ast_funcCall.h"
3 : #include "../../../inc/parsingAnalysis/ast/functions/ast_funcDecl.h"
4 : #include "../../../inc/parsingAnalysis/ast/functions/ast_return.h"
5 : #include <variant>
6 :
7 : namespace nicole {
8 :
9 : std::expected<std::monostate, Error>
10 0 : Monomorphize::visit(const AST_FUNC_CALL *node) const noexcept {
11 0 : if (!node) {
12 0 : return createError(ERROR_TYPE::NULL_NODE, "Invalid AST_FUNC_CALL");
13 0 : }
14 0 : for (const auto &chain : node->parameters()) {
15 0 : const auto result{chain->accept(*this)};
16 0 : if (!result) {
17 0 : return createError(result.error());
18 0 : }
19 0 : }
20 0 : return {};
21 0 : }
22 :
23 : std::expected<std::monostate, Error>
24 0 : Monomorphize::visit(const AST_FUNC_DECL *node) const noexcept {
25 0 : if (!node) {
26 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_FUNC_DECL");
27 0 : }
28 0 : const auto result{node->body()->accept(*this)};
29 0 : if (!result) {
30 0 : return createError(result.error());
31 0 : }
32 0 : return {};
33 0 : }
34 :
35 : std::expected<std::monostate, Error>
36 0 : Monomorphize::visit(const AST_RETURN *node) const noexcept {
37 0 : if (!node) {
38 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_RETURN");
39 0 : }
40 0 : if (!node->expression()) {
41 0 : return {};
42 0 : }
43 0 : const auto result{node->expression()->accept(*this)};
44 0 : if (!result) {
45 0 : return createError(result.error());
46 0 : }
47 0 : return {};
48 0 : }
49 :
50 : }
|