Skip to content

Commit

Permalink
add __parameters to IsExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jul 1, 2012
1 parent 7307e71 commit 08811d7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/declaration.h
Expand Up @@ -88,7 +88,7 @@ enum PURE;
// and used only in backend process, so it's rvalue

#ifdef BUG6652
#define STCbug6652 0x800000000000LL //
#define STCbug6652 0x800000000000LL //
#endif

struct Match
Expand Down
5 changes: 4 additions & 1 deletion src/expression.c
Expand Up @@ -5774,6 +5774,7 @@ Expression *IsExp::semantic(Scope *sc)
break;

case TOKfunction:
case TOKparameters:
{
if (targ->ty != Tfunction)
goto Lno;
Expand All @@ -5789,7 +5790,9 @@ Expression *IsExp::semantic(Scope *sc)
for (size_t i = 0; i < dim; i++)
{ Parameter *arg = Parameter::getNth(params, i);
assert(arg && arg->type);
args->push(new Parameter(arg->storageClass, arg->type, arg->ident, arg->defaultArg));
args->push(new Parameter(arg->storageClass, arg->type,
(tok2 == TOKparameters) ? arg->ident : NULL,
(tok2 == TOKparameters) ? arg->defaultArg : NULL));
}
tded = new TypeTuple(args);
break;
Expand Down
1 change: 1 addition & 0 deletions src/idgen.c
Expand Up @@ -333,6 +333,7 @@ Msgtable msgtable[] =
{ "derivedMembers" },
{ "isSame" },
{ "compiles" },
{ "parameters" },
};


Expand Down
1 change: 1 addition & 0 deletions src/lexer.c
Expand Up @@ -2912,6 +2912,7 @@ static Keyword keywords[] =

// Added after 1.0
{ "__argTypes", TOKargTypes },
{ "__parameters", TOKparameters },
{ "ref", TOKref },
{ "macro", TOKmacro },
#if DMDV2
Expand Down
1 change: 1 addition & 0 deletions src/lexer.h
Expand Up @@ -156,6 +156,7 @@ enum TOK
TOKref,
TOKmacro,
#if DMDV2
TOKparameters,
TOKtraits,
TOKoverloadset,
TOKpure,
Expand Down
1 change: 1 addition & 0 deletions src/parse.c
Expand Up @@ -5423,6 +5423,7 @@ Expression *Parser::parsePrimaryExp()
token.value == TOKenum ||
token.value == TOKinterface ||
token.value == TOKargTypes ||
token.value == TOKparameters ||
#if DMDV2
token.value == TOKconst && peek(&token)->value == TOKrparen ||
token.value == TOKinvariant && peek(&token)->value == TOKrparen ||
Expand Down

5 comments on commit 08811d7

@yebblies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason this wasn't done with a __trait?

@WalterBright
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__traits returns an expression, whereas a type tuple is needed.

@TurkeyMan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show how this is to be used? For instance my examples of enumerating function parameters and copying parameter lists?

@9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented on 08811d7 Jul 30, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TurkeyMan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spectacular! Thanks guys!

Please sign in to comment.