Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision cdec5af734d50032d94d1ef278c504c44b79ef73)
+++ src/GenPoly/Box.cc	(revision 56fcd77789e0a3dd06b9b874c59e22735ec493bb)
@@ -14,7 +14,5 @@
 //
 
-#include <map>
 #include <set>
-#include <sstream>
 #include <stack>
 #include <string>
@@ -22,5 +20,4 @@
 #include <algorithm>
 #include <cassert>
-#include <utility>
 
 #include "Box.h"
@@ -54,21 +51,8 @@
 		FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
 
-		/// Cache for layout struct decls
-		class LayoutStructDecls {
-		public:
-			/// Gets the layout struct declaration for a given number of members (0 for non-generic); creates declarations as needed.
-			/// Declarations are allocated with "new", not freed on LayoutStructDecls destruction
-			StructDecl* get( int members );
-			/// adds all struct declarations to the translation unit
-			void addToTranslationUnit( std::list< Declaration* >& translationUnit );
-		private:
-			/// Layout struct declarations, indexed by number of members in the generic struct (0 for non-generic)
-			std::map< int, StructDecl* > decls;
-		};
-
 		/// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call
 		class Pass1 : public PolyMutator {
 		  public:
-			Pass1( LayoutStructDecls &layoutDecls );
+			Pass1();
 			virtual Expression *mutate( ApplicationExpr *appExpr );
 			virtual Expression *mutate( AddressExpr *addrExpr );
@@ -104,5 +88,4 @@
 			bool useRetval;
 			UniqueName tempNamer;
-			LayoutStructDecls &layoutDecls;
 		};
 
@@ -110,5 +93,4 @@
 		class Pass2 : public PolyMutator {
 		  public:
-			Pass2( LayoutStructDecls &layoutDecls );
 			template< typename DeclClass >
 			DeclClass *handleDecl( DeclClass *decl, Type *type );
@@ -123,5 +105,4 @@
   
 			std::map< UniqueId, std::string > adapterName;
-			LayoutStructDecls &layoutDecls;
 		};
 
@@ -129,5 +110,4 @@
 		class Pass3 : public PolyMutator {
 		  public:
-			Pass3( LayoutStructDecls &layoutDecls );
 			template< typename DeclClass >
 			DeclClass *handleDecl( DeclClass *decl, Type *type );
@@ -140,5 +120,4 @@
 			virtual Type *mutate( FunctionType *funcType );
 		  private:
-			LayoutStructDecls &layoutDecls;
 		};
 
@@ -155,53 +134,10 @@
 
 	void box( std::list< Declaration *>& translationUnit ) {
-		LayoutStructDecls layoutStructs;
-		Pass1 pass1( layoutStructs );
-		Pass2 pass2( layoutStructs );
-		Pass3 pass3( layoutStructs );
+		Pass1 pass1;
+		Pass2 pass2;
+		Pass3 pass3;
 		mutateAll( translationUnit, pass1 );
 		mutateAll( translationUnit, pass2 );
 		mutateAll( translationUnit, pass3 );
-		layoutStructs.addToTranslationUnit( translationUnit );
-	}
-
-	//////////////////////////////////// LayoutStructDecls //////////////////////////////////////////////
-
-	namespace {
-		StructDecl* LayoutStructDecls::get( int members ) {
-			// Attempt to read declaration already in map
-			std::map< int, StructDecl* >::iterator decl = decls.find( members );
-			if ( decl != decls.end() ) return decl->second;
-
-			// Insert if not found
-			std::string member_str;
-			if ( members > 0 ) {
-				std::stringstream ss;
-				ss << members;
-				member_str = ss.str();
-			}
-			StructDecl *newDecl = new StructDecl( std::string("_layout") + member_str );
-
-			newDecl->get_members().push_back(
-					new ObjectDecl( "size", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ) );
-			newDecl->get_members().push_back(
-					new ObjectDecl( "align", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ) );
-			if ( members > 0 ) {
-				ArrayType *aType =
-						new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ),
-									   new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), member_str ) ), false, false );
-				newDecl->get_members().push_back(
-					new ObjectDecl( "offsets", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, aType, 0 ) );
-			}
-
-			decls.insert( std::make_pair( members, newDecl ) );
-
-			return newDecl;
-		}
-
-		void LayoutStructDecls::addToTranslationUnit( std::list< Declaration* >& translationUnit ) {
-			for ( std::map< int, StructDecl* >::reverse_iterator decl = decls.rbegin(); decl != decls.rend(); ++decl ) {
-				translationUnit.push_front( decl->second );
-			}
-		}
 	}
 
@@ -245,6 +181,5 @@
 		}
 
-		Pass1::Pass1( LayoutStructDecls &layoutDecls )
-			: useRetval( false ), tempNamer( "_temp" ), layoutDecls( layoutDecls ) {
+		Pass1::Pass1() : useRetval( false ), tempNamer( "_temp" ) {
 			adapters.push(AdapterMap());
 		}
@@ -374,4 +309,5 @@
 					Type *concrete = env->lookup( tyParm->first );
 					if ( concrete ) {
+						// TODO add alignment
 						arg = appExpr->get_args().insert( arg, new SizeofExpr( concrete->clone() ) );
 						arg++;
@@ -1000,6 +936,4 @@
 ////////////////////////////////////////// Pass2 ////////////////////////////////////////////////////
 
-		Pass2::Pass2( LayoutStructDecls &layoutDecls ) : layoutDecls(layoutDecls) {}
-
 		void Pass2::addAdapters( FunctionType *functionType ) {
 			std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
@@ -1074,4 +1008,5 @@
 			std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
 			std::list< DeclarationWithType *> inferredParams;
+			// TODO add alignment
 			ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
 //   ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 );
@@ -1104,6 +1039,4 @@
 ////////////////////////////////////////// Pass3 ////////////////////////////////////////////////////
 
-		Pass3::Pass3( LayoutStructDecls &layoutDecls ) : layoutDecls(layoutDecls) {}
-
 		template< typename DeclClass >
 		DeclClass * Pass3::handleDecl( DeclClass *decl, Type *type ) {
