ATLAS Offline Software
Loading...
Searching...
No Matches
StackElement.cxx File Reference
#include <cmath>
#include <iostream>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "ExpressionEvaluation/StackElement.h"
Include dependency graph for StackElement.cxx:

Go to the source code of this file.

Classes

class  ExpressionParsing::Helper_eq
class  ExpressionParsing::Helper_neq
class  ExpressionParsing::Helper_and
class  ExpressionParsing::Helper_or
class  ExpressionParsing::Helper_gt
class  ExpressionParsing::Helper_gte
class  ExpressionParsing::Helper_lt
class  ExpressionParsing::Helper_lte

Namespaces

namespace  ExpressionParsing
 Namespace holding all the expression evaluation code.

Macros

#define IMPL_ASSIGN_OP(OP)
 Helper macro implementing the assignment operator specialisations.
#define UNARY_MATH_FUNCTION(FUNC, BASEFUNC)
 Helper macro for implementing many of the mathematical functions.

Functions

template<class T_CompHelper, class T>
std::vector< int > ExpressionParsing::compareVector (std::vector< T > &&a, std::vector< T > &&b, T_CompHelper helper)
template<class T_CompHelper, class T>
std::vector< int > ExpressionParsing::compareVectorAlt (const std::vector< T > &&a, std::vector< T > &&b, T_CompHelper helper)
template<class T_CompHelper>
std::vector< int > ExpressionParsing::compareVector (std::vector< int > &&a, const std::vector< int > &&b, T_CompHelper helper)
template<class T_CompHelper>
std::vector< int > ExpressionParsing::compareVectorAlt (const std::vector< int > &&a, std::vector< int > &&b, T_CompHelper helper)
std::ostream & ExpressionParsing::operator<< (std::ostream &os, const StackElement &el)
 Declare an output operator for StackElement objects.

Macro Definition Documentation

◆ IMPL_ASSIGN_OP

#define IMPL_ASSIGN_OP ( OP)
Value:
StackElement& StackElement::operator OP( StackElement& rhs ) { \
makeVectorIfNecessary( rhs ); \
makeDoubleIfNecessary( rhs ); \
switch( m_type ) { \
case SE_INT: \
m_intVal OP rhs.scalarValue< int >(); \
break; \
case SE_DOUBLE: \
m_doubleVal OP rhs.scalarValue< double >(); \
break; \
case SE_VECINT: \
*this OP rhs.vectorValue< int >( m_vecIntVal.size() ); \
break; \
case SE_VECDOUBLE: \
*this OP rhs.vectorValue< double >( m_vecDoubleVal.size() ); \
break; \
default: \
throw std::runtime_error( "StackElement ill-defined in " \
#OP ); \
break; \
} \
return *this; \
}
void * StackElement
One element of a stack trace.
Definition stackstash.h:74

Helper macro implementing the assignment operator specialisations.

Definition at line 193 of file StackElement.cxx.

193#define IMPL_ASSIGN_OP( OP ) \
194 StackElement& StackElement::operator OP( StackElement& rhs ) { \
195 makeVectorIfNecessary( rhs ); \
196 makeDoubleIfNecessary( rhs ); \
197 switch( m_type ) { \
198 case SE_INT: \
199 m_intVal OP rhs.scalarValue< int >(); \
200 break; \
201 case SE_DOUBLE: \
202 m_doubleVal OP rhs.scalarValue< double >(); \
203 break; \
204 case SE_VECINT: \
205 *this OP rhs.vectorValue< int >( m_vecIntVal.size() ); \
206 break; \
207 case SE_VECDOUBLE: \
208 *this OP rhs.vectorValue< double >( m_vecDoubleVal.size() ); \
209 break; \
210 default: \
211 throw std::runtime_error( "StackElement ill-defined in " \
212 #OP ); \
213 break; \
214 } \
215 return *this; \
216 }

◆ UNARY_MATH_FUNCTION

#define UNARY_MATH_FUNCTION ( FUNC,
BASEFUNC )
Value:
StackElement StackElement::FUNC() { \
if (this->m_moved) throw std::logic_error("Content already moved");\
StackElement temp( std::move(*this) ); \
this->m_moved=true; \
temp.makeDouble(); \
if( temp.m_type == SE_DOUBLE ) { \
temp.m_doubleVal = BASEFUNC( temp.m_doubleVal ); \
return temp; \
} else if( temp.m_type == SE_VECDOUBLE ) { \
for( double& value : temp.m_vecDoubleVal ) { \
value = BASEFUNC( value ); \
} \
return temp; \
} else { \
/* @TODO throw exception */ \
return temp; \
} \
}

Helper macro for implementing many of the mathematical functions.

Definition at line 640 of file StackElement.cxx.

640#define UNARY_MATH_FUNCTION( FUNC, BASEFUNC ) \
641 StackElement StackElement::FUNC() { \
642 if (this->m_moved) throw std::logic_error("Content already moved");\
643 StackElement temp( std::move(*this) ); \
644 this->m_moved=true; \
645 temp.makeDouble(); \
646 if( temp.m_type == SE_DOUBLE ) { \
647 temp.m_doubleVal = BASEFUNC( temp.m_doubleVal ); \
648 return temp; \
649 } else if( temp.m_type == SE_VECDOUBLE ) { \
650 for( double& value : temp.m_vecDoubleVal ) { \
651 value = BASEFUNC( value ); \
652 } \
653 return temp; \
654 } else { \
655 /* @TODO throw exception */ \
656 return temp; \
657 } \
658 }