8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
40 const char* dbgCallbackName,
49 std::make_tuple( callback, resultType, cti
ALIB_DBG(, dbgCallbackName) ) );
52 "Binary operator '{}' already defined for types <{}> (aka {})\n"
53 " and <{}> (aka {}).",
59 std::make_tuple( callback, resultType, cti
ALIB_DBG(, dbgCallbackName) ) );
68 #define OP std::get<0>( *(table + i) )
69 #define LHS_TYPE std::get<1>( *(table + i) ).TypeID()
70 #define RHS_TYPE std::get<2>( *(table + i) ).TypeID()
71 #define CBFUNC std::get<3>( *(table + i) )
72 #define RESULTTYPE std::get<ALIB_REL_DBG(4,5)>( *(table + i) )
73 #define CTINVOKE std::get<ALIB_REL_DBG(5,6)>( *(table + i) )
75 for(
size_t i= 0 ; i < length ; ++i )
81 std::make_tuple( CBFUNC, RESULTTYPE, CTINVOKE
82 ALIB_DBG(, std::get<4>( *(table + i) )) ) );
85 "Binary operator '{}' already defined for types <{}> (aka {})\n"
86 " and <{}> (aka {}).",
87 OP,
Cmplr.TypeName(std::get<1>( *(table+i))), &LHS_TYPE,
88 Cmplr.TypeName(std::get<2>( *(table+i))), &RHS_TYPE )
92 std::make_tuple( CBFUNC, RESULTTYPE, CTINVOKE
93 ALIB_DBG(, std::get<4>( *(table + i) )) ) );
98 "This is rather an internal error of HashTable: The number of buckets "
99 "of hash map 'Operators' increased, although it was reserved above." )
117 "Binary operator alias '{}' already defined for types <{}> (aka {})\n"
118 "and <{}> (aka {}).",
131 #define ALIAS std::get<0>( *(table + i) )
132 #define LHS_TYPE std::get<1>( *(table + i) ).TypeID()
133 #define RHS_TYPE std::get<2>( *(table + i) ).TypeID()
134 #define OP std::get<3>( *(table + i) )
136 for(
size_t i= 0 ; i < length ; ++i )
143 "Binary operator alias '{}' already defined for types <{}> (aka {})\n"
144 "and <{}> (aka {}).",
145 ALIAS,
Cmplr.TypeName( std::get<1>( *(table + i) ) ), &LHS_TYPE,
146 Cmplr.TypeName( std::get<2>( *(table + i) ) ), &RHS_TYPE )
172 ciUnaryOp.
Operator= aliasIt.Mapped();
177 auto opIt=
Operators.Find( key, hashCode );
181 auto& op= opIt.Mapped();
192 "Type mismatch in definition of unary operator \"{}\" ({}) in plugin \"{}\".\n"
193 " Type specified: <{}> (aka {})\n"
194 " Type returned by callback: <{}> (aka {})",
197 &std::get<1>(op).TypeID(),
202 ciUnaryOp.
Callback = std::get<0>(op);
216 #define OP std::get<0>( *(table + i) )
217 #define SIDE std::get<1>( *(table + i) )
218 #define CONSTVAL std::get<2>( *(table + i) )
219 #define CONSTTYPE std::get<2>( *(table + i) ).TypeID()
220 #define OTHERBOX std::get<3>( *(table + i) )
221 #define OTHERTYPE std::get<3>( *(table + i) ).TypeID()
222 #define RESULT std::get<4>( *(table + i) )
224 for(
size_t i= 0 ; i < length ; ++i )
231 "Optimization already defined for operator \"{}\" with {!Lower}-hand "
232 "constant value \"{}\" of type <{}> (aka {}) and with "
233 "{!L}-hand type <{}> (aka {}).",
234 OP, SIDE, CONSTVAL,
Cmplr.TypeName(CONSTVAL), &CONSTTYPE,
268 ciBinaryOp.
Operator= aliasIt.Mapped();
271 #define CBFUNC std::get<0>(op)
272 #define RESULTTYPE std::get<1>(op)
273 #define CT_INVOKABLE std::get<2>(op)
275 # define DBG_CB_NAME std::get<3>(op)
279 auto opIt =
Operators.Find( key, hashCode );
283 auto& op= opIt.Mapped();
296 "Type mismatch in definition of binary operator \"{}\" ({}) of plugin \"{}\".\n"
297 " Type specified: <{}> (aka {})\n"
298 " Type returned by callback: <{}> (aka {})",
301 &RESULTTYPE .TypeID(),
326 if( entryIt.Mapped().IsType<
void>() )
359 if( ciFunction.
QtyArgs() == 0 )
363 if ( entry.Descriptor.Match( name ) )
378 ciFunction.
Name.
Reset( entry.Descriptor );
388 if( entry.Descriptor.Match( name ) )
391 size_t qtyGiven = ciFunction.
QtyArgs();
392 size_t qtyRequired = entry.SignatureLength;
393 bool isVariadic =
false;
394 if( entry.SignatureLength > 0 && ( entry.Signature[entry.SignatureLength - 1] ==
nullptr
395 || entry.Signature[entry.SignatureLength - 1]->IsType<
void>() ) )
401 size_t qtyShared = (std::min)( qtyGiven, qtyRequired );
402 bool sharedAreSameType =
true;
403 for(
size_t i= 0; i != qtyShared ; ++i )
404 sharedAreSameType&= ciFunction.
Arg(i).
IsSameType( *entry.Signature[i] );
407 if( !sharedAreSameType
408 || ( isVariadic ? qtyGiven < qtyRequired
409 : qtyGiven != qtyRequired ) )
413 Cmplr.WriteFunctionSignature( entry.Signature,
414 entry.SignatureLength,
424 && entry.Signature !=
nullptr
430 && entry.Signature ==
nullptr
436 ciFunction.
Name.
Reset( entry.Descriptor );
438 if( !entry.Callback )
453 "Type mismatch in definition of function \"{}\" ({}) in plugin \"{}\".\n"
454 " Type specified: <{}> (aka {})\n"
455 " Type returned by callback: <{}> (aka {})",
458 &entry.ResultType->TypeID(),
465 ciFunction.
Callback = entry.Callback;
487 for(
auto& entry : table )
490 if( !entry.Type.IsSameType( valueToCast ) )
494 bool operatorIsIn=
true;
495 if( entry.OperatorsAccepted !=
nullptr
496 && entry.OperatorsAccepted->size() > 0 )
499 for(
auto& op : *entry.OperatorsAccepted )
509 && entry.OperatorsDeclined !=
nullptr
510 && entry.OperatorsDeclined->size() > 0 )
512 for(
auto& op : *entry.OperatorsDeclined )
543 if( entry !=
nullptr )
575 entry= findAutoCastEntry(
AutoCasts, ciAutoCast, 1 );
576 if( entry !=
nullptr )
bool IsSameType(const Box &other) const
const std::type_info & TypeID() const
const Placeholder & Data() const
#define ALIB_CALLER_NULLED
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_IGNORE_UNUSED_MACRO
#define ALIB_ASSERT_ERROR(cond, domain,...)
Box(*)(Scope &scope, ArgIterator argsBegin, ArgIterator argsEnd) CallbackDecl
StdVectorMono< Box >::iterator ArgIterator
const alib::boxing::Box & Type
@ AllowEmptyParenthesesForIdentifierFunctions
@ AliasEqualsOperatorWithAssignOperator
@ AllowOmittingParenthesesOfParameterlessFunctions
@ MissingFunctionParentheses
@ IdentifierWithFunctionParentheses
@ Right
Denotes the right side of something.
@ Left
Denotes the left side of something.
@ Relative
Referring to a relative value.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
lang::integer integer
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
exceptions::Exception Exception
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
bool RhsIsConst
Input: denotes if rhs argument is constant value.
String ReverseCastFunctionNameRhs
String ReverseCastFunctionName
const nchar * DbgCallbackNameRhs
bool LhsIsConst
Input: Denotes if the lhs-argument is a constant value.
bool NonConstArgIsResult
Output: Used with optimization, see this struct's documentation for more information.
bool RhsIsConst
Input: Denotes if the rhs-argument is a constant value.
String & Operator
Input/Output: The binary operator symbol.
AString & Name
Input: The identifier name to search.
void AddFunctionsWithNonMatchingArguments(const String &signature)
String & Operator
Input/Output: The unary operator.
const nchar * DbgCallbackName
CallbackDecl Callback
Output: The native C++ callback function to be set by one of the plug-ins.
Compiler & Cmplr
The compiler that this plug-in is attached to.
StdVectorMono< Box > * Stack
static ALIB_DLL Box Integer
Sample type-box for integer types. (Precisely for type integer.)
An entry of the field AutoCasts. Defines auto-casts for custom types.
const char * DbgCallbackName
String ReverseCastFunctionName
Key type for operator hash maps Operators and OperatorAliases.
Hash functor for operator hash map.
Key type for operator hash maps Operators and OperatorAliases.
void AddOperatorAlias(const String &alias, Type lhsType, Type rhsType, const String &op)
HashMap< MonoAllocator, OperatorKey, std::tuple< CallbackDecl, Box, CTInvokable ALIB_DBG(, const char *) >, OperatorKey::Hash, OperatorKey::EqualTo > Operators
virtual ALIB_DLL bool TryCompilation(CIFunction &ciFunction) override
void AddOperatorAliases(OperatorAliasTableEntry(&table)[TCapacity])
const std::tuple< String, lang::Side, Type, const Box &, const Box & > BinaryOpOptimizationsTableEntry
std::vector< ConstantIdentifierEntry > ConstantIdentifiers
List of identifiers that return constant values to be compiled by this plug-in.
void AddBinaryOpOptimizations(BinaryOpOptimizationsTableEntry(&table)[TCapacity])
HashMap< MonoAllocator, BinOpOptKey, Box, BinOpOptKey::Hash, BinOpOptKey::EqualTo > BinaryOperatorOptimizations
std::vector< AutoCastEntry > AutoCasts
List of auto-casts to be compiled by this plug-in.
void AddOperators(OperatorTableEntry(&table)[TCapacity])
std::vector< FunctionEntry > Functions
List of functions to be compiled by this plug-in.
void AddOperator(const String &op, Type lhsType, Type rhsType, CallbackDecl callback, const char *dbgCallbackName, Type resultType, CTInvokable cti)
HashMap< MonoAllocator, OperatorKey, String, OperatorKey::Hash, OperatorKey::EqualTo > OperatorAliases
const std::tuple< String, Type, Type, String > OperatorAliasTableEntry
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
detail::UnionIntegrals Integrals
Collection of integrals of different sizes, placed next to each other.
integer Array[2]
Array of 64-bit signed integrals of length 2 on 64-bit platform, 1 on a 32-bit platform.