ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
expression.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !DOXYGEN
14#endif // !DOXYGEN
15
16
17namespace alib { namespace expressions {
18
19
21 const String& sourceString,
22 Scope* pCTScope )
23: allocator ( ma )
24, ctScope ( pCTScope )
25, name ( nullptr )
26, program ( nullptr )
27, originalString( ma, sourceString )
28{
29 normalizedString.SetBuffer(sourceString.Length());
30}
31
39
41{
42 if( name.IsNull() )
43 name= EXPRESSIONS.GetResource("ANON_EXPR_NAME");
44 return name;
45}
46
48{
49 ALIB_ASSERT_ERROR( program, "EXPR", "Internal error: Expression without program" )
50 return program->ResultType();
51}
52
54{
55 ALIB_ASSERT_ERROR( program, "EXPR","Internal error: Expression without program" )
56 #if ALIB_TIME && ALIB_DEBUG
57 Ticks startTime;
58 #endif
59
60 Box result= program->Run( scope );
61
62 #if ALIB_TIME && ALIB_DEBUG
63 DbgLastEvaluationTime= startTime.Age();
64 #endif
65
66 return result;
67}
68
69
71{
73 dynamic_cast<detail::Program*>( program )->compiler.getOptimizedExpressionString(*this);
74 return optimizedString;
75}
76
77
78}} // namespace [alib::expressions]
79
80
81#undef EOS
ALIB_API ExpressionVal(MonoAllocator &allocator, const String &sourceString, Scope *pCTScope)
detail::Program * program
The compiled expression program.
ALIB_API Box Evaluate(Scope &scope)
Ticks::Duration DbgLastEvaluationTime
String name
The name of the expression (if named, otherwise resourced, usually "ANONYMOUS" ).
AString optimizedString
The normalized string generated on request out of optimized expression program.
AString normalizedString
The normalized string as a result of compilation.
ALIB_API String GetOptimizedString()
ALIB_API ~ExpressionVal()
Destructor.
ALIB_API const Box & ResultType() const
Definition program.hpp:168
const String & GetResource(const NString &name)
ALIB_FORCE_INLINE void DbgLock(bool onOff) noexcept
ALIB_API void SetBuffer(integer newCapacity)
constexpr bool IsNull() const
Definition string.hpp:364
constexpr integer Length() const
Definition string.hpp:326
#define ALIB_ASSERT_ERROR(cond,...)
Definition alib.hpp:1271
static ALIB_FORCE_INLINE void Destruct(T &object)
Definition alib.cpp:69
expressions::ExpressionsCamp EXPRESSIONS
The singleton instance of ALib Camp class ExpressionsCamp.