summaryrefslogtreecommitdiff
path: root/node/FunctionNode.hh
blob: 56a019b3ffcd103f153637785b3d0a628184d862 (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
44
#ifndef PCC_FUNCTIONNODE_H
#define PCC_FUNCTIONNODE_H

#include <list>

#include "BaseNode.hh"
#include "StatementNode.hh"
#include "VariableList.hh"

namespace pcc {
class FunctionNode : public BaseNode {
  public:
    FunctionNode(Context* context, std::string&& name,
                 std::list<Declaration>&& arguments,
                 std::list<std::shared_ptr<DeclNode>>&& LocalDeclarations,
                 std::shared_ptr<TypeIdentifier> ReturnTypeIdentifier,
                 std::shared_ptr<StatementListNode> body);
    virtual Value CodeGen() override;
    virtual int Travel(Traveler& traveler) override;

  protected:
    std::string name_;
    std::list<Declaration> arguments_;
    std::list<std::shared_ptr<DeclNode>> LocalDeclarations_;
    std::shared_ptr<TypeIdentifier> ReturnTypeIdentifier_;
    VariableList locals_;
    std::shared_ptr<StatementListNode> body_;
};

class ExternNode : public FunctionNode {
  public:
    ExternNode(Context* context, std::string&& name,
               std::list<Declaration>&& arguments,
               std::shared_ptr<TypeIdentifier> ReturnTypeIdentifier,
               bool IsVariadic);
    virtual Value CodeGen() override;
    virtual int Travel(Traveler& traveler) override;

  protected:
    bool IsVariadic_;
};
} // namespace pcc

#endif