13 const char* dbgCallbackName,
22 std::make_tuple( callback, resultType, cti
ALIB_DBG(, dbgCallbackName) ) );
25 "Binary operator '{}' already defined for types <{}> (aka {})\n"
26 " and <{}> (aka {}).",
32 std::make_tuple( callback, resultType, cti
ALIB_DBG(, dbgCallbackName) ) );
40 #define OP std::get<0>( *(table + i) )
41 #define LHS_TYPE std::get<1>( *(table + i) ).TypeID()
42 #define RHS_TYPE std::get<2>( *(table + i) ).TypeID()
43 #define CBFUNC std::get<3>( *(table + i) )
44 #define RESULTTYPE std::get<ALIB_REL_DBG(4,5)>( *(table + i) )
45 #define CTINVOKE std::get<ALIB_REL_DBG(5,6)>( *(table + i) )
47 for(
size_t i= 0 ; i < length ; ++i ) {
52 std::make_tuple( CBFUNC, RESULTTYPE, CTINVOKE
53 ALIB_DBG(, std::get<4>( *(table + i) )) ) );
56 "Binary operator '{}' already defined for types <{}> (aka {})\n"
57 " and <{}> (aka {}).",
58 OP,
Cmplr.TypeName(std::get<1>( *(table+i))), &LHS_TYPE,
59 Cmplr.TypeName(std::get<2>( *(table+i))), &RHS_TYPE )
63 std::make_tuple( CBFUNC, RESULTTYPE, CTINVOKE
64 ALIB_DBG(, std::get<4>( *(table + i) )) ) );
69 "This is rather an internal error of HashTable: The number of buckets "
70 "of hash map 'Operators' increased, although it was reserved above." )
87 "Binary operator alias '{}' already defined for types <{}> (aka {})\n"
100 #define ALIAS std::get<0>( *(table + i) )
101 #define LHS_TYPE std::get<1>( *(table + i) ).TypeID()
102 #define RHS_TYPE std::get<2>( *(table + i) ).TypeID()
103 #define OP std::get<3>( *(table + i) )
105 for(
size_t i= 0 ; i < length ; ++i ) {
111 "Binary operator alias '{}' already defined for types <{}> (aka {})\n"
112 "and <{}> (aka {}).",
113 ALIAS,
Cmplr.TypeName( std::get<1>( *(table + i) ) ), &LHS_TYPE,
114 Cmplr.TypeName( std::get<2>( *(table + i) ) ), &RHS_TYPE )
139 ciUnaryOp.
Operator= aliasIt.Mapped();
144 auto opIt=
Operators.Find( key, hashCode );
148 auto& op= opIt.Mapped();
151 if( ciUnaryOp.
ArgIsConst && std::get<2>(op) ) {
158 "Type mismatch in definition of unary operator \"{}\" ({}) in plugin \"{}\".\n"
159 " Type specified: <{}> (aka {})\n"
160 " Type returned by callback: <{}> (aka {})",
163 &std::get<1>(op).TypeID(),
168 ciUnaryOp.
Callback = std::get<0>(op);
181 #define OP std::get<0>( *(table + i) )
182 #define SIDE std::get<1>( *(table + i) )
183 #define CONSTVAL std::get<2>( *(table + i) )
184 #define CONSTTYPE std::get<2>( *(table + i) ).TypeID()
185 #define OTHERBOX std::get<3>( *(table + i) )
186 #define OTHERTYPE std::get<3>( *(table + i) ).TypeID()
187 #define RESULT std::get<4>( *(table + i) )
189 for(
size_t i= 0 ; i < length ; ++i ) {
195 "Optimization already defined for operator \"{}\" with {!Lower}-hand "
196 "constant value \"{}\" of type <{}> (aka {}) and with "
197 "{!L}-hand type <{}> (aka {}).",
198 OP, SIDE, CONSTVAL,
Cmplr.TypeName(CONSTVAL), &CONSTTYPE,
229 ciBinaryOp.
Operator= aliasIt.Mapped();
232 #define CBFUNC std::get<0>(op)
233 #define RESULTTYPE std::get<1>(op)
234 #define CT_INVOKABLE std::get<2>(op)
236 # define DBG_CB_NAME std::get<3>(op)
240 auto opIt =
Operators.Find( key, hashCode );
244 auto& op= opIt.Mapped();
255 "Type mismatch in definition of binary operator \"{}\" ({}) of plugin \"{}\".\n"
256 " Type specified: <{}> (aka {})\n"
257 " Type returned by callback: <{}> (aka {})",
260 &RESULTTYPE .TypeID(),
282 if( entryIt.Mapped().IsType<
void>() )
313 if( ciFunction.
QtyArgs() == 0 ) {
315 if ( entry.Descriptor.Match( name ) ) {
329 ciFunction.
Name.
Reset( entry.Descriptor );
336 if( entry.Descriptor.Match( name ) ) {
338 size_t qtyGiven = ciFunction.
QtyArgs();
339 size_t qtyRequired = entry.SignatureLength;
340 bool isVariadic =
false;
341 if( entry.SignatureLength > 0 && ( entry.Signature[entry.SignatureLength - 1] ==
nullptr
342 || entry.Signature[entry.SignatureLength - 1]->IsType<
void>() ) )
348 size_t qtyShared = (std::min)( qtyGiven, qtyRequired );
349 bool sharedAreSameType =
true;
350 for(
size_t i= 0; i != qtyShared ; ++i )
351 sharedAreSameType&= ciFunction.
Arg(i).
IsSameType( *entry.Signature[i] );
354 if( !sharedAreSameType
355 || ( isVariadic ? qtyGiven < qtyRequired
356 : qtyGiven != qtyRequired ) )
360 Cmplr.WriteFunctionSignature( entry.Signature,
361 entry.SignatureLength,
371 && entry.Signature !=
nullptr
377 && entry.Signature ==
nullptr
383 ciFunction.
Name.
Reset( entry.Descriptor );
385 if( !entry.Callback ) {
398 "Type mismatch in definition of function \"{}\" ({}) in plugin \"{}\".\n"
399 " Type specified: <{}> (aka {})\n"
400 " Type returned by callback: <{}> (aka {})",
403 &entry.ResultType->TypeID(),
410 ciFunction.
Callback = entry.Callback;
430 for(
auto& entry : table ) {
432 if( !entry.Type.IsSameType( valueToCast ) )
436 bool operatorIsIn=
true;
437 if( entry.OperatorsAccepted !=
nullptr
438 && entry.OperatorsAccepted->size() > 0 )
441 for(
auto& op : *entry.OperatorsAccepted )
449 && entry.OperatorsDeclined !=
nullptr
450 && entry.OperatorsDeclined->size() > 0 )
452 for(
auto& op : *entry.OperatorsDeclined )
478 if( entry !=
nullptr ) {
506 entry= findAutoCastEntry(
AutoCasts, ciAutoCast, 1 );
507 if( entry !=
nullptr ) {
#define ALIB_CALLER_NULLED
#define ALIB_POP_ALLOWANCE
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_ALLOW_UNUSED_MACRO
bool IsSameType(const Box &other) const
const std::type_info & TypeID() const
const Placeholder & Data() const
Box(*)(Scope &scope, ArgIterator argsBegin, ArgIterator argsEnd) CallbackDecl
const alib::boxing::Box & Type
@ AllowEmptyParenthesesForIdentifierFunctions
@ AliasEqualsOperatorWithAssignOperator
@ AllowOmittingParenthesesOfParameterlessFunctions
@ MissingFunctionParentheses
@ IdentifierWithFunctionParentheses
StdVectorMA< Box >::iterator ArgIterator
@ Right
Denotes the right side of something.
@ Left
Denotes the left side of something.
@ Relative
Referring to a relative value.
lang::integer integer
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
exceptions::Exception Exception
Type alias in namespace #"%alib".
LocalString< 256 > String256
Type alias name for #"TLocalString;TLocalString<character,256>".
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.
StdVectorMA< Box > * Stack
static Box Integer
Sample type-box for integer types. (Precisely for type #"lang::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 #"Calculus::Operators" and #"Calculus::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
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
virtual 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
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 two on 64-bit platform, one on a 32-bit platform.