Index: src/Common/Eval.cc
===================================================================
--- src/Common/Eval.cc	(revision 933f32f2ae9703d54327e4727aceb5746433092d)
+++ src/Common/Eval.cc	(revision 0ce063b2cb1b34a9c165fe77d6c6a58643b6445b)
@@ -17,8 +17,11 @@
 
 #include "Common/PassVisitor.h"
+#include "AST/Pass.hpp"
 #include "InitTweak/InitTweak.h"
 #include "SynTree/Expression.h"
 
-struct Eval : public WithShortCircuiting {
+//-------------------------------------------------------------
+// Old AST
+struct EvalOld : public WithShortCircuiting {
 	long long int value = 0;
 	bool valid = true;
@@ -80,6 +83,78 @@
 };
 
+//-------------------------------------------------------------
+// New AST
+struct EvalNew : public ast::WithShortCircuiting {
+	long long int value = 0;
+	bool valid = true;
+
+	void previsit( const ast::Node * ) { visit_children = false; }
+	void postvisit( const ast::Node * ) { valid = false; }
+
+	void postvisit( const ast::ConstantExpr * expr ) {
+		value = expr->intValue();
+	}
+
+	void postvisit( const ast::CastExpr * expr ) {
+		auto arg = eval(expr->arg);
+		valid = arg.second;
+		value = arg.first;
+		// TODO: perform type conversion on value if valid
+	}
+
+	void postvisit( const ast::VariableExpr * expr ) {
+		if ( const ast::EnumInstType * inst = dynamic_cast<const ast::EnumInstType *>(expr->result.get()) ) {
+			if ( const ast::EnumDecl * decl = inst->base ) {
+				if ( decl->valueOf( expr->var, value ) ) { // value filled by valueOf
+					return;
+				}
+			}
+		}
+		valid = false;
+	}
+
+	void postvisit( const ast::ApplicationExpr * expr ) {
+		const ast::DeclWithType * function = InitTweak::getFunction(expr);
+		if ( ! function || function->linkage != ast::Linkage::Intrinsic ) { valid = false; return; }
+		const std::string & fname = function->name;
+		assertf( expr->args.size() == 1 || expr->args.size() == 2, "Intrinsic function with %zd arguments: %s", expr->args.size(), fname.c_str() );
+		std::pair<long long int, bool> arg1, arg2;
+		arg1 = eval(expr->args.front());
+		valid = valid && arg1.second;
+		if ( ! valid ) return;
+		if ( expr->args.size() == 2 ) {
+			arg2 = eval(expr->args.back());
+			valid = valid && arg2.second;
+			if ( ! valid ) return;
+		}
+		if (fname == "?+?") {
+			value = arg1.first + arg2.first;
+		} else if (fname == "?-?") {
+			value = arg1.first - arg2.first;
+		} else if (fname == "?*?") {
+			value = arg1.first * arg2.first;
+		} else if (fname == "?/?") {
+			value = arg1.first / arg2.first;
+		} else if (fname == "?%?") {
+			value = arg1.first % arg2.first;
+		} else {
+			valid = false;
+		}
+		// TODO: implement other intrinsic functions
+	}
+};
+
 std::pair<long long int, bool> eval(Expression * expr) {
-	PassVisitor<Eval> ev;
+	PassVisitor<EvalOld> ev;
+	if (expr) {
+		expr->accept(ev);
+		return std::make_pair(ev.pass.value, ev.pass.valid);
+	} else {
+		return std::make_pair(0, false);
+	}
+}
+
+std::pair<long long int, bool> eval(const ast::Expr * expr) {
+	ast::Pass<EvalNew> ev;
 	if (expr) {
 		expr->accept(ev);
Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision 933f32f2ae9703d54327e4727aceb5746433092d)
+++ src/Common/PassVisitor.impl.h	(revision 0ce063b2cb1b34a9c165fe77d6c6a58643b6445b)
@@ -23,21 +23,4 @@
 	assert( __return ); \
 	return __return;
-
-
-#define VISIT_BODY( node )          \
-	VISIT_START( node );          \
-	if( children_guard ) {        \
-		Visitor::visit( node ); \
-	}                             \
-	VISIT_END( node );            \
-
-
-#define MUTATE_BODY( type, node )    \
-	MUTATE_START( node );          \
-	if( children_guard ) {         \
-		Mutator::mutate( node ); \
-	}                              \
-	MUTATE_END( type, node );      \
-
 
 
@@ -2756,2 +2739,8 @@
 	MUTATE_END( TypeSubstitution, node );
 }
+
+#undef VISIT_START
+#undef VISIT_END
+
+#undef MUTATE_START
+#undef MUTATE_END
Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 933f32f2ae9703d54327e4727aceb5746433092d)
+++ src/Common/utility.h	(revision 0ce063b2cb1b34a9c165fe77d6c6a58643b6445b)
@@ -74,7 +74,7 @@
 
 template< typename Container >
-void deleteAll( Container &container ) {
-	for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
-		delete *i;
+void deleteAll( const Container &container ) {
+	for ( const auto &i : container ) {
+		delete i;
 	} // for
 }
