changeset 711:4f971f6382c7

Added enum Status to class Symbol.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 30 Jan 2008 18:28:21 +0100
parents c89ffd930727
children f8875ef9a66d
files trunk/src/dil/semantic/Pass2.d trunk/src/dil/semantic/Symbol.d
diffstat 2 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/semantic/Pass2.d	Tue Jan 29 22:51:44 2008 +0100
+++ b/trunk/src/dil/semantic/Pass2.d	Wed Jan 30 18:28:21 2008 +0100
@@ -87,26 +87,35 @@
 
   D visit(EnumDeclaration d)
   {
+    d.symbol.setCompleting();
+
     Type type = Types.Int; // Default to int.
     if (d.baseType)
       type = visitT(d.baseType).type;
     d.symbol.type = new TypeEnum(d.symbol, type);
+
     enterScope(d.symbol);
+
     foreach (member; d.members)
     {
       Expression finalValue;
+      member.symbol.setCompleting();
       if (member.value)
       {
         member.value = visitE(member.value);
         finalValue = interpret(member.value);
         if (finalValue is Interpreter.NAR)
-          continue;
+          finalValue = new IntExpression(0, d.symbol.type);
       }
       //else
         // TODO: increment a number variable and assign that to value.
+      member.symbol.type = d.symbol.type; // Assign TypeEnum.
       member.symbol.value = finalValue;
+      member.symbol.setComplete();
     }
+
     exitScope();
+    d.symbol.setComplete();
     return d;
   }
 
--- a/trunk/src/dil/semantic/Symbol.d	Tue Jan 29 22:51:44 2008 +0100
+++ b/trunk/src/dil/semantic/Symbol.d	Wed Jan 30 18:28:21 2008 +0100
@@ -31,10 +31,18 @@
 +/
 class Symbol
 {
-  SYM sid;
+  enum Status : ushort
+  {
+    Declared,   /// The symbol has been declared.
+    Completing, /// The symbol is being processed.
+    Complete    /// The symbol is complete.
+  }
+
+  SYM sid; /// The ID of this symbol.
+  Status status; /// The semantic status of this symbol.
   Symbol parent; /// The parent this symbol belongs to.
   Identifier* name; /// The name of this symbol.
-  /// The AST node that produced this symbol.
+  /// The syntax tree node that produced this symbol.
   /// Useful for source code location info and retrieval of doc comments.
   Node node;
 
@@ -45,6 +53,18 @@
     this.node = node;
   }
 
+  void setCompleting()
+  { status = Status.Completing; }
+
+  void setComplete()
+  { status = Status.Complete; }
+
+  bool isCompleting()
+  { return status == Status.Completing; }
+
+  bool isComplete()
+  { return status == Status.Complete; }
+
   // A template macro for building isXYZ() methods.
   private template isX(char[] kind)
   {