Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 39d89504881cd88008aec5648412e27d45b19c6e)
+++ src/ResolvExpr/Resolver.cc	(revision 3bc69f2bb3a0440994193575c9192a991f9d6223)
@@ -10,6 +10,6 @@
 // Created On       : Sun May 17 12:17:01 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Mar 16 16:07:00 2022
-// Update Count     : 246
+// Last Modified On : Fri Mar 18 10:41:00 2022
+// Update Count     : 247
 //
 
@@ -1245,5 +1245,5 @@
 	: public ast::WithSymbolTable, public ast::WithGuards,
 	  public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting,
-	  public ast::WithStmtsToAdd<>, public ast::WithConstTranslationUnit {
+	  public ast::WithStmtsToAdd<> {
 
 		ast::ptr< ast::Type > functionReturn = nullptr;
@@ -1251,15 +1251,15 @@
 		// for work previously in GenInit
 		static InitTweak::ManagedTypes_new managedTypes;
+		ResolveContext context;
 
 		bool inEnumDecl = false;
-
-		ResolveContext getContext() const {
-			return ResolveContext{ symtab, transUnit().global };
-		}
 
 	public:
 		static size_t traceId;
-		Resolver_new() = default;
-		Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
+		Resolver_new( const ast::TranslationGlobal & global ) :
+			context{ symtab, global } {}
+		Resolver_new( const ResolveContext & context ) :
+			ast::WithSymbolTable{ context.symtab },
+			context{ symtab, context.global } {}
 
 		const ast::FunctionDecl * previsit( const ast::FunctionDecl * );
@@ -1278,5 +1278,5 @@
 		const ast::AsmStmt *         previsit( const ast::AsmStmt * );
 		const ast::IfStmt *          previsit( const ast::IfStmt * );
-		const ast::WhileDoStmt *       previsit( const ast::WhileDoStmt * );
+		const ast::WhileDoStmt *     previsit( const ast::WhileDoStmt * );
 		const ast::ForStmt *         previsit( const ast::ForStmt * );
 		const ast::SwitchStmt *      previsit( const ast::SwitchStmt * );
@@ -1305,5 +1305,5 @@
 
 	void resolve( ast::TranslationUnit& translationUnit ) {
-		ast::Pass< Resolver_new >::run( translationUnit );
+		ast::Pass< Resolver_new >::run( translationUnit, translationUnit.global );
 	}
 
@@ -1312,8 +1312,5 @@
 	) {
 		assert( ctorInit );
-		ast::Pass< Resolver_new > resolver{ context.symtab };
-		ast::TranslationUnit transUnit;
-		transUnit.global = context.global;
-		resolver.core.translationUnit = &transUnit;
+		ast::Pass< Resolver_new > resolver( context );
 		return ctorInit->accept( resolver );
 	}
@@ -1323,8 +1320,5 @@
 	) {
 		assert( stmtExpr );
-		ast::Pass< Resolver_new > resolver{ context.symtab };
-		ast::TranslationUnit transUnit;
-		transUnit.global = context.global;
-		resolver.core.translationUnit = &transUnit;
+		ast::Pass< Resolver_new > resolver( context );
 		auto ret = mutate(stmtExpr->accept(resolver));
 		strict_dynamic_cast< ast::StmtExpr * >( ret )->computeResult();
@@ -1381,5 +1375,5 @@
 
 			for (auto & attr: mutDecl->attributes) {
-				attr = handleAttribute(mutDecl->location, attr, getContext() );
+				attr = handleAttribute(mutDecl->location, attr, context );
 			}
 
@@ -1394,5 +1388,5 @@
 			}
 			for (auto & asst : mutDecl->assertions) {
-				asst = fixObjectType(asst.strict_as<ast::ObjectDecl>(), getContext());
+				asst = fixObjectType(asst.strict_as<ast::ObjectDecl>(), context);
 				symtab.addId(asst);
 				mutType->assertions.emplace_back(new ast::VariableExpr(functionDecl->location, asst));
@@ -1406,10 +1400,10 @@
 
 			for (auto & param : mutDecl->params) {
-				param = fixObjectType(param.strict_as<ast::ObjectDecl>(), getContext());
+				param = fixObjectType(param.strict_as<ast::ObjectDecl>(), context);
 				symtab.addId(param);
 				paramTypes.emplace_back(param->get_type());
 			}
 			for (auto & ret : mutDecl->returns) {
-				ret = fixObjectType(ret.strict_as<ast::ObjectDecl>(), getContext());
+				ret = fixObjectType(ret.strict_as<ast::ObjectDecl>(), context);
 				returnTypes.emplace_back(ret->get_type());
 			}
@@ -1482,5 +1476,5 @@
 			// enumerator initializers should not use the enum type to initialize, since the
 			// enum type is still incomplete at this point. Use `int` instead.
-			objectDecl = fixObjectType(objectDecl, getContext());
+			objectDecl = fixObjectType(objectDecl, context);
 			currentObject = ast::CurrentObject{
 				objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } };
