changeset 278:e5a6b56c7716

- Moved declarations in enum NodeKind to the top. - Added statements to enum NodeKind. - Added mixin(set_kind) statement to every constructor that inherits from Statement.
author aziz
date Mon, 06 Aug 2007 15:35:04 +0000
parents 38a68e534a3b
children 79c095aae50d
files trunk/src/Statements.d trunk/src/SyntaxTree.d
diffstat 2 files changed, 116 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Statements.d	Mon Aug 06 15:15:01 2007 +0000
+++ b/trunk/src/Statements.d	Mon Aug 06 15:35:04 2007 +0000
@@ -22,6 +22,7 @@
   Statement[] ss;
   void opCatAssign(Statement s)
   {
+    mixin(set_kind);
     this.ss ~= s;
   }
 }
@@ -31,6 +32,7 @@
   Token* tok;
   this(Token* tok)
   {
+    mixin(set_kind);
     this.tok = tok;
   }
 }
@@ -39,6 +41,7 @@
 {
   this()
   {
+    mixin(set_kind);
   }
 }
 
@@ -49,6 +52,7 @@
   this()
   {
     super(NodeCategory.Other);
+    mixin(set_kind);
   }
 }
 
@@ -57,6 +61,7 @@
   Statement s;
   this(Statement s)
   {
+    mixin(set_kind);
     this.s = s;
   }
 }
@@ -67,6 +72,7 @@
   Statement s;
   this(Token* label, Statement s)
   {
+    mixin(set_kind);
     this.label = label;
     this.s = s;
   }
@@ -77,6 +83,7 @@
   Expression expression;
   this(Expression expression)
   {
+    mixin(set_kind);
     this.expression = expression;
   }
 }
@@ -86,6 +93,7 @@
   Declaration declaration;
   this(Declaration declaration)
   {
+    mixin(set_kind);
     this.declaration = declaration;
   }
 }
@@ -99,6 +107,7 @@
   Statement elseBody;
   this(Type type, Token* ident, Expression condition, Statement ifBody, Statement elseBody)
   {
+    mixin(set_kind);
     this.type = type;
     this.ident = ident;
     this.condition = condition;
@@ -118,6 +127,7 @@
   Statement whileBody;
   this(Expression condition, Statement whileBody)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.whileBody = whileBody;
   }
@@ -129,6 +139,7 @@
   Statement doBody;
   this(Expression condition, Statement doBody)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.doBody = doBody;
   }
@@ -142,6 +153,7 @@
 
   this(Statement init, Expression condition, Expression increment, Statement forBody)
   {
+    mixin(set_kind);
     this.init = init;
     this.condition = condition;
     this.increment = increment;
@@ -158,6 +170,7 @@
 
   this(TOK tok, Parameters params, Expression aggregate, Statement forBody)
   {
+    mixin(set_kind);
     this.tok = tok;
     this.params = params;
     this.aggregate = aggregate;
@@ -176,6 +189,7 @@
 
   this(TOK tok, Parameters params, Expression lower, Expression upper, Statement forBody)
   {
+    mixin(set_kind);
     this.tok = tok;
     this.params = params;
     this.lower = lower;
@@ -192,6 +206,7 @@
 
   this(Expression condition, Statement switchBody)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.switchBody = switchBody;
   }
@@ -204,6 +219,7 @@
 
   this(Expression[] values, Statement caseBody)
   {
+    mixin(set_kind);
     this.values = values;
     this.caseBody = caseBody;
   }
@@ -214,6 +230,7 @@
   Statement defaultBody;
   this(Statement defaultBody)
   {
+    mixin(set_kind);
     this.defaultBody = defaultBody;
   }
 }
@@ -223,6 +240,7 @@
   Token* ident;
   this(Token* ident)
   {
+    mixin(set_kind);
     this.ident = ident;
   }
 }
@@ -232,6 +250,7 @@
   Token* ident;
   this(Token* ident)
   {
+    mixin(set_kind);
     this.ident = ident;
   }
 }
