Index: libcfa/src/concurrency/coroutine.cfa
===================================================================
--- libcfa/src/concurrency/coroutine.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/concurrency/coroutine.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -46,8 +46,5 @@
 
 //-----------------------------------------------------------------------------
-FORALL_DATA_INSTANCE(CoroutineCancelled, (coroutine_t &), (coroutine_t))
-
-forall(T &)
-void mark_exception(CoroutineCancelled(T) *) {}
+EHM_VIRTUAL_TABLE(SomeCoroutineCancelled, std_coroutine_cancelled);
 
 forall(T &)
@@ -71,9 +68,10 @@
 
 	// TODO: Remove explitate vtable set once trac#186 is fixed.
-	CoroutineCancelled(T) except;
-	except.virtual_table = &get_exception_vtable(&except);
+	SomeCoroutineCancelled except;
+	except.virtual_table = &std_coroutine_cancelled;
 	except.the_coroutine = &cor;
 	except.the_exception = except;
-	throwResume except;
+	// Why does this need a cast?
+	throwResume (SomeCoroutineCancelled &)except;
 
 	except->virtual_table->free( except );
Index: libcfa/src/concurrency/coroutine.hfa
===================================================================
--- libcfa/src/concurrency/coroutine.hfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/concurrency/coroutine.hfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -22,5 +22,12 @@
 //-----------------------------------------------------------------------------
 // Exception thrown from resume when a coroutine stack is cancelled.
-FORALL_DATA_EXCEPTION(CoroutineCancelled, (coroutine_t &), (coroutine_t)) (
+EHM_EXCEPTION(SomeCoroutineCancelled)(
+	void * the_coroutine;
+	exception_t * the_exception;
+);
+
+EHM_EXTERN_VTABLE(SomeCoroutineCancelled, std_coroutine_cancelled);
+
+EHM_FORALL_EXCEPTION(CoroutineCancelled, (coroutine_t &), (coroutine_t)) (
 	coroutine_t * the_coroutine;
 	exception_t * the_exception;
@@ -37,5 +44,5 @@
 // Anything that implements this trait can be resumed.
 // Anything that is resumed is a coroutine.
-trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
+trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(SomeCoroutineCancelled)) {
 	void main(T & this);
 	$coroutine * get_coroutine(T & this);
Index: libcfa/src/concurrency/thread.cfa
===================================================================
--- libcfa/src/concurrency/thread.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/concurrency/thread.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -62,5 +62,5 @@
 }
 
-FORALL_DATA_INSTANCE(ThreadCancelled, (thread_t &), (thread_t))
+EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled);
 
 forall(T &)
@@ -73,21 +73,27 @@
 forall(T &)
 const char * msg(ThreadCancelled(T) *) {
-	return "ThreadCancelled";
+	return "ThreadCancelled(...)";
 }
 
 forall(T &)
 static void default_thread_cancel_handler(ThreadCancelled(T) & ) {
+	// Improve this error message, can I do formatting?
 	abort( "Unhandled thread cancellation.\n" );
 }
 
-forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)))
+static void default_thread_cancel_handler(SomeThreadCancelled & ) {
+	// Improve this error message, can I do formatting?
+	abort( "Unhandled thread cancellation.\n" );
+}
+
+forall(T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled))
 void ?{}( thread_dtor_guard_t & this,
-		T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) {
- 	$monitor * m = get_monitor(thrd);
+		T & thrd, void(*cancelHandler)(SomeThreadCancelled &)) {
+	$monitor * m = get_monitor(thrd);
 	$thread * desc = get_thread(thrd);
 
 	// Setup the monitor guard
 	void (*dtor)(T& mutex this) = ^?{};
-	bool join = cancelHandler != (void(*)(ThreadCancelled(T)&))0;
+	bool join = cancelHandler != (void(*)(SomeThreadCancelled&))0;
 	(this.mg){&m, (void(*)())dtor, join};
 
@@ -103,13 +109,14 @@
 	}
 	desc->state = Cancelled;
-	void(*defaultResumptionHandler)(ThreadCancelled(T) &) = 
+	void(*defaultResumptionHandler)(SomeThreadCancelled &) =
 		join ? cancelHandler : default_thread_cancel_handler;
 
-	ThreadCancelled(T) except;
 	// TODO: Remove explitate vtable set once trac#186 is fixed.
-	except.virtual_table = &get_exception_vtable(&except);
+	SomeThreadCancelled except;
+	except.virtual_table = &std_thread_cancelled;
 	except.the_thread = &thrd;
 	except.the_exception = __cfaehm_cancellation_exception( cancellation );
-	throwResume except;
+	// Why is this cast required?
+	throwResume (SomeThreadCancelled &)except;
 
 	except.the_exception->virtual_table->free( except.the_exception );
@@ -158,5 +165,5 @@
 
 //-----------------------------------------------------------------------------
-forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)))
+forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled))
 T & join( T & this ) {
 	thread_dtor_guard_t guard = { this, defaultResumptionHandler };
Index: libcfa/src/concurrency/thread.hfa
===================================================================
--- libcfa/src/concurrency/thread.hfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/concurrency/thread.hfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -32,5 +32,12 @@
 };
 
-FORALL_DATA_EXCEPTION(ThreadCancelled, (thread_t &), (thread_t)) (
+EHM_EXCEPTION(SomeThreadCancelled) (
+	void * the_thread;
+	exception_t * the_exception;
+);
+
+EHM_EXTERN_VTABLE(SomeThreadCancelled, std_thread_cancelled);
+
+EHM_FORALL_EXCEPTION(ThreadCancelled, (thread_t &), (thread_t)) (
 	thread_t * the_thread;
 	exception_t * the_exception;
@@ -79,6 +86,6 @@
 };
 
-forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)) )
-void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) );
+forall( T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled) )
+void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(SomeThreadCancelled &) );
 void ^?{}( thread_dtor_guard_t & this );
 
@@ -125,5 +132,5 @@
 //----------
 // join
-forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)) )
+forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled) )
 T & join( T & this );
 
Index: libcfa/src/exception.c
===================================================================
--- libcfa/src/exception.c	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/exception.c	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:13:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Oct 27 16:27:00 2020
-// Update Count     : 35
+// Last Modified On : Wed Feb 24 13:40:00 2021
+// Update Count     : 36
 //
 
@@ -26,4 +26,5 @@
 #include "concurrency/invoke.h"
 #include "stdhdr/assert.h"
+#include "virtual.h"
 
 #if defined( __ARM_ARCH )
@@ -46,12 +47,7 @@
 const _Unwind_Exception_Class __cfaehm_exception_class = 0x4c50575500414643;
 
