g4tools  5.4.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | List of all members
tools::valop Class Reference
Collaboration diagram for tools::valop:
Collaboration graph
[legend]

Public Types

enum  e_type {
  CMP_GT = 1, CMP_GE = 2, CMP_LT = 3, CMP_LE = 4,
  CMP_EQ = 5, CMP_NE = 6, CMP_AND = 7, CMP_OR = 8,
  ADD = 9, MUL = 10, SUB = 11, DIV = 12,
  ASSIGN = 13, MINUS = 14, UNSIGNED_INTEGER = 15, REAL = 16,
  NAME = 17, STRING = 18, FUNC = 20, BOOL_TRUE = 21,
  BOOL_FALSE = 22, NOT = 23, SYMBOL = 100, ASIDE = 101,
  NVMUL = 102, EQUAL = 103, SUPS = 104, SUBS = 105
}
 

Public Member Functions

 valop (e_type a_type)
 
 valop (e_type a_type, valop *a_A)
 
 valop (e_type a_type, valop *a_A, valop *a_B)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A, valop *a_B)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A, valop *a_B, valop *a_C)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A, valop *a_B, valop *a_C, valop *a_D)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A, valop *a_B, valop *a_C, valop *a_D, valop *a_E)
 
 valop (e_type a_type, ival_func *a_function, valop *a_A, valop *a_B, valop *a_C, valop *a_D, valop *a_E, valop *a_F)
 
 valop (e_type a_type, bool a_v)
 
 valop (e_type a_type, unsigned int a_number)
 
 valop (e_type a_type, double a_number)
 
 valop (e_type a_type, const std::string &a_string)
 
 valop (e_type a_type, const char *a_cstr)
 
 valop (e_type a_type, const std::string &a_name, int a_index)
 
virtual ~valop ()
 
 valop (const valop &a_from)
 
valopoperator= (const valop &a_from)
 
valopcopy () const
 
e_type type () const
 
void print (std::ostream &a_out)
 
bool is_leaf () const
 
bool is_binary () const
 
bool is_unary () const
 
void replace (valop *a_node, valop *a_to, bool a_delete)
 

Static Public Member Functions

static bool is_binary (e_type a_type)
 
static valop def ()
 

Public Attributes

e_type m_type
 
ival_funcm_function
 
value m_variable
 
std::string m_name
 
int m_index
 
valopm_A
 
valopm_B
 
valopm_C
 
valopm_D
 
valopm_E
 
valopm_F
 
int m_tag
 

Static Protected Member Functions

static int not_found ()
 

Detailed Description

Definition at line 11 of file valop.

Member Enumeration Documentation

◆ e_type

Enumerator
CMP_GT 
CMP_GE 
CMP_LT 
CMP_LE 
CMP_EQ 
CMP_NE 
CMP_AND 
CMP_OR 
ADD 
MUL 
SUB 
DIV 
ASSIGN 
MINUS 
UNSIGNED_INTEGER 
REAL 
NAME 
STRING 
FUNC 
BOOL_TRUE 
BOOL_FALSE 
NOT 
SYMBOL 
ASIDE 
NVMUL 
EQUAL 
SUPS 
SUBS 

Definition at line 17 of file valop.

17  {
18  CMP_GT = 1,
19  CMP_GE = 2,
20  CMP_LT = 3,
21  CMP_LE = 4,
22  CMP_EQ = 5,
23  CMP_NE = 6,
24  CMP_AND = 7,
25  CMP_OR = 8,
26 
27  ADD = 9,
28  MUL = 10,
29  SUB = 11,
30  DIV = 12,
31 
32  ASSIGN = 13,
33  MINUS = 14,
34  UNSIGNED_INTEGER = 15,
35  REAL = 16,
36  NAME = 17,
37  STRING = 18,
38  //PI = 19,
39  FUNC = 20,
40  BOOL_TRUE = 21,
41  BOOL_FALSE = 22,
42  NOT = 23,
43  // math edition :
44  SYMBOL = 100,
45  ASIDE = 101,
46  NVMUL = 102, //not visible mul
47  EQUAL = 103,
48  SUPS = 104, //super script
49  SUBS = 105 //sub script
50  };

Constructor & Destructor Documentation

◆ valop() [1/16]

tools::valop::valop ( e_type  a_type)
inline

