-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathprogram.h
66 lines (50 loc) · 1.95 KB
/
program.h
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
56
57
58
59
60
61
62
63
64
65
66
#ifndef SIMIT_PROGRAM_H
#define SIMIT_PROGRAM_H
#include <string>
#include <ostream>
#include <vector>
#include <memory>
#include "function.h"
#include "init.h"
#include "interfaces/uncopyable.h"
namespace simit {
extern const std::vector<std::string> VALID_BACKENDS;
extern std::string kBackend;
class Diagnostics;
/// A Simit program. You can load Simit source code using the \ref loadString
/// and \ref loadFile and compile the program using the \ref compile method.
class Program : private interfaces::Uncopyable {
public:
/// Create a new Simit program.
Program();
~Program();
/// Clear program of data (makes it undefined).
void clear();
/// Add the Simit code in the given string to the program.
/// \return 0 on success, and 1 if the Simit code has errors. If the code
/// has errors these can be retrieved through the \ref getErrors
/// and \ref getErrorString methods.
int loadString(const std::string &programString);
/// Add the Simit code in the given file to the program.
/// \return 0 on success, 1 if the Simit code has errors, and 2 if the file
/// could not be read. If the code has errors these can be retrieved
/// through the \ref getErrors and \ref getErrorString methods.
int loadFile(const std::string &filename);
/// Returns the names of all the functions in the program.
std::vector<std::string> getFunctionNames() const;
/// Compile and return a runnable function, or an undefined function if an
/// error occured.
Function compile(const std::string &function);
Function compileWithTimers(const std::string &function);
/// Verify the program by executing in-code comment tests.
int verify();
bool hasErrors() const;
const Diagnostics &getDiagnostics() const;
/// Writes a human-readable string represeting the program to the stream.
friend std::ostream &operator<<(std::ostream&, const Program&);
private:
struct ProgramContent;
ProgramContent *content;
};
}
#endif