@@ -241,6 +260,7 @@
   Expression expr;
   this(Expression expr)
   {
+    mixin(set_kind);
     this.expr = expr;
   }
 }
@@ -251,6 +271,7 @@
   Expression caseExpr;
   this(Token* ident, Expression caseExpr)
   {
+    mixin(set_kind);
     this.ident = ident;
     this.caseExpr = caseExpr;
   }
@@ -262,6 +283,7 @@
   Statement withBody;
   this(Expression expr, Statement withBody)
   {
+    mixin(set_kind);
     this.expr = expr;
     this.withBody = withBody;
   }
@@ -273,6 +295,7 @@
   Statement syncBody;
   this(Expression expr, Statement withBody)
   {
+    mixin(set_kind);
     this.expr = expr;
     this.syncBody = syncBody;
   }
@@ -285,6 +308,7 @@
   FinallyBody finallyBody;
   this(Statement tryBody, CatchBody[] catchBodies, FinallyBody finallyBody)
   {
+    mixin(set_kind);
     this.tryBody = tryBody;
     this.catchBodies = catchBodies;
     this.finallyBody = finallyBody;
@@ -297,6 +321,7 @@
   Statement catchBody;
   this(Parameter param, Statement catchBody)
   {
+    mixin(set_kind);
     this.param = param;
     this.catchBody = catchBody;
   }
@@ -307,6 +332,7 @@
   Statement finallyBody;
   this(Statement finallyBody)
   {
+    mixin(set_kind);
     this.finallyBody = finallyBody;
   }
 }
@@ -317,6 +343,7 @@
   Statement scopeBody;
   this(Token* condition, Statement scopeBody)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.scopeBody = scopeBody;
   }
@@ -327,6 +354,7 @@
   Expression expr;
   this(Expression expr)
   {
+    mixin(set_kind);
     this.expr = expr;
   }
 }
@@ -336,13 +364,17 @@
   Statement volatileBody;
   this(Statement volatileBody)
   {
+    mixin(set_kind);
     this.volatileBody = volatileBody;
   }
 }
 
 class AsmStatement : Statement
 {
-
+  this()
+  {
+    mixin(set_kind);
+  }
 }
 
 class PragmaStatement : Statement