Definition at line 103 of file valop.

104  :m_type(a_type),m_function(0),m_index(not_found())
105  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
106 #ifdef TOOLS_MEM
107  mem::increment(s_class().c_str());
108 #endif
109  }

◆ valop() [2/16]

tools::valop::valop ( e_type  a_type,
valop a_A 
)
inline

Definition at line 111 of file valop.

112  :m_type(a_type),m_function(0),m_index(not_found())
113  ,m_A(a_A),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
114 #ifdef TOOLS_MEM
115  mem::increment(s_class().c_str());
116 #endif
117  }

◆ valop() [3/16]

tools::valop::valop ( e_type  a_type,
valop a_A,
valop a_B 
)
inline

Definition at line 119 of file valop.

120  :m_type(a_type),m_function(0),m_index(not_found())
121  ,m_A(a_A),m_B(a_B),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
122 #ifdef TOOLS_MEM
123  mem::increment(s_class().c_str());
124 #endif
125  }

◆ valop() [4/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A 
)
inline

Definition at line 127 of file valop.

128  :m_type(a_type),m_function(0),m_index(not_found())
129  ,m_A(a_A),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
130 #ifdef TOOLS_MEM
131  mem::increment(s_class().c_str());
132 #endif
133  m_function = a_function?a_function->copy():0;
134  }

◆ valop() [5/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A,
valop a_B 
)
inline

Definition at line 136 of file valop.

137  :m_type(a_type),m_function(0),m_index(not_found())
138  ,m_A(a_A),m_B(a_B),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
139 #ifdef TOOLS_MEM
140  mem::increment(s_class().c_str());
141 #endif
142  m_function = a_function?a_function->copy():0;
143  }

◆ valop() [6/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A,
valop a_B,
valop a_C 
)
inline

Definition at line 145 of file valop.

146  :m_type(a_type),m_function(0),m_index(not_found())
147  ,m_A(a_A),m_B(a_B),m_C(a_C),m_D(0),m_E(0),m_F(0),m_tag(0){
148 #ifdef TOOLS_MEM
149  mem::increment(s_class().c_str());
150 #endif
151  m_function = a_function?a_function->copy():0;
152  }

◆ valop() [7/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A,
valop a_B,
valop a_C,
valop a_D 
)
inline

Definition at line 154 of file valop.

155  :m_type(a_type),m_function(0),m_index(not_found())
156  ,m_A(a_A),m_B(a_B),m_C(a_C),m_D(a_D),m_E(0),m_F(0),m_tag(0){
157 #ifdef TOOLS_MEM
158  mem::increment(s_class().c_str());
159 #endif
160  m_function = a_function?a_function->copy():0;
161  }

◆ valop() [8/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A,
valop a_B,
valop a_C,
valop a_D,
valop a_E 
)
inline

Definition at line 163 of file valop.

164  :m_type(a_type),m_function(0),m_index(not_found())
165  ,m_A(a_A),m_B(a_B),m_C(a_C),m_D(a_D),m_E(a_E),m_F(0),m_tag(0){
166 #ifdef TOOLS_MEM
167  mem::increment(s_class().c_str());
168 #endif
169  m_function = a_function?a_function->copy():0;
170  }

◆ valop() [9/16]

tools::valop::valop ( e_type  a_type,
ival_func a_function,
valop a_A,
valop a_B,
valop a_C,
valop a_D,
valop a_E,
valop a_F 
)
inline

Definition at line 172 of file valop.

175  :m_type(a_type),m_function(0),m_index(not_found())
176  ,m_A(a_A),m_B(a_B),m_C(a_C),m_D(a_D),m_E(a_E),m_F(a_F),m_tag(0){
177 #ifdef TOOLS_MEM
178  mem::increment(s_class().c_str());
179 #endif
180  m_function = a_function?a_function->copy():0;
181  }

◆ valop() [10/16]

tools::valop::valop ( e_type  a_type,
bool  a_v 
)
inline

Definition at line 183 of file valop.

184  :m_type(a_type),m_function(0),m_index(not_found())
185  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
186 #ifdef TOOLS_MEM
187  mem::increment(s_class().c_str());
188 #endif
189  m_variable.set(a_v);
190  }

◆ valop() [11/16]

tools::valop::valop ( e_type  a_type,
unsigned int  a_number 
)
inline

