Index: src/CodeTools/ResolvProtoDump.cc
===================================================================
--- src/CodeTools/ResolvProtoDump.cc	(revision a4a000d2a3ff4a2bfd24720b9abb1a16354d6a09)
+++ src/CodeTools/ResolvProtoDump.cc	(revision 40cd873d81d1e7979f1ab87d5c95a9cb89059a09)
@@ -27,9 +27,7 @@
 
 #include "Common/PassVisitor.h"
-#include "Common/utility.h"
 #include "CodeGen/OperatorTable.h"
 #include "SynTree/Declaration.h"
 #include "SynTree/Expression.h"
-#include "SynTree/Initializer.h"
 #include "SynTree/Statement.h"
 #include "SynTree/Type.h"
@@ -39,38 +37,15 @@
 	/// Visitor for dumping resolver prototype output
 	class ProtoDump : public WithShortCircuiting, public WithVisitorRef<ProtoDump> {
-		std::set<std::string> decls;             ///< Declarations in this scope
-		std::vector<std::string> exprs;          ///< Expressions in this scope
-		std::vector<ProtoDump> subs;             ///< Sub-scopes
-		std::unordered_set<std::string> closed;  ///< Closed type variables
-		const ProtoDump* parent;                 ///< Outer lexical scope
-		std::unique_ptr<Type> rtnType;           ///< Return type for this scope
+		std::set<std::string> decls;     ///< Declarations in this scope
+		std::vector<std::string> exprs;  ///< Expressions in this scope
+		std::vector<ProtoDump> subs;     ///< Sub-scopes
+		const ProtoDump* parent;         ///< Outer lexical scope
 
 	public:
 		/// Default constructor for root ProtoDump
-		ProtoDump() : decls(), exprs(), subs(), closed(), parent(nullptr), rtnType(nullptr) {}
+		ProtoDump() : decls(), exprs(), subs(), parent(nullptr) {}
 
 		/// Child constructor
-		ProtoDump(const ProtoDump* p, Type* r) 
-			: decls(), exprs(), subs(), closed(p->closed), parent(p), rtnType(r) {}
-
-		// Fix copy issues
-		ProtoDump(const ProtoDump& o) 
-			: decls(o.decls), exprs(o.exprs), subs(o.subs), closed(o.closed), parent(o.parent), 
-			  rtnType(maybeClone(o.rtnType.get())) {}
-		ProtoDump( ProtoDump&& ) = default;
-
-		ProtoDump& operator= (const ProtoDump& o) {
-			if ( this == &o ) return *this;
-
-			decls = o.decls;
-			exprs = o.exprs;
-			subs = o.subs;
-			closed = o.closed;
-			parent = o.parent;
-			rtnType.reset( maybeClone(o.rtnType.get()) );
-			
-			return *this;
-		}
-		ProtoDump& operator= (ProtoDump&&) = default;
+		ProtoDump(const ProtoDump* p) : decls(), exprs(), subs(), parent(p) {}
 
 	private:
@@ -208,10 +183,8 @@
 		/// Visitor for printing types
 		struct TypePrinter : public WithShortCircuiting, WithVisitorRef<TypePrinter>, WithGuards {
-			std::stringstream& ss;                          ///< Output to print to
-			const std::unordered_set<std::string>& closed;  ///< Closed type variables
-			unsigned depth;                                 ///< Depth of nesting from root type
-
-			TypePrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 
-				: ss(ss), closed(closed), depth(0) {}
+			std::stringstream& ss;  ///< Output to print to
+			unsigned depth;         ///< Depth of nesting from root type
+
+			TypePrinter( std::stringstream& ss ) : ss(ss), depth(0) {}
 
 			// basic type represented as integer type
@@ -279,9 +252,7 @@
 			void previsit( EnumInstType* ) { ss << (int)BasicType::SignedInt; }
 
+			// make sure first letter of TypeInstType is capitalized
 			void previsit( TypeInstType* vt ) {
-				// print closed variables as named types
-				if ( closed.count( vt->name ) ) { ss << '#' << vt->name; }
-				// otherwise make sure first letter is capitalized
-				else { ti_name( vt->name, ss ); }
+				ti_name( vt->name, ss );
 			}
 
@@ -309,18 +280,9 @@
 		/// builds description of function
 		void build( const std::string& name, FunctionType* fnTy, std::stringstream& ss ) {
-			PassVisitor<TypePrinter> printTy{ closed, ss };
-			// print return values
+			PassVisitor<TypePrinter> printTy{ ss };
 			build( printTy, from_decls( fnTy->returnVals ), ss, terminated );
-			// print name
 			rp_name( name, ss );
-			// print parameters
 			build( printTy, from_decls( fnTy->parameters ), ss, preceded );
-			// print assertions
-			for ( TypeDecl* tyvar : fnTy->forall ) {
-				for ( DeclarationWithType* assn : tyvar->assertions ) {
-					ss << " | "; 
-					build( assn->name, assn->get_type(), ss );
-				}
-			}
+			// TODO handle assertions
 		}
 
@@ -342,5 +304,5 @@
 
 			// print variable declaration as zero-arg function
-			PassVisitor<TypePrinter> printTy{ closed, ss };
+			PassVisitor<TypePrinter> printTy{ ss };
 			norefs->accept( printTy );
 			ss << ' ';
@@ -354,5 +316,5 @@
 
 			// print access as new field name
-			PassVisitor<TypePrinter> printTy{ closed, ss };
+			PassVisitor<TypePrinter> printTy{ ss };
 			norefs->accept( printTy );
 			ss << ' ';
@@ -375,9 +337,8 @@
 		struct ExprPrinter : WithShortCircuiting, WithVisitorRef<ExprPrinter> {
 			// TODO change interface to generate multiple expression candidates
-			const std::unordered_set<std::string>& closed;  ///< set of closed type vars
-			std::stringstream& ss;                          ///< Output to print to
-
-			ExprPrinter( const std::unordered_set<std::string>& closed, std::stringstream& ss ) 
-				: closed(closed), ss(ss) {}
+
+			std::stringstream& ss;  ///< Output to print to
+
+			ExprPrinter( std::stringstream& ss ) : ss(ss) {}
 
 			/// Names handled as nullary function calls
@@ -418,4 +379,5 @@
 			/// Address-of handled as operator
 			void previsit( AddressExpr* expr ) {
+				// TODO global function to implement this
 				ss << "$addr( ";
 				expr->arg->accept( *visitor );
@@ -427,5 +389,5 @@
 			/// TODO put cast target functions in, and add second expression for target
 			void previsit( CastExpr* cast ) {
-				PassVisitor<TypePrinter> tyPrinter{ closed, ss };
+				PassVisitor<TypePrinter> tyPrinter{ ss };
 				cast->result->accept( tyPrinter );
 				visit_children = false;
@@ -454,5 +416,5 @@
 			/// Constant expression replaced by its type
 			void previsit( ConstantExpr* expr ) {
-				PassVisitor<TypePrinter> tyPrinter{ closed, ss };
+				PassVisitor<TypePrinter> tyPrinter{ ss };
 				expr->constant.get_type()->accept( tyPrinter );
 				visit_children = false;
@@ -476,4 +438,5 @@
 			/// Logical expressions represented as operators
 			void previsit( LogicalExpr* expr ) {
+				// TODO global functions for these
 				ss << '$' << ( expr->get_isAnd() ? "and" : "or" ) << "( ";
 				expr->arg1->accept( *visitor );
@@ -486,4 +449,5 @@
 			/// Conditional expression represented as operator
 			void previsit( ConditionalExpr* expr ) {
+				// TODO global function for this
 				ss << "$if( ";
 				expr->arg1->accept( *visitor );
@@ -498,4 +462,5 @@
 			/// Comma expression represented as operator
 			void previsit( CommaExpr* expr ) {
+				// TODO global function for this
 				ss << "$seq( ";
 				expr->arg1->accept( *visitor );
@@ -508,37 +473,4 @@
 			// TODO handle ignored ImplicitCopyCtorExpr and below
 		};
-
-		void build( Initializer* init, std::stringstream& ss ) {
-			if ( SingleInit* si = dynamic_cast<SingleInit*>(init) ) {
-				PassVisitor<ExprPrinter> exprPrinter{ closed, ss };
-				si->value->accept( exprPrinter );
-				ss << ' ';
-			} else if ( ListInit* li = dynamic_cast<ListInit*>(init) ) {
-				for ( Initializer* it : li->initializers ) {
-					build( it, ss );
-					ss << ' ';
-				}
-			}
-		}
-
-		/// Adds an object initializer to the list of expressions
-		void build( const std::string& name, Initializer* init, std::stringstream& ss ) {
-			ss << "$constructor( ";
-			rp_name( name, ss );
-			ss << "() ";
-			build( init, ss );
-			ss << ')';
-		}
-
-		/// Adds a return expression to the list of expressions
-		void build( Type* rtnType, Expression* expr, std::stringstream& ss ) {
-			ss << "$constructor( ";
-			PassVisitor<TypePrinter> tyPrinter{ closed, ss };
-			rtnType->accept( tyPrinter );
-			ss << ' ';
-			PassVisitor<ExprPrinter> exprPrinter{ closed, ss };
-			expr->accept( exprPrinter );
-			ss << " )";
-		}
 
 		/// Adds all named declarations in a list to the local scope
@@ -575,11 +507,4 @@
 			build( obj->name, obj->type, ss );
 			addDecl( ss.str() );
-
-			// add initializer as expression if applicable
-			if ( obj->init ) {
-				std::stringstream ss;
-				build( obj->name, obj->init, ss );
-				addExpr( ss.str() );
-			}
 		}
 
@@ -592,26 +517,13 @@
 			// add body if available
 			if ( decl->statements ) {
-				std::list<Type*> rtns = from_decls( decl->type->returnVals );
-				Type* rtn = nullptr;
-				if ( rtns.size() == 1 ) {
-					if ( ! dynamic_cast<VoidType*>(rtns.front()) ) rtn = rtns.front()->clone();
-				} else if ( rtns.size() > 1 ) {
-					rtn = new TupleType{ Type::Qualifiers{}, rtns };
-				}
-				PassVisitor<ProtoDump> body{ this, rtn };
-
-				for ( TypeDecl* tyvar : decl->type->forall ) {
-					// add set of "closed" types to body so that it can print them as NamedType
-					body.pass.closed.insert( tyvar->name );
-
-					// add assertions to local scope as declarations as well
-					for ( DeclarationWithType* assn : tyvar->assertions ) {
-						assn->accept( body );
-					}
-				}
+				PassVisitor<ProtoDump> body{ this };
 				
 				// add named parameters and returns to local scope
 				body.pass.addAll( decl->type->returnVals );
 				body.pass.addAll( decl->type->parameters );
+				
+				// TODO add assertions to local scope
+
+				// TODO add set of "closed" types to body so that it can print them as NamedType
 
 				// add contents of function to new scope
@@ -642,18 +554,7 @@
 		}
 
-		void previsit( ReturnStmt* stmt ) {
-			// do nothing for void-returning functions or statements returning nothing
-			if ( ! rtnType || ! stmt->expr ) return;
-
-			// otherwise construct the return type from the expression
-			std::stringstream ss;
-			build( rtnType.get(), stmt->expr, ss );
-			addExpr( ss.str() );
-			visit_children = false;
-		}
-
 		void previsit( Expression* expr ) {
 			std::stringstream ss;
-			PassVisitor<ExprPrinter> exPrinter{ closed, ss };
+			PassVisitor<ExprPrinter> exPrinter{ss};
 			expr->accept( exPrinter );
 			addExpr( ss.str() );
@@ -661,26 +562,14 @@
 		}
 
-		/// Print non-prelude global declarations for resolv proto
-		void printGlobals() const {
-			std::cout << "#ptr<T> $addr T" << std::endl;  // &?
-			int i = (int)BasicType::SignedInt;
-			std::cout << i << " $and " << i << ' ' << i << std::endl;  // ?&&?
-			std::cout << i << " $or " << i << ' ' << i << std::endl;  // ?||?
-			std::cout << "T $if " << i << " T T" << std::endl; // ternary operator
-			std::cout << "T $seq X T" << std::endl;  // ?,?
-		}
-
 	public:
 		/// Prints this ProtoDump instance
 		void print(unsigned indent = 0) const {
-			// print globals at root level
-			if ( ! parent ) printGlobals();
+			std::string tab( indent, '\t' );
 			// print decls
-			std::string tab( indent, '\t' );
 			for ( const std::string& d : decls ) {
 				std::cout << tab << d << std::endl;
 			}
 			// print divider
-			std::cout << '\n' << tab << "%%\n" << std::endl;
+			std::cout << tab << "%%" << std::endl;
 			// print top-level expressions
 			for ( const std::string& e : exprs ) {
