Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/GenPoly/Box.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Rob Schluntz
-// Last Modified On : Tue Aug 11 16:22:35 2015
-// Update Count     : 89
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Nov 19 17:40:51 2015
+// Update Count     : 133
 //
 
@@ -47,4 +47,6 @@
 	namespace {
 		const std::list<Label> noLabels;
+
+		FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
 
 		class Pass1 : public PolyMutator {
@@ -78,5 +80,5 @@
 			ObjectDecl *makeTemporary( Type *type );
 
-			typedef std::map< std::string, FunctionDecl *> AdapterMap;
+			typedef std::map< std::string, DeclarationWithType *> AdapterMap;
 			std::map< std::string, DeclarationWithType *> assignOps;
 			std::stack< AdapterMap > adapters;
@@ -144,37 +146,7 @@
 		}
 
-		bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars ) {
-			bool doTransform = false;
-			if ( ! function->get_returnVals().empty() ) {
-				if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( function->get_returnVals().front()->get_type() ) ) {
-	
-					// figure out if the return type is specified by a type parameter
-					for ( std::list< TypeDecl *>::const_iterator tyVar = function->get_forall().begin(); tyVar != function->get_forall().end(); ++tyVar ) {
-						if ( (*tyVar)->get_name() == typeInst->get_name() ) {
-							doTransform = true;
-							name = typeInst->get_name();
-							break;
-						} // if
-					} // for
-					if ( ! doTransform && otherTyVars.find( typeInst->get_name() ) != otherTyVars.end() ) {
-						doTransform = true;
-					} // if
-				} // if
-			} // if
-			return doTransform;
-		}
-
-		bool isPolyRet( FunctionType *function, std::string &name ) {
-			TyVarMap dummyTyVars;
-			return isPolyRet( function, name, dummyTyVars );
-		}
-
-		bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) {
-			std::string dummyString;
-			return isPolyRet( function, dummyString, otherTyVars );
-		}
-
 		Pass1::Pass1()
 			: useRetval( false ), tempNamer( "_temp" ) {
+			adapters.push(AdapterMap());
 		}
 
@@ -210,9 +182,11 @@
 
 		DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) {
-			if ( functionDecl->get_statements() ) {
+			if ( functionDecl->get_statements() ) {		// empty routine body ?
+				doBeginScope();
 				TyVarMap oldtyVars = scopeTyVars;
 				DeclarationWithType *oldRetval = retval;
 				bool oldUseRetval = useRetval;
-	
+
+				// process polymorphic return value
 				retval = 0;
 				std::string typeName;
@@ -227,19 +201,44 @@
 				} // if
 	
-				scopeTyVars.clear();
-///     std::cerr << "clear\n";
+				FunctionType *functionType = functionDecl->get_functionType();
 				makeTyVarMap( functionDecl->get_functionType(), scopeTyVars );
 				findAssignOps( functionDecl->get_functionType()->get_forall() );
+
+				std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
+				std::list< FunctionType *> functions;
+				for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
+					for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
+						findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
+					} // for
+				} // for
+				for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
+					findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter );
+				} // for
+				AdapterMap & adapters = Pass1::adapters.top();
+				for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
+					std::string mangleName = SymTab::Mangler::mangle( *funType );
+					if ( isPolyRet( *funType, scopeTyVars ) ) {
+						// if the return type involved polymorphic types, then the adapter will need to take those
+						// polymorphic types as pointers. Therefore, there can be two different functions with the same
+						// mangled name, so we need the mangled names to be different.
+						mangleName += "polyret_";
+					} // if
+					if ( adapters.find( mangleName ) == adapters.end() ) {
+						std::string adapterName = makeAdapterName( mangleName );
+						adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ) );
+					} // if
+				} // for
+
 				functionDecl->set_statements( functionDecl->get_statements()->acceptMutator( *this ) );
   
 				scopeTyVars = oldtyVars;
-///     std::cerr << "end FunctionDecl: ";
-///     for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
-///       std::cerr << i->first << " ";
-///     }
-///     std::cerr << "\n";
+				// std::cerr << "end FunctionDecl: ";
+				// for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
+				// 	std::cerr << i->first << " ";
+				// }
+				// std::cerr << "\n";
 				retval = oldRetval;
 				useRetval = oldUseRetval;
-				// doEndScope();
+				doEndScope();
 			} // if
 			return functionDecl;
@@ -349,4 +348,7 @@
 			} // if
 			std::string mangleName = SymTab::Mangler::mangle( function );
+			if ( isPolyRet( function, tyVars ) ) {
+				mangleName += "polyret_";
+			} // if
 			std::string adapterName = makeAdapterName( mangleName );
 
@@ -457,8 +459,10 @@
 ///       return new CastExpr( new VariableExpr( param ), arg->get_type()->clone() );
 ///     } else {
-				UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
-				deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
-				deref->get_results().push_back( arg->get_type()->clone() );
-				return deref;
+				if ( dynamic_cast<TypeInstType *>(arg->get_type()) == NULL ) {
+					UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
+					deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
+					deref->get_results().push_back( arg->get_type()->clone() );
+					return deref;
+				} // if
 ///     }
 			} // if
@@ -544,7 +548,6 @@
 			} // for
 
-			// parameter function types for which an appropriate adapter has been generated.
-			// we cannot use the types after applying substitutions, since two different 
-			// parameter types may be unified to the same type
+			// parameter function types for which an appropriate adapter has been generated.  we cannot use the types
+			// after applying substitutions, since two different parameter types may be unified to the same type
 			std::set< std::string > adaptersDone;
 
@@ -554,47 +557,33 @@
 				std::string mangleName = SymTab::Mangler::mangle( realFunction );
 
-				// only attempt to create an adapter or pass one as a parameter if we haven't 
-				// already done so for this pre-substitution parameter function type.
+				// only attempt to create an adapter or pass one as a parameter if we haven't already done so for this
+				// pre-substitution parameter function type.
 				if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
-					std::string mangleName = SymTab::Mangler::mangle( realFunction );
 					adaptersDone.insert( adaptersDone.begin(), mangleName );
 					
-					// apply substitution to type variables to figure out what the 
-					// adapter's type should look like
+					// apply substitution to type variables to figure out what the adapter's type should look like
 					assert( env );
 					env->apply( realFunction );
 					mangleName = SymTab::Mangler::mangle( realFunction );
 