Definition at line 192 of file valop.

193  :m_type(a_type),m_function(0),m_index(not_found())
194  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
195 #ifdef TOOLS_MEM
196  mem::increment(s_class().c_str());
197 #endif
198  m_variable.set(a_number);
199  }

◆ valop() [12/16]

tools::valop::valop ( e_type  a_type,
double  a_number 
)
inline

Definition at line 201 of file valop.

202  :m_type(a_type),m_function(0),m_index(not_found())
203  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
204 #ifdef TOOLS_MEM
205  mem::increment(s_class().c_str());
206 #endif
207  m_variable.set(a_number);
208  }

◆ valop() [13/16]

tools::valop::valop ( e_type  a_type,
const std::string &  a_string 
)
inline

Definition at line 210 of file valop.

211  :m_type(a_type),m_function(0),m_index(not_found())
212  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
213 #ifdef TOOLS_MEM
214  mem::increment(s_class().c_str());
215 #endif
216  m_variable.set(a_string);
217  }

◆ valop() [14/16]

tools::valop::valop ( e_type  a_type,
const char *  a_cstr 
)
inline

Definition at line 220 of file valop.

221  :m_type(a_type),m_function(0),m_index(not_found())
222  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
223 #ifdef TOOLS_MEM
224  mem::increment(s_class().c_str());
225 #endif
226  m_variable.set(a_cstr);
227  }

◆ valop() [15/16]

tools::valop::valop ( e_type  a_type,
const std::string &  a_name,
int  a_index 
)
inline

Definition at line 229 of file valop.

230  :m_type(a_type),m_function(0),m_name(a_name),m_index(a_index)
231  ,m_A(0),m_B(0),m_C(0),m_D(0),m_E(0),m_F(0),m_tag(0){
232  // a_name needed to not confuse with the constructor (e_type,unsigned int).
233 #ifdef TOOLS_MEM
234  mem::increment(s_class().c_str());
235 #endif
236  }

◆ ~valop()

virtual tools::valop::~valop ( )
inlinevirtual

Definition at line 238 of file valop.

238  {
239  delete m_function;
240  delete m_A;
241  delete m_B;
242  delete m_C;
243  delete m_D;
244  delete m_E;
245  delete m_F;
246 #ifdef TOOLS_MEM
247  mem::decrement(s_class().c_str());
248 #endif
249  }

◆ valop() [16/16]

tools::valop::valop ( const valop a_from)
inline

Definition at line 251 of file valop.

252  :m_type(a_from.m_type)
253  ,m_function(a_from.m_function?a_from.m_function->copy():0)
254  ,m_variable(a_from.m_variable)
255  ,m_name(a_from.m_name)
256  ,m_index(a_from.m_index)
257 
258  ,m_A(a_from.m_A?new valop(*a_from.m_A):0)
259  ,m_B(a_from.m_B?new valop(*a_from.m_B):0)
260  ,m_C(a_from.m_C?new valop(*a_from.m_C):0)
261  ,m_D(a_from.m_D?new valop(*a_from.m_D):0)
262  ,m_E(a_from.m_E?new valop(*a_from.m_E):0)
263  ,m_F(a_from.m_F?new valop(*a_from.m_F):0)
264 
265  ,m_tag(a_from.m_tag)
266  {
267 #ifdef TOOLS_MEM
268  mem::increment(s_class().c_str());
269 #endif
270  }

Member Function Documentation

◆ copy()

valop* tools::valop::copy ( ) const
inline

Definition at line 302 of file valop.

302 {return new valop(*this);}

◆ def()

static valop tools::valop::def ( )
inlinestatic

Definition at line 300 of file valop.

300 {return valop(REAL,0.0);}

◆ is_binary() [1/2]

bool tools::valop::is_binary ( ) const
inline

Definition at line 328 of file valop.

328  {
329  switch(m_type) {
330  case CMP_GT:
331  case CMP_GE:
332  case CMP_LT:
333  case CMP_LE:
334  case CMP_EQ:
335  case CMP_NE:
336  case CMP_AND:
337  case CMP_OR:
338 
339  case ADD:
340  case MUL:
341  case SUB:
342  case DIV:
343 
344  case ASIDE:
345  case NVMUL:
346  case EQUAL:
347  case SUPS:
348  case SUBS:
349  return true;
350  default:
351  return false;
352  }
353  }

