Line data Source code
1 : #include "../../../inc/visitors/monomorphize/monomorphize.h"
2 : #include "../../../inc/parsingAnalysis/ast/tree.h"
3 : #include <variant>
4 :
5 : /**
6 :
7 : FillSemanticInfo ---> insertar delcaraciones en las tablas / insertar tipos /
8 : comprobar que las variables pertenecen al scope (llamadas a variables) /
9 : comrpobar llamadas a enum
10 :
11 : TypeAnalysis ---> comprobar en una llamada a funcion que esta existe debido a
12 : sobrecarga de funciones requiere que se trate en el typeAnalysis / igual con
13 : metodos / llamadas a atributos / variables auto
14 :
15 : */
16 :
17 : namespace nicole {
18 :
19 : std::expected<std::monostate, Error>
20 0 : Monomorphize::visit(const AST_STATEMENT *node) const noexcept {
21 0 : if (!node) {
22 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_STATEMENT");
23 0 : }
24 0 : return node->expression()->accept(*this);
25 0 : }
26 :
27 : std::expected<std::monostate, Error>
28 0 : Monomorphize::visit(const AST_BODY *node) const noexcept {
29 0 : if (!node) {
30 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_BODY");
31 0 : }
32 0 : for (const auto &statement : node->body()) {
33 0 : const auto val{statement->accept(*this)};
34 0 : if (!val) {
35 0 : return createError(val.error());
36 0 : }
37 0 : }
38 0 : return {};
39 0 : }
40 :
41 : std::expected<std::monostate, Error>
42 0 : Monomorphize::visit(const Tree *tree) const noexcept {
43 0 : if (!tree) {
44 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid Tree");
45 0 : }
46 0 : return tree->root()->accept(*this);
47 0 : }
48 :
49 : } // namespace nicole
|