-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFwdTypes.hpp
43 lines (34 loc) · 913 Bytes
/
FwdTypes.hpp
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 FwdTypes_h
#define FwdTypes_h
#include <memory>
#include <exception>
#include <string_view>
#include <string>
#include <variant>
#include <ostream>
class Error : public std::exception {
std::string str;
public:
Error(std::string_view s) : str{ s } {}
const char *what() const noexcept override { return str.c_str(); }
};
class SType {
public:
virtual ~SType() {}
};
class ExprVisitor;
class StmtVisitor;
class LoxCallable;
class LoxClass;
class LoxInstance;
using Value = std::variant<std::monostate,bool,double,std::string,std::shared_ptr<LoxCallable>,std::shared_ptr<LoxInstance>>;
enum class ValueType { Nil, Boolean, Number, String, Callable, Instance };
std::string toString(const Value&);
bool isTruthy(const Value& l);
class Return {
Value value;
public:
Return(Value&& value) : value{ value } {}
const auto get() const { return value; }
};
#endif // FwdTypes_h