Compiler implementation of the D programming language.
Template implementation.
These functions substitute for dynamic_cast. dynamic_cast does not work on earlier versions of gcc.
Is this Object an error?
Are any of the Objects an error?
Try to get arg as a type.
[mixin] template Identifier (parameters) [Constraint] https://dlang.org/spec/template.html https://dlang.org/spec/template-mixin.html
for recursive expansion detection
Overload existing TemplateDeclaration 'this' with the new one 's'. Return true if successful; i.e. no conflict.
Similar to toChars
, but does not print the template constraints
Check to see if constraint is satisfied.
Destructively get the error message from the last constraint evaluation
const(char)* tip
| tip to show after printing all overloads |
Create a scope for the parameters of the TemplateInstance ti
in the parent scope sc from the ScopeDsymbol paramsym.
If paramsym is null a new ScopeDsymbol is used in place of paramsym.
TemplateInstance ti
| the TemplateInstance whose parameters to generate the scope for. |
Scope* sc
| the parent scope of ti |
Given that ti is an instance of this TemplateDeclaration, deduce the types of the parameters to this, and store those deduced types in dedtypes[].
Determine partial specialization order of 'this' vs td2.
Match function arguments against a specific template function.
Declare template parameter tp with value o, and install it in the scope sc.
Limited function template instantiation for using fd.leastAsSpecialized()
Given a new instance tithis of this TemplateDeclaration, see if there already exists an instance. If so, return that existing instance.
Add instance ti to TemplateDeclaration's table of instances. Return a handle we can use to later remove it if it fails instantiation.
Remove TemplateInstance from table of instances.
Check if the last template parameter is a tuple one, and returns it if so, else returns null
.
TemplateTupleParameter
We can overload templates.
Given function arguments, figure out which template function to expand, and return matching result.
MatchAccumulator m
| matching result |
Dsymbol dstart
| the root of overloaded function templates |
Loc loc
| instantiation location |
Scope* sc
| instantiation scope |
Objects* tiargs
| initial list of template arguments |
Type tthis
| if !NULL, the 'this' pointer argument |
Expressions* fargs
| arguments to function |
const(char)** pMessage
| address to store error message, or null |
Check whether the type t representation relies on one or more the template parameters.
Type t
| Tested type, if null, returns false. |
TemplateParameters* tparams
| Template parameters. |
size_t iStart
| Start index of tparams to limit the tested parameters. If it's nonzero, tparams[0..iStart] will be excluded from the test target. |
https://dlang.org/spec/template.html#TemplateTypeParameter
https://dlang.org/spec/template.html#TemplateThisParameter
https://dlang.org/spec/template.html#TemplateValueParameter
https://dlang.org/spec/template.html#TemplateAliasParameter
https://dlang.org/spec/template.html#TemplateSequenceParameter
https://dlang.org/spec/template.html#explicit_tmp_instantiation
This constructor is only called when we figured out which function template to instantiate.
Given an error instantiating the TemplateInstance, give the nested TemplateInstance instantiations that got us here. Those are a list threaded into the nested scopes.
Lazily generate identifier for template instance. This is because 75% of the ident's are never needed.
Compare proposed template instantiation with existing template instantiation. Note that this is not commutative because of the auto ref check.
TemplateInstance ti
| existing template instantiation |
Returns true if this is not instantiated in non-root module, and is a part of non-speculative instantiatiation.
Find template declaration corresponding to template instance.
Confirm s is a valid template, then store it.
Run semantic of tiargs as arguments of template.
Run semantic on the elements of tiargs.
Determine if template instance is really a template function, and that template function needs to infer types from the function arguments.
Like findBestMatch, iterate possible template candidates, but just looks only the necessity of type inference.
Determines if a TemplateInstance will need a nested generation of the TemplateDeclaration. Sets enclosing property if so, and returns != 0;
Append 'this' to the specific module members[]
Declare parameters of template instance, initialize them with the template instance arguments.
This instance needs an identifier for name mangling purposes. Create one by taking the template declaration name and adding the type signature for it.
IsExpression can evaluate the specified type speculatively, and even if it instantiates any symbols, they are normally unnecessary for the final executable. However, if those symbols leak to the actual code, compiler should remark them as non-speculative to generate their code and link to the final executable.
Return true if e could be valid only as a template value parameter. Return false if it might be an alias or tuple. (Note that even in this case, it could still turn out to be a value).
https://dlang.org/spec/template-mixin.html
This struct is needed for TemplateInstance to be the key in an associative array. Fixing https://issues.dlang.org/show_bug.cgi?id=15812 and https://issues.dlang.org/show_bug.cgi?id=15813 would make it unnecessary.
Match to a particular TemplateParameter.
© 1999–2019 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/dmd_dtemplate.html