-// Base exception vtable is abstract, you should not have base exceptions.
-struct __cfaehm_base_exception_t_vtable
-		___cfaehm_base_exception_t_vtable_instance = {
-	.parent = NULL,
-	.size = 0,
-	.copy = NULL,
-	.free = NULL,
-	.msg = NULL
+// Base Exception type id:
+struct __cfa__parent_vtable __cfatid_exception_t = {
+	NULL,
 };
 
Index: libcfa/src/exception.h
===================================================================
--- libcfa/src/exception.h	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/exception.h	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:11:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Oct 27 14:45:00 2020
-// Update Count     : 11
+// Last Modified On : Thr Apr  8 15:20:00 2021
+// Update Count     : 12
 //
 
@@ -29,6 +29,7 @@
 struct __cfaehm_base_exception_t;
 typedef struct __cfaehm_base_exception_t exception_t;
+struct __cfa__parent_vtable;
 struct __cfaehm_base_exception_t_vtable {
-	const struct __cfaehm_base_exception_t_vtable * parent;
+	const struct __cfa__parent_vtable * __cfavir_typeid;
 	size_t size;
 	void (*copy)(struct __cfaehm_base_exception_t *this,
@@ -40,6 +41,5 @@
 	struct __cfaehm_base_exception_t_vtable const * virtual_table;
 };
-extern struct __cfaehm_base_exception_t_vtable
-	___cfaehm_base_exception_t_vtable_instance;
+extern struct __cfa__parent_vtable __cfatid_exception_t;
 
 
@@ -104,7 +104,7 @@
 	/* The first field must be a pointer to a virtual table.
 	 * That virtual table must be a decendent of the base exception virtual table.
+	 * The virtual table must point at the prober type-id.
+	 * None of these can be enforced in an assertion.
 	 */
-	virtualT const & get_exception_vtable(exceptT *);
-	// Always returns the virtual table for this type (associated types hack).
 };
 
Index: libcfa/src/exception.hfa
===================================================================
--- libcfa/src/exception.hfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/exception.hfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -10,6 +10,6 @@
 // Created On       : Thu Apr  7 10:25:00 2020
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Aug  4 16:22:00 2020
-// Update Count     : 3
+// Last Modified On : Thr Apr  8 15:16:00 2021
+// Update Count     : 4
 //
 
@@ -18,111 +18,53 @@
 // -----------------------------------------------------------------------------------------------
 
-// TRIVIAL_EXCEPTION_DECLARATION(exception_name);
-// Declare a trivial exception, one that adds no fields or features.
-// This will make the exception visible and may go in a .hfa or .cfa file.
-#define TRIVIAL_EXCEPTION_DECLARATION(...) \
-	_EXC_DISPATCH(_TRIVIAL_EXCEPTION_DECLARATION, __VA_ARGS__)
+// EHM_EXCEPTION(exception_name)(fields...);
+// Create an exception (a virtual structure that inherits from exception_t)
+// with the given name and fields.
+#define EHM_EXCEPTION(exception_name) \
+	_EHM_TYPE_ID_STRUCT(exception_name, ); \
+	_EHM_TYPE_ID_VALUE(exception_name, ); \
+	_EHM_VIRTUAL_TABLE_STRUCT(exception_name, , ); \
+	_EHM_EXCEPTION_STRUCT(exception_name, , )
 
-// TRIVIAL_EXCEPTION_INSTANCE(exception_name);
-// Create the trival exception. This must be used exactly once and should be used in a .cfa file,
-// as it creates the unique instance of the virtual table.
-#define TRIVIAL_EXCEPTION_INSTANCE(...) _EXC_DISPATCH(_TRIVIAL_EXCEPTION_INSTANCE, __VA_ARGS__)
+// EHM_EXTERN_VTABLE(exception_name, table_name);
+// Forward declare a virtual table called table_name for exception_name type.
+#define EHM_EXTERN_VTABLE(exception_name, table_name) \
+	_EHM_EXTERN_VTABLE(exception_name, , table_name)
 
-// TRIVIAL_EXCEPTION(exception_name[, parent_name]);
-// Does both of the above, a short hand if the exception is only used in one .cfa file.
-// For legacy reasons this is the only one that official supports having a parent other than the
-// base exception. This feature may be removed or changed.
-#define TRIVIAL_EXCEPTION(...) \
-	_EXC_DISPATCH(_TRIVIAL_EXCEPTION_DECLARATION, __VA_ARGS__); \
-	_EXC_DISPATCH(_TRIVIAL_EXCEPTION_INSTANCE, __VA_ARGS__)
+// EHM_VIRTUAL_TABLE(exception_name, table_name);
+// Define a virtual table called table_name for exception_name type.
+#define EHM_VIRTUAL_TABLE(exception_name, table_name) \
+	_EHM_DEFINE_COPY(exception_name, ) \
+	_EHM_DEFINE_MSG(exception_name, ) \
+	_EHM_VIRTUAL_TABLE(exception_name, , table_name)
 
-// FORALL_TRIVIAL_EXCEPTION(exception_name, (assertions...), (parameters...));
-// Forward declare a polymorphic but otherwise trivial exception type. You must provide the entire
-// assertion list (exactly what would go in the forall clause) and parameters list (only the
-// parameter names from the assertion list, same order and comma seperated). This should be
-// visible where ever use the exception. This just generates the polymorphic framework, see
-// POLY_VTABLE_DECLARATION to allow instantiations.
-#define FORALL_TRIVIAL_EXCEPTION(exception_name, assertions, parameters) \
-	_FORALL_TRIVIAL_EXCEPTION(exception_name, __cfaehm_base_exception_t, assertions, parameters, )
+// EHM_FORALL_EXCEPTION(exception_name, (assertions), (parameters))(fields...);
+// As EHM_EXCEPTION but for polymorphic types instead of monomorphic ones.
+// The assertions list should include all polymorphic parameters and
+// assertions inside a parentisized list. Parameters should include all the
+// polymorphic parameter names inside a parentisized list (same order).
+#define EHM_FORALL_EXCEPTION(exception_name, assertions, parameters) \
+	_EHM_TYPE_ID_STRUCT(exception_name, forall assertions); \
+	_EHM_VIRTUAL_TABLE_STRUCT(exception_name, forall assertions, parameters); \
+	_EHM_EXCEPTION_STRUCT(exception_name, forall assertions, parameters)
 
-// FORALL_TRIVIAL_INSTANCE(exception_name, (assertions...), (parameters...))
-// Create the forall trivial exception. The assertion list and parameters must match.
-// There must be exactly one use of this in a program for each exception type. This just
-// generates the polymorphic framework, see POLY_VTABLE_INSTANCE to allow instantiations.
-#define FORALL_TRIVIAL_INSTANCE(exception_name, assertions, parameters) \
-	_FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters)
+// EHM_FORALL_EXTERN_VTABLE(exception_name, (arguments), table_name);
+// As EHM_EXTERN_VTABLE but for polymorphic types instead of monomorphic ones.
+// Arguments should be the parentisized list of polymorphic arguments.
+#define EHM_FORALL_EXTERN_VTABLE(exception_name, arguments, table_name) \
+	_EHM_EXTERN_VTABLE(exception_name, arguments, table_name)
 
-// DATA_EXCEPTION(exception_name)(fields...);
-// Forward declare an exception that adds fields but no features. The added fields go in the
-// second argument list. The virtual table instance must be provided later (see VTABLE_INSTANCE).
-#define DATA_EXCEPTION(...) _EXC_DISPATCH(_DATA_EXCEPTION, __VA_ARGS__)
+// EHM_FORALL_VIRTUAL_TABLE(exception_name, (arguments), table_name);
+// As EHM_VIRTUAL_TABLE but for polymorphic types instead of monomorphic ones.
+// Arguments should be the parentisized list of polymorphic arguments.
+#define EHM_FORALL_VIRTUAL_TABLE(exception_name, arguments, table_name) \
+	_EHM_TYPE_ID_VALUE(exception_name, arguments); \
+	_EHM_DEFINE_COPY(exception_name, arguments) \
+	_EHM_DEFINE_MSG(exception_name, arguments) \
+	_EHM_VIRTUAL_TABLE(exception_name, arguments, table_name)
 
-// FORALL_DATA_EXCEPTION(exception_name, (assertions...), (parameters...))(fields...);
-// Define a polymorphic exception that adds fields but no additional features. The assertion list
-// and matching parameters must match. Then you can give the list of fields. This should be
-// visible where ever you use the exception. This just generates the polymorphic framework, see
-// POLY_VTABLE_DECLARATION to allow instantiations.
-#define FORALL_DATA_EXCEPTION(exception_name, assertions, parameters) \
-	_FORALL_DATA_EXCEPTION(exception_name, __cfaehm_base_exception_t, assertions, parameters, )
+#define EHM_TYPE_ID(exception_name) _EHM_TYPE_ID_TYPE(exception_name)
 
-// FORALL_DATA_INSTANCE(exception_name, (assertions...), (parameters...))
-// Create a polymorphic data exception. The assertion list and parameters must match. This should
-// appear once in each program. This just generates the polymorphic framework, see
-// POLY_VTABLE_INSTANCE to allow instantiations.
-#define FORALL_DATA_INSTANCE(exception_name, assertions, parameters) \
-	_FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters)
-
-// VTABLE_DECLARATION(exception_name)([new_features...]);
-// Declare a virtual table type for an exception with exception_name. You may also add features
-// (fields on the virtual table) by including them in the second list.
-#define VTABLE_DECLARATION(...) _EXC_DISPATCH(_VTABLE_DECLARATION, __VA_ARGS__)
-
-// VTABLE_INSTANCE(exception_name)(msg [, others...]);
-// Create the instance of the virtual table. There must be exactly one instance of a virtual table
-// for each exception type. This fills in most of the fields of the virtual table (uses ?=? and
-// ^?{}) but you must provide the message function and any other fields added in the declaration.
-#define VTABLE_INSTANCE(...) _EXC_DISPATCH(_VTABLE_INSTANCE, __VA_ARGS__)
-
-// FORALL_VTABLE_DECLARATION(exception_name, (assertions...), (parameters...))([new_features...]);
-// Declare a polymorphic virtual table type for an exception with exception_name, the given
-// assertions and parameters. You may also add features (fields on the virtual table). This just
-// generates the polymorphic framework, see POLY_VTABLE_DECLARATION to allow instantiations.
-#define FORALL_VTABLE_DECLARATION(exception_name, assertions, parameters) \
-	_FORALL_VTABLE_DECLARATION(exception_name, __cfaehm_base_exception_t, assertions, parameters, )
-
-// POLY_VTABLE_DECLARATION(exception_name, types...);
-// Declares that an instantiation for this exception exists for the given types. This should be
-// visible anywhere you use the instantiation of the exception is used.
-#define POLY_VTABLE_DECLARATION(exception_name, ...) \
-	VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable(exception_name(__VA_ARGS__) *); \
-	extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name)
-
-// POLY_VTABLE_INSTANCE(exception_name, types...)(msg [, others...]);
-// Creates an instantiation for the given exception for the given types. This should occur only
-// once in the entire program. You must fill in all features, message and any others given in the
-// initial declaration.
-#define POLY_VTABLE_INSTANCE(exception_name, ...) \
-	_POLY_VTABLE_INSTANCE(exception_name, __cfaehm_base_exception_t, __VA_ARGS__)
-
-// VTABLE_TYPE(exception_name) | VTABLE_NAME(exception_name)
-// Get the name of the vtable type or the name of the vtable instance for an exception type.
-#define VTABLE_TYPE(exception_name) struct _GLUE2(exception_name,_vtable)
-#define VTABLE_NAME(exception_name) _GLUE3(_,exception_name,_vtable_instance)
-
-// VTABLE_FIELD(exception_name);
-// FORALL_VTABLE_FIELD(exception_name, (parameters-or-types));
-// The declaration of the virtual table field. Should be the first declaration in a virtual type.
-#define VTABLE_FIELD(exception_name) VTABLE_TYPE(exception_name) const * virtual_table
-#define FORALL_VTABLE_FIELD(exception_name, parameters) \
-	VTABLE_TYPE(exception_name) parameters const * virtual_table
-
-// VTABLE_INIT(object_reference, exception_name);
-// Sets a virtual table field on an object to the virtual table instance for the type.
-#define VTABLE_INIT(this, exception_name) (this).virtual_table = &VTABLE_NAME(exception_name)
-
-// VTABLE_ASSERTION(exception_name, (parameters...))
-// The assertion that there is an instantiation of the vtable for the exception and types.
-#define VTABLE_ASSERTION(exception_name, parameters) \
-	{ VTABLE_TYPE(exception_name) parameters VTABLE_NAME(exception_name); }
+#define EHM_MATCH_ALL __cfa__parent_vtable
 
 // IS_EXCEPTION(exception_name [, (...parameters)])
@@ -135,113 +77,113 @@
 #define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~)
 
-// All internal helper macros begin with an underscore.
-#define _CLOSE(...) __VA_ARGS__ }
-#define _GLUE2(left, right) left##right
-#define _GLUE3(left, middle, right) left##middle##right
-#define _EXC_DISPATCH(to, ...) to(__VA_ARGS__,__cfaehm_base_exception_t,)
-#define _UNPACK(...) __VA_ARGS__
+// Macros starting with a leading underscore are internal.
 
