ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
expression.cpp
1namespace alib { namespace expressions {
2
3
5 const String& sourceString,
6 Scope* pCTScope )
7: allocator ( ma )
8, ctScope ( pCTScope )
9, name ( nullptr )
10, program ( nullptr )
11, originalString( ma, sourceString ) { normalizedString.SetBuffer(sourceString.Length()); }
12
14 allocator.DbgLock(false);
15 if(program)
16 delete static_cast<detail::Program*>(program);
18}
19
21 if( name.IsNull() )
22 name= EXPRESSIONS.GetResource("ANON_EXPR_NAME");
23 return name;
24}
25
27{
28 ALIB_ASSERT_ERROR( program, "EXPR", "Internal error: Expression without program" )
29 return static_cast<detail::Program*>(program)->ResultType();
30}
31
33 ALIB_ASSERT_ERROR( program, "EXPR","Internal error: Expression without program" )
34 ALIB_DBG( Ticks startTime; )
35
36 Box result= static_cast<detail::Program*>(program)->Run( scope );
37
38
39 ALIB_DBG( DbgLastEvaluationTime= startTime.Age(); )
40
41 return result;
42}
43
44
46 if( optimizedString.IsNull() )
47 static_cast<detail::Program*>(program)->compiler.getOptimizedExpressionString(*this);
48 return optimizedString;
49}
50
52{ return static_cast<detail::Program*>(program)->Length(); }
53
55 detail::Program* prg= static_cast<detail::Program*>(program);
56 return prg->Length() == 1 && prg->At(0).IsConstant();
57}
58
61
62#if ALIB_DEBUG
64{ return detail::VirtualMachine::DbgList(*static_cast<detail::Program*>(expression->GetProgram()));}
65#endif
66
67}} // namespace [alib::expressions]
68
69
70#undef EOS
#define ALIB_DBG(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
AString optimizedString
The normalized string generated on request out of optimized expression program.
detail::ProgramBase * program
The compiled expression program.
String originalString
The original source string of the expression.
ExpressionVal(MonoAllocator &allocator, const String &sourceString, Scope *pCTScope)
Definition expression.cpp:4
String name
The name of the expression (if named, otherwise resourced, usually "ANONYMOUS" ).
Ticks::Duration DbgLastEvaluationTime
AString normalizedString
The normalized string as a result of compilation.
VM::Command & At(VM::PC pc)
Definition program.hpp:159
constexpr integer Length() const
Definition string.hpp:300
AString DbgList(Expression expression)
void Destruct(T &object)
Definition tmp.hpp:82
Definition alox.cpp:14
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
boxing::Box Box
Type alias in namespace #"%alib".
Definition box.hpp:1128
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
expressions::ExpressionsCamp EXPRESSIONS
The singleton instance of ALib Camp class #"ExpressionsCamp".
time::Ticks Ticks
Type alias in namespace #"%alib".
Definition ticks.hpp:86
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
static AString DbgList(Program &program)