mirror of
https://github.com/allankoechke/cpp-expr-eval.git
synced 2026-11-30 17:11:34 +00:00
45 lines
839 B
C++
45 lines
839 B
C++
#ifndef RUNTIME_H
|
|
#define RUNTIME_H
|
|
|
|
#include <string>
|
|
#include <format>
|
|
|
|
struct RuntimeVar {
|
|
enum class RuntimeVarType{
|
|
STRING,
|
|
NUMBER,
|
|
NIL,
|
|
BOOL
|
|
} type;
|
|
|
|
std::string value;
|
|
bool b_value = false;
|
|
double d_value = 0.0;
|
|
|
|
RuntimeVar();
|
|
|
|
explicit RuntimeVar(std::string v);
|
|
|
|
explicit RuntimeVar(bool t);
|
|
|
|
explicit RuntimeVar(double d);
|
|
|
|
[[nodiscard]] std::string typeStr() const;
|
|
|
|
[[nodiscard]] double toDouble() const;
|
|
|
|
[[nodiscard]] std::string toString() const;
|
|
|
|
[[nodiscard]] bool toBool() const;
|
|
|
|
RuntimeVar operator+(const RuntimeVar& other) const;
|
|
|
|
RuntimeVar operator-(const RuntimeVar& other) const;
|
|
|
|
RuntimeVar operator*(const RuntimeVar& other) const;
|
|
|
|
RuntimeVar operator/(const RuntimeVar& other) const;
|
|
};
|
|
|
|
#endif // RUNTIME_H
|