Index: src/SymTab/Indexer.cc
===================================================================
--- src/SymTab/Indexer.cc	(revision 522363e8799469eb8e37c765e3c5d28f46066d9a)
+++ src/SymTab/Indexer.cc	(revision 33a25f904db2c5a826a55cdb66cfd7d4cc979de3)
@@ -230,349 +230,4 @@
 
 		return *this;
-	}
-
-	void Indexer::visit( ObjectDecl *objectDecl ) {
-		enterScope();
-		maybeAccept( objectDecl->get_type(), *this );
-		leaveScope();
-		maybeAccept( objectDecl->get_init(), *this );
-		maybeAccept( objectDecl->get_bitfieldWidth(), *this );
-		if ( objectDecl->get_name() != "" ) {
-			debugPrint( "Adding object " << objectDecl->get_name() << std::endl );
-			addId( objectDecl );
-		} // if
-	}
-
-	void Indexer::visit( FunctionDecl *functionDecl ) {
-		if ( functionDecl->get_name() == "" ) return;
-		debugPrint( "Adding function " << functionDecl->get_name() << std::endl );
-		addId( functionDecl );
-		enterScope();
-		maybeAccept( functionDecl->get_functionType(), *this );
-		maybeAccept( functionDecl->get_statements(), *this );
-		leaveScope();
-	}
-
-
-// A NOTE ON THE ORDER OF TRAVERSAL
-//
-// Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is
-// no such thing as a recursive type or typedef.
-//
-//             typedef struct { T *x; } T; // never allowed
-//
-// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
-// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
-// declaration).
-//
-//             struct T { struct T *x; }; // allowed
-//
-// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
-// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
-// queried later in this pass.
-//
-// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
-
-
-	void Indexer::visit( TypeDecl *typeDecl ) {
-		// see A NOTE ON THE ORDER OF TRAVERSAL, above
-		// note that assertions come after the type is added to the symtab, since they are not part of the type proper
-		// and may depend on the type itself
-		enterScope();
-		acceptAll( typeDecl->get_parameters(), *this );
-		maybeAccept( typeDecl->get_base(), *this );
-		leaveScope();
-		debugPrint( "Adding type " << typeDecl->get_name() << std::endl );
-		addType( typeDecl );
-		acceptAll( typeDecl->get_assertions(), *this );
-		acceptNewScope( typeDecl->get_init(), *this );
-	}
-
-	void Indexer::visit( TypedefDecl *typeDecl ) {
-		enterScope();
-		acceptAll( typeDecl->get_parameters(), *this );
-		maybeAccept( typeDecl->get_base(), *this );
-		leaveScope();
-		debugPrint( "Adding typedef " << typeDecl->get_name() << std::endl );
-		addType( typeDecl );
-	}
-
-	void Indexer::visit( StructDecl *aggregateDecl ) {
-		// make up a forward declaration and add it before processing the members
-		// needs to be on the heap because addStruct saves the pointer
-		StructDecl &fwdDecl = *new StructDecl( aggregateDecl->get_name() );
-		cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
-		debugPrint( "Adding fwd decl for struct " << fwdDecl.get_name() << std::endl );
-		addStruct( &fwdDecl );
-
-		enterScope();
-		acceptAll( aggregateDecl->get_parameters(), *this );
-		acceptAll( aggregateDecl->get_members(), *this );
-		leaveScope();
-
-		debugPrint( "Adding struct " << aggregateDecl->get_name() << std::endl );
-		// this addition replaces the forward declaration
-		addStruct( aggregateDecl );
-	}
-
-	void Indexer::visit( UnionDecl *aggregateDecl ) {
-		// make up a forward declaration and add it before processing the members
-		UnionDecl fwdDecl( aggregateDecl->get_name() );
-		cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
-		debugPrint( "Adding fwd decl for union " << fwdDecl.get_name() << std::endl );
-		addUnion( &fwdDecl );
-
-		enterScope();
-		acceptAll( aggregateDecl->get_parameters(), *this );
-		acceptAll( aggregateDecl->get_members(), *this );
-		leaveScope();
-
-		debugPrint( "Adding union " << aggregateDecl->get_name() << std::endl );
-		addUnion( aggregateDecl );
-	}
-
-	void Indexer::visit( EnumDecl *aggregateDecl ) {
-		debugPrint( "Adding enum " << aggregateDecl->get_name() << std::endl );
-		addEnum( aggregateDecl );
-		// unlike structs, contexts, and unions, enums inject their members into the global scope
-		acceptAll( aggregateDecl->get_members(), *this );
-	}
-
-	void Indexer::visit( TraitDecl *aggregateDecl ) {
-		enterScope();
-		acceptAll( aggregateDecl->get_parameters(), *this );
-		acceptAll( aggregateDecl->get_members(), *this );
-		leaveScope();
-
-		debugPrint( "Adding trait " << aggregateDecl->get_name() << std::endl );
-		addTrait( aggregateDecl );
-	}
-
-	void Indexer::visit( CompoundStmt *compoundStmt ) {
-		enterScope();
-		acceptAll( compoundStmt->get_kids(), *this );
-		leaveScope();
-	}
-
-	void Indexer::visit( IfStmt *ifStmt ) {
-	    // for statements introduce a level of scope
-	    enterScope();
-	    Visitor::visit( ifStmt );
-	    leaveScope();
-	}
-
-	void Indexer::visit( ForStmt *forStmt ) {
-	    // for statements introduce a level of scope
-	    enterScope();
-	    Visitor::visit( forStmt );
-	    leaveScope();
-	}
-
-	void Indexer::visit( CatchStmt *catchStmt ) {
-		// catch statements introduce a level of scope (for the caught exception)
-		enterScope();
-		Visitor::visit( catchStmt );
-		leaveScope();
-	}
-
-	void Indexer::visit( ApplicationExpr *applicationExpr ) {
-		acceptNewScope( applicationExpr->get_result(), *this );
-		maybeAccept( applicationExpr->get_function(), *this );
-		acceptAll( applicationExpr->get_args(), *this );
-	}
-
-	void Indexer::visit( UntypedExpr *untypedExpr ) {
-		acceptNewScope( untypedExpr->get_result(), *this );
-		acceptAll( untypedExpr->get_args(), *this );
-	}
-
-	void Indexer::visit( NameExpr *nameExpr ) {
-		acceptNewScope( nameExpr->get_result(), *this );
-	}
-
-	void Indexer::visit( AddressExpr *addressExpr ) {
-		acceptNewScope( addressExpr->get_result(), *this );
-		maybeAccept( addressExpr->get_arg(), *this );
-	}
-
-	void Indexer::visit( LabelAddressExpr *labAddressExpr ) {
-		acceptNewScope( labAddressExpr->get_result(), *this );
-	}
-
-	void Indexer::visit( CastExpr *castExpr ) {
-		acceptNewScope( castExpr->get_result(), *this );
-		maybeAccept( castExpr->get_arg(), *this );
-	}
-
-	void Indexer::visit( UntypedMemberExpr *memberExpr ) {
-		acceptNewScope( memberExpr->get_result(), *this );
-		maybeAccept( memberExpr->get_aggregate(), *this );
-	}
-
-	void Indexer::visit( MemberExpr *memberExpr ) {
-		acceptNewScope( memberExpr->get_result(), *this );
-		maybeAccept( memberExpr->get_aggregate(), *this );
-	}
-
-	void Indexer::visit( VariableExpr *variableExpr ) {
-		acceptNewScope( variableExpr->get_result(), *this );
-	}
-
-	void Indexer::visit( ConstantExpr *constantExpr ) {
-		acceptNewScope( constantExpr->get_result(), *this );
-		maybeAccept( constantExpr->get_constant(), *this );
-	}
-
-	void Indexer::visit( SizeofExpr *sizeofExpr ) {
-		acceptNewScope( sizeofExpr->get_result(), *this );
-		if ( sizeofExpr->get_isType() ) {
-			maybeAccept( sizeofExpr->get_type(), *this );
-		} else {
-			maybeAccept( sizeofExpr->get_expr(), *this );
-		}
-	}
-
-	void Indexer::visit( AlignofExpr *alignofExpr ) {
-		acceptNewScope( alignofExpr->get_result(), *this );
-		if ( alignofExpr->get_isType() ) {
-			maybeAccept( alignofExpr->get_type(), *this );
-		} else {
-			maybeAccept( alignofExpr->get_expr(), *this );
-		}
-	}
-
-	void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
-		acceptNewScope( offsetofExpr->get_result(), *this );
-		maybeAccept( offsetofExpr->get_type(), *this );
-	}
-
-	void Indexer::visit( OffsetofExpr *offsetofExpr ) {
-		acceptNewScope( offsetofExpr->get_result(), *this );
-		maybeAccept( offsetofExpr->get_type(), *this );
-		maybeAccept( offsetofExpr->get_member(), *this );
-	}
-
-	void Indexer::visit( OffsetPackExpr *offsetPackExpr ) {
-		acceptNewScope( offsetPackExpr->get_result(), *this );
-		maybeAccept( offsetPackExpr->get_type(), *this );
-	}
-
-	void Indexer::visit( AttrExpr *attrExpr ) {
-		acceptNewScope( attrExpr->get_result(), *this );
-		if ( attrExpr->get_isType() ) {
-			maybeAccept( attrExpr->get_type(), *this );
-		} else {
-			maybeAccept( attrExpr->get_expr(), *this );
-		}
-	}
-
-	void Indexer::visit( LogicalExpr *logicalExpr ) {
-		acceptNewScope( logicalExpr->get_result(), *this );
-		maybeAccept( logicalExpr->get_arg1(), *this );
-		maybeAccept( logicalExpr->get_arg2(), *this );
-	}
-
-	void Indexer::visit( ConditionalExpr *conditionalExpr ) {
-		acceptNewScope( conditionalExpr->get_result(), *this );
-		maybeAccept( conditionalExpr->get_arg1(), *this );
-		maybeAccept( conditionalExpr->get_arg2(), *this );
-		maybeAccept( conditionalExpr->get_arg3(), *this );
-	}
-
-	void Indexer::visit( CommaExpr *commaExpr ) {
-		acceptNewScope( commaExpr->get_result(), *this );
-		maybeAccept( commaExpr->get_arg1(), *this );
-		maybeAccept( commaExpr->get_arg2(), *this );
-	}
-
-	void Indexer::visit( TypeExpr *typeExpr ) {
-		acceptNewScope( typeExpr->get_result(), *this );
-		maybeAccept( typeExpr->get_type(), *this );
-	}
-
-	void Indexer::visit( AsmExpr *asmExpr ) {
-		maybeAccept( asmExpr->get_inout(), *this );
-		maybeAccept( asmExpr->get_constraint(), *this );
-		maybeAccept( asmExpr->get_operand(), *this );
-	}
-
-	void Indexer::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
-		acceptNewScope( impCpCtorExpr->get_result(), *this );
-		maybeAccept( impCpCtorExpr->get_callExpr(), *this );
-		acceptAll( impCpCtorExpr->get_tempDecls(), *this );
-		acceptAll( impCpCtorExpr->get_returnDecls(), *this );
-		acceptAll( impCpCtorExpr->get_dtors(), *this );
-	}
-
-	void Indexer::visit( ConstructorExpr * ctorExpr ) {
-		acceptNewScope( ctorExpr->get_result(), *this );
-		maybeAccept( ctorExpr->get_callExpr(), *this );
-	}
-
-	void Indexer::visit( CompoundLiteralExpr *compLitExpr ) {
-		acceptNewScope( compLitExpr->get_result(), *this );
-		maybeAccept( compLitExpr->get_initializer(), *this );
-	}
-
-	void Indexer::visit( RangeExpr *rangeExpr ) {
-		maybeAccept( rangeExpr->get_low(), *this );
-		maybeAccept( rangeExpr->get_high(), *this );
-	}
-
-	void Indexer::visit( UntypedTupleExpr *tupleExpr ) {
-		acceptNewScope( tupleExpr->get_result(), *this );
-		acceptAll( tupleExpr->get_exprs(), *this );
-	}
-
-	void Indexer::visit( TupleExpr *tupleExpr ) {
-		acceptNewScope( tupleExpr->get_result(), *this );
-		acceptAll( tupleExpr->get_exprs(), *this );
-	}
-
-	void Indexer::visit( TupleIndexExpr *tupleExpr ) {
-		acceptNewScope( tupleExpr->get_result(), *this );
-		maybeAccept( tupleExpr->get_tuple(), *this );
-	}
-
-	void Indexer::visit( TupleAssignExpr *tupleExpr ) {
-		acceptNewScope( tupleExpr->get_result(), *this );
-		maybeAccept( tupleExpr->get_stmtExpr(), *this );
-	}
-
-	void Indexer::visit( StmtExpr *stmtExpr ) {
-		acceptNewScope( stmtExpr->get_result(), *this );
-		maybeAccept( stmtExpr->get_statements(), *this );
-		acceptAll( stmtExpr->get_returnDecls(), *this );
-		acceptAll( stmtExpr->get_dtors(), *this );
-	}
-
-	void Indexer::visit( UniqueExpr *uniqueExpr ) {
-		acceptNewScope( uniqueExpr->get_result(), *this );
-		maybeAccept( uniqueExpr->get_expr(), *this );
-	}
-
-
-	void Indexer::visit( TraitInstType *traitInst ) {
-		acceptAll( traitInst->get_parameters(), *this );
-	}
-
-	void Indexer::visit( StructInstType *structInst ) {
-		if ( ! lookupStruct( structInst->get_name() ) ) {
-			debugPrint( "Adding struct " << structInst->get_name() << " from implicit forward declaration" << std::endl );
-			addStruct( structInst->get_name() );
-		}
-		enterScope();
-		acceptAll( structInst->get_parameters(), *this );
-		leaveScope();
-	}
-
-	void Indexer::visit( UnionInstType *unionInst ) {
-		if ( ! lookupUnion( unionInst->get_name() ) ) {
-			debugPrint( "Adding union " << unionInst->get_name() << " from implicit forward declaration" << std::endl );
-			addUnion( unionInst->get_name() );
-		}
-		enterScope();
-		acceptAll( unionInst->get_parameters(), *this );
-		leaveScope();
 	}
 
