206
bool MatchName::scope_matches (vector<Name> &scopes,
207
vector<MatchTemplateArgList*> &scope_template_args,
208
int match_pos, int sig_pos) {
210
assert (this->scopes () > 0 && this->scopes () > match_pos);
212
Name &name = _scopes[match_pos];
213
MatchTemplateArgList *mtal = _scope_template_args[match_pos];
216
static DString dots ("...");
217
if (name.str () == dots) {
218
// if '...' is the start of the qualified name match expression => match
221
// handle ellipses (brute force :-( )
222
while (sig_pos >= 0) {
223
if (scope_matches (scopes, scope_template_args, match_pos, sig_pos))
230
// if the argument scope is the global scope it is a mismatch
234
// check template arguments of the scope
236
MatchTemplateArgList *sig_mtal = scope_template_args[sig_pos];
237
if (!sig_mtal || !mtal->matches(*sig_mtal))
241
// compare the name pattern
242
if (!name.matches (scopes[sig_pos].str ()))
246
// check the next scope
248
return scope_matches (scopes, scope_template_args, match_pos, sig_pos);
250
// no scope to check left, 'scope' must be defined in the global scope
206
258
bool MatchName::oper_matches (CFunctionInfo *obj) {
207
259
static DString any ("%");
241
293
return obj->Name () == obstr[((int)_oper) - 1];
296
bool MatchName::oper_matches (Operator oper) {
297
static DString any ("%");
299
// '%' as a function name also matches operators
300
if (!_name.str ().empty ())
301
return _name.str () == any;
303
// only operator signatures are considered
304
if (_oper == OP_UNDEFINED)
311
// return true, iff the operator is the same
312
return _oper == oper;
244
315
bool MatchName::conv_matches (CFunctionInfo *obj) {
245
316
static DString any ("%");
257
328
return ct && !_conv_type.is_undefined () && _conv_type.matches (ct);
331
bool MatchName::conv_matches (MatchTypeRef type) {
332
static DString any ("%");
334
// '%' as a function name also matches operators
335
if (!_name.str ().empty ())
336
return _name.str () == any;
338
// any operator is ok
342
// check the conversion type of the function (if it is a conversion function)
343
return !type.is_undefined () && !_conv_type.is_undefined () &&
344
_conv_type.matches (type);
260
347
bool MatchName::name_matches (CObjectInfo *obj) {
261
348
if (_name_template_args) {
262
349
CTemplateInstance *instance = obj->TemplateInstance ();
266
353
return _name.matches (obj->Name ());
356
bool MatchName::name_matches (Name &name,
357
MatchTemplateArgList *name_template_args) {
358
if (_name_template_args) {
359
if (!name_template_args ||
360
!_name_template_args->matches (*name_template_args))
363
return _name.matches (name.str ());
269
366
bool MatchName::matches (CObjectInfo *obj) {
270
367
// if the match name contains a scope check it first
271
368
CScopeInfo *obj_scope = nscope (obj);
391
bool MatchName::matches (MatchName &matched_name) {
392
// if the matched name is not defined in the global scope and the match
393
// name has no scopes, it is no match
394
if (scopes () == 0 && matched_name.scopes () > 0)
397
// if the match name has a scope, compare it
398
if (scopes () > 0 && !scope_matches (matched_name._scopes,
399
matched_name._scope_template_args,
400
scopes () - 1, matched_name.scopes () - 1))
403
if (matched_name.oper () != OP_UNDEFINED) {
404
// this an operator name match expression
405
return oper_matches (matched_name.oper ());
407
else if (!matched_name.conv_type ().is_undefined ()) {
408
// this is a conversion operator match expression
409
return conv_matches (matched_name.conv_type ());
411
else if (_oper == OP_UNDEFINED && _conv_type.is_undefined ()) {
413
return name_matches (matched_name._name, matched_name._name_template_args);