16,
DCS (
"ExpressionEvalScope")
30,
DCS (
"ExpressionCTScope")
44void Scope::freeResources() {
56 auto stackSize=
Stack->size();
70 Stack->reserve( stackSize );
91 constexpr std::pair<Box&,NString> typeKeys[]=
103 size_t idx=
sizeof( typeKeys ) /
sizeof( std::pair<Box&, NString> );
107 auto& name=
EXPRESSIONS.GetResource( typeKeys[idx].second );
109 AddType( typeKeys[idx].first, nameNarrow );
131 "Expected none-operator as first enum record" )
139 if( record.Symbol.IsNotEmpty() )
141 record.Replacement );
148 "Expected none-operator as first enum record" )
151 if ( enumRecordIt->Symbol.Equals<
NC>(
A_CHAR(
"[]"))
160 : enumRecordIt->Precedence;
169 enumEntry.Replacement );
203 "No plug-ins attached. Invoke SetupDefaults() on compiler instance." )
205 if( expressionString.
IsEmpty() )
221 static integer recursionCounter= 0;
223 if( recursionCounter++ == 0 )
224 startOfCompilation=
allocator.TakeSnapshot();
234 expression->DbgParseTime= startTime.Age();
246 expression->normalizedString );
247 expression->normalizedString.TrimEnd();
249 static_cast<detail::Program*
>(expression->program)->AssembleFinalize();
250 ALIB_DBG( expression->DbgAssemblyTime= startTime.Age(); )
252 if(--recursionCounter == 0)
258 "EXPR",
"No exception when parsing expression, but result type is void!" )
262 "EXPR",
"No exception when parsing expression, but result type is void." )
267 if(--recursionCounter == 0)
271 catch( std::exception& )
274 if(--recursionCounter == 0)
281 expression->ctScope->Allocator.DbgLock(
true);
288 auto startOfDecompilation=
allocator.TakeSnapshot();
298 expression.allocator.DbgLock(
true);
324 if( expressionString.
IsNull() ) {
332 auto compiledExpression=
Compile( expressionString );
333 compiledExpression->allocator.DbgLock(
false);
334 compiledExpression->name.Allocate( compiledExpression->allocator, name);
335 compiledExpression->allocator.DbgLock(
true);
338 it.Mapped()= compiledExpression;
364 parsedExpression->allocator.DbgLock(
false);
365 parsedExpression->name.Allocate( parsedExpression->allocator, name );
366 parsedExpression->allocator.DbgLock(
true);
368 Expression sharedExpression( parsedExpression );
371 return sharedExpression;
381 "EXPR",
"Type already registered with compiler." )
390 "Custom type \"{}\" not registered. Please use Compiler::AddType to do so.", &box.
TypeID() )
392 return "Unknown Type";
394 return entry.Mapped();
398 bool variadic= qty && (*(boxArray + qty -1)) ==
nullptr;
404 for(
size_t i= 0 ; i < qty ; ++i ) {
408 target <<
'<' <<
TypeName( **boxArray++ ) <<
'>';
422 std::vector<Box*> buf;
423 buf.reserve(
size_t(end - begin) );
424 while( begin != end )
425 buf.emplace_back( &*begin++ );
#define ALIB_CALLER_NULLED
#define ALIB_ASSERT(cond, domain)
#define ALIB_DEBUG_CRITICAL_SECTIONS
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define IF_ALIB_CAMP(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
const std::type_info & TypeID() const
Normalization CfgNormalization
ListMA< String > UnaryOperators
Compilation CfgCompilation
Compilation flags.
virtual Expression Compile(const String &expressionString)
NString TypeName(Type box)
StringVectorMA CfgNormalizationDisallowed
void WriteFunctionSignature(Box **boxArray, size_t qty, AString &target)
virtual Expression GetNamed(const String &name)
BuiltInPlugins CfgBuiltInPlugins
void AddBinaryOperator(const String &symbol, int precedence)
strings::util::Token CfgNestedExpressionFunction
virtual bool AddNamed(const String &name, const String &expressionString)
ExpressionRepository * Repository
void getOptimizedExpressionString(ExpressionVal &expression)
String CfgNestedExpressionThrowIdentifier
HashMap< MonoAllocator, String, int > BinaryOperators
void AddUnaryOperator(const String &symbol)
@ AutoCast
Installs #"plugins::AutoCast;*".
@ DateAndTime
Installs #"plugins::DateAndTime;*". ).
@ Arithmetics
Installs #"plugins::Arithmetics;*".
@ Strings
Installs #"plugins::Strings;*".
@ Math
Installs #"plugins::Math;*".
@ ElvisOperator
Installs #"plugins::ElvisOperator;*".
detail::Parser * parser
The expression parser.
virtual Scope * createCompileTimeScope(MonoAllocator &expressionAllocator)
void AddType(Type sample, const NString &name)
HashMap< MonoAllocator, AString, Expression, std::hash< String >, std::equal_to< String > > namedExpressions
The map of 'named' expressions.
HashMap< MonoAllocator, String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticUnaryOperatorAliases
HashMap< MonoAllocator, lang::TypeFunctors::Key, NAString, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo > typeMap
The map of Type names and bit flag values.
virtual ~Compiler()
Destructor.
HashMap< MonoAllocator, String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticBinaryOperatorAliases
detail::ProgramBase * program
The compiled expression program.
MonoAllocator & allocator
const Box & ResultType() const
void InsertPlugin(CompilerPlugin *plugin, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
void DbgLock(bool onOff) noexcept
void ConstructT(TArgs &&... args)
AllocatorType & GetAllocator() noexcept
TAString & ToUpper(integer regionStart=0, integer regionLength=MAX_LEN)
void DbgDisableBufferReplacementWarning()
constexpr bool IsEmpty() const
constexpr bool IsNotNull() const
constexpr bool IsNull() const
const RecordsTraits< TEnum >::Type & GetRecord(TEnum element)
@ Not
Verbal alias "Not" to operator '!'.
@ Equal
Equal operator ('=='). Precedence 500.
const alib::boxing::Box & Type
@ DefaultAlphabeticOperatorAliases
@ CaseSensitiveNamedExpressions
@ AliasEqualsOperatorWithAssignOperator
@ NamedExpressionNotFound
Compile-time exception thrown when an expression refers to an unknown named nested expression.
@ EmptyExpressionString
Thrown when an empty string is tried to be compiled.
StdVectorMA< Box >::iterator ArgIterator
@ Transfer
Transfers responsibility to the receiving party.
void LoadResourcedTokens(camp::Camp &module, const NString &resourceName, strings::util::Token *target, int dbgSizeVerifier, character outerSeparator=',', character innerSeparator=' ')
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TString< nchar > NString
Type alias in namespace #"%alib".
containers::SharedPtr< format::Formatter > SPFormatter
lang::integer integer
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
enumrecords::EnumRecords< TEnum > EnumRecords
Type alias in namespace #"%alib".
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
expressions::ExpressionsCamp EXPRESSIONS
The singleton instance of ALib Camp class #"ExpressionsCamp".
exceptions::Exception Exception
Type alias in namespace #"%alib".
expressions::Expression Expression
Type alias in namespace #"%alib".
LocalString< 128 > String128
Type alias name for #"TLocalString;TLocalString<character,128>".
time::Ticks Ticks
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
std::vector< T, StdMA< T > > StdVectorMA
Type alias in namespace #"%alib".
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
static ForwardIterator begin()
static constexpr ForwardIterator end()
Members used by the virtual machine. This is constructed only with evaluation-time scopes.
VMMembers * EvalScopeVMMembers
The members used for the virtual machine. Available only with evaluation-time instances.
StdVectorMA< Box > * Stack
virtual void freeResources()
This method is called in the destructor, as well as in method #"Scope::Reset".
MonoAllocator & Allocator
HashMap< MonoAllocator, NString, ScopeResource * > * NamedResources
lang::DbgCriticalSections DCS
MonoAllocator * EvalScopeAllocator
static Box Integer
Sample type-box for integer types. (Precisely for type #"lang::integer".).
static Box Boolean
Sample type-box for C++ type bool.
static Box Void
Sample type-box for C++ type void.
static Box Float
Sample type-box for C++ type double.
static Box DateTime
Sample type-box for date and time values of type #"time::DateTime").
virtual AST * Optimize(Normalization normalization)=0
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized)=0
static Parser * Create(Compiler &compiler)
static AST * Decompile(Program &program, MonoAllocator &allocator)