-					if ( needsAdapter( realFunction, exprTyVars, true ) ) {
-						// the function still contains type variables, which means we are in a polymorphic
-						// context and the adapter function is a parameter - call the parameter and don't 
-						// create a new adapter.
-						appExpr->get_args().push_front( new NameExpr( makeAdapterName ( mangleName ) ) );
-					} else {
-						if ( isPolyRet( originalFunction, exprTyVars ) ) {
-							// if the return type involved polymorphic types, then
-							// the adapter will need to take those polymorphic types
-							// as pointers. Therefore, there can be two different
-							// functions with the same mangled name, so we need two adapter map
-							// stacks and also we need the mangled names to be different.
-							mangleName += "polyret_";
-						}
-
-						AdapterMap & adapters = Pass1::adapters.top();
-						AdapterMap::iterator adapter = adapters.find( mangleName );
-						if ( adapter == adapters.end() ) {
-							// adapter has not been created yet in the current scope, so define it
-							FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars );
-							adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) );
-							stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) );
-						} // if
-						assert( adapter != adapters.end() );
-
-						// add the appropriate adapter as a parameter
-						appExpr->get_args().push_front( new VariableExpr( adapter->second ) );
-					} // if
+					if ( isPolyRet( originalFunction, exprTyVars ) ) {
+						mangleName += "polyret_";
+					} // if
+
+					AdapterMap & adapters = Pass1::adapters.top();
+					AdapterMap::iterator adapter = adapters.find( mangleName );
+					if ( adapter == adapters.end() ) {
+						// adapter has not been created yet in the current scope, so define it
+						FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars );
+						adapter = adapters.insert( adapters.begin(), std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) );
+						stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) );
+					} // if
+					assert( adapter != adapters.end() );
+
+					// add the appropriate adapter as a parameter
+					appExpr->get_args().push_front( new VariableExpr( adapter->second ) );
 				} // if
 			} // for
-		}
+		} // passAdapters
 
 		TypeInstType *isPolyPtr( Type *type, const TypeSubstitution *env, const TyVarMap &tyVars ) {
@@ -769,9 +758,9 @@
 
 		Expression *Pass1::mutate( ApplicationExpr *appExpr ) {
-///     std::cerr << "mutate appExpr: ";
-///     for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
-///       std::cerr << i->first << " ";
-///     }
-///     std::cerr << "\n";
+			// std::cerr << "mutate appExpr: ";
+			// for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
+			// 	std::cerr << i->first << " ";
+			// }
+			// std::cerr << "\n";
 			bool oldUseRetval = useRetval;
 			useRetval = false;
@@ -799,9 +788,9 @@
 				ret = addPolyRetParam( appExpr, function, typeName, arg );
 			} else if ( needsAdapter( function, scopeTyVars ) ) {
-///     std::cerr << "needs adapter: ";
-///     for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
-///       std::cerr << i->first << " ";
-///     }
-///     std::cerr << "\n";
+				// std::cerr << "needs adapter: ";
+				// for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
+				// 	std::cerr << i->first << " ";
+				// }
+				// std::cerr << "\n";
 				// change the application so it calls the adapter rather than the passed function
 				ret = applyAdapter( appExpr, function, arg, scopeTyVars );
@@ -913,5 +902,5 @@
 			// actually, maybe this could (should?) push
 			// a copy of the current map
-			adapters.push(AdapterMap());
+			adapters.push(adapters.top());
 		}
 
@@ -935,4 +924,7 @@
 			for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
 				std::string mangleName = SymTab::Mangler::mangle( *funType );
+				if ( isPolyRet( *funType, scopeTyVars ) ) {
+					mangleName += "polyret_";
+				} // if
 				if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
 					std::string adapterName = makeAdapterName( mangleName );
@@ -1000,4 +992,5 @@
 			for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
 				ObjectDecl *thisParm;
+				// add all size parameters to parameter list
 				if ( (*tyParm)->get_kind() == TypeDecl::Any ) {
 					thisParm = newObj->clone();
@@ -1006,4 +999,5 @@
 					++last;
 				}
+				// move all assertions into parameter list
 				for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
 ///      *assert = (*assert)->acceptMutator( *this );
Index: src/GenPoly/Box.h
===================================================================
--- src/GenPoly/Box.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/GenPoly/Box.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue May 19 07:32:33 2015
-// Update Count     : 2
+// Last Modified On : Thu Nov 19 17:24:01 2015
+// Update Count     : 5
 //
 
Index: src/GenPoly/GenPoly.cc
===================================================================
--- src/GenPoly/GenPoly.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/GenPoly/GenPoly.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue May 19 07:37:46 2015
-// Update Count     : 1
+// Last Modified On : Thu Nov 19 17:23:44 2015
+// Update Count     : 10
 //
 
@@ -21,36 +21,56 @@
 
 namespace GenPoly {
-	// interface functions
-	bool isPolyVal( Type *type, const TyVarMap &tyVars ) {
-		return isPolyVal( type, tyVars, false );
+	// A function needs an adapter if it returns a polymorphic value or if any of its
+	// parameters have polymorphic type
+	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {
+		if ( ! adaptee->get_returnVals().empty() && isPolyVal( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
+			return true;
+		} // if
+		for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
+			if ( isPolyVal( (*innerArg)->get_type(), tyVars ) ) {
+				return true;
+			} // if
+		} // for
+		return false;
 	}
 
-	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {  
-		return needsAdapter( adaptee, tyVars, false );
+	bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars ) {
+		bool doTransform = false;
+		if ( ! function->get_returnVals().empty() ) {
+			if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( function->get_returnVals().front()->get_type() ) ) {
+	
+				// figure out if the return type is specified by a type parameter
+				for ( std::list< TypeDecl *>::const_iterator tyVar = function->get_forall().begin(); tyVar != function->get_forall().end(); ++tyVar ) {
+					if ( (*tyVar)->get_name() == typeInst->get_name() ) {
+						doTransform = true;
+						name = typeInst->get_name();
+						break;
+					} // if
+				} // for
+				if ( ! doTransform && otherTyVars.find( typeInst->get_name() ) != otherTyVars.end() ) {
+					doTransform = true;
+				} // if
+			} // if
+		} // if
+		return doTransform;
 	}
 
-	bool isPolyVal( Type *type, const TyVarMap &tyVars, bool considerAllTyVars ) {
-		if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {
+	bool isPolyRet( FunctionType *function, std::string &name ) {
+		TyVarMap dummyTyVars;
+		return isPolyRet( function, name, dummyTyVars );
+	}
+
+	bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) {
+		std::string dummyString;
+		return isPolyRet( function, dummyString, otherTyVars );
+	}
+
+	bool isPolyVal( Type *type, const TyVarMap &tyVars ) {
+		if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
 			if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
 				return true;
 			} // if
-			return considerAllTyVars;
 		} // if
 		return false;
-	}
-
-	// A function needs an adapter if it returns a polymorphic value or if any of its
-	// parameters have polymorphic type
-	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars, bool considerAllTyVars ) {
-		bool needsAdapter = false;
-		if ( ! adaptee->get_returnVals().empty() && isPolyVal( adaptee->get_returnVals().front()->get_type(), tyVars, considerAllTyVars ) ) {
-			needsAdapter = true;
-		} // if
-		for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); ! needsAdapter && innerArg != adaptee->get_parameters().end(); ++innerArg ) {
-			if ( isPolyVal( (*innerArg)->get_type(), tyVars, considerAllTyVars ) ) {
-				needsAdapter = true;
-			} // if
-		} // for
-		return needsAdapter;
 	}
 
