Index: src/Common/Examine.cc
===================================================================
--- src/Common/Examine.cc	(revision eb211bf8d8987a9f51f479f33bbdf5dd9ba03d82)
+++ src/Common/Examine.cc	(revision 3c4bf050c37d1391ba25a62e7b3d185e99ef7f44)
@@ -5,16 +5,18 @@
 // file "LICENCE" distributed with Cforall.
 //
-// Examine.h --
+// Examine.cc -- Helpers for examining AST code.
 //
 // Author           : Andrew Beach
 // Created On       : Wed Sept 2 14:02 2020
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Sep  8 12:15 2020
-// Update Count     : 0
+// Last Modified On : Fri Dec 10 10:27 2021
+// Update Count     : 1
 //
 
 #include "Common/Examine.h"
 
+#include "AST/Type.hpp"
 #include "CodeGen/OperatorTable.h"
+#include "InitTweak/InitTweak.h"
 
 DeclarationWithType * isMainFor( FunctionDecl * func, AggregateDecl::Aggregate kind ) {
@@ -36,4 +38,35 @@
 
 namespace {
+
+// getTypeofThis but does some extra checks used in this module.
+const ast::Type * getTypeofThisSolo( const ast::FunctionDecl * func ) {
+	if ( 1 != func->params.size() ) {
+		return nullptr;
+	}
+	auto ref = func->type->params.front().as<ast::ReferenceType>();
+	return (ref) ? ref->base : nullptr;
+}
+
+}
+
+const ast::DeclWithType * isMainFor(
+		const ast::FunctionDecl * func, ast::AggregateDecl::Aggregate kind ) {
+	if ( "main" != func->name ) return nullptr;
+	if ( 1 != func->params.size() ) return nullptr;
+
+	auto param = func->params.front();
+
+	auto type = dynamic_cast<const ast::ReferenceType *>( param->get_type() );
+	if ( !type ) return nullptr;
+
+	auto obj = type->base.as<ast::StructInstType>();
+	if ( !obj ) return nullptr;
+
+	if ( kind != obj->base->kind ) return nullptr;
+
+	return param;
+}
+
+namespace {
 	Type * getDestructorParam( FunctionDecl * func ) {
 		if ( !CodeGen::isDestructor( func->name ) ) return nullptr;
@@ -48,4 +81,11 @@
 		return nullptr;
 	}
+
+const ast::Type * getDestructorParam( const ast::FunctionDecl * func ) {
+	if ( !CodeGen::isDestructor( func->name ) ) return nullptr;
+	//return InitTweak::getParamThis( func )->type;
+	return getTypeofThisSolo( func );
+}
+
 }
 
@@ -57,2 +97,11 @@
 	return false;
 }
+
+bool isDestructorFor(
+		const ast::FunctionDecl * func, const ast::StructDecl * type_decl ) {
+	if ( const ast::Type * type = getDestructorParam( func ) ) {
+		auto stype = dynamic_cast<const ast::StructInstType *>( type );
+		return stype && stype->base.get() == type_decl;
+	}
+	return false;
+}
Index: src/Common/Examine.h
===================================================================
--- src/Common/Examine.h	(revision eb211bf8d8987a9f51f479f33bbdf5dd9ba03d82)
+++ src/Common/Examine.h	(revision 3c4bf050c37d1391ba25a62e7b3d185e99ef7f44)
@@ -5,19 +5,24 @@
 // file "LICENCE" distributed with Cforall.
 //
-// Examine.h --
+// Examine.h -- Helpers for examining AST code.
 //
 // Author           : Andrew Beach
 // Created On       : Wed Sept 2 13:57 2020
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Sep  8 12:08 2020
-// Update Count     : 0
+// Last Modified On : Fri Dec 10 10:28 2021
+// Update Count     : 1
 //
 
+#include "AST/Decl.hpp"
 #include "SynTree/Declaration.h"
 
 /// Check if this is a main function for a type of an aggregate kind.
 DeclarationWithType * isMainFor( FunctionDecl * func, AggregateDecl::Aggregate kind );
+const ast::DeclWithType * isMainFor(
+	const ast::FunctionDecl * func, ast::AggregateDecl::Aggregate kind );
 // Returns a pointer to the parameter if true, nullptr otherwise.
 
 /// Check if this function is a destructor for the given structure.
 bool isDestructorFor( FunctionDecl * func, StructDecl * type_decl );
+bool isDestructorFor(
+	const ast::FunctionDecl * func, const ast::StructDecl * type );
