ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
compilerplugin.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_expressions of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace expressions {
9
10//==================================================================================================
11/// This interface class represents "plug-ins" which are attachable to container class
12/// \alib{expressions;Compiler}. The compiler uses the plug-ins to <em>"compile"</em> single
13/// nodes of <em>abstract syntax trees</em>, which are the intermediate, internal result of parsing
14/// expression strings.
15///
16/// In depth information on how this class is used is given in the
17/// \ref alib::expressions "User Manual And Tutorial" of module \alib_expressions_nl.
18///
19/// The overloaded methods #TryCompilation are not abstract, but have a default implementation
20/// that return constant \c false. A plug-in derived from this class needs to override only those
21/// methods that represent syntax elements of an expression, that it volunteers to take
22/// responsibility for.
23///
24/// The overloaded methods have one input/output parameter which is of one of the following types:
25/// - \alib{expressions::CompilerPlugin;CIFunction},
26/// - \alib{expressions::CompilerPlugin;CIUnaryOp},
27/// - \alib{expressions::CompilerPlugin;CIBinaryOp} or
28/// - \alib{expressions::CompilerPlugin;CIAutoCast}.
29///
30/// These inner types of this struct are derived from likewise inner struct
31/// \alib{expressions::CompilerPlugin;CompilationInfo}, which provides all output members and
32/// those input members that are common between the four descendants. In other words, the variants
33/// of the struct provide detail information on the node that is actually compiled.
34///
35/// When overriding one of the overloaded methods #TryCompilation, it has to be checked if
36/// the custom plug-in is responsible for the permutation of given parameter types which are passed.
37/// If so, the actual 'compilation' is performed, by filling the result members of the given
38/// struct and by returning \c true. Each overloaded
39/// method provides a suitable return type, which are defined as inner types of this class.
40///
41/// The output information comprises a \ref alib_expressions_prereq_sb "sample box" that
42/// determines the result type of the native C++ function that is later invoked when the expression
43/// is evaluated against a scope.
44/// Together with this type information, the pointer to the callback function itself needs to be
45/// set in the given struct.
46///
47/// Alternatively, if a constant result is to be returned, the pointer to the callback function
48/// might be kept \e nulled. In this case, the \b %Box object that represents the result type
49/// of the callback function is used to provide the constant value, instead of just a sample value.
50///
51/// There are two possibilities, why a compiler plug-in might return a constant value, instead of
52/// a function:
53/// 1. \e Identifiers (parameterless functions) might just represent constant values. (For example
54/// identifiers \c "True" or \c "Monday" do that, while \c "Today" returns a callback function.).
55/// 2. The compiler provides information about whether the given parameters are constant values.
56/// In this case, a compiler plug-in may decide to evaluate the result of the function at
57/// compile-time. This is often, but not always possible and depends largely on the fact
58/// if scope information is used with the function as well. <br>
59/// For more details on this topic see manual section
60/// \ref alib_expressions_details_optimizations "11.5 Optimizations".
61///
62/// \attention
63/// If constant data is returned, it has to be assured, that the contents of the returned
64/// \b %Box remains valid during the life-cycle of the expression. This is ensured for all
65/// C++ fundamental types. For custom types it depends on where the constant value is received
66/// from and how boxing is performed.
67/// (By default, custom types bigger as two "words" (2 x 64/32 bits) are boxed as pointers to the
68/// assigned object.)<br>
69/// Field \doxlinkproblem{structalib_1_1expressions_1_1CompilerPlugin_1_1CompilationInfo.html;a6696af828b4392429a520f56c258c553;CompilationInfo::CompileTimeScope}
70/// is to be used for compile-time allocations.
71///
72/// The plug-ins are attached to the \b %Compiler using a dedicated prioritization defined
73/// with (arithmetical) enum type \alib{expressions;CompilePriorities}.
74/// This means, that if a higher prioritized plug-in already compiles a certain
75/// permutation of expression node type and argument types, then a lower prioritized plug-in is not
76/// even asked to do so. With this concept, <b>ALib Expressions</b> provides a lot of flexibility:
77/// the built-in operators and identifiers can be unplugged completely or just sparsely "superseded"
78/// in certain aspects by adding a custom \b %CompilerPlugin with a higher priority than that of
79/// the built-in one.
80///
81/// \note
82/// Instead of deriving from this struct, it is recommended to consider convenience struct
83/// \alib{expressions;plugins::Calculus} instead.
84///
85/// \note
86/// More information on this topic is given in manual section
87/// \ref alib_expressions_cpcc_calculus "5.4 Class Calculus"
88//==================================================================================================
89struct CompilerPlugin : public lang::Plugin<Compiler, CompilePriorities>
90{
91 /// The name of the plug-in. This is used with exception information and with
92 /// \alib{expressions;DbgList;program listings} which are available in
93 /// debug-compilations of the library.
95
96 /// The compiler that this plug-in is attached to.
98
99 /// Public inner base struct which provides input and output information for compiling
100 /// single entities (nodes of the \e AST) of a parsed expression.
101 ///
102 /// Descendant types
103 /// - \alib{expressions::CompilerPlugin;CIFunction},
104 /// - \alib{expressions::CompilerPlugin;CIUnaryOp} and
105 /// - \alib{expressions::CompilerPlugin;CIBinaryOp}
106 ///
107 /// extend this struct with input information, specific to the type of <em>AST</em>-node
108 /// currently compiled. Special, descendant type
109 /// - \alib{expressions::CompilerPlugin;CIAutoCast}
110 ///
111 /// in addition adds specific output members.
112 ///
113 /// Together, these four descendants comprise the parameters of the four overloaded methods
114 /// \alib{expressions::CompilerPlugin;TryCompilation}.
116 {
117 /// The scope found here is the same object passed to method
118 /// \alib{expressions;Compiler::Compile}, which internally invokes the overloaded
119 /// methods #TryCompilation, that receive an object of this type.
120 ///
121 /// If a compiled expression syntax element evaluates to a constant stored in
122 /// #TypeOrValue it has to be ensured that the boxed data is to available during the
123 /// life-cycle of the expression.
124 ///
125 /// To allocate custom compilation data, a custom, derived type, might, for example, be
126 /// extended with simple\c std::vector of pointers to the created objects.
127 /// (Attention: Vectors of value-types must not be used, as with their growth, the objects
128 /// get moved within the heap memory!).<br>.
129 /// Any data allocated, is to be deleted in the virtual destructor of the custom scope type.
131
132 /// An allocator to be used exclusively during compile-time.
133 /// Its memory is cleared (respectively reset to a previous state) after the compilation
134 /// completed.<br>
135 /// (Refers to object \alib{expressions;Compiler::allocator}.)
137
138 /// Input: A start iterator to \ref alib_expressions_prereq_sb "sample boxes"
139 /// that provide the argument types to search a native callback function for.<br>
140 /// In case that descendant classes denote that arguments found in this iterator are
141 /// constant, then the boxes are not just sample boxes, but contain the constant values.
143
144 /// Input: The end iterator to #ArgsBegin. The expression <c>ArgsEnd - ArgsBegin</c> may be
145 /// used to receive the number of arguments provided.
147
148 #if ALIB_DEBUG
149 /// Output: The C++ name of the callback function. This field is available only in debug
150 /// compilations of the library. Hence, setting it must be performed with preprocessor
151 /// conditionals.
152 const nchar* DbgCallbackName =nullptr;
153 #endif
154
155 /// Output: The native C++ callback function to be set by one of the plug-ins.
157
158 /// Output: Specifies the return type of #Callback, respectively, as the name indicates, the
159 /// result value in case of constant results.<br>
160 /// Note that in case of constant compile-time values, it might be necessary to allocate
161 /// compile-time memory for the values. For this, field #CompileTimeScope is to be used.
162 Box TypeOrValue = nullptr;
163
164
165 /// Constructor.
166 /// @param scope The scope usable for allocation of constant values (compile-time
167 /// allocations). Assigned to field #CompileTimeScope.
168 /// @param allocator Assigned to field #CompileTimeAllocator.
169 ///
170 CompilationInfo( Scope& scope, MonoAllocator& allocator )
171 : CompileTimeScope ( scope )
172 , CompileTimeAllocator ( allocator )
173 , ArgsBegin ( scope.Stack->begin())
174 , ArgsEnd ( scope.Stack->end() ) {}
175 };
176
177 /// Info struct for compiling expression identifiers and functions.
178 /// This struct is used with method \ref TryCompilation(CIFunction&) to provide information
179 /// to derived compiler plug-ins, as well as to receive information back.
181 {
182 /// Input: The identifier name to search.
184
185 /// Input: If the function was given as a pure "identifier" this flag is \c true.
186 /// \see See also flag
187 /// \alib{expressions::Compilation;AllowOmittingParenthesesOfParameterlessFunctions} of
188 /// field \see See also \alib{expressions;Compiler::CfgCompilation.}.
190
191 /// Input: Denotes if all arguments provided are constant values. Operator callbacks that do
192 /// not use context information from the scope, should calculate the then constant result
193 /// and return this value instead of the callback method. (Compile-time optimization.)
195
196 /// A plug-in may add names of functions that matched, while the arguments did not.
197 /// This will be stored in the details of a potential exception, if no other plug-in
198 /// compiles this function and may be displayed to the end-user.
199 ///
200 /// To add entries here, convenience method #AddFunctionsWithNonMatchingArguments is
201 /// provided.
203
204 /// Constructor.
205 /// @param scope Passed to parent.
206 /// @param compileTimeAllocator Passed to parent.
207 /// @param name Stored in #Name.
208 /// @param isIdentifier Stored in #IsIdentifier.
209 /// @param argsAreConst Passed to #AllArgsAreConst.
210 /// @param hints Stored in #FunctionsWithNonMatchingArguments.
212 MonoAllocator& compileTimeAllocator,
213 AString& name,
214 bool isIdentifier,
215 bool argsAreConst,
216 ListMA<String>& hints )
217 : CompilationInfo(scope, compileTimeAllocator)
218 , Name (name)
219 , IsIdentifier (isIdentifier)
220 , AllArgsAreConst(argsAreConst)
222
223
224 /// Returns the number of arguments given.
225 /// @return The number of arguments the function call requested.
226 size_t QtyArgs() { return size_t( ArgsEnd - ArgsBegin ); }
227
228 /// Returns the argument number \p{no}.
229 /// @param no The number of the argument requested.
230 /// @return A reference to the requested argument.
231 Box& Arg( size_t no ) { return *(ArgsBegin + static_cast<ptrdiff_t>( no ) ); }
232
233 /// Convenience method that adds creates a monotonically allocated copy of the given string
234 /// and adds it to list #FunctionsWithNonMatchingArguments.
235 ///
236 /// @param signature The function signature to add.
239 };
240
241 /// Info struct for compiling an unary operator.
242 /// This struct is used with method \ref TryCompilation(CIUnaryOp&) to provide information
243 /// to derived compiler plug-ins, as well as to receive information back.
245 {
246 String& Operator; ///< Input/Output: The unary operator.
247
248 /// Input: Denotes if the argument is a constant value. Operator callbacks that do
249 /// not use context information from the scope, should calculate the then constant result
250 /// and return this value instead of the callback method. (Compile-time optimization.)
252
253
254 /// Constructor.
255 /// @param scope Passed to parent.
256 /// @param compileTimeAllocator Passed to parent.
257 /// @param op Stored in #Operator.
258 /// @param argIsConst Passed to field #ArgIsConst.
259 CIUnaryOp( Scope& scope , MonoAllocator& compileTimeAllocator,
260 String& op , bool argIsConst )
261 : CompilationInfo( scope, compileTimeAllocator )
262 , Operator ( op )
263 , ArgIsConst ( argIsConst ) {}
264 };
265
266 /// Info struct for compiling a binary operator.
267 /// This struct is used with method \ref TryCompilation(CIBinaryOp&) to provide information
268 /// to derived compiler plug-ins, as well as to receive information back.
269 ///
270 /// Information about whether the arguments are constants is separately given for \e lhs and
271 /// \e rhs with fields #LhsIsConst and #RhsIsConst.
272 ///
273 /// If both flags evaluate to \c true, operator callback functions that do not use context
274 /// information from the scope (or otherwise rely on external or random data), should calculate
275 /// the - then constant - result at compile-time and return a constant value instead of the
276 /// callback method.
277 ///
278 /// If exactly one of the argument is constant, then some operators might detect further
279 /// possibilities of optimization. Such optimization is operator-specific but goes along the
280 /// lines of the following samples:
281 ///
282 /// term + 0 -> term
283 /// term - 0 -> term
284 /// term * 0 -> 0
285 /// term * 1 -> term
286 /// term / 1 -> term
287 /// term && false -> false
288 /// term && true -> term
289 /// term || true -> true
290 /// term || false -> term
291 ///
292 /// These cases have in common that the result of the operator is either a constant
293 /// or equals the non-constant argument.
294 ///
295 /// In both cases inherited field \c %Callback is to be left \c nullptr. If the result is
296 /// constant, inherited field \b %TypeOrValue is to be set to the constant value.
297 /// In the second case that the non-constant argument equals the result, this can be indicated
298 /// by setting field #NonConstArgIsResult to \c true. In this case, the compiler will choose
299 /// the non-constant argument and drop the other.
300 ///
301 /// \note
302 /// Class \alib{expressions::plugins;Calculus} which specializes this plug-in class,
303 /// provides a convenient way to define the optimization rules described here, along with
304 /// its mechanics to support binary operator compilation.
306 {
307 String& Operator; ///< Input/Output: The binary operator symbol.
308
309 /// Input: Denotes if the lhs-argument is a constant value.
311
312 /// Input: Denotes if the rhs-argument is a constant value.
314
315 /// Output: Used with optimization, see this struct's documentation for more information.
317
318
319 /// Constructor.
320 /// @param scope Passed to parent.
321 /// @param compileTimeAllocator Passed to parent.
322 /// @param op Stored in #Operator.
323 /// @param lhsIsConst Stored in #LhsIsConst.
324 /// @param rhsIsConst Stored in #RhsIsConst.
325 CIBinaryOp( Scope& scope, MonoAllocator& compileTimeAllocator,
326 String& op, bool lhsIsConst, bool rhsIsConst)
327 : CompilationInfo ( scope, compileTimeAllocator )
328 , Operator ( op )
329 , LhsIsConst ( lhsIsConst )
330 , RhsIsConst ( rhsIsConst )
331 , NonConstArgIsResult( false ) {}
332 };
333
334 /// Info struct for compiling automatic type casts. Such automatic cast is tried to be inserted
335 /// into the expression program by the compiler if:
336 ///
337 /// - An unary operator for a type cannot be found.
338 /// - A binary operator for a combination of types cannot be found.
339 /// - Two different types for \c T and \c F were given with conditional operator <c>Q ? T : F</c>.
340 ///
341 /// For which the scenarios a cast is needed can be determined with field #Operator and also by
342 /// checking the number of given arguments.
343 ///
344 /// Built-in compiler plug-in \alib{expressions::plugins;AutoCast} ignores unary operations.
345 /// For binary operations, it just always tries to match both types to the 'major' one. It does
346 /// this, as it is more probable, that for two same types an operator is available.<br>
347 ///
348 /// In contrast to this, a custom plug-in may choose to cast both values to a joint one or to
349 /// any combination of types that it provides an operator for!
350 ///
351 /// Compile-time optimization is supported with auto-casts the same as with other compilation
352 /// mechanics.
353 /// Information about whether the arguments are constants is separately given for the first and
354 /// second argument with fields #IsConst and #RhsIsConst.
355 ///
356 /// Hence, if a plug-in leaves the parent field
357 /// \doxlinkproblem{structalib_1_1expressions_1_1CompilerPlugin_1_1CompilationInfo.html;ab0a3a9d76927f2237a65d8b2df28469e;Callback}
358 /// and/or field #CallbackRhs
359 /// \e nulled, but stores a constant cast result value in
360 /// \doxlinkproblem{structalib_1_1expressions_1_1CompilerPlugin_1_1CompilationInfo.html;a129f564498f6d55964e394925e2bf6c0;TypeOrValue}
361 /// and/or #TypeOrValueRhs,
362 /// then this is detected by the compiler and instead of inserting a cast function call, the
363 /// original constant value is replaced with the returned constant value(s).
364 ///
365 /// If a cast function is compiled (returned with this struct), and the resulting program
366 /// should be duly \e "decompilable", then along with the callback information, a
367 /// compilable expression function name has to be returned in field
368 /// #ReverseCastFunctionName, respectively #ReverseCastFunctionNameRhs.
369 /// For further information on this topic see
370 /// \ref alib_expressions_details_optimizations_norm "11.5.6 Optimized Expression Strings"
372 {
373 /// The operator that the cast is required for. If this is <b>'?:'</b> then
374 /// the request is made for conditional operator <c>Q ? T : F</c>. In this case, the
375 /// requirement is to cast both given arguments to the same type - otherwise, the
376 /// conditional operator does not compile!
378
379 /// Input: denotes if the unary argument, respectively the lhs argument of a binary
380 /// operator, is a constant value.
382
383 /// Input: denotes if rhs argument is constant value.
385
386 /// Output: Native C++ callback function to cast the first type with.
387 /// \note
388 /// The optional callback function for casting the left-hand side type is returned with
389 /// inherited field \doxlinkproblem{structalib_1_1expressions_1_1CompilerPlugin_1_1CompilationInfo.html;ab0a3a9d76927f2237a65d8b2df28469e;Callback}.
391
392 /// Output: Specifies the return type of #CallbackRhs, respectively, as the name indicates,
393 /// the result value in case of constant a result.<br>
394 /// In case of constant compile-time values, it might be necessary to allocate
395 /// compile-time memory for the values. For this, field #CompileTimeScope is to be used.
396 /// \note
397 /// The optional return type and value casting the left-hand side argument is returned with
398 /// inherited field \doxlinkproblem{structalib_1_1expressions_1_1CompilerPlugin_1_1CompilationInfo.html;a129f564498f6d55964e394925e2bf6c0;TypeOrValue}.
400
401 /// This is the name of the left-hand side cast function, respectively that of the unary
402 /// argument's cast function, that is used when an expression with auto-cast
403 /// functions is \e decompiled to generate compilable, optimized expression strings.
405
406 /// This is the name of the right-hand side cast function that is inserted when an expression
407 /// with an auto-cast functions is \e decompiled to generate compilable, optimized expression
408 /// strings.
410
411 #if ALIB_DEBUG
412 /// Output: The C++ name of the callback function. This field is available only in debug
413 /// compilations of the library. Hence, setting it must be performed with preprocessor
414 /// conditionals.
416 #endif
417
418 /// Constructor.
419 /// @param scope Passed to parent.
420 /// @param compileTimeAllocator Passed to parent.
421 /// @param op Stored in #Operator.
422 /// @param isConst Stored in IsConst.
423 /// @param rhsIsConst Stored in RhsIsConst.
424 CIAutoCast( Scope& scope, MonoAllocator& compileTimeAllocator,
425 String& op, bool isConst, bool rhsIsConst )
426 : CompilationInfo ( scope, compileTimeAllocator )
427 , Operator ( op )
428 , IsConst ( isConst )
429 , RhsIsConst ( rhsIsConst )
430 , CallbackRhs ( nullptr )
431 , TypeOrValueRhs ( nullptr ) {}
432 };
433
434 /// Constructor.
435 /// @param name Assigned to field #Name.
436 /// @param compiler The compiler we will get attached to. Gets stored in field #Cmplr.
437 /// @param pPriority The priority of this plugin.
438 CompilerPlugin( const NString& name, Compiler& compiler, CompilePriorities pPriority )
439 : Plugin(pPriority)
440 , Name( name )
441 , Cmplr( compiler ) {}
442
443 /// Virtual destructor
444 virtual ~CompilerPlugin() {}
445
446
447 /// Used to compile identifiers (parameterless functions ) and functions parsed from
448 /// expression strings.
449 ///
450 /// The function name is given as an in/out parameter. Implementations might (should) choose to
451 /// - on the one hand allow abbreviations and letter case-insensitive identifier recognitions,
452 /// and
453 /// - consequently return 'corrected' identifier names if an identifier name matched and the
454 /// element got compiled.
455 ///
456 /// Such corrected names will appear in the normalized expression strings returned by
457 /// \alib{expressions;ExpressionVal::GetNormalizedString}, in case flag
458 /// \alib{expressions;Normalization::ReplaceFunctionNames} is set in field
459 /// \alib{expressions;Compiler::CfgNormalization}.
460 ///
461 /// On success, this method has to provide a (native C++) callback function that accepts
462 /// start and end iterators of boxed arguments which are of the same time as proposed by
463 /// the corresponding iterators found in parameter \p{ciFunction}, along with the return type
464 /// of that function.
465 ///
466 /// Alternatively, if a constant identifier is compiled or if all parameters are known to be
467 /// constant at compile-time, a constant value might be returned.
468 /// For details of the input and output parameters of the function, see struct
469 /// \alib{expressions::CompilerPlugin;CIFunction}.
470 ///
471 /// @param[in,out] ciFunction The compilation info struct.
472 /// @return Implementations have to return \c true if the given info struct was filled, or in
473 /// other words, if the plug-in chose to compile the <em>AST</em>-node.<br>
474 /// This default implementation returns \c false to indicate that no compilation
475 /// was done.
476 virtual bool TryCompilation( CIFunction& ciFunction ) { (void) ciFunction; return false; }
477
478 /// Used to compile unary operators parsed from expressions.
479 ///
480 /// On success, this method has to provide a native C++ callback function together with
481 /// a \ref alib_expressions_prereq_sb "sample box" that specifies its return type.
482 /// Both are to be stored in output parameter \p{result}.
483 ///
484 /// Alternatively, if field \c %ArgIsConst of the given compilation info struct is \c true,
485 /// a constant value might be returned.
486 /// For details of the input and output parameters of the function, see struct
487 /// \alib{expressions::CompilerPlugin;CIUnaryOp}.
488 ///
489 /// The implementation might allow alias operators. If such alias is found, the used original
490 /// operator should be returned in/out parameter \p{operator}.
491 ///
492 /// Such "corrected" operators will appear in the normalized expression strings returned by
493 /// \alib{expressions;ExpressionVal::GetNormalizedString}, in case flag
494 /// \alib{expressions;Normalization::ReplaceAliasOperators} is set in field
495 /// \alib{expressions;Compiler::CfgNormalization}.
496 ///
497 /// @param[in,out] ciUnaryOp The compilation info struct.
498 /// @return Implementations have to return \c true if the given info struct was filled, or in
499 /// other words, if the plug-in chose to compile the <em>AST</em>-node.<br>
500 /// This default implementation returns \c false to indicate that no compilation
501 /// was done.
502 virtual bool TryCompilation( CIUnaryOp& ciUnaryOp ) { (void) ciUnaryOp; return false; }
503
504 /// Used to compile binary operators parsed from expressions.
505 ///
506 /// On success, this method has to provide a native C++ callback function together with
507 /// a \ref alib_expressions_prereq_sb "sample box" that specifies its return type.
508 /// Both are to be stored in output parameter \p{result}.
509 ///
510 /// Alternatively, depending on fields \c %LhsIsConst and \c %RhsIsConst of the given compilation
511 /// info struct, a constant value might be returned or, as a third alternative, field
512 /// \c %NonConstArgIsResult may be set to \c true, if an "identity" operator is detected
513 /// For details of the input and output parameters of the function, see struct
514 /// \alib{expressions::CompilerPlugin;CIBinaryOp}.
515 ///
516 /// The implementation might allow alias operators. If such alias is found, the used original
517 /// operator should be returned in/out parameter \p{operator}.
518 ///
519 /// Such "corrected" operators will appear in the normalized expression strings returned by
520 /// \alib{expressions;ExpressionVal::GetNormalizedString}, in case flag
521 /// \alib{expressions;Normalization::ReplaceAliasOperators} is set in field
522 /// \alib{expressions;Compiler::CfgNormalization}.
523 ///
524 ///
525 /// @param[in,out] ciBinaryOp The compilation info struct.
526 /// @return Implementations have to return \c true if the given info struct was filled, or in
527 /// other words, if the plug-in chose to compile the <em>AST</em>-node.<br>
528 /// This default implementation returns \c false to indicate that no compilation
529 /// was done.
530 virtual bool TryCompilation( CIBinaryOp& ciBinaryOp ) { (void) ciBinaryOp; return false; }
531
532 /// Used to provide information to the compiler for casting types.
533 ///
534 /// For details on how this method is overridden, consult the documentation of the input/output
535 /// parameter type \alib{expressions::CompilerPlugin;CIAutoCast}.
536 ///
537 ///
538 /// @param[in,out] ciAutoCast The compilation info struct.
539 /// @return Implementations have to return \c true if the given info struct was filled, or in
540 /// other words, if the plug-in chose to provide auto-cast information as requested.<br>
541 /// This default implementation returns \c false to indicate that no compilation
542 /// was done.
543 virtual bool TryCompilation( CIAutoCast& ciAutoCast ) { (void) ciAutoCast; return false; }
544
545};
546
547} // namespace alib[::expressions]
548
549/// Type alias in namespace \b alib.
551
552} // namespace [alib]
#define ALIB_EXPORT
Definition alib.inl:497
Box(*)(Scope &scope, ArgIterator argsBegin, ArgIterator argsEnd) CallbackDecl
StdVectorMA< Box >::iterator ArgIterator
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
Definition list.inl:693
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2198
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
expressions::CompilerPlugin CompilerPlugin
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
Definition box.inl:1149
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189
bool RhsIsConst
Input: denotes if rhs argument is constant value.
CIAutoCast(Scope &scope, MonoAllocator &compileTimeAllocator, String &op, bool isConst, bool rhsIsConst)
CIBinaryOp(Scope &scope, MonoAllocator &compileTimeAllocator, String &op, bool lhsIsConst, bool rhsIsConst)
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)
CIFunction(Scope &scope, MonoAllocator &compileTimeAllocator, AString &name, bool isIdentifier, bool argsAreConst, ListMA< String > &hints)
CIUnaryOp(Scope &scope, MonoAllocator &compileTimeAllocator, String &op, bool argIsConst)
String & Operator
Input/Output: The unary operator.
CompilationInfo(Scope &scope, MonoAllocator &allocator)
CallbackDecl Callback
Output: The native C++ callback function to be set by one of the plug-ins.
virtual bool TryCompilation(CIUnaryOp &ciUnaryOp)
virtual bool TryCompilation(CIFunction &ciFunction)
Compiler & Cmplr
The compiler that this plug-in is attached to.
CompilerPlugin(const NString &name, Compiler &compiler, CompilePriorities pPriority)
virtual bool TryCompilation(CIBinaryOp &ciBinaryOp)
virtual ~CompilerPlugin()
Virtual destructor.
virtual bool TryCompilation(CIAutoCast &ciAutoCast)