Mercurial > projects > ldc
comparison dmd/template.c @ 1609:1d0220dd613a
Merge DMD r274: harmonization
---
dmd/expression.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
dmd/template.c | 41 +++++++++++++++++++++++++++++++++++
dmd/template.h | 1 +
3 files changed, 103 insertions(+), 1 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:21 -0300 |
parents | 207a8a438dea |
children | 4f63d530861f |
comparison
equal
deleted
inserted
replaced
1608:679d101395e8 | 1609:1d0220dd613a |
---|---|
4084 tempdecl->declareParameter(sc, tp, o); | 4084 tempdecl->declareParameter(sc, tp, o); |
4085 } | 4085 } |
4086 } | 4086 } |
4087 | 4087 |
4088 | 4088 |
4089 /***************************************************** | |
4090 * Determine if template instance is really a template function, | |
4091 * and that template function needs to infer types from the function | |
4092 * arguments. | |
4093 */ | |
4094 | |
4095 int TemplateInstance::needsTypeInference(Scope *sc) | |
4096 { | |
4097 //printf("TemplateInstance::needsTypeInference() %s\n", toChars()); | |
4098 if (!tempdecl) | |
4099 tempdecl = findTemplateDeclaration(sc); | |
4100 for (TemplateDeclaration *td = tempdecl; td; td = td->overnext) | |
4101 { | |
4102 /* If any of the overloaded template declarations need inference, | |
4103 * then return TRUE | |
4104 */ | |
4105 FuncDeclaration *fd; | |
4106 if (!td->onemember || | |
4107 (fd = td->onemember->toAlias()->isFuncDeclaration()) == NULL || | |
4108 fd->type->ty != Tfunction) | |
4109 { | |
4110 /* Not a template function, therefore type inference is not possible. | |
4111 */ | |
4112 //printf("false\n"); | |
4113 return FALSE; | |
4114 } | |
4115 | |
4116 /* Determine if the instance arguments, tiargs, are all that is necessary | |
4117 * to instantiate the template. | |
4118 */ | |
4119 TemplateTupleParameter *tp = td->isVariadic(); | |
4120 //printf("tp = %p, td->parameters->dim = %d, tiargs->dim = %d\n", tp, td->parameters->dim, tiargs->dim); | |
4121 TypeFunction *fdtype = (TypeFunction *)fd->type; | |
4122 if (Parameter::dim(fdtype->parameters) && | |
4123 (tp || tiargs->dim < td->parameters->dim)) | |
4124 return TRUE; | |
4125 } | |
4126 //printf("false\n"); | |
4127 return FALSE; | |
4128 } | |
4129 | |
4089 void TemplateInstance::semantic2(Scope *sc) | 4130 void TemplateInstance::semantic2(Scope *sc) |
4090 { int i; | 4131 { int i; |
4091 | 4132 |
4092 if (semanticRun >= 2) | 4133 if (semanticRun >= 2) |
4093 return; | 4134 return; |