diff trunk/src/dil/Symbols.d @ 562:b0533550d64c

Added semantic() to VariableDeclaration. Renamed member type to typeNode in VariableDeclaration. Added insert() and error() to class Scope. Made class SymbolTable a struct. Added insert() and lookup() to ScopeSymbol. Added insert() to Aggregate. Added semantic() to TypeNode.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 28 Dec 2007 17:48:47 +0100
parents 302e50e71ec2
children 184a8d8bad2e
line wrap: on
line diff
--- a/trunk/src/dil/Symbols.d	Wed Dec 26 23:38:16 2007 +0100
+++ b/trunk/src/dil/Symbols.d	Fri Dec 28 17:48:47 2007 +0100
@@ -15,11 +15,22 @@
 /// A symbol that has its own scope with a symbol table.
 class ScopeSymbol : Symbol
 {
-  SymbolTable symbolTable; /// The symbol table.
+  protected SymbolTable symbolTable; /// The symbol table.
 
   this()
   {
-    symbolTable = new SymbolTable;
+  }
+
+  /// Look up ident in the table.
+  Symbol lookup(Identifier* ident)
+  {
+    return symbolTable.lookup(ident);
+  }
+
+  /// Insert a symbol into the table.
+  void insert(Symbol s, Identifier* ident)
+  {
+    symbolTable.insert(s, ident);
   }
 }
 
@@ -28,6 +39,17 @@
 {
   Function[] funcs;
   Variable[] fields;
+
+  override void insert(Symbol s, Identifier* ident)
+  {
+    if (s.sid == SYM.Variable)
+      // Append variable to fields.
+      fields ~= cast(Variable)cast(void*)s;
+    else if (s.sid == SYM.Function)
+      // Append function to funcs.
+      funcs ~= cast(Function)cast(void*)s;
+    super.insert(s, ident);
+  }
 }
 
 class Class : Aggregate