changeset 289:a99357783c6f

- Fix: assign targs to member targs of TraitsExpression. - Changed class FunctionLiteralExpression. Storing return type and parameters as members instead of funcType. Adapted parser accordingly.
author aziz
date Wed, 08 Aug 2007 11:35:03 +0000
parents 833b301497f4
children 7933a0c17c9f
files trunk/src/Expressions.d trunk/src/Parser.d
diffstat 2 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Expressions.d	Wed Aug 08 10:46:02 2007 +0000
+++ b/trunk/src/Expressions.d	Wed Aug 08 11:35:03 2007 +0000
@@ -775,16 +775,27 @@
 
 class FunctionLiteralExpression : Expression
 {
-  FunctionType funcType;
+  Type returnType;
+  Parameters parameters;
   FunctionBody funcBody;
-  TOK funcTok;
 
-  this(FunctionType funcType, FunctionBody funcBody, TOK funcTok = TOK.Invalid)
+  this()
   {
     mixin(set_kind);
-    this.funcType = funcType;
+  }
+
+  this(Type returnType, Parameters parameters, FunctionBody funcBody)
+  {
+    this();
+    this.returnType = returnType;
+    this.parameters = parameters;
     this.funcBody = funcBody;
-    this.funcTok = funcTok;
+  }
+
+  this(FunctionBody funcBody)
+  {
+    this();
+    this.funcBody = funcBody;
   }
 }
 
@@ -798,6 +809,7 @@
   {
     mixin(set_kind);
     this.ident = ident;
+    this.targs = targs;
   }
 }
 }
--- a/trunk/src/Parser.d	Wed Aug 08 10:46:02 2007 +0000
+++ b/trunk/src/Parser.d	Wed Aug 08 11:35:03 2007 +0000
@@ -3390,13 +3390,11 @@
       break;
     case T.LBrace:
       // DelegateLiteral := { Statements }
-//       auto funcType = new FunctionType(null, Parameters.init);
       auto funcBody = parseFunctionBody();
-      e = new FunctionLiteralExpression(null, funcBody);
+      e = new FunctionLiteralExpression(funcBody);
       break;
     case T.Function, T.Delegate:
       // FunctionLiteral := (function|delegate) Type? '(' ArgumentList ')' '{' Statements '}'
-//       TOK funcTok = token.type;
       nT(); // Skip function|delegate token.
       Type returnType;
       Parameters parameters;
@@ -3406,9 +3404,8 @@
           returnType = parseType();
         parameters = parseParameterList();
       }
-      auto funcType = new FunctionType(returnType, parameters);
       auto funcBody = parseFunctionBody();
-      e = new FunctionLiteralExpression(funcType, funcBody/+, funcTok+/);
+      e = new FunctionLiteralExpression(returnType, parameters, funcBody);
       break;
     case T.Assert:
       Expression msg;
@@ -3498,9 +3495,8 @@
       {
         auto parameters = parseParameterList();
         // ( ParameterList ) FunctionBody
-        auto funcType = new FunctionType(null, parameters);
         auto funcBody = parseFunctionBody();
-        e = new FunctionLiteralExpression(funcType, funcBody);
+        e = new FunctionLiteralExpression(null, parameters, funcBody);
       }
       else
       {