This built-in CompilerPlugin of ALib Expressions primarily compiles unary and binary operators for permutations of types Boolean, Integer and Float.
By default, this plug-in is automatically created and inserted into each instance of class Compiler with the invocation of SetupDefaults.
General Notes:
size > 81920
size > 8 * 1024
are resulting in an identical expression program and thus the latter has no evaluation penalty.0.0 and 1.1.1.true and false.true and false.'==' is aliased with '='.'&&') and '||' are aliased with operators '&' and '|'.Constant Identifiers:
The following constant identifiers provide variants for boolean values. No abbreviation is allowed.
| Return Type | Name | Description |
|---|---|---|
| Boolean | True | Returns constant true. |
| Boolean | False | Returns constant false. |
| Boolean | Yes | Returns constant true. |
| Boolean | No | Returns constant false. |
| Boolean | On | Returns constant true. |
| Boolean | Off | Returns constant false. |
Type Conversion Functions:
| Return Type | Name | Min. Abbreviation | Signature | Description |
|---|---|---|---|---|
| Boolean | Boolean | bool | <any> | Converts any type of boxed value by invoking box-function FIsTrue. |
| Integer | Integer | int | Boolean | Converts true to 1, false to 0. |
| Integer | Integer | int | Integer | Does nothing (identity function). |
| Integer | Integer | int | Float | Returns the integral part of a floating point number. |
| Float | Float | float | Boolean | Converts true to 1.0, false to 0.0. |
| Float | Float | float | Integer | Converts an integral value to floating point. |
| Float | Float | float | Float | Does nothing (identity function). |
Functions:
| Return Type | Name | Min. Abbreviation | Signature | Description |
|---|---|---|---|---|
| Integer | Length | len | <any array> | Returns the length of an array.
|
Unary Operators:
| Return Type | Operator | Argument Type | Description |
|---|---|---|---|
| Integer | + | Boolean | Converts the boolean value to integer. |
| Integer | + | Integer | Identity operator (has no effect). |
| Float | + | Float | Identity operator (has no effect). |
| Integer | - | Boolean | Converts the boolean value to integer and negates it. |
| Integer | - | Integer | Negates an integral value. |
| Float | - | Float | Negates a floating point value. |
| Boolean | ! | Boolean | Boolean not operator. |
| Boolean | ! | Integer | Returns the result of the comparison with 0. |
| Boolean | ! | Float | Returns the result of the comparison with 0.0. |
| Integer | ~ | Integer | Bitwise integral negation. |
Binary Operators:
| Return Type | Lhs Type | Operator | Rhs Type | Description |
|---|---|---|---|---|
| Integer | Boolean | * | Boolean | Multiplication with interpreting both boolean operands as integral value 0 or 1. |
| Integer | Boolean | * | Integer | Multiplication with interpreting the boolean operand as integral value 0 or 1. |
| Float | Boolean | * | Float | Multiplication with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | * | Boolean | Multiplication with interpreting the boolean operand as integral value 0 or 1. |
| Integer | Integer | * | Integer | Multiplication. |
| Float | Integer | * | Float | Multiplication. |
| Float | Float | * | Boolean | Multiplication with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Float | Float | * | Integer | Multiplication. |
| Float | Float | * | Float | Multiplication. |
| Integer | Boolean | / | Integer | Division with interpreting the boolean operand as integral value 0 or 1. |
| Float | Boolean | / | Float | Division with interpreting the boolean operand as integral value 0 or 1. |
| Integer | Integer | / | Integer | Division. |
| Float | Integer | / | Float | Division. |
| Float | Float | / | Integer | Division. |
| Float | Float | / | Float | Division. |
| Integer | Boolean | % | Integer | Modulo with interpreting the boolean operand as integral value 0 or 1. |
| Float | Boolean | % | Float | Modulo with interpreting the boolean operand as integral value 0 or 1. |
| Integer | Integer | % | Integer | Modulo. |
| Float | Integer | % | Float | Modulo. |
| Float | Float | % | Integer | Modulo. |
| Float | Float | % | Float | Modulo. |
| Integer | Boolean | + | Boolean | Addition with interpreting both boolean operands as integral value 0 or 1. |
| Integer | Boolean | + | Integer | Addition with interpreting the boolean operand as integral value 0 or 1. |
| Float | Boolean | + | Float | Addition with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | + | Boolean | Addition with interpreting the boolean operand as integral value 0 or 1. |
| Integer | Integer | + | Integer | Addition. |
| Float | Integer | + | Float | Addition. |
| Float | Float | + | Boolean | Addition with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Float | Float | + | Integer | Addition. |
| Float | Float | + | Float | Addition. |
| Integer | Boolean | - | Boolean | Subtraction with interpreting both boolean operands as integral value 0 or 1. |
| Integer | Boolean | - | Integer | Subtraction with interpreting the boolean operand as integral value 0 or 1. |
| Float | Boolean | - | Float | Subtraction with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | - | Boolean | Subtraction with interpreting the boolean operand as integral value 0 or 1. |
| Integer | Integer | - | Integer | Subtraction. |
| Float | Integer | - | Float | Subtraction. |
| Float | Float | - | Boolean | Subtraction with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Float | Float | - | Integer | Subtraction. |
| Float | Float | - | Float | Subtraction. |
| Integer | Boolean | << | Integer | Bitwise shift left with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | << | Boolean | Bitwise shift left with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | << | Integer | Bitwise shift left. |
| Integer | Boolean | >> | Integer | Bitwise shift right with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | >> | Boolean | Bitwise shift right with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Integer | Integer | >> | Integer | Bitwise shift right. |
| Boolean | Boolean | < | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | < | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | < | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | < | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | < | Integer | Comparison operator. |
| Boolean | Integer | < | Float | Comparison operator. |
| Boolean | Float | < | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | < | Integer | Comparison operator. |
| Boolean | Float | < | Float | Comparison operator. |
| Boolean | Boolean | <= | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | <= | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | <= | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | <= | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | <= | Integer | Comparison operator. |
| Boolean | Integer | <= | Float | Comparison operator. |
| Boolean | Float | <= | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | <= | Integer | Comparison operator. |
| Boolean | Float | <= | Float | Comparison operator. |
| Boolean | Boolean | > | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | > | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | > | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | > | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | > | Integer | Comparison operator. |
| Boolean | Integer | > | Float | Comparison operator. |
| Boolean | Float | > | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | > | Integer | Comparison operator. |
| Boolean | Float | > | Float | Comparison operator. |
| Boolean | Boolean | >= | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | >= | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | >= | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | >= | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | >= | Integer | Comparison operator. |
| Boolean | Integer | >= | Float | Comparison operator. |
| Boolean | Float | >= | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | >= | Integer | Comparison operator. |
| Boolean | Float | >= | Float | Comparison operator. |
| Boolean | Boolean | == | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | == | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | == | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | == | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | == | Integer | Comparison operator. |
| Boolean | Integer | == | Float | Comparison operator. |
| Boolean | Float | == | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | == | Integer | Comparison operator. |
| Boolean | Float | == | Float | Comparison operator. |
| Boolean | Boolean | != | Boolean | Comparison operator with interpreting both boolean operands as integral value 0 or 1. |
| Boolean | Boolean | != | Integer | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Boolean | != | Float | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Integer | != | Boolean | Comparison operator with interpreting the boolean operand as integral value 0 or 1. |
| Boolean | Integer | != | Integer | Comparison operator. |
| Boolean | Integer | != | Float | Comparison operator. |
| Boolean | Float | != | Boolean | Comparison operator with interpreting the boolean operand as floating point value 0.0 or 1.0. |
| Boolean | Float | != | Integer | Comparison operator. |
| Boolean | Float | != | Float | Comparison operator. |
| Integer | Integer | & | Integer | Bitwise boolean "and" operator. |
| Integer | Integer | | | Integer | Bitwise boolean "or" operator. |
| Integer | Integer | ^ | Integer | Bitwise boolean "xor" operator. |
| Boolean | Boolean | && | Boolean | Logical boolean "and" operator. |
| Boolean | Boolean | && | Integer | Logical boolean "and" operator. The integral operand is tested for a non-zero value. |
| Boolean | Boolean | && | Float | Logical boolean "and" operator. The floating point operand is tested for a non-zero value. |
| Boolean | Integer | && | Boolean | Logical boolean "and" operator. The integral operand is tested for a non-zero value. |
| Boolean | Integer | && | Integer | Logical boolean "and" operator. The integral operands are tested for a non-zero value. |
| Boolean | Integer | && | Float | Logical boolean "and" operator. The integral and floating point operands are tested for a non-zero value. |
| Boolean | Float | && | Boolean | Logical boolean "and" operator. The floating point operand is tested for a non-zero value. |
| Boolean | Float | && | Integer | Logical boolean "and" operator. The integral and floating point operands are tested for a non-zero value. |
| Boolean | Float | && | Float | Logical boolean "and" operator. The floating point operands are tested for a non-zero value. |
| Boolean | Boolean | || | Boolean | Logical boolean "or" operator. |
| Boolean | Boolean | || | Integer | Logical boolean "or" operator. The integral operand is tested for a non-zero value. |
| Boolean | Boolean | || | Float | Logical boolean "or" operator. The floating point operand is tested for a non-zero value. |
| Boolean | Integer | || | Boolean | Logical boolean "or" operator. The integral operand is tested for a non-zero value. |
| Boolean | Integer | || | Integer | Logical boolean "or" operator. The integral operands are tested for a non-zero value. |
| Boolean | Integer | || | Float | Logical boolean "or" operator. The integral and floating point operands are tested for a non-zero value. |
| Boolean | Float | || | Boolean | Logical boolean "or" operator. The floating point operand is tested for a non-zero value. |
| Boolean | Float | || | Integer | Logical boolean "or" operator. The integral and floating point operands are tested for a non-zero value. |
| Boolean | Float | || | Float | Logical boolean "or" operator. The floating point operands are tested for a non-zero value. |
Definition at line 225 of file arithmetics.inl.
Public Method Index: | |
| ALIB_DLL | Arithmetics (Compiler &compiler) |
| virtual | ~Arithmetics () override |
| Virtual destructor. | |
| virtual ALIB_DLL bool | TryCompilation (CIFunction &ciFunction) override |
Public Method Index: inherited from alib::expressions::plugins::Calculus | |
| Calculus (const NString &name, Compiler &compiler, CompilePriorities pPriority) | |
| virtual | ~Calculus () override |
| Virtual destructor. | |
| ALIB_DLL void | AddBinaryOpOptimizations (BinaryOpOptimizationsTableEntry *table, size_t length) |
| template<size_t TCapacity> | |
| void | AddBinaryOpOptimizations (BinaryOpOptimizationsTableEntry(&table)[TCapacity]) |
| void | AddOperator (const String &op, Type lhsType, Type rhsType, CallbackDecl callback, const char *dbgCallbackName, Type resultType, CTInvokable cti) |
| void | AddOperatorAlias (const String &alias, Type lhsType, Type rhsType, const String &op) |
| void | AddOperatorAliases (OperatorAliasTableEntry *table, size_t length) |
| template<size_t TCapacity> | |
| void | AddOperatorAliases (OperatorAliasTableEntry(&table)[TCapacity]) |
| ALIB_DLL void | AddOperators (OperatorTableEntry *table, size_t length) |
| template<size_t TCapacity> | |
| void | AddOperators (OperatorTableEntry(&table)[TCapacity]) |
| virtual ALIB_DLL bool | TryCompilation (CIAutoCast &autoCast) override |
| virtual ALIB_DLL bool | TryCompilation (CIBinaryOp &ciBinaryOp) override |
| virtual ALIB_DLL bool | TryCompilation (CIUnaryOp &ciUnaryOp) override |
Public Method Index: inherited from alib::expressions::CompilerPlugin | |
| CompilerPlugin (const NString &name, Compiler &compiler, CompilePriorities pPriority) | |
| virtual | ~CompilerPlugin () |
| Virtual destructor. | |
Public Method Index: inherited from alib::lang::Plugin< Compiler, CompilePriorities > | |
| PrioritiesType | GetPriority () const |
Additional Inherited Members | |
Public Type Index: inherited from alib::expressions::plugins::Calculus | |
| using | BinaryOpOptimizationsTableEntry = const std::tuple<String, lang::Side, Type, const Box&, const Box&> |
| using | CTInvokable = bool |
| using | OperatorAliasTableEntry = const std::tuple<String, Type, Type, String> |
| using | OperatorTableEntry |
Public Type Index: inherited from alib::lang::Plugin< Compiler, CompilePriorities > | |
| using | PluginType |
| This exposes the template parameter TPlugin to the outer world. | |
| using | PrioritiesType |
| This exposes the template parameter pTPlugin to the outer world. | |
Public Static Field Index: inherited from alib::expressions::plugins::Calculus | |
| static constexpr CTInvokable | CTI = true |
| static constexpr CTInvokable | ETI = false |
Public Field Index: inherited from alib::expressions::plugins::Calculus | |
| MonoAllocator | allocator |
| std::vector< AutoCastEntry > | AutoCasts |
| List of auto-casts to be compiled by this plug-in. | |
| HashMap< MonoAllocator, BinOpOptKey, Box, BinOpOptKey::Hash, BinOpOptKey::EqualTo > | BinaryOperatorOptimizations |
| std::vector< ConstantIdentifierEntry > | ConstantIdentifiers |
| List of identifiers that return constant values to be compiled by this plug-in. | |
| std::vector< FunctionEntry > | Functions |
| List of functions to be compiled by this plug-in. | |
| HashMap< MonoAllocator, OperatorKey, String, OperatorKey::Hash, OperatorKey::EqualTo > | OperatorAliases |
| HashMap< MonoAllocator, OperatorKey, std::tuple< CallbackDecl, Box, CTInvokable ALIB_DBG(, const char *) >, OperatorKey::Hash, OperatorKey::EqualTo > | Operators |
Public Field Index: inherited from alib::expressions::CompilerPlugin | |
| Compiler & | Cmplr |
| The compiler that this plug-in is attached to. | |
| const NString | Name |
Protected Field Index: inherited from alib::lang::Plugin< Compiler, CompilePriorities > | |
| PrioritiesType | priority |
| The priority of this plug-in. | |
Protected Method Index: inherited from alib::lang::Plugin< Compiler, CompilePriorities > | |
| Plugin (PrioritiesType pPriority) | |
Constructor. Creates the hash maps.
| compiler | The compiler we will get attached to. |
|
inlineoverridevirtual |
Virtual destructor.
Definition at line 236 of file arithmetics.inl.
|
overridevirtual |
Invokes parent's method. On failure, tries to compile function Length(array).
| [in,out] | ciFunction | The compilation information. |
true if an entry was found. false otherwise. Reimplemented from alib::expressions::plugins::Calculus.