Line data Source code
1 : #ifndef AST_BODY_H
2 : #define AST_BODY_H
3 :
4 : #include "../../../tables/scope/scope.h"
5 : #include "ast_statement.h"
6 : #include <memory>
7 : #include <vector>
8 :
9 : namespace nicole {
10 :
11 : class AST_BODY : public AST {
12 : private:
13 : std::vector<std::shared_ptr<AST_STATEMENT>> body_;
14 : mutable std::shared_ptr<Scope> scope_;
15 :
16 : public:
17 : explicit AST_BODY(
18 : const long long unsigned nodeId, const SourceLocation &srcLoc,
19 : const std::vector<std::shared_ptr<AST_STATEMENT>> &body) noexcept
20 18 : : AST(nodeId, AST_TYPE::BODY, srcLoc), body_{body} {}
21 :
22 : [[nodiscard]] const std::vector<std::shared_ptr<AST_STATEMENT>> &
23 180 : body() const noexcept {
24 180 : return body_;
25 180 : }
26 :
27 0 : [[nodiscard]] const std::shared_ptr<Scope> &scope() const noexcept {
28 0 : return scope_;
29 0 : }
30 :
31 0 : void setScope(const std::shared_ptr<Scope> &scope) const noexcept {
32 0 : scope_ = scope;
33 0 : }
34 :
35 : [[nodiscard]] std::expected<std::string, Error>
36 0 : accept(const PrintTree &visitor) const noexcept override {
37 0 : return visitor.visit(this);
38 0 : }
39 :
40 : [[nodiscard]] std::expected<bool, Error>
41 0 : accept(const ValidateTree &visitor) const noexcept override {
42 0 : return visitor.visit(this);
43 0 : }
44 :
45 : [[nodiscard]] std::expected<std::monostate, Error>
46 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
47 0 : return visitor.visit(this);
48 0 : }
49 :
50 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
51 0 : accept(const TypeAnalysis &visitor) const noexcept override {
52 0 : return visitor.visit(this);
53 0 : }
54 :
55 : [[nodiscard]] std::expected<std::monostate, Error>
56 0 : accept(const Monomorphize &visitor) const noexcept override {
57 0 : return visitor.visit(this);
58 0 : }
59 :
60 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
61 0 : accept(const CodeGeneration &visitor) const noexcept override {
62 0 : return visitor.visit(this);
63 0 : }
64 : };
65 :
66 : } // namespace nicole
67 :
68 : #endif
|