@@ -762,4 +417,5 @@
 
 	void Indexer::addId( DeclarationWithType *decl ) {
+		debugPrint( "Adding Id " << decl->name << std::endl );
 		makeWritable();
 
@@ -811,4 +467,5 @@
 
 	void Indexer::addType( NamedTypeDecl *decl ) {
+		debugPrint( "Adding type " << decl->name << std::endl );
 		makeWritable();
 
@@ -838,8 +495,10 @@
 
 	void Indexer::addStruct( const std::string &id ) {
+		debugPrint( "Adding fwd decl for struct " << id << std::endl );
 		addStruct( new StructDecl( id ) );
 	}
 
 	void Indexer::addStruct( StructDecl *decl ) {
+		debugPrint( "Adding struct " << decl->name << std::endl );
 		makeWritable();
 
@@ -860,4 +519,5 @@
 
 	void Indexer::addEnum( EnumDecl *decl ) {
+		debugPrint( "Adding enum " << decl->name << std::endl );
 		makeWritable();
 
@@ -878,8 +538,10 @@
 
 	void Indexer::addUnion( const std::string &id ) {
+		debugPrint( "Adding fwd decl for union " << id << std::endl );
 		addUnion( new UnionDecl( id ) );
 	}
 
 	void Indexer::addUnion( UnionDecl *decl ) {
+		debugPrint( "Adding union " << decl->name << std::endl );
 		makeWritable();
 
@@ -900,4 +562,5 @@
 
 	void Indexer::addTrait( TraitDecl *decl ) {
+		debugPrint( "Adding trait " << decl->name << std::endl );
 		makeWritable();
 