◆ is_binary() [2/2]

static bool tools::valop::is_binary ( e_type  a_type)
inlinestatic

Definition at line 53 of file valop.

53  {
54  switch(a_type) {
55  case CMP_GT:
56  case CMP_GE:
57  case CMP_LT:
58  case CMP_LE:
59  case CMP_EQ:
60  case CMP_NE:
61  case CMP_AND:
62  case CMP_OR:
63 
64  case ADD:
65  case MUL:
66  case SUB:
67  case DIV:
68 
69  case ASIDE:
70  case NVMUL:
71  case EQUAL:
72  case SUPS:
73  case SUBS:
74  return true;
75  default:
76  return false;
77  }
78  }

◆ is_leaf()

bool tools::valop::is_leaf ( ) const
inline

Definition at line 313 of file valop.

313  {
314  switch(m_type) {
315  case UNSIGNED_INTEGER:
316  case REAL:
317  case STRING:
318  case NAME:
319  //case PI:
320  case SYMBOL:
321  case BOOL_TRUE:
322  case BOOL_FALSE:
323  return true;
324  default:
325  return false;
326  }
327  }

◆ is_unary()

bool tools::valop::is_unary ( ) const
inline

Definition at line 354 of file valop.

354  {
355  switch(m_type) {
356  case MINUS:
357  case NOT:
358  case ASSIGN:
359  return true;
360  case FUNC:
361  if(!m_A) return false;
362  if(!m_function) return false;
363  if(m_function->number_of_arguments()==1) return true;
364  return false;
365  default:
366  return false;
367  }
368  }

◆ not_found()

static int tools::valop::not_found ( )
inlinestaticprotected

Definition at line 383 of file valop.

383 {return -1;}

◆ operator=()

valop& tools::valop::operator= ( const valop a_from)
inline

Definition at line 271 of file valop.

271  {
272  if(&a_from==this) return *this;
273 
274  m_type = a_from.m_type;
275 
276  delete m_function;
277  m_function = a_from.m_function?a_from.m_function->copy():0;
278 
279  m_variable = a_from.m_variable;
280  m_name = a_from.m_name;
281  m_index = a_from.m_index;
282 
283  delete m_A;
284  delete m_B;
285  delete m_C;
286  delete m_D;
287  delete m_E;
288  delete m_F;
289  m_A = a_from.m_A?new valop(*a_from.m_A):0;
290  m_B = a_from.m_B?new valop(*a_from.m_B):0;
291  m_C = a_from.m_C?new valop(*a_from.m_C):0;
292  m_D = a_from.m_D?new valop(*a_from.m_D):0;
293  m_E = a_from.m_E?new valop(*a_from.m_E):0;
294  m_F = a_from.m_F?new valop(*a_from.m_F):0;
295 
296  m_tag = a_from.m_tag;
297  return *this;
298  }

◆ print()

void tools::valop::print ( std::ostream &  a_out)
inline

Definition at line 306 of file valop.

306  {
307  a_out << "Type : " << this << " " << (int)m_type << std::endl;
308  //if(!m_variable.is_none()) m_variable.print(a_out);
309  if(m_A) m_A->print(a_out);
310  if(m_B) m_B->print(a_out);
311  }

◆ replace()

void tools::valop::replace ( valop a_node,
valop a_to,
bool  a_delete 
)
inline

Definition at line 373 of file valop.

373  {
374  if(m_A==a_node) {if(a_delete) delete m_A;m_A = a_to;return;}
375  if(m_B==a_node) {if(a_delete) delete m_B;m_B = a_to;return;}
376  if(m_C==a_node) {if(a_delete) delete m_C;m_C = a_to;return;}
377  if(m_D==a_node) {if(a_delete) delete m_D;m_D = a_to;return;}
378  if(m_E==a_node) {if(a_delete) delete m_E;m_E = a_to;return;}
379  if(m_F==a_node) {if(a_delete) delete m_F;m_F = a_to;return;}
380  }

◆ type()

e_type tools::valop::type ( ) const
inline

Definition at line 304 of file valop.

304 {return m_type;}

Member Data Documentation

◆ m_A

valop* tools::valop::m_A

Definition at line 390 of file valop.

