aboutsummaryrefslogtreecommitdiff
path: root/include/cps/FileAST.h
blob: a1515974cc58c2cc594151e5657d0d0333304f4a (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
45
46
47
48
49
50
51
52
53
54
55

#pragma once
#include "cps/AST.h"
#include "cps/FileMode.h"
#include <memory>
#include <string>

namespace cps {

class OpenFileStmtAST : public StmtAST {
    std::unique_ptr<ExprAST> FileName;
    FileMode Mode;

public:
    OpenFileStmtAST(std::unique_ptr<ExprAST> FileName, FileMode Mode, int Line)
        : StmtAST(Line), FileName(std::move(FileName)), Mode(Mode) {}

    ExprAST *getFileName() const { return FileName.get(); }
    FileMode getMode() const { return Mode; }
};

class ReadFileStmtAST : public StmtAST {
    std::unique_ptr<ExprAST> FileName;
    std::string VarName;

public:
    ReadFileStmtAST(std::unique_ptr<ExprAST> FileName, const std::string &VarName, int Line)
        : StmtAST(Line), FileName(std::move(FileName)), VarName(VarName) {}

    ExprAST *getFileName() const { return FileName.get(); }
    const std::string &getVarName() const { return VarName; }
};

class WriteFileStmtAST : public StmtAST {
    std::unique_ptr<ExprAST> FileName;
    std::unique_ptr<ExprAST> Data;

public:
    WriteFileStmtAST(std::unique_ptr<ExprAST> FileName, std::unique_ptr<ExprAST> Data, int Line)
        : StmtAST(Line), FileName(std::move(FileName)), Data(std::move(Data)) {}

    ExprAST *getFileName() const { return FileName.get(); }
    ExprAST *getData() const { return Data.get(); }
};

class CloseFileStmtAST : public StmtAST {
    std::unique_ptr<ExprAST> FileName;

public:
    CloseFileStmtAST(std::unique_ptr<ExprAST> FileName, int Line)
        : StmtAST(Line), FileName(std::move(FileName)) {}

    ExprAST *getFileName() const { return FileName.get(); }
};

} // namespace cps