summaryrefslogtreecommitdiff
path: root/willow/tools/willowc/include/compiler.hpp
blob: 96ca4802d6a87994cd9a43503b8e137d46a954b7 (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
#ifndef WILLOWC_INCLUDE_COMPILER_HPP
#define WILLOWC_INCLUDE_COMPILER_HPP

#include <sourcemanager.hpp>

#include <willow/IR/DiagnosticEngine.h>
#include <string>

namespace willowc {

class Compiler {
public:
  struct Options {
    std::string filename;
    bool use_stdin;
    willow::Severity log_level;
  };
  Compiler();
  Compiler(const Compiler &) = delete;
  Compiler &operator=(const Compiler &) = delete;

  willow::LogicalResult addSourceFile(const std::string &path);
  willow::LogicalResult addStdIn();
  // TODO
  void run();
  void compile(FileID file);

  void setLogLevel(willow::Severity sev) { log_level_ = sev; }
  size_t numFiles() { return sourcemanager_.numFiles(); }
private:
  SourceManager sourcemanager_;
  willow::Severity log_level_;
  willow::DiagnosticEngine diagnostic_engine_;

  void emitDiagnostic(const willow::Diagnostic &d);
};

}; // namespace willowc

#endif // WILLOWC_INCLUDE_COMPILER_HPP