Index: src/GenPoly/GenPoly.h
===================================================================
--- src/GenPoly/GenPoly.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/GenPoly/GenPoly.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue May 19 07:38:34 2015
-// Update Count     : 1
+// Last Modified On : Thu Nov 19 17:24:03 2015
+// Update Count     : 4
 //
 
@@ -25,12 +25,10 @@
 	typedef std::map< std::string, TypeDecl::Kind > TyVarMap;
 
-	// considerAllTyVars allows ignoring the contents of the TyVarMap parameter, for the situations where
-	// it is important only that a TypeInstType node exists.
-
 	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
-	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars, bool considerAllTyVars );
-	bool isPolyFun( FunctionType *fun, const TyVarMap &tyVars );
+	bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars );
+	bool isPolyRet( FunctionType *function, std::string &name );
+	bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars );
+//	bool isPolyFun( FunctionType *fun, const TyVarMap &tyVars );
 	bool isPolyVal( Type *type, const TyVarMap &tyVars );
-	bool isPolyVal( Type *type, const TyVarMap &tyVars, bool considerAllTyVars );
 	void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
 } // namespace GenPoly
Index: src/Parser/LinkageSpec.cc
===================================================================
--- src/Parser/LinkageSpec.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/Parser/LinkageSpec.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Sat May 16 13:22:09 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May 16 13:23:21 2015
-// Update Count     : 2
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Aug 19 15:53:05 2015
+// Update Count     : 5
 // 
 
@@ -79,4 +79,19 @@
 }
 
+
+bool LinkageSpec::isOverridable( Type t ) {
+	switch ( t ) {
+	  case Intrinsic:
+	  case AutoGen:
+		return true;
+	  case Cforall:
+	  case C:
+	  case Compiler:
+		return false;
+	}
+	assert( false );
+	return false;
+}
+
 bool LinkageSpec::isBuiltin( Type t ) {
 	switch ( t ) {
Index: src/Parser/LinkageSpec.h
===================================================================
--- src/Parser/LinkageSpec.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/Parser/LinkageSpec.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Sat May 16 13:24:28 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May 16 13:26:14 2015
-// Update Count     : 3
+// Last Modified By : Rob Schluntz
+// Last Modified On : Tue Aug 18 14:11:55 2015
+// Update Count     : 5
 //
 
@@ -34,4 +34,5 @@
 	static bool isGeneratable( Type );
 	static bool isOverloadable( Type );
+	static bool isOverridable( Type );
 	static bool isBuiltin( Type );
 };
Index: src/ResolvExpr/CastCost.cc
===================================================================
--- src/ResolvExpr/CastCost.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/ResolvExpr/CastCost.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 06:57:43 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 17 06:59:10 2015
-// Update Count     : 2
+// Last Modified By : Rob Schluntz
+// Last Modified On : Mon Oct 05 14:48:45 2015
+// Update Count     : 5
 //
 
@@ -56,4 +56,5 @@
 				return Cost::infinity;
 			} else {
+				// xxx - why are we adding cost 0 here?
 				return converter.get_cost() + Cost( 0, 0, 0 );
 			} // if
@@ -82,8 +83,8 @@
 				newEnv.add( pointerType->get_forall() );
 				newEnv.add( pointerType->get_base()->get_forall() );
