Skip to content

Commit

Permalink
add parent to __traits for QtD support
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Apr 18, 2011
1 parent 7740c0e commit 2e261cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/idgen.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2010 by Digital Mars
// Copyright (c) 1999-2011 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -312,6 +312,7 @@ Msgtable msgtable[] =
{ "isLazy" },
{ "hasMember" },
{ "identifier" },
{ "parent" },
{ "getMember" },
{ "getOverloads" },
{ "getVirtualFunctions" },
Expand Down
17 changes: 16 additions & 1 deletion src/traits.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2010 by Digital Mars
// Copyright (c) 1999-2011 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -196,6 +196,21 @@ Expression *TraitsExp::semantic(Scope *sc)
StringExp *se = new StringExp(loc, s->ident->toChars());
return se->semantic(sc);
}
else if (ident == Id::parent)
{
if (dim != 1)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Dsymbol *s = getDsymbol(o);
if (s)
s = s->toParent();
if (!s)
{
error("argument %s has no parent", o->toChars());
goto Lfalse;
}
return (new DsymbolExp(loc, s))->semantic(sc);
}

#endif
else if (ident == Id::hasMember ||
Expand Down

0 comments on commit 2e261cd

Please sign in to comment.