◆ m_B

valop* tools::valop::m_B

Definition at line 391 of file valop.

◆ m_C

valop* tools::valop::m_C

Definition at line 392 of file valop.

◆ m_D

valop* tools::valop::m_D

Definition at line 393 of file valop.

◆ m_E

valop* tools::valop::m_E

Definition at line 394 of file valop.

◆ m_F

valop* tools::valop::m_F

Definition at line 395 of file valop.

◆ m_function

ival_func* tools::valop::m_function

Definition at line 386 of file valop.

◆ m_index

int tools::valop::m_index

Definition at line 389 of file valop.

◆ m_name

std::string tools::valop::m_name

Definition at line 388 of file valop.

◆ m_tag

int tools::valop::m_tag

Definition at line 397 of file valop.

◆ m_type

e_type tools::valop::m_type

Definition at line 385 of file valop.

◆ m_variable

value tools::valop::m_variable

Definition at line 387 of file valop.


The documentation for this class was generated from the following file:
tools::valop::m_C
valop * m_C
Definition: valop:392
tools::valop::SYMBOL
@ SYMBOL
Definition: valop:44
tools::valop::CMP_GE
@ CMP_GE
Definition: valop:19
tools::valop::print
void print(std::ostream &a_out)
Definition: valop:306
tools::valop::m_F
valop * m_F
Definition: valop:395
tools::valop::SUPS
@ SUPS
Definition: valop:48
tools::valop::m_E
valop * m_E
Definition: valop:394
tools::valop::m_D
valop * m_D
Definition: valop:393
tools::valop::NVMUL
@ NVMUL
Definition: valop:46
tools::valop::ADD
@ ADD
Definition: valop:27
tools::valop::m_index
int m_index
Definition: valop:389
tools::valop::BOOL_TRUE
@ BOOL_TRUE
Definition: valop:40
tools::valop::CMP_EQ
@ CMP_EQ
Definition: valop:22
tools::valop::m_tag
int m_tag
Definition: valop:397
tools::ival_func::copy
virtual ival_func * copy() const =0
tools::valop::m_A
valop * m_A
Definition: valop:390
tools::ival_func::number_of_arguments
virtual size_t number_of_arguments() const =0
tools::valop::BOOL_FALSE
@ BOOL_FALSE
Definition: valop:41
tools::value::set
void set(short a_value)
Definition: value:499
tools::valop::CMP_GT
@ CMP_GT
Definition: valop:18
tools::valop::DIV
@ DIV
Definition: valop:30
tools::valop::NAME
@ NAME
Definition: valop:36
tools::valop::m_B
valop * m_B
Definition: valop:391
tools::valop::NOT
@ NOT
Definition: valop:42
tools::valop::MUL
@ MUL
Definition: valop:28
tools::valop::m_variable
value m_variable
Definition: valop:387
tools::valop::SUB
@ SUB
Definition: valop:29
tools::valop::m_type
e_type m_type
Definition: valop:385
tools::valop::CMP_OR
@ CMP_OR
Definition: valop:25
tools::valop::CMP_LT
@ CMP_LT
Definition: valop:20
tools::valop::MINUS
@ MINUS
Definition: valop:33
tools::valop::STRING
@ STRING
Definition: valop:37
tools::valop::m_function
ival_func * m_function
Definition: valop:386
tools::valop::ASSIGN
@ ASSIGN
Definition: valop:32
tools::valop::CMP_NE
@ CMP_NE
Definition: valop:23
tools::valop::UNSIGNED_INTEGER
@ UNSIGNED_INTEGER
Definition: valop:34
tools::valop::REAL
@ REAL
Definition: valop:35
tools::valop::ASIDE
@ ASIDE
Definition: valop:45
tools::valop::CMP_LE
@ CMP_LE
Definition: valop:21
tools::valop::valop
valop(e_type a_type)
Definition: valop:103
tools::valop::m_name
std::string m_name
Definition: valop:388
tools::valop::SUBS
@ SUBS
Definition: valop:49
tools::valop::EQUAL
@ EQUAL
Definition: valop:47
tools::valop::FUNC
@ FUNC
Definition: valop:39
tools::valop::not_found
static int not_found()
Definition: valop:383
tools::valop::CMP_AND
@ CMP_AND
Definition: valop:24