-				int assignResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
-				if ( assignResult > 0 ) {
+				int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
+				if ( castResult > 0 ) {
 					cost = Cost( 0, 0, 1 );
-				} else if ( assignResult < 0 ) {
+				} else if ( castResult < 0 ) {
 					cost = Cost( 1, 0, 0 );
 				} // if
Index: src/ResolvExpr/PtrsAssignable.cc
===================================================================
--- src/ResolvExpr/PtrsAssignable.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/ResolvExpr/PtrsAssignable.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 11:44:11 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 17 11:47:36 2015
-// Update Count     : 2
+// Last Modified By : Rob Schluntz
+// Last Modified On : Mon Sep 21 14:34:58 2015
+// Update Count     : 7
 //
 
@@ -106,5 +106,5 @@
 	void PtrsAssignable::visit( TypeInstType *inst ) {
 		EqvClass eqvClass;
-		if ( env.lookup( inst->get_name(), eqvClass ) ) {
+		if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
 			result = ptrsAssignable( eqvClass.type, dest, env );
 		} else {
Index: src/ResolvExpr/PtrsCastable.cc
===================================================================
--- src/ResolvExpr/PtrsCastable.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/ResolvExpr/PtrsCastable.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 11:48:00 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 17 11:51:17 2015
-// Update Count     : 2
+// Last Modified By : Rob Schluntz
+// Last Modified On : Mon Oct 05 14:49:12 2015
+// Update Count     : 7
 //
 
@@ -133,5 +133,5 @@
 
 	void PtrsCastable::visit(TypeInstType *inst) {
-		result = objectCast( inst, env, indexer ) && objectCast( dest, env, indexer ) ? 1 : -1;
+		result = objectCast( inst, env, indexer ) > 0 && objectCast( dest, env, indexer ) > 0 ? 1 : -1;
 	}
 
Index: src/ResolvExpr/Unify.cc
===================================================================
--- src/ResolvExpr/Unify.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/ResolvExpr/Unify.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 12:27:10 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jun 26 14:57:05 2015
-// Update Count     : 7
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Sep 02 14:43:22 2015
+// Update Count     : 36
 //
 
@@ -28,5 +28,5 @@
 
 
-//#define DEBUG
+// #define DEBUG
 
 namespace ResolvExpr {
@@ -81,9 +81,15 @@
 	bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
 		TypeEnvironment newEnv;
-		OpenVarSet openVars;
+		OpenVarSet openVars, closedVars; // added closedVars
 		AssertionSet needAssertions, haveAssertions;
 		Type *newFirst = first->clone(), *newSecond = second->clone();
 		env.apply( newFirst );
 		env.apply( newSecond );
+
+		// do we need to do this? Seems like we do, types should be able to be compatible if they
+		// have free variables that can unify
+		findOpenVars( newFirst, openVars, closedVars, needAssertions, haveAssertions, false );
+		findOpenVars( newSecond, openVars, closedVars, needAssertions, haveAssertions, true );
+
 		bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
 		delete newFirst;
@@ -426,7 +432,31 @@
 
 	void Unify::visit(ArrayType *arrayType) {
-		// XXX -- compare array dimension
 		ArrayType *otherArray = dynamic_cast< ArrayType* >( type2 );
-		if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
+		// to unify, array types must both be VLA or both not VLA
+		// and must both have a dimension expression or not have a dimension
+		if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() 
+				&& ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0)
+					|| (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) {
+
+			// not positive this is correct in all cases, but it's needed for typedefs
+			if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) {
+				return;
+			}
+
+			if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() &&
+				arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) {
+				ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() );
+				ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() );
+				assert(ce1 && ce2);
+
+				Constant * c1 = ce1->get_constant();
+				Constant * c2 = ce2->get_constant();
+
+				if ( c1->get_value() != c2->get_value() ) {
+					// does not unify if the dimension is different
+					return;
+				}
+			}
+
 			result = unifyExact( arrayType->get_base(), otherArray->get_base(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
 		} // if
@@ -436,4 +466,6 @@
 	bool unifyDeclList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
 		for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
+			// Type * commonType;
+			// if ( ! unifyInexact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) {
 			if ( ! unifyExact( (*list1Begin)->get_type(), (*list2Begin)->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
 				return false;
@@ -450,5 +482,5 @@
 		FunctionType *otherFunction = dynamic_cast< FunctionType* >( type2 );
 		if ( otherFunction && functionType->get_isVarArgs() == otherFunction->get_isVarArgs() ) {
-  
+
 			if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
 	
Index: src/SymTab/IdTable.cc
===================================================================
--- src/SymTab/IdTable.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SymTab/IdTable.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 17:04:02 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 17 17:07:43 2015
-// Update Count     : 3
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Oct 07 12:21:13 2015
+// Update Count     : 73
 //
 
@@ -37,4 +37,5 @@
 			for ( InnerTableType::iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
 				std::stack< DeclEntry >& entry = inner->second;
+				// xxx - should be while?
 				if ( ! entry.empty() && entry.top().second == scopeLevel ) {
 					entry.pop();
@@ -52,4 +53,9 @@
 		if ( decl->get_linkage() == LinkageSpec::C ) {
 			manglename = name;
+		} else if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) {
+			// mangle the name without including the appropriate suffix
+			// this will make it so that overridable routines are placed
+			// into the same "bucket" as their user defined versions.
+			manglename = Mangler::mangle( decl, false );
 		} else {
 			manglename = Mangler::mangle( decl );
@@ -60,18 +66,36 @@
 
 		if ( it == declTable.end() ) {
+			// first time this name mangling has been defined
 			declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
 		} else {
 			std::stack< DeclEntry >& entry = it->second;
 			if ( ! entry.empty() && entry.top().second == scopeLevel ) {
-				if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) {
+				// if we're giving the same name mangling to things of
+				//  different types then there is something wrong
+				Declaration *old = entry.top().first;
+				assert( (dynamic_cast<ObjectDecl*>( decl ) && dynamic_cast<ObjectDecl*>( old ) )
+				  || (dynamic_cast<FunctionDecl*>( decl ) && dynamic_cast<FunctionDecl*>( old ) ) );
+
+				if ( LinkageSpec::isOverridable( old->get_linkage() ) ) {
+					// new definition shadows the autogenerated one, even at the same scope
+					declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
+				} else if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) {
+					// typesCompatible doesn't really do the right thing here. When checking compatibility of function types,
+					// we should ignore outermost pointer qualifiers, except _Atomic?
 					FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl );
-					FunctionDecl *old = dynamic_cast< FunctionDecl* >( entry.top().first );
-					if ( newentry && old && newentry->get_statements() && old->get_statements() ) {
-						throw SemanticError( "duplicate function definition for ", decl );
+					FunctionDecl *oldentry = dynamic_cast< FunctionDecl* >( old );
+					if ( newentry && oldentry ) {
+						if ( newentry->get_statements() && oldentry->get_statements() ) {
+							throw SemanticError( "duplicate function definition for 1 ", decl );
+						} // if
 					} else {
+						// two objects with the same mangled name defined in the same scope.
+						// both objects must be marked extern or both must be intrinsic for this to be okay
+						// xxx - perhaps it's actually if either is intrinsic then this is okay?
+						//       might also need to be same storage class?
 						ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( decl );
-						ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( entry.top().first );
-						if ( newobj && oldobj && newobj->get_init() && oldobj->get_init() ) {
-							throw SemanticError( "duplicate definition for ", decl );
+						ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( old );
+						if (newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {
+							throw SemanticError( "duplicate definition for 3 ", decl );
 						} // if
 					} // if
@@ -80,8 +104,9 @@
 				} // if
 			} else {
+				// new scope level - shadow existing definition
 				declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
 			} // if
 		} // if
-		// ensure the set of routines with C linkage cannot be overloaded
+		// this ensures that no two declarations with the same unmangled name both have C linkage
 		for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
 			if ( ! i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) {
Index: src/SymTab/Mangler.cc
===================================================================
--- src/SymTab/Mangler.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SymTab/Mangler.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 21:40:29 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jun  8 15:12:12 2015
-// Update Count     : 8
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Aug 19 15:52:24 2015
+// Update Count     : 19
 //
 
@@ -30,5 +30,5 @@
 
 namespace SymTab {
-	Mangler::Mangler() : nextVarNum( 0 ), isTopLevel( true ) {
+	Mangler::Mangler( bool mangleOverridable ) : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ) {
 	}
 
@@ -41,4 +41,5 @@
 		nextVarNum = rhs.nextVarNum;
 		isTopLevel = rhs.isTopLevel;
+		mangleOverridable = rhs.mangleOverridable;
 	}
 
@@ -59,4 +60,16 @@
 		mangleName << "__";
 		maybeAccept( declaration->get_type(), *this );
+		if ( mangleOverridable && LinkageSpec::isOverridable( declaration->get_linkage() ) ) {
+			// want to be able to override autogenerated and intrinsic routines,
+			// so they need a different name mangling
+			if ( declaration->get_linkage() == LinkageSpec::AutoGen ) {
+				mangleName << "autogen__";
+			} else if ( declaration->get_linkage() == LinkageSpec::Intrinsic ) {
+				mangleName << "intrinsic__";
+			} else {
+				// if we add another kind of overridable function, this has to change
+				assert( false );
+			} // if
+		}
 		isTopLevel = wasTopLevel;
 	}
@@ -214,5 +227,5 @@
 				varNums[ (*i )->get_name() ] = std::pair< int, int >( nextVarNum++, (int )(*i )->get_kind() );
 				for ( std::list< DeclarationWithType* >::iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
-					Mangler sub_mangler;
+					Mangler sub_mangler( mangleOverridable );
 					sub_mangler.nextVarNum = nextVarNum;
 					sub_mangler.isTopLevel = false;
Index: src/SymTab/Mangler.h
===================================================================
--- src/SymTab/Mangler.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SymTab/Mangler.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 21:44:03 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jun  8 14:47:14 2015
-// Update Count     : 5
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Aug 19 15:48:46 2015
+// Update Count     : 14
 //
 
@@ -25,5 +25,5 @@
 	  public:
 		template< typename SynTreeClass >
-	    static std::string mangle( SynTreeClass *decl ); // interface to clients
+	    static std::string mangle( SynTreeClass *decl, bool mangleOverridable = true ); // interface to clients
 
 ///   using Visitor::visit;
@@ -50,6 +50,7 @@
 		int nextVarNum;
 		bool isTopLevel;
+		bool mangleOverridable;
   
-		Mangler();
+		Mangler( bool mangleOverridable );
 		Mangler( const Mangler & );
   
@@ -61,6 +62,6 @@
 
 	template< typename SynTreeClass >
-	std::string Mangler::mangle( SynTreeClass *decl ) {
-		Mangler mangler;
+	std::string Mangler::mangle( SynTreeClass *decl, bool mangleOverridable ) {
+		Mangler mangler( mangleOverridable );
 		maybeAccept( decl, mangler );
 		return mangler.get_mangleName();
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SymTab/Validate.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 21:50:04 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Aug 11 16:59:35 2015
-// Update Count     : 196
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri Nov 20 16:33:52 2015
+// Update Count     : 201
 //
 
@@ -54,4 +54,5 @@
 #include "MakeLibCfa.h"
 #include "TypeEquality.h"
+#include "ResolvExpr/typeops.h"
 
 #define debugPrint( x ) if ( doDebug ) { std::cout << x; }
@@ -125,8 +126,8 @@
 	};
 
-	class AddStructAssignment : public Visitor {
+	class AutogenerateRoutines : public Visitor {
 	  public:
 		/// Generates assignment operators for aggregate types as required
-		static void addStructAssignment( std::list< Declaration * > &translationUnit );
+		static void autogenerateRoutines( std::list< Declaration * > &translationUnit );
 
 		std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
@@ -151,5 +152,5 @@
 		virtual void visit( CatchStmt *catchStmt );
 
-		AddStructAssignment() : functionNesting( 0 ) {}
+		AutogenerateRoutines() : functionNesting( 0 ) {}
 	  private:
 		template< typename StmtClass > void visitStatement( StmtClass *stmt );
@@ -195,7 +196,5 @@
 		acceptAll( translationUnit, pass1 );
 		acceptAll( translationUnit, pass2 );
-		// need to collect all of the assignment operators prior to
-		// this point and only generate assignment operators if one doesn't exist
-		AddStructAssignment::addStructAssignment( translationUnit );
+		AutogenerateRoutines::autogenerateRoutines( translationUnit );
 		acceptAll( translationUnit, pass3 );
 	}
@@ -501,6 +500,6 @@
 	static const std::list< std::string > noLabels;
 
-	void AddStructAssignment::addStructAssignment( std::list< Declaration * > &translationUnit ) {
-		AddStructAssignment visitor;
+	void AutogenerateRoutines::autogenerateRoutines( std::list< Declaration * > &translationUnit ) {
+		AutogenerateRoutines visitor;
 		acceptAndAdd( translationUnit, visitor, false );
 	}
@@ -704,5 +703,5 @@
 	}
 
-	void AddStructAssignment::visit( EnumDecl *enumDecl ) {
+	void AutogenerateRoutines::visit( EnumDecl *enumDecl ) {
 		if ( ! enumDecl->get_members().empty() ) {
 			EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
@@ -713,5 +712,5 @@
 	}
 
-	void AddStructAssignment::visit( StructDecl *structDecl ) {
+	void AutogenerateRoutines::visit( StructDecl *structDecl ) {
 		if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
 			StructInstType *structInst = new StructInstType( Type::Qualifiers(), structDecl->get_name() );
@@ -722,5 +721,5 @@
 	}
 
-	void AddStructAssignment::visit( UnionDecl *unionDecl ) {
+	void AutogenerateRoutines::visit( UnionDecl *unionDecl ) {
 		if ( ! unionDecl->get_members().empty() ) {
 			UnionInstType *unionInst = new UnionInstType( Type::Qualifiers(), unionDecl->get_name() );
@@ -730,5 +729,5 @@
 	}
 
-	void AddStructAssignment::visit( TypeDecl *typeDecl ) {
+	void AutogenerateRoutines::visit( TypeDecl *typeDecl ) {
 		CompoundStmt *stmts = 0;
 		TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
@@ -758,18 +757,18 @@
 	}
 
-	void AddStructAssignment::visit( FunctionType *) {
+	void AutogenerateRoutines::visit( FunctionType *) {
 		// ensure that we don't add assignment ops for types defined as part of the function
 	}
 
-	void AddStructAssignment::visit( PointerType *) {
+	void AutogenerateRoutines::visit( PointerType *) {
 		// ensure that we don't add assignment ops for types defined as part of the pointer
 	}
 
-	void AddStructAssignment::visit( ContextDecl *) {
+	void AutogenerateRoutines::visit( ContextDecl *) {
 		// ensure that we don't add assignment ops for types defined as part of the context
 	}
 
 	template< typename StmtClass >
-	inline void AddStructAssignment::visitStatement( StmtClass *stmt ) {
+	inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) {
 		std::set< std::string > oldStructs = structsDone;
 		addVisit( stmt, *this );
@@ -777,5 +776,5 @@
 	}
 
-	void AddStructAssignment::visit( FunctionDecl *functionDecl ) {
+	void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) {
 		maybeAccept( functionDecl->get_functionType(), *this );
 		acceptAll( functionDecl->get_oldDecls(), *this );
@@ -785,33 +784,33 @@
 	}
 
-	void AddStructAssignment::visit( CompoundStmt *compoundStmt ) {
+	void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) {
 		visitStatement( compoundStmt );
 	}
 
-	void AddStructAssignment::visit( IfStmt *ifStmt ) {
+	void AutogenerateRoutines::visit( IfStmt *ifStmt ) {
 		visitStatement( ifStmt );
 	}
 
-	void AddStructAssignment::visit( WhileStmt *whileStmt ) {
+	void AutogenerateRoutines::visit( WhileStmt *whileStmt ) {
 		visitStatement( whileStmt );
 	}
 
-	void AddStructAssignment::visit( ForStmt *forStmt ) {
+	void AutogenerateRoutines::visit( ForStmt *forStmt ) {
 		visitStatement( forStmt );
 	}
 
-	void AddStructAssignment::visit( SwitchStmt *switchStmt ) {
+	void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) {
 		visitStatement( switchStmt );
 	}
 
-	void AddStructAssignment::visit( ChooseStmt *switchStmt ) {
+	void AutogenerateRoutines::visit( ChooseStmt *switchStmt ) {
 		visitStatement( switchStmt );
 	}
 
-	void AddStructAssignment::visit( CaseStmt *caseStmt ) {
+	void AutogenerateRoutines::visit( CaseStmt *caseStmt ) {
 		visitStatement( caseStmt );
 	}
 
-	void AddStructAssignment::visit( CatchStmt *cathStmt ) {
+	void AutogenerateRoutines::visit( CatchStmt *cathStmt ) {
 		visitStatement( cathStmt );
 	}
@@ -857,5 +856,5 @@
 			Type * t1 = tyDecl->get_base();
 			Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
-			if ( ! typeEquals( t1, t2, true ) ) {
+			if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
 				throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() );
 			}
Index: src/SynTree/Mutator.h
===================================================================
--- src/SynTree/Mutator.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SynTree/Mutator.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 23 23:24:18 2015
-// Update Count     : 7
+// Last Modified On : Thu Nov 19 22:26:16 2015
+// Update Count     : 8
 //
 #include <cassert>
@@ -103,5 +103,5 @@
 inline TreeType *maybeMutate( TreeType *tree, MutatorType &mutator ) {
 	if ( tree ) {
-		TreeType *newnode = dynamic_cast< TreeType* >( tree->acceptMutator( mutator ) );
+		TreeType *newnode = dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
 		assert( newnode );
 		return newnode;
Index: src/SynTree/ObjectDecl.cc
===================================================================
--- src/SynTree/ObjectDecl.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SynTree/ObjectDecl.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jul 13 18:08:27 2015
-// Update Count     : 16
+// Last Modified By : Rob Schluntz
+// Last Modified On : Tue Sep 29 14:13:01 2015
+// Update Count     : 18
 //
 
@@ -52,14 +52,14 @@
 		get_type()->print( os, indent );
 	} else {
-		os << "untyped entity ";
+		os << " untyped entity ";
 	} // if
 
 	if ( init ) {
-		os << "with initializer ";
+		os << " with initializer ";
 		init->print( os, indent );
 	} // if
 
 	if ( bitfieldWidth ) {
-		os << "with bitfield width ";
+		os << " with bitfield width ";
 		bitfieldWidth->print( os );
 	} // if
Index: src/SynTree/Type.h
===================================================================
--- src/SynTree/Type.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/SynTree/Type.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul  9 16:46:15 2015
-// Update Count     : 14
+// Last Modified On : Fri Nov 20 12:54:09 2015
+// Update Count     : 15
 //
 
@@ -201,6 +201,6 @@
 	std::list<DeclarationWithType*> parameters;
 
-	// does the function accept a variable number of arguments following the arguments
-	// specified in the parameters list.    This could be because of
+	// Does the function accept a variable number of arguments following the arguments specified in the parameters list.
+	// This could be because of
 	// - an ellipsis in a prototype declaration
 	// - an unprototyped declaration
@@ -239,5 +239,5 @@
 
 	/// Accesses generic parameters of base struct (NULL if none such)
-	std::list<TypeDecl*>* get_baseParameters();
+	std::list<TypeDecl*> * get_baseParameters();
 	
 	/// Looks up the members of this struct named "name" and places them into "foundDecls".
@@ -266,5 +266,5 @@
 
 	/// Accesses generic parameters of base union (NULL if none such)
-	std::list<TypeDecl*>* get_baseParameters();
+	std::list<TypeDecl*> * get_baseParameters();
 	
 	/// looks up the members of this union named "name" and places them into "foundDecls"
Index: src/examples/Makefile.am
===================================================================
--- src/examples/Makefile.am	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/Makefile.am	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -11,6 +11,6 @@
 ## Created On       : Sun May 31 09:08:15 2015
 ## Last Modified By : Peter A. Buhr
-## Last Modified On : Thu Jun  4 23:13:10 2015
-## Update Count     : 22
+## Last Modified On : Fri Nov 20 16:03:46 2015
+## Update Count     : 24
 ###############################################################################
 
@@ -19,5 +19,5 @@
 CC = @CFA_BINDIR@/cfa
 
-noinst_PROGRAMS = fstream_test vector_test
-fstream_test_SOURCES = iostream.c fstream.c fstream_test.c
+noinst_PROGRAMS = fstream_test vector_test # build but do not install
+fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
Index: src/examples/Makefile.in
===================================================================
--- src/examples/Makefile.in	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/Makefile.in	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -49,5 +49,5 @@
 PROGRAMS = $(noinst_PROGRAMS)
 am_fstream_test_OBJECTS = iostream.$(OBJEXT) fstream.$(OBJEXT) \
-	fstream_test.$(OBJEXT)
+	fstream_test.$(OBJEXT) iterator.$(OBJEXT)
 fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
 fstream_test_LDADD = $(LDADD)
@@ -176,5 +176,5 @@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-fstream_test_SOURCES = iostream.c fstream.c fstream_test.c
+fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
 all: all-am
Index: src/examples/fstream.c
===================================================================
--- src/examples/fstream.c	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/fstream.c	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:12:33 2015
-// Update Count     : 2
+// Last Modified On : Thu Nov 19 22:43:31 2015
+// Update Count     : 4
 //
 
@@ -30,11 +30,11 @@
 		fwrite( data, size, 1, os->file );
 		os->fail = ferror( os->file );
-	}
+	} // if
 	return os;
-}
+} // write
 
 int fail( ofstream *os ) {
 	return os->fail;
-}
+} // fail
 
 static ofstream *make_ofstream() {
@@ -42,5 +42,5 @@
 	new_stream->fail = 0;
 	return new_stream;
-}
+} // make_ofstream
 
 ofstream *ofstream_stdout() {
@@ -48,5 +48,5 @@
 	stdout_stream->file = stdout;
 	return stdout_stream;
-}
+} // ofstream_stdout
 
 ofstream *ofstream_stderr() {
@@ -54,5 +54,5 @@
 	stderr_stream->file = stderr;
 	return stderr_stream;
-}
+} // ofstream_stderr
 
 ofstream *ofstream_fromfile( const char *name ) {
Index: src/examples/hello.c
===================================================================
--- src/examples/hello.c	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/hello.c	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:14:58 2015
-// Update Count     : 1
+// Last Modified On : Fri Nov 20 16:02:50 2015
+// Update Count     : 3
 //
 
@@ -28,4 +28,4 @@
 // Local Variables: //
 // tab-width: 4 //
-// compile-command: "cfa hello.c fstream.o iostream.o" //
+// compile-command: "cfa hello.c fstream.o iostream.o iterator.o" //
 // End: //
Index: src/examples/iostream.c
===================================================================
--- src/examples/iostream.c	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/iostream.c	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:18:13 2015
-// Update Count     : 2
+// Last Modified On : Fri Nov 20 13:19:19 2015
+// Update Count     : 9
 //
 
@@ -17,8 +17,5 @@
 extern "C" {
 #include <stdio.h>
-//#include <string.h>
-//#include <ctype.h>
-	typedef long unsigned int size_t;
-	size_t strlen(const char *s);
+#include <string.h>										// strlen
 }
 
@@ -26,29 +23,57 @@
 ostype * ?<<?( ostype *os, char c ) {
 	return write( os, &c, 1 );
-}
+} // ?<<?
 
 forall( dtype ostype | ostream( ostype ) )
 ostype * ?<<?( ostype *os, int i ) {
-	char buffer[20];      // larger than the largest integer
+	char buffer[32];									// larger than the largest integer
 	sprintf( buffer, "%d", i );
 	return write( os, buffer, strlen( buffer ) );
-}
+} // ?<<?
 
 forall( dtype ostype | ostream( ostype ) )
 ostype * ?<<?( ostype *os, double d ) {
-	char buffer[32];      // larger than the largest double
+	char buffer[32];									// larger than the largest double
 	sprintf( buffer, "%g", d );
 	return write( os, buffer, strlen( buffer ) );
-}
+} // ?<<?
 
 forall( dtype ostype | ostream( ostype ) )
 ostype * ?<<?( ostype *os, const char *cp ) {
 	return write( os, cp, strlen( cp ) );
-}
+} // ?<<?
+
+forall( dtype ostype | ostream( ostype ) )
+ostype * ?<<?( ostype *os, const void *p ) {
+	char buffer[32];									// larger than the largest pointer
+	sprintf( buffer, "%p", p );
+	return write( os, buffer, strlen( buffer ) );
+} // ?<<?
+
+forall( type elt_type | writeable( elt_type ),
+		type iterator_type | iterator( iterator_type, elt_type ),
+		dtype os_type | ostream( os_type ) )
+void write( iterator_type begin, iterator_type end, os_type *os ) {
+	void print( elt_type i ) {
+		os << i << ' ';
+	}
+	for_each( begin, end, print );
+} // ?<<?
+
+forall( type elt_type | writeable( elt_type ),
+		type iterator_type | iterator( iterator_type, elt_type ),
+		dtype os_type | ostream( os_type ) )
+void write_reverse( iterator_type begin, iterator_type end, os_type *os ) {
+	void print( elt_type i ) {
+		os << i << ' ';
+	}
+	for_each_reverse( begin, end, print );
+} // ?<<?
+
 
 forall( dtype istype | istream( istype ) )
 istype * ?>>?( istype *is, char *cp ) {
 	return read( is, cp, 1 );
-}
+} // ?>>?
 
 forall( dtype istype | istream( istype ) )
@@ -72,5 +97,5 @@
 	unread( is, cur );
 	return is;
-}
+} // ?>>?
 
 // Local Variables: //
Index: src/examples/iostream.h
===================================================================
--- src/examples/iostream.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/iostream.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,10 +10,12 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:18:46 2015
-// Update Count     : 1
+// Last Modified On : Thu Nov 19 17:56:51 2015
+// Update Count     : 5
 //
 
 #ifndef IOSTREAM_H
 #define IOSTREAM_H
+
+#include "iterator.h"
 
 typedef unsigned long streamsize_type;
@@ -34,4 +36,16 @@
 forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, double );
 forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, const char * );
+forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, void * );
+
+// writes the range [begin, end) to the given stream
+forall( type elt_type | writeable( elt_type ),
+		type iterator_type | iterator( iterator_type, elt_type ),
+		dtype os_type | ostream( os_type ) )
+void write( iterator_type begin, iterator_type end, os_type *os );
+
+forall( type elt_type | writeable( elt_type ),
+		type iterator_type | iterator( iterator_type, elt_type ),
+		dtype os_type | ostream( os_type ) )
+void write_reverse( iterator_type begin, iterator_type end, os_type *os );
 
 
Index: src/examples/iterator.c
===================================================================
--- src/examples/iterator.c	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/iterator.c	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,40 +10,23 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:41:41 2015
-// Update Count     : 3
+// Last Modified On : Thu Nov 19 17:54:37 2015
+// Update Count     : 24
 //
 
 #include "iterator.h"
 
-/// forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
-/// void
-/// for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) )
-/// {
-///   iterator_type i;
-///   for ( i = begin; i != end; ++i ) {
-///	 func( *i );
-///   }
-/// }
-
-forall( type elt_type | writeable( elt_type ),
-		type iterator_type | iterator( iterator_type, elt_type ),
-		dtype os_type | ostream( os_type ) )
-void write_all( iterator_type begin, iterator_type end, os_type *os ) {
-	iterator_type i;
-	for ( i = begin; i != end; ++i ) {
-		os << *i << ' ';
+forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
+void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
+	for ( iterator_type i = begin; i != end; ++i ) {
+		func( *i );
 	}
 }
 
-forall( type elt_type | writeable( elt_type ),
-		type iterator_type | iterator( iterator_type, elt_type ),
-		dtype os_type | ostream( os_type ) )
-void write_reverse( iterator_type begin, iterator_type end, os_type *os ) {
-	iterator_type i; // "= end;" does not work
-	i = end;
-	do {
+forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
+void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
+	for ( iterator_type i = end; i != begin; ) {
 		--i;
-		os << *i << ' ';
-	} while ( i != begin );
+		func( *i );
+	}
 }
 
Index: src/examples/iterator.h
===================================================================
--- src/examples/iterator.h	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/iterator.h	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,12 +10,10 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:41:57 2015
-// Update Count     : 3
+// Last Modified On : Thu Nov 19 17:58:28 2015
+// Update Count     : 6
 //
 
 #ifndef ITERATOR_H
 #define ITERATOR_H
-
-#include "iostream.h"
 
 // An iterator can be used to traverse a data structure.
@@ -34,5 +32,5 @@
 };
 
-context iterator_for ( type iterator_type, type collection_type, type elt_type | iterator( iterator_type, elt_type ) ) {
+context iterator_for( type iterator_type, type collection_type, type elt_type | iterator( iterator_type, elt_type ) ) {
 //	[ iterator_type begin, iterator_type end ] get_iterators( collection_type );
 	iterator_type begin( collection_type );
@@ -43,14 +41,6 @@
 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
 
-// writes the range [begin, end) to the given stream
-forall( type elt_type | writeable( elt_type ),
-		type iterator_type | iterator( iterator_type, elt_type ),
-		dtype os_type | ostream( os_type ) )
-void write_all( iterator_type begin, iterator_type end, os_type *os );
-
-forall( type elt_type | writeable( elt_type ),
-		type iterator_type | iterator( iterator_type, elt_type ),
-		dtype os_type | ostream( os_type ) )
-void write_reverse( iterator_type begin, iterator_type end, os_type *os );
+forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
+void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
 
 #endif // ITERATOR_H
Index: src/examples/vector_test.c
===================================================================
--- src/examples/vector_test.c	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/examples/vector_test.c	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 27 18:42:55 2015
-// Update Count     : 2
+// Last Modified On : Thu Nov 19 17:54:34 2015
+// Update Count     : 9
 //
 
@@ -29,25 +29,18 @@
 	sout << "enter N elements and C-d on a separate line:\n";
 	for ( ;; ) {
-	sin >> &num;
+		sin >> &num;
 	  if ( fail( sin ) || eof( sin ) ) break;
-	append( &vec, num );
+		append( &vec, num );
 	}
 	// write out the numbers
 
 	sout << "Array elements:\n";
-//	write_all( begin( vec ), end( vec ), sout );
-//	sout << "\n";
-	for ( int index = 0; index <= last( vec ); index += 1 ) {
-	sout << vec[ index ] << " ";
-	}
+	write( begin( vec ), end( vec ), sout );
 	sout << "\n";
-#if 1
+
 	sout << "Array elements reversed:\n";
 	write_reverse( begin( vec ), end( vec ), sout );
 	sout << "\n";
-#endif
 }
-
-// ../bin/cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o
 
 // Local Variables: //
Index: src/libcfa/prelude.cf
===================================================================
--- src/libcfa/prelude.cf	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/libcfa/prelude.cf	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -7,7 +7,7 @@
 // Author           : Glen Ditchfield
 // Created On       : Sat Nov 29 07:23:41 2014
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jun  9 14:43:47 2015
-// Update Count     : 75
+// Last Modified By : Rob Schluntz
+// Last Modified On : Thu Nov 19 11:09:47 2015
+// Update Count     : 76
 //
 
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 02ec39027c7edf89457931dda6e36b7d2d0cee73)
+++ src/main.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Fri May 15 23:12:02 2015
-// Last Modified By : Rob Schluntz
-// Last Modified On : Thu Jul 30 16:08:18 2015
-// Update Count     : 167
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Nov 19 22:31:40 2015
+// Update Count     : 168
 //
 
@@ -227,6 +227,5 @@
 		} // if
 
-		// add the assignment statement after the 
-		// initialization of a type parameter
+		// add the assignment statement after the initialization of a type parameter
 		OPTPRINT( "validate" )
 		SymTab::validate( translationUnit, symtabp );
