libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
symbolicVariable.cpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
9#include <triton/cpuSize.hpp>
11
12
13
14namespace triton {
15 namespace engines {
16 namespace symbolic {
17
19 triton::uint64 origin,
21 triton::uint32 size,
22 const std::string& alias) {
23 this->alias = alias;
24 this->comment = "";
25 this->id = id;
26 this->name = TRITON_SYMVAR_NAME + std::to_string(id);
27 this->origin = origin;
28 this->size = size;
29 this->type = type;
30
31 if (this->size > triton::bitsize::max_supported)
32 throw triton::exceptions::SymbolicVariable("SymbolicVariable::SymbolicVariable(): Size cannot be greater than triton::bitsize::max_supported.");
33
34 if (this->size == 0)
35 throw triton::exceptions::SymbolicVariable("SymbolicVariable::SymbolicVariable(): Size cannot be zero.");
36 }
37
38
40 this->alias = other.alias;
41 this->comment = other.comment;
42 this->id = other.id;
43 this->name = other.name;
44 this->origin = other.origin;
45 this->size = other.size;
46 this->type = other.type;
47 }
48
49
51 this->alias = other.alias;
52 this->comment = other.comment;
53 this->id = other.id;
54 this->name = other.name;
55 this->origin = other.origin;
56 this->size = other.size;
57 this->type = other.type;
58 return *this;
59 }
60
61
65
66
67 const std::string& SymbolicVariable::getAlias(void) const {
68 return this->alias;
69 }
70
71
72 const std::string& SymbolicVariable::getComment(void) const {
73 return this->comment;
74 }
75
76
77 const std::string& SymbolicVariable::getName(void) const {
78 return this->name;
79 }
80
81
83 return this->id;
84 }
85
86
88 return this->origin;
89 }
90
91
93 return this->size;
94 }
95
96
97 void SymbolicVariable::setAlias(const std::string& alias) {
98 this->alias = alias;
99 }
100
101
102 void SymbolicVariable::setComment(const std::string& comment) {
103 this->comment = comment;
104 }
105
106
107 std::ostream& operator<<(std::ostream& stream, const SymbolicVariable& symVar) {
108 if (symVar.getAlias().empty())
109 stream << symVar.getName() << ":" << symVar.getSize();
110 else
111 stream << symVar.getAlias() << ":" << symVar.getSize();
112 return stream;
113 }
114
115
116 std::ostream& operator<<(std::ostream& stream, const SymbolicVariable* symVar) {
117 stream << *symVar;
118 return stream;
119 }
120
121
122 bool operator<(const SymbolicVariable& symvar1, const SymbolicVariable& symvar2) {
123 return symvar1.getId() < symvar2.getId();
124 }
125
126 }; /* symbolic namespace */
127 }; /* engines namespace */
128}; /*triton namespace */
TRITON_EXPORT const std::string & getName(void) const
Returns the name of the symbolic variable.
std::string comment
The comment of the symbolic variable.
TRITON_EXPORT SymbolicVariable & operator=(const SymbolicVariable &other)
Operator.
triton::uint32 size
The size (in bits) of the symbolic variable.
TRITON_EXPORT triton::uint32 getSize(void) const
Returns the size (in bits) of the symbolic variable.
TRITON_EXPORT triton::engines::symbolic::variable_e getType(void) const
Returns the symbolic variable type assignment.
triton::usize id
The id of the symbolic variable. This id is unique.
std::string name
The name of the symbolic variable. Names are always something like this: SymVar_X.
TRITON_EXPORT const std::string & getAlias(void) const
Returns the alias of the symbolic variable.
triton::uint64 origin
The origin of the symbolic variable.
triton::engines::symbolic::variable_e type
The symbolic variable type assignment.
TRITON_EXPORT triton::uint64 getOrigin(void) const
Returns the source value of the symbolic variable.
TRITON_EXPORT void setComment(const std::string &comment)
Sets the comment of the symbolic variable.
TRITON_EXPORT triton::usize getId(void) const
Returns the id of the symbolic variable. This id is unique.
TRITON_EXPORT const std::string & getComment(void) const
Returns the comment of the symbolic variable.
TRITON_EXPORT void setAlias(const std::string &alias)
Sets the alias of the symbolic variable.
TRITON_EXPORT SymbolicVariable(triton::engines::symbolic::variable_e type, triton::uint64 origin, triton::usize id, triton::uint32 size, const std::string &alias)
Constructor.
std::string alias
The alias of the symbolic variable.
The exception class used by symbolic variables.
constexpr triton::uint32 max_supported
max size supported in bit
Definition cpuSize.hpp:76
std::ostream & operator<<(std::ostream &stream, const SymbolicExpression &symExpr)
Displays a symbolic expression.
bool operator<(const SymbolicVariable &symvar1, const SymbolicVariable &symvar2)
Compares two symbolic variables.
variable_e
Type of symbolic variable.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.
#define TRITON_SYMVAR_NAME