@@ -1488,5 +1482,5 @@
 		else {
 			if (!objectDecl->isTypeFixed) {
-				auto newDecl = fixObjectType(objectDecl, getContext());
+				auto newDecl = fixObjectType(objectDecl, context);
 				auto mutDecl = mutate(newDecl);
 
@@ -1519,5 +1513,5 @@
 			// nested type decls are hoisted already. no need to do anything
 			if (auto obj = member.as<ast::ObjectDecl>()) {
-				member = fixObjectType(obj, getContext());
+				member = fixObjectType(obj, context);
 			}
 		}
@@ -1542,5 +1536,5 @@
 		return ast::mutate_field(
 			assertDecl, &ast::StaticAssertDecl::cond,
-			findIntegralExpression( assertDecl->cond, getContext() ) );
+			findIntegralExpression( assertDecl->cond, context ) );
 	}
 
@@ -1557,9 +1551,9 @@
 
 	const ast::ArrayType * Resolver_new::previsit( const ast::ArrayType * at ) {
-		return handlePtrType( at, getContext() );
+		return handlePtrType( at, context );
 	}
 
 	const ast::PointerType * Resolver_new::previsit( const ast::PointerType * pt ) {
-		return handlePtrType( pt, getContext() );
+		return handlePtrType( pt, context );
 	}
 
@@ -1569,5 +1563,5 @@
 
 		return ast::mutate_field(
-			exprStmt, &ast::ExprStmt::expr, findVoidExpression( exprStmt->expr, getContext() ) );
+			exprStmt, &ast::ExprStmt::expr, findVoidExpression( exprStmt->expr, context ) );
 	}
 
@@ -1576,5 +1570,5 @@
 
 		asmExpr = ast::mutate_field(
-			asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, getContext() ) );
+			asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, context ) );
 
 		return asmExpr;
@@ -1590,10 +1584,10 @@
 	const ast::IfStmt * Resolver_new::previsit( const ast::IfStmt * ifStmt ) {
 		return ast::mutate_field(
-			ifStmt, &ast::IfStmt::cond, findIntegralExpression( ifStmt->cond, getContext() ) );
+			ifStmt, &ast::IfStmt::cond, findIntegralExpression( ifStmt->cond, context ) );
 	}
 
 	const ast::WhileDoStmt * Resolver_new::previsit( const ast::WhileDoStmt * whileDoStmt ) {
 		return ast::mutate_field(
-			whileDoStmt, &ast::WhileDoStmt::cond, findIntegralExpression( whileDoStmt->cond, getContext() ) );
+			whileDoStmt, &ast::WhileDoStmt::cond, findIntegralExpression( whileDoStmt->cond, context ) );
 	}
 
@@ -1601,10 +1595,10 @@
 		if ( forStmt->cond ) {
 			forStmt = ast::mutate_field(
-				forStmt, &ast::ForStmt::cond, findIntegralExpression( forStmt->cond, getContext() ) );
+				forStmt, &ast::ForStmt::cond, findIntegralExpression( forStmt->cond, context ) );
 		}
 
 		if ( forStmt->inc ) {
 			forStmt = ast::mutate_field(
-				forStmt, &ast::ForStmt::inc, findVoidExpression( forStmt->inc, getContext() ) );
+				forStmt, &ast::ForStmt::inc, findVoidExpression( forStmt->inc, context ) );
 		}
 