-#define _TRIVIAL_EXCEPTION_DECLARATION(exception_name, parent_name, ...) \
-	_VTABLE_DECLARATION(exception_name, parent_name)(); \
-	struct exception_name { \
-		VTABLE_FIELD(exception_name); \
-	}; \
-	void ?{}(exception_name & this); \
-	const char * _GLUE2(exception_name,_msg)(exception_name * this)
+// Create an exception type definition. must be tailing, can be polymorphic.
+#define _EHM_EXCEPTION_STRUCT(exception_name, forall_clause, parameters) \
+	forall_clause struct exception_name { \
+		_EHM_VTABLE_TYPE(exception_name) parameters const * virtual_table; \
+		_CLOSE
 
-#define _TRIVIAL_EXCEPTION_INSTANCE(exception_name, parent_name, ...) \
-	void ?{}(exception_name & this) { \
-		VTABLE_INIT(this, exception_name); \
-	} \
-	const char * _GLUE2(exception_name,_msg)(exception_name * this) { \
-		return #exception_name; \
-	} \
-	_VTABLE_INSTANCE(exception_name, parent_name,)(_GLUE2(exception_name,_msg))
+// Create a (possibly polymorphic) virtual table forward declaration.
+#define _EHM_EXTERN_VTABLE(exception_name, arguments, table_name) \
+	extern const _EHM_VTABLE_TYPE(exception_name) arguments table_name
 
-#define _FORALL_TRIVIAL_EXCEPTION(exception_name, parent_name, assertions, \
-		parameters, parent_parameters) \
-	_FORALL_VTABLE_DECLARATION(exception_name, parent_name, assertions, \
-		parameters, parent_parameters)(); \
-	forall assertions struct exception_name { \
-		FORALL_VTABLE_FIELD(exception_name, parameters); \
-	}; \
-	_FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters)
-
-#define _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) \
-	forall(_UNPACK assertions | \
-		is_exception(exception_name parameters, VTABLE_TYPE(exception_name) parameters)) \
-	void ?{}(exception_name parameters & this)
-
-#define _FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters) \
-	_FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) { \
-		(this).virtual_table = &get_exception_vtable(&this); \
+// Create a (possibly polymorphic) virtual table definition.
+#define _EHM_VIRTUAL_TABLE(exception_type, arguments, table_name) \
+	const _EHM_VTABLE_TYPE(exception_type) arguments table_name @= { \
+		.__cfavir_typeid : &_EHM_TYPE_ID_NAME(exception_type), \
+		.size : sizeof(struct exception_type arguments), \
+		.copy : copy, \
+		.^?{} : ^?{}, \
+		.msg : msg, \
 	}
 
-#define _DATA_EXCEPTION(exception_name, parent_name, ...) \
-	_VTABLE_DECLARATION(exception_name, parent_name)(); \
-	struct exception_name { \
-		VTABLE_FIELD(exception_name); \
-		_CLOSE
+// Create a (possibly polymorphic) copy function from an assignment operator.
+#define _EHM_DEFINE_FORALL_COPY(exception_name, forall_clause, parameters) \
+	forall_clause void copy(exception_name parameters * this, \
+			exception_name parameters * that) { \
+		*this = *that; \
+	}
 
-#define _FORALL_DATA_EXCEPTION(exception_name, parent_name, \
-		assertions, parameters, parent_parameters) \
-	_FORALL_VTABLE_DECLARATION(exception_name, parent_name, \
-		assertions, parameters, parent_parameters)(); \
-	_FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters); \
-	forall assertions struct exception_name { \
-		FORALL_VTABLE_FIELD(exception_name, parameters); \
-		_CLOSE
+#define _EHM_DEFINE_COPY(exception_name, arguments) \
+	void copy(exception_name arguments * this, exception_name arguments * that) { \
+		*this = *that; \
+	}
 
-#define _VTABLE_DECLARATION(exception_name, parent_name, ...) \
-	struct exception_name; \
-	VTABLE_TYPE(exception_name); \
-	VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *); \
-	extern VTABLE_TYPE(exception_name) VTABLE_NAME(exception_name); \
-	VTABLE_TYPE(exception_name) { \
-		VTABLE_TYPE(parent_name) const * parent; \
-		size_t size; \
-		void (*copy)(exception_name * this, exception_name * other); \
-		void (*^?{})(exception_name & this); \
-		const char * (*msg)(exception_name * this); \
-		_CLOSE
+// Create a (possibly polymorphic) msg function
+#define _EHM_DEFINE_FORALL_MSG(exception_name, forall_clause, parameters) \
+	forall_clause const char * msg(exception_name parameters * this) { \
+		return #exception_name #parameters; \
+	}
 
-#define _VTABLE_INSTANCE(exception_name, parent_name, ...) \
-	VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *) { \
-		return VTABLE_NAME(exception_name); \
-	} \
-	void _GLUE2(exception_name,_copy)(exception_name * this, exception_name * other) { \
-		*this = *other; \
-	} \
-	VTABLE_TYPE(exception_name) VTABLE_NAME(exception_name) @= { \
-		&VTABLE_NAME(parent_name), sizeof(exception_name), \
-		_GLUE2(exception_name,_copy), ^?{}, \
-		_CLOSE
+#define _EHM_DEFINE_MSG(exception_name, arguments) \
+	const char * msg(exception_name arguments * this) { \
+		return #exception_name #arguments; \
+	}
 
-#define _FORALL_VTABLE_DECLARATION(exception_name, parent_name, assertions, \
-		parameters, parent_parameters) \
-	forall assertions struct exception_name; \
-	forall assertions VTABLE_TYPE(exception_name) { \
-		VTABLE_TYPE(parent_name) parent_parameters const * parent; \
+// Produces the C compatable name of the virtual table type for a virtual type.
+#define _EHM_VTABLE_TYPE(type_name) struct _GLUE2(type_name,_vtable)
+
+// Create the vtable type for exception name.
+#define _EHM_VIRTUAL_TABLE_STRUCT(exception_name, forall_clause, parameters) \
+	forall_clause struct exception_name; \
+	forall_clause _EHM_VTABLE_TYPE(exception_name) { \
+		_EHM_TYPE_ID_TYPE(exception_name) parameters const * __cfavir_typeid; \
 		size_t size; \
 		void (*copy)(exception_name parameters * this, exception_name parameters * other); \
 		void (*^?{})(exception_name parameters & this); \
 		const char * (*msg)(exception_name parameters * this); \
-		_CLOSE
+	}
 
-#define _POLY_VTABLE_INSTANCE(exception_name, parent_name, ...) \
-	extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name); \
-	VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable( \
-			exception_name(__VA_ARGS__) *) { \
-		return VTABLE_NAME(exception_name); \
-	} \
-	void _GLUE2(exception_name,_copy)( \
-			exception_name(__VA_ARGS__) * this, exception_name(__VA_ARGS__) * other) { \
-		*this = *other; \
-	} \
-	VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name) @= { \
-		&VTABLE_NAME(parent_name), sizeof(exception_name(__VA_ARGS__)), \
-		_GLUE2(exception_name,_copy), ^?{}, \
-		_CLOSE
+// Define the function required to satify the trait for exceptions.
+#define _EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \
+	forall_clause inline void mark_exception( \
+		exception_name parameters const &, \
+		_EHM_VTABLE_TYPE(exception_name) parameters const &) {} \
+
+#define _EHM_TRAIT_FUNCTION2(exception_name, forall_clause, parameters) \
+	forall_clause _EHM_VTABLE_TYPE(exception_name) parameters const & \
+			get_exception_vtable(exception_name parameters const & this)
+
+#define __EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \
+	forall_clause inline _EHM_VTABLE_TYPE(exception_name) parameters const & \
+			get_exception_vtable(exception_name parameters const & this) { \
+		/* This comes before the structure definition, but we know the offset. */ \
+		/* return (_EHM_VTABLE_TYPE(exception_name) parameters const &)this; */ \
+		assert(false); \
+	}
+
+// Generates a new type-id structure. This is used to mangle the name of the
+// type-id instance so it also includes polymorphic information. Must be the
+// direct decendent of exception_t.
+// The second field is used to recover type information about the exception.
+#define _EHM_TYPE_ID_STRUCT(exception_name, forall_clause) \
+	forall_clause _EHM_TYPE_ID_TYPE(exception_name) { \
+		__cfa__parent_vtable const * parent; \
+	}
+
+// Generate a new type-id value.
+#define _EHM_TYPE_ID_VALUE(exception_name, arguments) \
+	__attribute__(( section(".gnu.linkonce." "__cfatid_" #exception_name) )) \
+	_EHM_TYPE_ID_TYPE(exception_name) arguments const \
+			_EHM_TYPE_ID_NAME(exception_name) = { \
+		&__cfatid_exception_t, \
+	}
+
+// _EHM_TYPE_ID_STRUCT and _EHM_TYPE_ID_VALUE are the two that would need to
+// be updated to extend the hierarchy if we are still using macros when that
+// is added.
+
+// Produce the C compatable name of the type-id type for an exception type.
+#define _EHM_TYPE_ID_TYPE(exception_name) \
+	struct _GLUE2(__cfatid_struct_, exception_name)
+
+// Produce the name of the instance of the type-id for an exception type.
+#define _EHM_TYPE_ID_NAME(exception_name) _GLUE2(__cfatid_,exception_name)
 
 #define _IS_EXCEPTION(kind, exception_name, parameters, ...) \
-	kind(exception_name parameters, VTABLE_TYPE(exception_name) parameters)
+	kind(exception_name parameters, _EHM_VTABLE_TYPE(exception_name) parameters)
+
+// Internal helper macros:
+#define _CLOSE(...) __VA_ARGS__ }
+#define _GLUE2(left, right) left##right
Index: libcfa/src/fstream.cfa
===================================================================
--- libcfa/src/fstream.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/fstream.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -321,18 +321,15 @@
 
 
+EHM_VIRTUAL_TABLE(Open_Failure, Open_Failure_main_table);
 void ?{}( Open_Failure & this, ofstream & ostream ) {
-	VTABLE_INIT(this, Open_Failure);
+	this.virtual_table = &Open_Failure_main_table;
 	this.ostream = &ostream;
 	this.tag = 1;
 }
 void ?{}( Open_Failure & this, ifstream & istream ) {
-	VTABLE_INIT(this, Open_Failure);
+	this.virtual_table = &Open_Failure_main_table;
 	this.istream = &istream;
 	this.tag = 0;
 }
-const char * Open_Failure_msg(Open_Failure * this) {
-	return "Open_Failure";
-}
-VTABLE_INSTANCE(Open_Failure)(Open_Failure_msg);
 void throwOpen_Failure( ofstream & ostream ) {
 	Open_Failure exc = { ostream };
Index: libcfa/src/fstream.hfa
===================================================================
--- libcfa/src/fstream.hfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/fstream.hfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -133,5 +133,5 @@
 
 
-DATA_EXCEPTION(Open_Failure)(
+EHM_EXCEPTION(Open_Failure)(
 	union {
 		ofstream * ostream;
Index: libcfa/src/virtual.c
===================================================================
--- libcfa/src/virtual.c	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ libcfa/src/virtual.c	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -15,7 +15,9 @@
 
 #include "virtual.h"
+#include "assert.h"
 
 int __cfa__is_parent( struct __cfa__parent_vtable const * parent,
     	struct __cfa__parent_vtable const * child ) {
+	assert( child );
 	do {
 		if ( parent == child )
@@ -28,4 +30,5 @@
 void * __cfa__virtual_cast( struct __cfa__parent_vtable const * parent,
     	struct __cfa__parent_vtable const * const * child ) {
+	assert( child );
 	return (__cfa__is_parent(parent, *child)) ? (void *)child : (void *)0;
 }
Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ src/Concurrency/Keywords.cc	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -42,6 +42,9 @@
 
 namespace Concurrency {
+	inline static std::string getTypeIdName( std::string const & exception_name ) {
+		return exception_name.empty() ? std::string() : Virtual::typeIdType( exception_name );
+	}
 	inline static std::string getVTableName( std::string const & exception_name ) {
-		return exception_name.empty() ? std::string() : Virtual::vtableTypeName(exception_name);
+		return exception_name.empty() ? std::string() : Virtual::vtableTypeName( exception_name );
 	}
 
@@ -75,4 +78,5 @@
 		  type_name( type_name ), field_name( field_name ), getter_name( getter_name ),
 		  context_error( context_error ), exception_name( exception_name ),
+		  typeid_name( getTypeIdName( exception_name ) ),
 		  vtable_name( getVTableName( exception_name ) ),
 		  needs_main( needs_main ), cast_target( cast_target ) {}
@@ -84,4 +88,5 @@
 
 		void handle( StructDecl * );
+		void addTypeId( StructDecl * );
 		void addVtableForward( StructDecl * );
 		FunctionDecl * forwardDeclare( StructDecl * );
@@ -99,4 +104,5 @@
 		const std::string context_error;
 		const std::string exception_name;
+		const std::string typeid_name;
 		const std::string vtable_name;
 		bool needs_main;
@@ -106,4 +112,5 @@
 		FunctionDecl * dtor_decl = nullptr;
 		StructDecl * except_decl = nullptr;
+		StructDecl * typeid_decl = nullptr;
 		StructDecl * vtable_decl = nullptr;
 	};
@@ -392,4 +399,7 @@
 		else if ( !except_decl && exception_name == decl->name && decl->body ) {
 			except_decl = decl;
+		}
+		else if ( !typeid_decl && typeid_name == decl->name && decl->body ) {
+			typeid_decl = decl;
 		}
 		else if ( !vtable_decl && vtable_name == decl->name && decl->body ) {
@@ -448,5 +458,11 @@
 		if( !dtor_decl ) SemanticError( decl, context_error );
 
-		addVtableForward( decl );
+		if ( !exception_name.empty() ) {
+			if( !typeid_decl ) SemanticError( decl, context_error );
+			if( !vtable_decl ) SemanticError( decl, context_error );
+
+			addTypeId( decl );
+			addVtableForward( decl );
+		}
 		FunctionDecl * func = forwardDeclare( decl );
 		ObjectDecl * field = addField( decl );
@@ -454,19 +470,24 @@
 	}
 
+	void ConcurrentSueKeyword::addTypeId( StructDecl * decl ) {
+		assert( typeid_decl );
+		StructInstType typeid_type( Type::Const, typeid_decl );
+		typeid_type.parameters.push_back( new TypeExpr(
+			new StructInstType( noQualifiers, decl )
+			) );
+		declsToAddBefore.push_back( Virtual::makeTypeIdInstance( &typeid_type ) );
+	}
+
 	void ConcurrentSueKeyword::addVtableForward( StructDecl * decl ) {
-		if ( vtable_decl ) {
-			std::list< Expression * > poly_args = {
-				new TypeExpr( new StructInstType( noQualifiers, decl ) ),
-			};
-			declsToAddBefore.push_back( Virtual::makeGetExceptionForward(
-				vtable_decl->makeInst( poly_args ),
-				except_decl->makeInst( poly_args )
-			) );
-			declsToAddBefore.push_back( Virtual::makeVtableForward(
-				vtable_decl->makeInst( move( poly_args ) ) ) );
-		// Its only an error if we want a vtable and don't have one.
-		} else if ( ! vtable_name.empty() ) {
-			SemanticError( decl, context_error );
-		}
+		assert( vtable_decl );
+		std::list< Expression * > poly_args = {
+			new TypeExpr( new StructInstType( noQualifiers, decl ) ),
+		};
+		declsToAddBefore.push_back( Virtual::makeGetExceptionForward(
+			vtable_decl->makeInst( poly_args ),
+			except_decl->makeInst( poly_args )
+		) );
+		declsToAddBefore.push_back( Virtual::makeVtableForward(
+			vtable_decl->makeInst( move( poly_args ) ) ) );
 	}
 
Index: src/Virtual/ExpandCasts.cc
===================================================================
--- src/Virtual/ExpandCasts.cc	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ src/Virtual/ExpandCasts.cc	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -32,4 +32,14 @@
 namespace Virtual {
 
+static bool is_prefix( const std::string & prefix, const std::string& entire ) {
+	size_t const p_size = prefix.size();
+	return (p_size < entire.size() && prefix == entire.substr(0, p_size));
+}
+
+static bool is_type_id_object( const ObjectDecl * objectDecl ) {
+	const std::string & objectName = objectDecl->name;
+	return is_prefix( "__cfatid_", objectName );
+}
+
 	// Indented until the new ast code gets added.
 
@@ -66,36 +76,4 @@
 	};
 
-	/* Currently virtual depends on the rather brittle name matching between
-	 * a (strict/explicate) virtual type, its vtable type and the vtable
-	 * instance.
-	 * A stronger implementation, would probably keep track of those triads
-	 * and use that information to create better error messages.
-	 */
-
-	namespace {
-
-	std::string get_vtable_name( std::string const & name ) {
-		return name + "_vtable";
-	}
-
-	std::string get_vtable_inst_name( std::string const & name ) {
-		return std::string("_") + get_vtable_name( name ) + "_instance";
-	}
-
-	std::string get_vtable_name_root( std::string const & name ) {
-		return name.substr(0, name.size() - 7 );
-	}
-
-	std::string get_vtable_inst_name_root( std::string const & name ) {
-		return get_vtable_name_root( name.substr(1, name.size() - 10 ) );
-	}
-
-	bool is_vtable_inst_name( std::string const & name ) {
-		return 17 < name.size() &&
-			name == get_vtable_inst_name( get_vtable_inst_name_root( name ) );
-	}
-
-	} // namespace
-
 	class VirtualCastCore {
 		Type * pointer_to_pvt(int level_of_indirection) {
@@ -141,11 +119,7 @@
 
 	void VirtualCastCore::premutate( ObjectDecl * objectDecl ) {
-		if ( is_vtable_inst_name( objectDecl->get_name() ) ) {
-			if ( ObjectDecl * existing = indexer.insert( objectDecl ) ) {
-				std::string msg = "Repeated instance of virtual table, original found at: ";
-				msg += existing->location.filename;
-				msg += ":" + toString( existing->location.first_line );
-				SemanticError( objectDecl->location, msg );
-			}
+		if ( is_type_id_object( objectDecl ) ) {
+			// Multiple definitions should be fine because of linkonce.
+			indexer.insert( objectDecl );
 		}
 	}
@@ -170,52 +144,87 @@
 	}
 
-	/// Get the virtual table type used in a virtual cast.
-	Type * getVirtualTableType( const VirtualCastExpr * castExpr ) {
-		const Type * objectType;
-		if ( auto target = dynamic_cast<const PointerType *>( castExpr->result ) ) {
-			objectType = target->base;
-		} else if ( auto target = dynamic_cast<const ReferenceType *>( castExpr->result ) ) {
-			objectType = target->base;
+	/// Get the base type from a pointer or reference.
+	const Type * getBaseType( const Type * type ) {
+		if ( auto target = dynamic_cast<const PointerType *>( type ) ) {
+			return target->base;
+		} else if ( auto target = dynamic_cast<const ReferenceType *>( type ) ) {
+			return target->base;
 		} else {
-			castError( castExpr, "Virtual cast type must be a pointer or reference type." );
-		}
-		assert( objectType );
-
-		const StructInstType * structType = dynamic_cast<const StructInstType *>( objectType );
-		if ( nullptr == structType ) {
-			castError( castExpr, "Virtual cast type must refer to a structure type." );
-		}
-		const StructDecl * structDecl = structType->baseStruct;
-		assert( structDecl );
-
-		const ObjectDecl * fieldDecl = nullptr;
-		if ( 0 < structDecl->members.size() ) {
-			const Declaration * memberDecl = structDecl->members.front();
+			return nullptr;
+		}
+	}
+
+	/* Attempt to follow the "head" field of the structure to get the...
+	 * Returns nullptr on error, otherwise owner must free returned node.
+	 */
+	StructInstType * followHeadPointerType(
+			const StructInstType * oldType,
+			const std::string& fieldName,
+			const CodeLocation& errorLocation ) {
+
+		// First section of the function is all about trying to fill this variable in.
+		StructInstType * newType = nullptr;
+		{
+			const StructDecl * oldDecl = oldType->baseStruct;
+			assert( oldDecl );
+
+			// Helper function for throwing semantic errors.
+			auto throwError = [&fieldName, &errorLocation, &oldDecl](const std::string& message) {
+				const std::string& context = "While following head pointer of " +
+					oldDecl->name + " named '" + fieldName + "': ";
+				SemanticError( errorLocation, context + message );
+			};
+
+			if ( oldDecl->members.empty() ) {
+				throwError( "Type has no fields." );
+			}
+			const Declaration * memberDecl = oldDecl->members.front();
 			assert( memberDecl );
-			fieldDecl = dynamic_cast<const ObjectDecl *>( memberDecl );
-			if ( fieldDecl && fieldDecl->name != "virtual_table" ) {
-				fieldDecl = nullptr;
-			}
-		}
-		if ( nullptr == fieldDecl ) {
-			castError( castExpr, "Virtual cast type must have a leading virtual_table field." );
-		}
-		const PointerType * fieldType = dynamic_cast<const PointerType *>( fieldDecl->type );
-		if ( nullptr == fieldType ) {
-			castError( castExpr, "Virtual cast type virtual_table field is not a pointer." );
-		}
-		assert( fieldType->base );
-		auto virtualStructType = dynamic_cast<const StructInstType *>( fieldType->base );
-		assert( virtualStructType );
-
-		// Here is the type, but if it is polymorphic it will have lost information.
-		// (Always a clone so that it may always be deleted.)
-		StructInstType * virtualType = virtualStructType->clone();
-		if ( ! structType->parameters.empty() ) {
-			deleteAll( virtualType->parameters );
-			virtualType->parameters.clear();
-			cloneAll( structType->parameters, virtualType->parameters );
-		}
-		return virtualType;
+			const ObjectDecl * fieldDecl = dynamic_cast<const ObjectDecl *>( memberDecl );
+			assert( fieldDecl );
+			if ( fieldName != fieldDecl->name ) {
+				throwError( "Head field did not have expected name." );
+			}
+
+			const Type * fieldType = fieldDecl->type;
+			if ( nullptr == fieldType ) {
+				throwError( "Could not get head field." );
+			}
+			const PointerType * ptrType = dynamic_cast<const PointerType *>( fieldType );
+			if ( nullptr == ptrType ) {
+				throwError( "First field is not a pointer type." );
+			}
+			assert( ptrType->base );
+			newType = dynamic_cast<StructInstType *>( ptrType->base );
+			if ( nullptr == newType ) {
+				throwError( "First field does not point to a structure type." );
+			}
+		}
+
+		// Now we can look into copying it.
+		newType = newType->clone();
+		if ( ! oldType->parameters.empty() ) {
+			deleteAll( newType->parameters );
+			newType->parameters.clear();
+			cloneAll( oldType->parameters, newType->parameters );
+		}
+		return newType;
+	}
+
+	/// Get the type-id type from a virtual type.
+	StructInstType * getTypeIdType( const Type * type, const CodeLocation& errorLocation ) {
+		const StructInstType * typeInst = dynamic_cast<const StructInstType *>( type );
+		if ( nullptr == typeInst ) {
+			return nullptr;
+		}
+		StructInstType * tableInst =
+			followHeadPointerType( typeInst, "virtual_table", errorLocation );
+		if ( nullptr == tableInst ) {
+			return nullptr;
+		}
+		StructInstType * typeIdInst =
+			followHeadPointerType( tableInst, "__cfavir_typeid", errorLocation );
+		delete tableInst;
+		return typeIdInst;
 	}
 
@@ -228,9 +237,16 @@
 		assert( pvt_decl );
 
-		const Type * vtable_type = getVirtualTableType( castExpr );
-		ObjectDecl * table = indexer.lookup( vtable_type );
-		if ( nullptr == table ) {
-			SemanticError( castLocation( castExpr ),
-				"Could not find virtual table instance." );
+		const Type * base_type = getBaseType( castExpr->result );
+		if ( nullptr == base_type ) {
+			castError( castExpr, "Virtual cast target must be a pointer or reference type." );
+		}
+		const Type * type_id_type = getTypeIdType( base_type, castLocation( castExpr ) );
+		if ( nullptr == type_id_type ) {
+			castError( castExpr, "Ill formed virtual cast target type." );
+		}
+		ObjectDecl * type_id = indexer.lookup( type_id_type );
+		delete type_id_type;
+		if ( nullptr == type_id ) {
+			castError( castExpr, "Virtual cast does not target a virtual type." );
 		}
 
@@ -238,5 +254,5 @@
 			new ApplicationExpr( VariableExpr::functionPointer( vcast_decl ), {
 					new CastExpr(
-						new AddressExpr( new VariableExpr( table ) ),
+						new AddressExpr( new VariableExpr( type_id ) ),
 						pointer_to_pvt(1)
 					),
@@ -252,5 +268,4 @@
 		castExpr->set_result( nullptr );
 		delete castExpr;
-		delete vtable_type;
 		return result;
 	}
Index: src/Virtual/Tables.cc
===================================================================
--- src/Virtual/Tables.cc	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ src/Virtual/Tables.cc	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -10,6 +10,6 @@
 // Created On       : Mon Aug 31 11:11:00 2020
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Sep  3 14:56:00 2020
-// Update Count     : 0
+// Last Modified On : Thr Apr  8 15:51:00 2021
+// Update Count     : 1
 //
 
@@ -22,6 +22,22 @@
 namespace Virtual {
 
+std::string typeIdType( std::string const & type_name ) {
+	return "__cfatid_struct_" + type_name;
+}
+
+std::string typeIdName( std::string const & type_name ) {
+	return "__cfatid_" + type_name;
+}
+
+static std::string typeIdTypeToInstance( std::string const & type_name ) {
+	return typeIdName(type_name.substr(16));
+}
+
 std::string vtableTypeName( std::string const & name ) {
 	return name + "_vtable";
+}
+
+std::string baseTypeName( std::string const & vtable_type_name ) {
+	return vtable_type_name.substr(0, vtable_type_name.size() - 7);
 }
 
@@ -81,4 +97,8 @@
 				inits.push_back(
 						new SingleInit( new AddressExpr( new NameExpr( parentInstance ) ) ) );
+			} else if ( std::string( "__cfavir_typeid" ) == field->name ) {
+				std::string const & baseType = baseTypeName( vtableType->name );
+				std::string const & typeId = typeIdName( baseType );
+				inits.push_back( new SingleInit( new AddressExpr( new NameExpr( typeId ) ) ) );
 			} else if ( std::string( "size" ) == field->name ) {
 				inits.push_back( new SingleInit( new SizeofExpr( objectType->clone() ) ) );
@@ -147,3 +167,43 @@
 }
 
-}
+ObjectDecl * makeTypeIdForward() {
+	return nullptr;
+}
+
+Attribute * linkonce( const std::string & subsection ) {
+	const std::string section = "\".gnu.linkonce." + subsection + "\"";
+	// Adjust for terminator and quotes.
+	size_t str_size = section.size() + 1 - 2;
+	return new Attribute( "section", {
+		new ConstantExpr( Constant(
+			new ArrayType(
+				noQualifiers,
+				new BasicType( noQualifiers, BasicType::Char ),
+				new ConstantExpr( Constant::from_ulong( str_size ) ),
+				false, false ),
+			section,
+			std::nullopt
+		) ),
+	} );
+}
+
+ObjectDecl * makeTypeIdInstance( StructInstType const * typeIdType ) {
+	assert( typeIdType );
+	StructInstType * type = typeIdType->clone();
+	type->tq.is_const = true;
+	std::string const & typeid_name = typeIdTypeToInstance( typeIdType->name );
+	return new ObjectDecl(
+		typeid_name,
+		noStorageClasses,
+		LinkageSpec::Cforall,
+		/* bitfieldWidth */ nullptr,
+		type,
+		new ListInit( { new SingleInit(
+			new AddressExpr( new NameExpr( "__cfatid_exception_t" ) )
+			) } ),
+		{ linkonce( typeid_name ) },
+		noFuncSpecifiers
+	);
+}
+
+}
Index: src/Virtual/Tables.h
===================================================================
--- src/Virtual/Tables.h	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ src/Virtual/Tables.h	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -10,6 +10,6 @@
 // Created On       : Mon Aug 31 11:07:00 2020
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Sep  1 14:29:00 2020
-// Update Count     : 0
+// Last Modified On : Thr Apr  8 15:55:00 2021
+// Update Count     : 1
 //
 
@@ -22,4 +22,6 @@
 namespace Virtual {
 
+std::string typeIdType( std::string const & type_name );
+std::string typeIdName( std::string const & type_name );
 std::string vtableTypeName( std::string const & type_name );
 std::string instanceName( std::string const & vtable_name );
@@ -50,3 +52,8 @@
  */
 
+ObjectDecl * makeTypeIdInstance( StructInstType const * typeIdType );
+/* Build an instance of the type-id from the type of the type-id.
+ * TODO: Should take the parent type. Currently locked to the exception_t.
+ */
+
 }
Index: tests/exceptions/.expect/resume-threads.txt
===================================================================
--- tests/exceptions/.expect/resume-threads.txt	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/.expect/resume-threads.txt	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -6,7 +6,4 @@
 
 catch-all
-
-throwing child exception
-inner parent match
 
 caught yin as yin
Index: tests/exceptions/.expect/resume.txt
===================================================================
--- tests/exceptions/.expect/resume.txt	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/.expect/resume.txt	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -6,7 +6,4 @@
 
 catch-all
-
-throwing child exception
-inner parent match
 
 caught yin as yin
Index: tests/exceptions/.expect/terminate-threads.txt
===================================================================
--- tests/exceptions/.expect/terminate-threads.txt	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/.expect/terminate-threads.txt	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -5,7 +5,4 @@
 
 catch-all
-
-throwing child exception
-inner parent match
 
 caught yin as yin
Index: tests/exceptions/.expect/terminate.txt
===================================================================
--- tests/exceptions/.expect/terminate.txt	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/.expect/terminate.txt	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -5,7 +5,4 @@
 
 catch-all
-
-throwing child exception
-inner parent match
 
 caught yin as yin
Index: tests/exceptions/cancel/coroutine.cfa
===================================================================
--- tests/exceptions/cancel/coroutine.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/cancel/coroutine.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,5 +4,6 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION(internal_error);
+EHM_EXCEPTION(internal_error)();
+EHM_VIRTUAL_TABLE(internal_error, internal_vt);
 
 coroutine WillCancel {};
@@ -14,5 +15,5 @@
 void main(WillCancel & wc) {
 	printf("1");
-	cancel_stack((internal_error){});
+	cancel_stack((internal_error){&internal_vt});
 	printf("!");
 }
@@ -24,5 +25,5 @@
 		resume(cancel);
 		printf("4");
-	} catchResume (CoroutineCancelled(WillCancel) * error) {
+	} catchResume (SomeCoroutineCancelled * error) {
 		printf("2");
 		if ((virtual internal_error *)error->the_exception) {
Index: tests/exceptions/cancel/thread.cfa
===================================================================
--- tests/exceptions/cancel/thread.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/cancel/thread.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,5 +4,6 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION(internal_error);
+EHM_EXCEPTION(internal_error)();
+EHM_VIRTUAL_TABLE(internal_error, internal_vt);
 
 thread WillCancel {};
@@ -14,5 +15,5 @@
 void main(WillCancel &) {
 	printf("1");
-	cancel_stack((internal_error){});
+	cancel_stack((internal_error){&internal_vt});
 	printf("!");
 }
@@ -25,5 +26,5 @@
 		join(cancel);
 		printf("4");
-	} catchResume (ThreadCancelled(WillCancel) * error) {
+	} catchResume (SomeThreadCancelled * error) {
 		printf("2");
 		if ((virtual internal_error *)error->the_exception) {
@@ -42,5 +43,5 @@
 		}
 		printf("4");
-	} catchResume (ThreadCancelled(WillCancel) * error) {
+	} catchResume (SomeThreadCancelled * error) {
 		printf("2");
 		if ((virtual internal_error *)error->the_exception) {
Index: tests/exceptions/conditional.cfa
===================================================================
--- tests/exceptions/conditional.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/conditional.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -6,44 +6,9 @@
 #include <exception.hfa>
 
-VTABLE_DECLARATION(num_error)(
-	int (*code)(num_error *this);
+EHM_EXCEPTION(num_error)(
+	int num;
 );
 
-struct num_error {
-	VTABLE_FIELD(num_error);
-    char * msg;
-    int num;
-};
-
-const char * num_error_msg(num_error * this) {
-    if ( ! this->msg ) {
-        static const char * base = "Num Error with code: X";
-        this->msg = (char *)malloc(22);
-        for (int i = 0 ; (this->msg[i] = base[i]) ; ++i);
-    }
-    this->msg[21] = '0' + this->num;
-    return this->msg;
-}
-void ?{}(num_error & this, int num) {
-	VTABLE_INIT(this, num_error);
-    this.msg = 0;
-    this.num = num;
-}
-void ?{}(num_error & this, num_error & other) {
-    this.virtual_table = other.virtual_table;
-    this.msg = 0;
-    this.num = other.num;
-}
-void ^?{}(num_error & this) {
-    if( this.msg ) free( this.msg );
-}
-int num_error_code( num_error * this ) {
-    return this->num;
-}
-
-VTABLE_INSTANCE(num_error)(
-	num_error_msg,
-	num_error_code,
-);
+EHM_VIRTUAL_TABLE(num_error, num_error_vt);
 
 void caught_num_error(int expect, num_error * actual) {
@@ -52,11 +17,11 @@
 
 int main(int argc, char * argv[]) {
-	num_error exc = 2;
+	num_error exc = {&num_error_vt, 2};
 
 	try {
 		throw exc;
-	} catch (num_error * error ; 3 == error->virtual_table->code( error )) {
+	} catch (num_error * error ; 3 == error->num ) {
 		caught_num_error(3, error);
-	} catch (num_error * error ; 2 == error->virtual_table->code( error )) {
+	} catch (num_error * error ; 2 == error->num ) {
 		caught_num_error(2, error);
 	}
@@ -64,7 +29,7 @@
 	try {
 		throwResume exc;
-	} catchResume (num_error * error ; 3 == error->virtual_table->code( error )) {
+	} catchResume (num_error * error ; 3 == error->num ) {
 		caught_num_error(3, error);
-	} catchResume (num_error * error ; 2 == error->virtual_table->code( error )) {
+	} catchResume (num_error * error ; 2 == error->num ) {
 		caught_num_error(2, error);
 	}
Index: tests/exceptions/data-except.cfa
===================================================================
--- tests/exceptions/data-except.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/data-except.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -3,44 +3,34 @@
 #include <exception.hfa>
 
-DATA_EXCEPTION(paired)(
+EHM_EXCEPTION(paired)(
 	int first;
 	int second;
 );
 
-void ?{}(paired & this, int first, int second) {
-	VTABLE_INIT(this, paired);
-	this.first = first;
-	this.second = second;
-}
+EHM_VIRTUAL_TABLE(paired, paired_vt);
 
-const char * paired_msg(paired * this) {
-	return "paired";
-}
-
-VTABLE_INSTANCE(paired)(paired_msg);
-
-void throwPaired(int first, int second) {
-	paired exc = {first, second};
+const char * virtual_msg(paired * this) {
+	return this->virtual_table->msg(this);
 }
 
 int main(int argc, char * argv[]) {
-	paired except = {3, 13};
+	paired except = {&paired_vt, 3, 13};
 
 	try {
 		throw except;
 	} catch (paired * exc) {
-		printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
+		printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
 		++exc->first;
 	}
 
-	printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
+	printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
 
 	try {
 		throwResume except;
 	} catchResume (paired * exc) {
-		printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
+		printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
 		++exc->first;
 	}
 
-	printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
+	printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
 }
Index: tests/exceptions/defaults.cfa
===================================================================
--- tests/exceptions/defaults.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/defaults.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,18 +4,13 @@
 #include <exception.hfa>
 
-DATA_EXCEPTION(log_message)(
+EHM_EXCEPTION(log_message)(
 	char * msg;
 );
 
-void ?{}(log_message & this, char * msg) {
-	VTABLE_INIT(this, log_message);
-	this.msg = msg;
-}
-
-const char * get_log_message(log_message * this) {
+_EHM_DEFINE_COPY(log_message, )
+const char * msg(log_message * this) {
 	return this->msg;
 }
-
-VTABLE_INSTANCE(log_message)(get_log_message);
+_EHM_VIRTUAL_TABLE(log_message, , log_vt);
 
 // Logging messages don't have to be handled.
@@ -28,34 +23,39 @@
 	// We can catch log:
 	try {
-		throwResume (log_message){"Should be printed.\n"};
+		throwResume (log_message){&log_vt, "Should be printed.\n"};
 	} catchResume (log_message * this) {
 		printf("%s", this->virtual_table->msg(this));
 	}
 	// But we don't have to:
-	throwResume (log_message){"Should not be printed.\n"};
+	throwResume (log_message){&log_vt, "Should not be printed.\n"};
 }
 
 // I don't have a good use case for doing the same with termination.
-TRIVIAL_EXCEPTION(jump);
+EHM_EXCEPTION(jump)();
 void defaultTerminationHandler(jump &) {
 	printf("jump default handler.\n");
 }
 
+EHM_VIRTUAL_TABLE(jump, jump_vt);
+
 void jump_test(void) {
 	try {
-		throw (jump){};
+		throw (jump){&jump_vt};
 	} catch (jump * this) {
 		printf("jump catch handler.\n");
 	}
-	throw (jump){};
+	throw (jump){&jump_vt};
 }
 
-TRIVIAL_EXCEPTION(first);
-TRIVIAL_EXCEPTION(unhandled_exception);
+EHM_EXCEPTION(first)();
+EHM_VIRTUAL_TABLE(first, first_vt);
+
+EHM_EXCEPTION(unhandled_exception)();
+EHM_VIRTUAL_TABLE(unhandled_exception, unhandled_vt);
 
 void unhandled_test(void) {
 	forall(T &, V & | is_exception(T, V))
 	void defaultTerminationHandler(T &) {
-		throw (unhandled_exception){};
+		throw (unhandled_exception){&unhandled_vt};
 	}
 	void defaultTerminationHandler(unhandled_exception &) {
@@ -63,5 +63,5 @@
 	}
 	try {
-		throw (first){};
+		throw (first){&first_vt};
 	} catch (unhandled_exception * t) {
 		printf("Catch unhandled_exception.\n");
@@ -69,18 +69,19 @@
 }
 
-TRIVIAL_EXCEPTION(second);
+EHM_EXCEPTION(second)();
+EHM_VIRTUAL_TABLE(second, second_vt);
 
 void cross_test(void) {
 	void defaultTerminationHandler(first &) {
 		printf("cross terminate default\n");
-		throw (second){};
+		throw (second){&second_vt};
 	}
 	void defaultResumptionHandler(first &) {
 		printf("cross resume default\n");
-		throwResume (second){};
+		throwResume (second){&second_vt};
 	}
 	try {
 		printf("cross terminate throw\n");
-		throw (first){};
+		throw (first){&first_vt};
 	} catch (second *) {
 		printf("cross terminate catch\n");
@@ -88,5 +89,5 @@
 	try {
 		printf("cross resume throw\n");
-		throwResume (first){};
+		throwResume (first){&first_vt};
 	} catchResume (second *) {
 		printf("cross resume catch\n");
Index: tests/exceptions/finally.cfa
===================================================================
--- tests/exceptions/finally.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/finally.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,8 +4,10 @@
 #include "except-io.hfa"
 
-TRIVIAL_EXCEPTION(myth);
+EHM_EXCEPTION(myth)();
+
+EHM_VIRTUAL_TABLE(myth, myth_vt);
 
 int main(int argc, char * argv[]) {
-	myth exc;
+	myth exc = {&myth_vt};
 
 	try {
Index: tests/exceptions/interact.cfa
===================================================================
--- tests/exceptions/interact.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/interact.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,11 +4,14 @@
 #include "except-io.hfa"
 
-TRIVIAL_EXCEPTION(star);
-TRIVIAL_EXCEPTION(moon);
+EHM_EXCEPTION(star)();
+EHM_EXCEPTION(moon)();
+
+EHM_VIRTUAL_TABLE(star, star_vt);
+EHM_VIRTUAL_TABLE(moon, moon_vt);
 
 int main(int argc, char * argv[]) {
 	// Resume falls back to terminate.
 	try {
-		throwResume (star){};
+		throwResume (star){&star_vt};
 	} catch (star *) {
 		printf("caught as termination\n");
@@ -17,5 +20,5 @@
 	try {
 		loud_region a = "try block with resume throw";
-		throwResume (star){};
+		throwResume (star){&star_vt};
 	} catch (star *) {
 		printf("caught as termination\n");
@@ -29,5 +32,5 @@
 	try {
 		try {
-			throw (star){};
+			throw (star){&star_vt};
 		} catchResume (star *) {
 			printf("resume catch on terminate\n");
@@ -43,5 +46,5 @@
 	try {
 		try {
-			throwResume (star){};
+			throwResume (star){&star_vt};
 		} catch (star *) {
 			printf("terminate catch on resume\n");
@@ -58,5 +61,5 @@
 		try {
 			try {
-				throw (star){};
+				throw (star){&star_vt};
 			} catchResume (star *) {
 				printf("inner resume catch (error)\n");
@@ -75,5 +78,5 @@
 		try {
 			try {
-				throwResume (star){};
+				throwResume (star){&star_vt};
 			} catch (star *) {
 				printf("inner termination catch\n");
@@ -94,10 +97,10 @@
 				try {
 					printf("throwing resume moon\n");
-					throwResume (moon){};
+					throwResume (moon){&moon_vt};
 				} catch (star *) {
 					printf("termination catch\n");
 				}
 				printf("throwing resume star\n");
-				throwResume (star){};
+				throwResume (star){&star_vt};
 			} catchResume (star *) {
 				printf("resumption star catch\n");
@@ -105,5 +108,5 @@
 		} catchResume (moon *) {
 			printf("resumption moon catch, will terminate\n");
-			throw (star){};
+			throw (star){&star_vt};
 		}
 	} catchResume (star *) {
Index: tests/exceptions/polymorphic.cfa
===================================================================
--- tests/exceptions/polymorphic.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/polymorphic.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -3,15 +3,15 @@
 #include <exception.hfa>
 
-FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T));
-FORALL_TRIVIAL_INSTANCE(proxy, (U), (U))
+EHM_FORALL_EXCEPTION(proxy, (T&), (T))();
 
-const char * msg(proxy(int) * this) { return "proxy(int)"; }
-const char * msg(proxy(char) * this) { return "proxy(char)"; }
-POLY_VTABLE_INSTANCE(proxy, int)(msg);
-POLY_VTABLE_INSTANCE(proxy, char)(msg);
+EHM_FORALL_VIRTUAL_TABLE(proxy, (int), proxy_int);
+EHM_FORALL_VIRTUAL_TABLE(proxy, (char), proxy_char);
 
 void proxy_test(void) {
+	proxy(int) an_int = {&proxy_int};
+	proxy(char) a_char = {&proxy_char};
+
     try {
-		throw (proxy(int)){};
+		throw an_int;
 	} catch (proxy(int) *) {
 		printf("terminate catch\n");
@@ -19,5 +19,5 @@
 
 	try {
-		throwResume (proxy(char)){};
+		throwResume a_char;
 	} catchResume (proxy(char) *) {
 		printf("resume catch\n");
@@ -25,5 +25,5 @@
 
 	try {
-		throw (proxy(char)){};
+		throw a_char;
 	} catch (proxy(int) *) {
 		printf("caught proxy(int)\n");
@@ -33,21 +33,15 @@
 }
 
-FORALL_DATA_EXCEPTION(cell, (T), (T))(
+EHM_FORALL_EXCEPTION(cell, (T), (T))(
 	T data;
 );
 
-FORALL_DATA_INSTANCE(cell, (T), (T))
-
-const char * msg(cell(int) * this) { return "cell(int)"; }
-const char * msg(cell(char) * this) { return "cell(char)"; }
-const char * msg(cell(bool) * this) { return "cell(bool)"; }
-POLY_VTABLE_INSTANCE(cell, int)(msg);
-POLY_VTABLE_INSTANCE(cell, char)(msg);
-POLY_VTABLE_INSTANCE(cell, bool)(msg);
+EHM_FORALL_VIRTUAL_TABLE(cell, (int), int_cell);
+EHM_FORALL_VIRTUAL_TABLE(cell, (char), char_cell);
+EHM_FORALL_VIRTUAL_TABLE(cell, (bool), bool_cell);
 
 void cell_test(void) {
 	try {
-		cell(int) except;
-		except.data = -7;
+		cell(int) except = {&int_cell, -7};
 		throw except;
 	} catch (cell(int) * error) {
@@ -56,6 +50,5 @@
 
 	try {
-		cell(bool) ball;
-		ball.data = false;
+		cell(bool) ball = {&bool_cell, false};
 		throwResume ball;
 		printf("%i\n", ball.data);
Index: tests/exceptions/resume.cfa
===================================================================
--- tests/exceptions/resume.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/resume.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,17 +4,24 @@
 #include "except-io.hfa"
 
-TRIVIAL_EXCEPTION(yin);
-TRIVIAL_EXCEPTION(yang);
-TRIVIAL_EXCEPTION(zen);
-TRIVIAL_EXCEPTION(moment_of, zen);
+EHM_EXCEPTION(yin)();
+EHM_EXCEPTION(yang)();
+EHM_EXCEPTION(zen)();
+
+EHM_VIRTUAL_TABLE(yin, yin_vt);
+EHM_VIRTUAL_TABLE(yang, yang_vt);
+EHM_VIRTUAL_TABLE(zen, zen_vt);
 
 void in_void(void);
 
 int main(int argc, char * argv[]) {
+	yin a_yin = {&yin_vt};
+	yang a_yang = {&yang_vt};
+	zen a_zen = {&zen_vt};
+
 	// The simple throw catchResume test.
 	try {
 		loud_exit a = "simple try clause";
 		printf("simple throw\n");
-		throwResume (zen){};
+		throwResume a_zen;
 		printf("end of try clause\n");
 	} catchResume (zen * error) {
@@ -26,18 +33,7 @@
 	// Throw catch-all test.
 	try {
-		throwResume (zen){};
+		throwResume a_zen;
 	} catchResume (exception_t * error) {
 		printf("catch-all\n");
-	}
-	printf("\n");
-
-	// Catch a parent of the given exception.
-	try {
-		printf("throwing child exception\n");
-		throwResume (moment_of){};
-	} catchResume (zen *) {
-		printf("inner parent match\n");
-	} catchResume (moment_of *) {
-		printf("outer exact match\n");
 	}
 	printf("\n");
@@ -46,5 +42,5 @@
 	try {
 		try {
-			throwResume (yin){};
+			throwResume a_yin;
 		} catchResume (zen *) {
 			printf("caught yin as zen\n");
@@ -62,5 +58,5 @@
 			loud_exit a = "rethrow inner try";
 			printf("rethrow inner try\n");
-			throwResume (zen){};
+			throwResume a_zen;
 		} catchResume (zen *) {
 			loud_exit a = "rethrowing catch clause";
@@ -77,8 +73,8 @@
 	try {
 		try {
-			throwResume (yin){};
+			throwResume a_yin;
 		} catchResume (yin *) {
 			printf("caught yin, will throw yang\n");
-			throwResume (yang){};
+			throwResume a_yang;
 		} catchResume (yang *) {
 			printf("caught exception from same try\n");
@@ -93,10 +89,10 @@
 		try {
 			printf("throwing first exception\n");
-			throwResume (yin){};
+			throwResume a_yin;
 		} catchResume (yin *) {
 			printf("caught first exception\n");
 			try {
 				printf("throwing second exception\n");
-				throwResume (yang){};
+				throwResume a_yang;
 			} catchResume (yang *) {
 				printf("caught second exception\n");
@@ -114,10 +110,10 @@
 	try {
 		try {
-			throwResume (zen){};
-			throwResume (zen){};
+			throwResume a_zen;
+			throwResume a_zen;
 		} catchResume (zen *) {
 			printf("inner catch\n");
 		}
-		throwResume (zen){};
+		throwResume a_zen;
 	} catchResume (zen *) {
 		printf("outer catch\n");
@@ -130,8 +126,9 @@
 // Do a throw and rethrow in a void function.
 void in_void(void) {
+    zen a_zen = {&zen_vt};
 	try {
 		try {
 			printf("throw\n");
-			throwResume (zen){};
+			throwResume a_zen;
 		} catchResume (zen *) {
 			printf("rethrow\n");
Index: tests/exceptions/terminate.cfa
===================================================================
--- tests/exceptions/terminate.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/terminate.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -4,17 +4,24 @@
 #include "except-io.hfa"
 
-TRIVIAL_EXCEPTION(yin);
-TRIVIAL_EXCEPTION(yang);
-TRIVIAL_EXCEPTION(zen);
-TRIVIAL_EXCEPTION(moment_of, zen);
+EHM_EXCEPTION(yin)();
+EHM_EXCEPTION(yang)();
+EHM_EXCEPTION(zen)();
+
+EHM_VIRTUAL_TABLE(yin, yin_vt);
+EHM_VIRTUAL_TABLE(yang, yang_vt);
+EHM_VIRTUAL_TABLE(zen, zen_vt);
 
 void in_void(void);
 
 int main(int argc, char * argv[]) {
+	yin a_yin = {&yin_vt};
+	yang a_yang = {&yang_vt};
+	zen a_zen = {&zen_vt};
+
 	// The simple throw catch test.
 	try {
 		loud_exit a = "simple try clause";
 		printf("simple throw\n");
-		throw (zen){};
+		throw a_zen;
 		printf("end of try clause\n");
 	} catch (zen * error) {
@@ -26,18 +33,7 @@
 	// Throw catch-all test.
 	try {
-		throw (zen){};
+		throw a_zen;
 	} catch (exception_t * error) {
 		printf("catch-all\n");
-	}
-	printf("\n");
-
-	// Catch a parent of the given exception.
-	try {
-		printf("throwing child exception\n");
-		throw (moment_of){};
-	} catch (zen *) {
-		printf("inner parent match\n");
-	} catch (moment_of *) {
-		printf("outer exact match\n");
 	}
 	printf("\n");
@@ -46,5 +42,5 @@
 	try {
 		try {
-			throw (yin){};
+			throw a_yin;
 		} catch (zen *) {
 			printf("caught yin as zen\n");
@@ -62,5 +58,5 @@
 			loud_exit a = "rethrow inner try";
 			printf("rethrow inner try\n");
-			throw (zen){};
+			throw a_zen;
 		} catch (zen *) {
 			loud_exit a = "rethrowing catch clause";
@@ -77,8 +73,8 @@
 	try {
 		try {
-			throw (yin){};
+			throw a_yin;
 		} catch (yin *) {
 			printf("caught yin, will throw yang\n");
-			throw (yang){};
+			throw a_yang;
 		} catch (yang *) {
 			printf("caught exception from same try\n");
@@ -93,10 +89,10 @@
 		try {
 			printf("throwing first exception\n");
-			throw (yin){};
+			throw a_yin;
 		} catch (yin *) {
 			printf("caught first exception\n");
 			try {
 				printf("throwing second exception\n");
-				throw (yang){};
+				throw a_yang;
 			} catch (yang *) {
 				printf("caught second exception\n");
@@ -114,10 +110,10 @@
 	try {
 		try {
-			throw (zen){};
-			throw (zen){};
+			throw a_zen;
+			throw a_zen;
 		} catch (zen *) {
 			printf("inner catch\n");
 		}
-		throw (zen){};
+		throw a_zen;
 	} catch (zen *) {
 		printf("outer catch\n");
@@ -130,8 +126,9 @@
 // Do a throw and rethrow in a void function.
 void in_void(void) {
+	zen a_zen = {&zen_vt};
 	try {
 		try {
 			printf("throw\n");
-			throw (zen){};
+			throw a_zen;
 		} catch (zen *) {
 			printf("rethrow\n");
Index: tests/exceptions/trash.cfa
===================================================================
--- tests/exceptions/trash.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/trash.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -3,14 +3,17 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION(yin);
-TRIVIAL_EXCEPTION(yang);
+EHM_EXCEPTION(yin)();
+EHM_EXCEPTION(yang)();
+
+EHM_VIRTUAL_TABLE(yin, yin_vt);
+EHM_VIRTUAL_TABLE(yang, yang_vt);
 
 int main(int argc, char * argv[]) {
 	try {
 		try {
-			throw (yin){};
+			throw (yin){&yin_vt};
 		} finally {
 			try {
-				throw (yang){};
+				throw (yang){&yang_vt};
 			} catch (yin *) {
 				printf("inner yin\n");
Index: tests/exceptions/type-check.cfa
===================================================================
--- tests/exceptions/type-check.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/type-check.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -3,5 +3,5 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION(truth);
+EHM_EXCEPTION(truth)();
 
 int main(int argc, char * argv[]) {
Index: tests/exceptions/virtual-cast.cfa
===================================================================
--- tests/exceptions/virtual-cast.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/virtual-cast.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -12,6 +12,18 @@
 #include <assert.h>
 
+
+
+// Hand defined alpha virtual type:
+struct __cfatid_struct_alpha {
+	__cfa__parent_vtable const * parent;
+};
+
+__attribute__(( section(".gnu.linkonce.__cfatid_alpha") ))
+struct __cfatid_struct_alpha __cfatid_alpha = {
+	(__cfa__parent_vtable *)0,
+};
+
 struct alpha_vtable {
-	alpha_vtable const * const parent;
+	struct __cfatid_struct_alpha const * const __cfavir_typeid;
 	char (*code)(void);
 };
@@ -27,6 +39,16 @@
 
 
+// Hand defined beta virtual type:
+struct __cfatid_struct_beta {
+	__cfatid_struct_alpha const * parent;
+};
+
+__attribute__(( section(".gnu.linkonce.__cfatid_beta") ))
+struct __cfatid_struct_beta __cfatid_beta = {
+	&__cfatid_alpha,
+};
+
 struct beta_vtable {
-	alpha_vtable const * const parent;
+	struct __cfatid_struct_beta const * const __cfavir_typeid;
 	char (*code)(void);
 };
@@ -42,6 +64,16 @@
 
 
+// Hand defined gamma virtual type:
+struct __cfatid_struct_gamma {
+	__cfatid_struct_beta const * parent;
+};
+
+__attribute__(( section(".gnu.linkonce.__cfatid_gamma") ))
+struct __cfatid_struct_gamma __cfatid_gamma = {
+	&__cfatid_beta,
+};
+
 struct gamma_vtable {
-	beta_vtable const * const parent;
+	struct __cfatid_struct_gamma const * const __cfavir_typeid;
 	char (*code)(void);
 };
@@ -57,7 +89,7 @@
 
 extern "C" {
-	alpha_vtable _alpha_vtable_instance = { 0, ret_a };
-	beta_vtable _beta_vtable_instance = { &_alpha_vtable_instance, ret_b };
-	gamma_vtable _gamma_vtable_instance = { &_beta_vtable_instance, ret_g };
+	alpha_vtable _alpha_vtable_instance = { &__cfatid_alpha, ret_a };
+	beta_vtable _beta_vtable_instance = { &__cfatid_beta, ret_b };
+	gamma_vtable _gamma_vtable_instance = { &__cfatid_gamma, ret_g };
 }
 
Index: tests/exceptions/virtual-poly.cfa
===================================================================
--- tests/exceptions/virtual-poly.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/exceptions/virtual-poly.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -8,6 +8,16 @@
 #include <assert.h>
 
+
+struct __cfatid_struct_mono_base {
+    __cfa__parent_vtable const * parent;
+};
+
+__attribute__(( section(".gnu.linkonce.__cfatid_mono_base") ))
+struct __cfatid_struct_mono_base __cfatid_mono_base = {
+    (__cfa__parent_vtable *)0,
+};
+
 struct mono_base_vtable {
-	mono_base_vtable const * const parent;
+	__cfatid_struct_mono_base const * const __cfavir_typeid;
 };
 
@@ -17,6 +27,11 @@
 
 forall(T)
+struct __cfatid_struct_mono_child {
+    __cfatid_struct_mono_base const * parent;
+};
+
+forall(T)
 struct mono_child_vtable {
-	mono_base_vtable const * const parent;
+	__cfatid_struct_mono_child(T) const * const __cfavir_typeid;
 };
 
@@ -26,7 +41,10 @@
 };
 
-mono_base_vtable _mono_base_vtable_instance @= { 0 };
+__cfatid_struct_mono_child(int) __cfatid_mono_child @= {
+	&__cfatid_mono_base,
+};
+
 mono_child_vtable(int) _mono_child_vtable_instance @= {
-	&_mono_base_vtable_instance
+	&__cfatid_mono_child,
 };
 
@@ -37,7 +55,13 @@
 }
 
+
+forall(U)
+struct __cfatid_struct_poly_base {
+    __cfa__parent_vtable const * parent;
+};
+
 forall(U)
 struct poly_base_vtable {
-	poly_base_vtable(U) const * const parent;
+	__cfatid_struct_poly_base(U) const * const __cfavir_typeid;
 };
 
@@ -48,6 +72,11 @@
 
 forall(V)
+struct __cfatid_struct_poly_child {
+    __cfatid_struct_poly_base(V) const * parent;
+};
+
+forall(V)
 struct poly_child_vtable {
-	poly_base_vtable(V) const * const parent;
+	__cfatid_struct_poly_child(V) const * const __cfavir_typeid;
 };
 
@@ -57,14 +86,13 @@
 };
 
-poly_base_vtable(int) _poly_base_vtable_instance @= { 0 };
+__cfatid_struct_poly_base(int) __cfatid_poly_base @= {
+	(__cfa__parent_vtable *)0,
+};
+__cfatid_struct_poly_child(int) __cfatid_poly_child = {
+    &__cfatid_poly_base,
+};
 poly_child_vtable(int) _poly_child_vtable_instance @= {
-	&_poly_base_vtable_instance
+	&__cfatid_poly_child,
 };
-/* Resolver bug keeps me from adding these.
-poly_base_vtable(char) _poly_base_vtable_instance @= { 0 };
-poly_child_vtable(char) _poly_child_vtable_instance @= {
-	&_poly_base_vtable_instance
-};
-*/
 
 void poly_poly_test() {
@@ -77,4 +105,4 @@
 	mono_poly_test();
 	poly_poly_test();
-	printf( "done\n" );				// non-empty .expect file
+	printf( "done\n" );
 }
Index: tests/linking/exception-nothreads.cfa
===================================================================
--- tests/linking/exception-nothreads.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/linking/exception-nothreads.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -17,9 +17,10 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION(ping);
+EHM_EXCEPTION(ping)();
+EHM_VIRTUAL_TABLE(ping, ping_vt);
 
 int main(void) {
 	try {
-		throwResume (ping){};
+		throwResume (ping){&ping_vt};
 	} catchResume (ping *) {
 		printf("%s threads\n", threading_enabled() ? "with" : "no");
Index: tests/linking/exception-withthreads.cfa
===================================================================
--- tests/linking/exception-withthreads.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/linking/exception-withthreads.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -18,9 +18,10 @@
 #include "../exceptions/with-threads.hfa"
 
-TRIVIAL_EXCEPTION(ping);
+EHM_EXCEPTION(ping)();
+EHM_VIRTUAL_TABLE(ping, ping_vt);
 
 int main(void) {
 	try {
-		throwResume (ping){};
+		throwResume (ping){&ping_vt};
 	} catchResume (ping *) {
 		printf("%s threads\n", threading_enabled() ? "with" : "no");
Index: tests/quasiKeyword.cfa
===================================================================
--- tests/quasiKeyword.cfa	(revision e07b5897db46ca1ee98f3e1de79d3c5eeb7821bb)
+++ tests/quasiKeyword.cfa	(revision ecfd7589e4796949fcc35b475a024d4acda6e636)
@@ -14,5 +14,5 @@
 #include <exception.hfa>
 
-TRIVIAL_EXCEPTION( E );
+EHM_EXCEPTION( E )();
 
 void catch( int i ) {}
