aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/include/declaration.hpp
blob: 08fd64182e152be3043a7bef4b8c62131b8895a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef AST_DECLARATION_HPP
#define AST_DECLARATION_HPP

#include "node.hpp"

#include <memory>

class Expression;
class Type;
class Declaration;

typedef std::shared_ptr<Expression> ExpressionPtr;
typedef std::shared_ptr<Type> TypePtr;
typedef std::shared_ptr<Declaration> DeclarationPtr;


class Declaration : public Node {
private:
    TypePtr type;
    std::string id;
    ExpressionPtr init;
    DeclarationPtr next_decl;
    DeclarationPtr list_next_decl;
    
public:
    Declaration(const std::string& _id = "", Expression* _init = nullptr);

    virtual void print() const;
    virtual void printxml() const;
    virtual VariableStackBindings printasm(VariableStackBindings bindings) const;

    void addDeclaration(Declaration* _next_decl);
    void addList(Declaration* _next_decl);

    void setType(Type* _type);

    DeclarationPtr getNext() const;
    DeclarationPtr getNextListItem() const;
    std::string getId() const;
    std::string getType() const;
};

#endif