@@ -1616,5 +1610,5 @@
 		switchStmt = ast::mutate_field(
 			switchStmt, &ast::SwitchStmt::cond,
-			findIntegralExpression( switchStmt->cond, getContext() ) );
+			findIntegralExpression( switchStmt->cond, context ) );
 		currentObject = ast::CurrentObject{ switchStmt->location, switchStmt->cond->result };
 		return switchStmt;
@@ -1629,5 +1623,5 @@
 			ast::ptr< ast::Expr > untyped =
 				new ast::CastExpr{ caseStmt->location, caseStmt->cond, initAlts.front().type };
-			ast::ptr< ast::Expr > newExpr = findSingleExpression( untyped, getContext() );
+			ast::ptr< ast::Expr > newExpr = findSingleExpression( untyped, context );
 
 			// case condition cannot have a cast in C, so it must be removed here, regardless of
@@ -1650,5 +1644,5 @@
 			branchStmt = ast::mutate_field(
 				branchStmt, &ast::BranchStmt::computedTarget,
-				findSingleExpression( branchStmt->computedTarget, target, getContext() ) );
+				findSingleExpression( branchStmt->computedTarget, target, context ) );
 		}
 		return branchStmt;
@@ -1660,5 +1654,5 @@
 			returnStmt = ast::mutate_field(
 				returnStmt, &ast::ReturnStmt::expr,
-				findSingleExpression( returnStmt->expr, functionReturn, getContext() ) );
+				findSingleExpression( returnStmt->expr, functionReturn, context ) );
 		}
 		return returnStmt;
@@ -1675,5 +1669,5 @@
 			throwStmt = ast::mutate_field(
 				throwStmt, &ast::ThrowStmt::expr,
-				findSingleExpression( throwStmt->expr, exceptType, getContext() ) );
+				findSingleExpression( throwStmt->expr, exceptType, context ) );
 		}
 		return throwStmt;
@@ -1719,5 +1713,5 @@
 
 			ast::TypeEnvironment env;
-			CandidateFinder funcFinder( getContext(), env );
+			CandidateFinder funcFinder( context, env );
 
 			// Find all candidates for a function in canonical form
@@ -1933,9 +1927,9 @@
 				);
 
-				clause2.target.args.emplace_back( findSingleExpression( init, getContext() ) );
+				clause2.target.args.emplace_back( findSingleExpression( init, context ) );
 			}
 
 			// Resolve the conditions as if it were an IfStmt, statements normally
-			clause2.cond = findSingleExpression( clause.cond, getContext() );
+			clause2.cond = findSingleExpression( clause.cond, context );
 			clause2.stmt = clause.stmt->accept( *visitor );
 
@@ -1952,6 +1946,6 @@
 			ast::ptr< ast::Type > target =
 				new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
-			timeout2.time = findSingleExpression( stmt->timeout.time, target, getContext() );
-			timeout2.cond = findSingleExpression( stmt->timeout.cond, getContext() );
+			timeout2.time = findSingleExpression( stmt->timeout.time, target, context );
+			timeout2.cond = findSingleExpression( stmt->timeout.cond, context );
 			timeout2.stmt = stmt->timeout.stmt->accept( *visitor );
 
@@ -1966,5 +1960,5 @@
 			ast::WaitForStmt::OrElse orElse2;
 
-			orElse2.cond = findSingleExpression( stmt->orElse.cond, getContext() );
+			orElse2.cond = findSingleExpression( stmt->orElse.cond, context );
 			orElse2.stmt = stmt->orElse.stmt->accept( *visitor );
 
@@ -1987,5 +1981,5 @@
 		for (auto & expr : exprs) {
 			// only struct- and union-typed expressions are viable candidates
-			expr = findKindExpression( expr, getContext(), structOrUnion, "with expression" );
+			expr = findKindExpression( expr, context, structOrUnion, "with expression" );
 
 			// if with expression might be impure, create a temporary so that it is evaluated once
@@ -2013,5 +2007,5 @@
 		ast::ptr< ast::Expr > untyped = new ast::UntypedInitExpr{
 			singleInit->location, singleInit->value, currentObject.getOptions() };
-		ast::ptr<ast::Expr> newExpr = findSingleExpression( untyped, getContext() );
+		ast::ptr<ast::Expr> newExpr = findSingleExpression( untyped, context );
 		const ast::InitExpr * initExpr = newExpr.strict_as< ast::InitExpr >();
 
