2022-03-31 21:20:41 +00:00
|
|
|
#ifndef DOMAIN_VALUE_H
|
|
|
|
#define DOMAIN_VALUE_H
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
#include "address_space.h"
|
2022-03-31 21:20:41 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <optional>
|
|
|
|
|
2022-04-08 17:13:53 +00:00
|
|
|
|
2022-03-31 21:20:41 +00:00
|
|
|
namespace domain {
|
|
|
|
|
2022-05-15 21:55:03 +00:00
|
|
|
class ComponentInstance;
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
class Value {
|
|
|
|
public:
|
|
|
|
enum ValueType {
|
|
|
|
INT,
|
|
|
|
STRING,
|
|
|
|
BOOL,
|
|
|
|
ADDRESS_SPACE,
|
|
|
|
ADDRESS_SPACE_REFERENCE,
|
|
|
|
ATTRIBUTE_REFERENCE,
|
|
|
|
MEMORY_REFERENCE,
|
|
|
|
MEMORY,
|
|
|
|
WIRE_REFERENCE,
|
|
|
|
NIL,
|
|
|
|
UNDEFINED,
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
long long intValue = 0;
|
|
|
|
std::string stringValue;
|
|
|
|
bool boolValue = false;
|
|
|
|
std::optional<AddressSpace> addressSpace = std::nullopt;
|
|
|
|
std::string reference;
|
|
|
|
domain::ComponentInstance *memory = nullptr;
|
|
|
|
|
|
|
|
std::optional<std::string> memoryReference = std::nullopt;
|
|
|
|
|
|
|
|
ValueType type = UNDEFINED;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Value() = default;
|
|
|
|
|
2022-06-13 22:53:46 +00:00
|
|
|
bool equals(Value value);
|
2022-05-27 06:18:17 +00:00
|
|
|
|
|
|
|
std::string string();
|
2022-06-27 09:39:13 +00:00
|
|
|
std::string getTypename();
|
2022-05-27 06:18:17 +00:00
|
|
|
|
|
|
|
ValueType getType();
|
|
|
|
|
|
|
|
bool isType(ValueType type);
|
|
|
|
|
|
|
|
long long asInt();
|
|
|
|
|
|
|
|
std::string asString();
|
|
|
|
|
|
|
|
bool asBool();
|
|
|
|
|
|
|
|
std::string asReference();
|
|
|
|
|
|
|
|
std::optional<std::string> asMemoryReference();
|
|
|
|
|
|
|
|
domain::ComponentInstance *asMemory();
|
|
|
|
|
|
|
|
AddressSpace asAddressSpace();
|
|
|
|
|
|
|
|
void setInt(long long intValue);
|
|
|
|
|
|
|
|
void setString(std::string value);
|
|
|
|
|
|
|
|
void setBool(bool value);
|
|
|
|
|
|
|
|
void setReference(std::string value);
|
|
|
|
|
|
|
|
std::string stringify();
|
|
|
|
|
|
|
|
static Value fromInt(long long value);
|
|
|
|
|
|
|
|
static Value fromString(std::string value);
|
|
|
|
|
|
|
|
static Value fromBool(bool value);
|
|
|
|
|
|
|
|
static Value fromNull();
|
|
|
|
|
|
|
|
static Value fromAddressSpace(AddressSpace addressSpace);
|
|
|
|
|
|
|
|
static Value fromReference(std::string value, ValueType type);
|
|
|
|
|
|
|
|
static Value fromMemoryReference(std::optional<std::string> memoryReference);
|
|
|
|
|
|
|
|
static Value ofType(ValueType type);
|
|
|
|
};
|
2022-03-31 21:20:41 +00:00
|
|
|
|
|
|
|
} // namespace domain
|
|
|
|
|
|
|
|
#endif // DOMAIN_VALUE_H
|