@@ -352,6 +384,7 @@
   Statement pragmaBody;
   this(Token* ident, Expression[] args, Statement pragmaBody)
   {
+    mixin(set_kind);
     this.ident = ident;
     this.args = args;
     this.pragmaBody = pragmaBody;
@@ -364,6 +397,7 @@
   Token* mixinIdent;
   this(Expression[] templateIdent, Token* mixinIdent)
   {
+    mixin(set_kind);
     this.templateIdent = templateIdent;
     this.mixinIdent = mixinIdent;
   }
@@ -375,6 +409,7 @@
   Statement ifBody, elseBody;
   this(Expression condition, Statement ifBody, Statement elseBody)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.ifBody = ifBody;
     this.elseBody = elseBody;
@@ -386,6 +421,7 @@
   Expression condition, message;
   this(Expression condition, Expression message)
   {
+    mixin(set_kind);
     this.condition = condition;
     this.message = message;
   }
@@ -397,6 +433,7 @@
   Statement debugBody, elseBody;
   this(Token* cond, Statement debugBody, Statement elseBody)
   {
+    mixin(set_kind);
     this.cond = cond;
     this.debugBody = debugBody;
     this.elseBody = elseBody;
@@ -409,6 +446,7 @@
   Statement versionBody, elseBody;
   this(Token* cond, Statement versionBody, Statement elseBody)
   {
+    mixin(set_kind);
     this.cond = cond;
     this.versionBody = versionBody;
     this.elseBody = elseBody;
@@ -421,6 +459,7 @@
   Statement statement;
   this(TOK tok, Statement statement)
   {
+    mixin(set_kind);
     this.tok = tok;
     this.statement = statement;
   }
@@ -431,6 +470,7 @@
   Linkage linkage;
   this(Linkage linkage, Statement statement)
   {
+    mixin(set_kind);
     super(TOK.Extern, statement);
     this.linkage = linkage;
   }
--- a/trunk/src/SyntaxTree.d	Mon Aug 06 15:15:01 2007 +0000
+++ b/trunk/src/SyntaxTree.d	Mon Aug 06 15:35:04 2007 +0000
@@ -16,6 +16,79 @@
 
 enum NodeKind
 {
+  // Declarations:
+  EmptyDeclaration,
+  IllegalDeclaration,
+  ModuleDeclaration,
+  ImportDeclaration,
+  AliasDeclaration,
+  TypedefDeclaration,
+  EnumDeclaration,
+  ClassDeclaration,
+  InterfaceDeclaration,
+  StructDeclaration,
+  UnionDeclaration,
+  ConstructorDeclaration,
+  StaticConstructorDeclaration,
+  DestructorDeclaration,
+  StaticDestructorDeclaration,
+  FunctionDeclaration,
+  VariableDeclaration,
+  InvariantDeclaration,
+  UnittestDeclaration,
+  DebugDeclaration,
+  VersionDeclaration,
+  StaticIfDeclaration,
+  StaticAssertDeclaration,
+  TemplateDeclaration,
+  NewDeclaration,
+  DeleteDeclaration,
+  AttributeDeclaration,
+  ExternDeclaration,
+  AlignDeclaration,
+  PragmaDeclaration,
+  MixinDeclaration,
+
+  // Statements:
+  Statements,
+  IllegalStatement,
+  EmptyStatement,
+  ScopeStatement,
+  LabeledStatement,
+  ExpressionStatement,
+  DeclarationStatement,
+  IfStatement,
+  ConditionalStatement,
+  WhileStatement,
+  DoWhileStatement,
+  ForStatement,
+  ForeachStatement,
+  ForeachRangeStatement, // D2.0
+  SwitchStatement,
+  CaseStatement,
+  DefaultStatement,
+  ContinueStatement,
+  BreakStatement,
+  ReturnStatement,
+  GotoStatement,
+  WithStatement,
+  SynchronizedStatement,
+  TryStatement,
+  CatchBody,
+  FinallyBody,
+  ScopeGuardStatement,
+  ThrowStatement,
+  VolatileStatement,
+  AsmStatement,
+  PragmaStatement,
+  MixinStatement,
+  StaticIfStatement,
+  StaticAssertStatement,
+  DebugStatement,
+  VersionStatement,
+  AttributeStatement,
+  ExternStatement,
+
   // Expressions:
   EmptyExpression,
   BinaryExpression,
@@ -99,38 +172,8 @@
   ArrayInitializer,
   StructInitializer,
 
-  // Declarations:
-  EmptyDeclaration,
-  IllegalDeclaration,
-  ModuleDeclaration,
-  ImportDeclaration,
-  AliasDeclaration,
-  TypedefDeclaration,
-  EnumDeclaration,
-  ClassDeclaration,
-  InterfaceDeclaration,
-  StructDeclaration,
-  UnionDeclaration,
-  ConstructorDeclaration,
-  StaticConstructorDeclaration,
-  DestructorDeclaration,
-  StaticDestructorDeclaration,
-  FunctionDeclaration,
-  VariableDeclaration,
-  InvariantDeclaration,
-  UnittestDeclaration,
-  DebugDeclaration,
-  VersionDeclaration,
-  StaticIfDeclaration,
-  StaticAssertDeclaration,
-  TemplateDeclaration,
-  NewDeclaration,
-  DeleteDeclaration,
-  AttributeDeclaration,
-  ExternDeclaration,
-  AlignDeclaration,
-  PragmaDeclaration,
-  MixinDeclaration,
+  // Miscellaneous:
+  FunctionBody,
 }
 
 /// This string is mixed in into the constructor of a class that inherits from Node.