Index: translator/SynTree/AddressExpr.cc
===================================================================
--- translator/SynTree/AddressExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/AddressExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: AddressExpr.cc,v 1.6 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Expression.h"
+#include "Type.h"
+#include "utility.h"
+
+
+AddressExpr::AddressExpr( Expression *arg, Expression *_aname )
+    : Expression( _aname ), arg( arg )
+{
+    for( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) {
+	get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );
+    }
+}
+
+AddressExpr::AddressExpr( const AddressExpr &other )
+    : Expression( other ), arg( maybeClone( other.arg ) )
+{
+}
+
+AddressExpr::~AddressExpr()
+{
+    delete arg;
+}
+
+void 
+AddressExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Address of:" << std::endl;
+    if( arg ) {
+	arg->print( os, indent+2 );
+    }
+}
+
+
Index: translator/SynTree/AggregateDecl.cc
===================================================================
--- translator/SynTree/AggregateDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/AggregateDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: AggregateDecl.cc,v 1.7 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Declaration.h"
+#include "Type.h"
+#include "utility.h"
+
+
+AggregateDecl::AggregateDecl( const std::string &name )
+    : Parent( name, Declaration::NoStorageClass, LinkageSpec::Cforall )
+{
+}
+
+AggregateDecl::AggregateDecl( const AggregateDecl &other )
+    : Parent( other )
+{
+    cloneAll( other.members, members );
+    cloneAll( other.parameters, parameters );
+}
+
+AggregateDecl::~AggregateDecl()
+{
+    deleteAll( members );
+    deleteAll( parameters );
+}
+
+void 
+AggregateDecl::print( std::ostream &os, int indent ) const
+{
+    using std::string;
+    using std::endl;
+
+    os << typeString() << " " << get_name();
+    if( !parameters.empty() ) {
+	os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+4 );
+    }
+    if( !members.empty() ) {
+	os << endl << string( indent+2, ' ' ) << "with members" << endl;
+	printAll( members, os, indent+4 );
+    }
+}
+
+void 
+AggregateDecl::printShort( std::ostream &os, int indent ) const
+{
+    using std::string;
+    using std::endl;
+
+    os << typeString() << " " << get_name();
+    if( !parameters.empty() ) {
+	os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+4 );
+    }
+}
+
+std::string StructDecl::typeString() const { return "struct"; }
+
+std::string UnionDecl::typeString() const { return "union"; }
+
+std::string EnumDecl::typeString() const { return "enum"; }
+
+std::string ContextDecl::typeString() const { return "context"; }
+
Index: translator/SynTree/ApplicationExpr.cc
===================================================================
--- translator/SynTree/ApplicationExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/ApplicationExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,77 @@
+#include <cassert>
+
+#include "Expression.h"
+#include "Declaration.h"
+#include "Type.h"
+#include "TypeSubstitution.h"
+#include "utility.h"
+
+
+ParamEntry::ParamEntry( const ParamEntry &other )
+    : decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )
+{
+}
+
+ParamEntry &
+ParamEntry::operator=( const ParamEntry &other )
+{
+    if( &other == this ) return *this;
+    decl = other.decl;
+    actualType = maybeClone( other.actualType );
+    formalType = maybeClone( other.formalType );
+    expr = maybeClone( other.expr );
+    return *this;
+}
+
+ParamEntry::~ParamEntry()
+{
+    delete actualType;
+    delete formalType;
+    delete expr;
+}
+
+ApplicationExpr::ApplicationExpr( Expression *funcExpr )
+    : function( funcExpr )
+{
+    PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() );
+    assert( pointer );
+    FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
+    assert( function );
+    
+    for( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
+	get_results().push_back( (*i)->get_type()->clone() );
+    }
+}
+
+ApplicationExpr::ApplicationExpr( const ApplicationExpr &other )
+    : Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams )
+{
+    cloneAll( other.args, args );
+}
+
+ApplicationExpr::~ApplicationExpr()
+{
+    delete function;
+    deleteAll( args );
+}
+
+void 
+ApplicationExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Application of" << std::endl;
+    function->print( os, indent+2 );
+    if( !args.empty() ) {
+	os << std::string( indent, ' ' ) << "to arguments" << std::endl;
+	printAll( args, os, indent+2 );
+    }
+    if( !inferParams.empty() ) {
+	os << std::string(indent, ' ') << "with inferred parameters:" << std::endl;
+	for( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
+	    os << std::string(indent+2, ' ');
+	    Declaration::declFromId( i->second.decl )->printShort( os, indent+2 );
+	    os << std::endl;
+	}
+    }
+    Expression::print( os, indent );
+}
+
Index: translator/SynTree/ArrayType.cc
===================================================================
--- translator/SynTree/ArrayType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/ArrayType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: ArrayType.cc,v 1.6 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic )
+    : Type( tq ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic )
+{
+    base->set_isLvalue( false );
+}
+
+ArrayType::ArrayType( const ArrayType &other )
+    : Type( other ), base( maybeClone( other.base ) ), dimension( maybeClone( other.dimension ) ),
+	isVarLen( other.isVarLen ), isStatic( other.isStatic )
+{
+}
+
+ArrayType::~ArrayType()
+{
+    delete base;
+    delete dimension;
+}
+
+void 
+ArrayType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    if( isStatic ) {
+	os << "static ";
+    }
+    if( isVarLen ) {
+	os << "variable length array of ";
+    } else if( dimension ) {
+	os << "array of ";
+	dimension->print( os, indent );
+    } else {
+	os << "open array of ";
+    }
+    if( base ) {
+	base->print( os, indent );
+    }
+}
+
Index: translator/SynTree/AttrType.cc
===================================================================
--- translator/SynTree/AttrType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/AttrType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: AttrType.cc,v 1.3 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+AttrType::AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr )
+    : Type( tq ), name( name ), expr( expr ), type( 0 ), isType( false )
+{
+}
+
+AttrType::AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type )
+    : Type( tq ), name( name ), expr( 0 ), type( type ), isType( true )
+{
+}
+
+AttrType::AttrType( const AttrType &other )
+    : Type( other ), name( other.name ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType )
+{
+}
+
+AttrType::~AttrType()
+{
+    delete expr;
+    delete type;
+}
+
+void 
+AttrType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    os << "attribute " << name << " applied to ";
+    if( expr ) {
+	os << "expression ";
+	expr->print( os, indent );
+    }
+    if( type ) {
+	os << "type ";
+	type->print( os, indent );
+    }
+}
+
Index: translator/SynTree/BasicType.cc
===================================================================
--- translator/SynTree/BasicType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/BasicType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: BasicType.cc,v 1.10 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <cassert>
+
+#include "Type.h"
+
+
+BasicType::BasicType( const Type::Qualifiers &tq, Kind bt )
+    : Type( tq ), kind( bt )
+{
+}
+
+void
+BasicType::print( std::ostream &os, int indent ) const
+{
+    static const char *kindNames[] = {	
+	"bool", "char", "signed char", "unsigned char", "short signed int", "short unsigned int",
+	"signed int", "unsigned int", "long signed int", "long unsigned int", "long long signed int",
+	"long long unsigned int", "float", "double", "long double", "float complex", "double complex",
+	"long double complex", "float imaginary", "double imaginary", "long double imaginary"
+    };
+
+    Type::print( os, indent );
+    os << kindNames[ kind ] << ' ';
+}
+
+bool 
+BasicType::isInteger() const
+{
+    switch( kind ) {
+    case Bool:
+    case Char:
+    case SignedChar:
+    case UnsignedChar:
+    case ShortSignedInt:
+    case ShortUnsignedInt:
+    case SignedInt:
+    case UnsignedInt:
+    case LongSignedInt:
+    case LongUnsignedInt:
+    case LongLongSignedInt:
+    case LongLongUnsignedInt:
+	return true;
+
+    case Float:
+    case Double:
+    case LongDouble:
+    case FloatComplex:
+    case DoubleComplex:
+    case LongDoubleComplex:
+    case FloatImaginary:
+    case DoubleImaginary:
+    case LongDoubleImaginary:
+	return false;
+
+    case NUMBER_OF_BASIC_TYPES:
+	assert( false );
+    }
+    assert( false );
+    return false;
+}
+
+
Index: translator/SynTree/CodeGenVisitor.cc
===================================================================
--- translator/SynTree/CodeGenVisitor.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/CodeGenVisitor.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,44 @@
+#include <iostream>
+#include <list>
+
+#include "Statement.h"
+#include "Expression.h"
+#include "CodeGenVisitor.h"
+using namespace std;
+
+//*** Types
+void CodeGenVisitor::visit(Type *type){ }
+void CodeGenVisitor::visit(BasicType *basicType) { }
+
+//*** Constant
+void CodeGenVisitor::visit(Constant *constant) { 
+    cout << constant->get_value() << endl;
+}
+
+//*** Expressions
+void CodeGenVisitor::visit(Expression *expr){ }
+
+void CodeGenVisitor::visit(ConstantExpr *cnst){
+    if(cnst != 0)
+	visit(cnst->get_constant());
+}
+
+//*** Statements
+void CodeGenVisitor::visit(Statement *stmt){ }
+
+void CodeGenVisitor::visit(ExprStmt *exprStmt){
+    if(exprStmt != 0)
+	exprStmt->get_expr()->accept(*this);	// visit(exprStmt->get_expr()) doesn't work
+}
+
+void CodeGenVisitor::visit(SwitchStmt *switchStmt){
+    cout << "switch(" << endl;	    
+    // visit(switchStmt->get_condition());   // why doesn't this work?
+    switchStmt->get_condition()->accept(*this);
+
+    cout << ") {" << endl;	
+    // visit(switchStmt->get_body());  // why doesn't this work?
+    cout << "}" << endl;	
+}
+
+
Index: translator/SynTree/CodeGenVisitor.h
===================================================================
--- translator/SynTree/CodeGenVisitor.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/CodeGenVisitor.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,30 @@
+#ifndef CODEGENV_H
+#define CODEGENV_H
+
+#include <typeinfo>
+
+#include "SynTree.h"
+#include "Visitor.h"
+
+
+class CodeGenVisitor : public Visitor {
+public:
+    //*** Types
+    virtual void visit(Type *);
+    virtual void visit(BasicType *);
+
+    //*** Constant
+    virtual void visit(Constant *);
+
+    //*** Expressions
+    virtual void visit(Expression *);
+    virtual void visit(ConstantExpr *);
+
+    //*** Statements
+    virtual void visit(Statement *);
+    virtual void visit(ExprStmt *);
+    virtual void visit(SwitchStmt *);
+};
+
+
+#endif /* #ifndef CODEGENV_H */
Index: translator/SynTree/CommaExpr.cc
===================================================================
--- translator/SynTree/CommaExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/CommaExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: CommaExpr.cc,v 1.7 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Expression.h"
+#include "Type.h"
+#include "utility.h"
+
+
+CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname )
+    : Expression( _aname ), arg1( arg1 ), arg2( arg2 )
+{
+    cloneAll( arg2->get_results(), get_results() );
+}
+
+CommaExpr::CommaExpr( const CommaExpr &other )
+    : Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) )
+{
+}
+
+CommaExpr::~CommaExpr()
+{
+    delete arg1;
+    delete arg2;
+}
+
+void 
+CommaExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Comma Expression:" << std::endl;
+    arg1->print( os, indent+2 );
+    os << std::endl;
+    arg2->print( os, indent+2 );
+    Expression::print( os, indent );
+}
+
+
Index: translator/SynTree/CompoundStmt.cc
===================================================================
--- translator/SynTree/CompoundStmt.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/CompoundStmt.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: CompoundStmt.cc,v 1.4 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Statement.h"
+#include "utility.h"
+#include <algorithm>
+#include <functional>
+
+
+CompoundStmt::CompoundStmt( std::list<Label> labels )
+    : Statement( labels )
+{
+}
+
+CompoundStmt::CompoundStmt( const CompoundStmt &other )
+    : Statement( other )
+{
+    cloneAll( other.kids, kids );
+}
+
+CompoundStmt::~CompoundStmt()
+{
+    deleteAll( kids );
+}
+
+void 
+CompoundStmt::print( std::ostream &os, int indent )
+{
+    printAll( kids, os, indent );
+}
+
+
+
+
+
Index: translator/SynTree/Constant.cc
===================================================================
--- translator/SynTree/Constant.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Constant.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <list>
+
+#include "Constant.h"
+#include "Type.h"
+
+
+Constant::Constant(Type *_type, std::string _value):
+    type(_type), value(_value) {}
+
+Constant::~Constant() {}
+
+Constant *Constant::clone() const { return 0; }
+
+void Constant::print( std::ostream &os ) const {
+    os << value;
+    if( type ) {
+	os << " (type: ";
+	type->print( os );
+	os << ")";
+    }
+}
+
+
+
+
Index: translator/SynTree/Constant.h
===================================================================
--- translator/SynTree/Constant.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Constant.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Constant.h,v 1.6 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#ifndef CONSTANT_H
+#define CONSTANT_H
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+
+
+class Constant
+{
+public:
+    Constant( Type *type, std::string value );
+    virtual ~Constant();
+
+    Type *get_type() { return type; }
+    void set_type( Type *newValue ) { type = newValue; }
+    std::string get_value() { return value; }
+    void set_value( std::string newValue ) { value = newValue; }
+
+    virtual Constant *clone() const;
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os ) const;
+    
+private:
+    Type *type;
+    std::string value;
+};
+
+
+
+
+#endif /* #ifndef CONSTANT_H */
Index: translator/SynTree/DeclStmt.cc
===================================================================
--- translator/SynTree/DeclStmt.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/DeclStmt.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: DeclStmt.cc,v 1.4 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Statement.h"
+#include "Declaration.h"
+#include "utility.h"
+
+
+DeclStmt::DeclStmt( std::list<Label> labels, Declaration *decl )
+    : Statement( labels ), decl( decl )
+{
+}
+
+DeclStmt::DeclStmt( const DeclStmt &other )
+    : Statement( other ), decl( maybeClone( other.decl ) )
+{
+}
+
+DeclStmt::~DeclStmt()
+{
+    delete decl;
+}
+
+void 
+DeclStmt::print( std::ostream &os, int indent )
+{
+    os << "Declaration of ";
+    if( decl ) {
+	decl->print( os, indent );
+    }
+}
+
+
Index: translator/SynTree/Declaration.cc
===================================================================
--- translator/SynTree/Declaration.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Declaration.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Declaration.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <string>
+#include <map>
+#include "Declaration.h"
+#include "Expression.h"
+#include "Initializer.h"
+#include "Type.h"
+#include "utility.h"
+
+
+const char* Declaration::storageClassName[] = { "", "auto", "static", "extern", "register" };  
+
+static UniqueId lastUniqueId = 0;
+typedef std::map< UniqueId, Declaration* > IdMapType;
+static IdMapType idMap;
+
+Declaration::Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage )
+    : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 )
+{
+}
+
+Declaration::Declaration( const Declaration &other )
+    : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId )
+{
+}
+
+Declaration::~Declaration()
+{
+}
+
+void
+Declaration::fixUniqueId()
+{
+    uniqueId = ++lastUniqueId;
+    idMap[ uniqueId ] = this;
+}
+
+/* static class method */
+Declaration *
+Declaration::declFromId( UniqueId id )
+{
+    IdMapType::const_iterator i = idMap.find( id );
+    if( i != idMap.end() ) {
+	return i->second;
+    } else {
+	return 0;
+    }
+}
+
+/* static class method */
+void 
+Declaration::dumpIds( std::ostream &os )
+{
+    for( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) {
+	os << i->first << " -> ";
+	i->second->printShort( os );
+	os << std::endl;
+    }
+}
+
Index: translator/SynTree/Declaration.h
===================================================================
--- translator/SynTree/Declaration.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Declaration.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,300 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Declaration.h,v 1.22 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#ifndef DECLARATION_H
+#define DECLARATION_H
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+#include "Parser/LinkageSpec.h"
+
+
+class Declaration
+{
+public:
+    enum StorageClass
+    {  
+	NoStorageClass,
+	Auto,
+	Static,
+	Extern,
+	Register,
+	Fortran
+    };	
+    
+    Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage );
+    Declaration( const Declaration &other );
+    virtual ~Declaration();
+
+    std::string get_name() const { return name; }
+    void set_name( std::string newValue ) { name = newValue; }
+    StorageClass get_storageClass() const { return storageClass; }
+    void set_storageClass( StorageClass newValue ) { storageClass = newValue; }
+    LinkageSpec::Type get_linkage() const { return linkage; }
+    void set_linkage( LinkageSpec::Type newValue ) { linkage = newValue; }
+    UniqueId get_uniqueId() const { return uniqueId; }
+    
+    void fixUniqueId( void );
+    virtual Declaration *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Declaration *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 ) const = 0;
+    virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
+    
+    static const char* storageClassName[];  
+    
+    static void dumpIds( std::ostream &os );
+    static Declaration *declFromId( UniqueId id );
+    
+private:
+    std::string name;
+    StorageClass storageClass;
+    LinkageSpec::Type linkage;
+    UniqueId uniqueId;
+};
+
+class DeclarationWithType : public Declaration
+{
+public:
+    DeclarationWithType( const std::string &name, StorageClass sc, LinkageSpec::Type linkage );
+    DeclarationWithType( const DeclarationWithType &other );
+    virtual ~DeclarationWithType();
+
+    std::string get_mangleName() const { return mangleName; }
+    void set_mangleName( std::string newValue ) { mangleName = newValue; }
+    
+    virtual DeclarationWithType *clone() const = 0;
+    virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
+    
+    virtual Type *get_type() const = 0;
+    virtual void set_type(Type *) = 0;
+    
+private:
+    // this represents the type with all types and typedefs expanded
+    // it is generated by SymTab::Validate::Pass2
+    std::string mangleName;
+};
+
+class ObjectDecl : public DeclarationWithType
+{
+    typedef DeclarationWithType Parent;
+
+public:
+    ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init );
+    ObjectDecl( const ObjectDecl &other );
+    virtual ~ObjectDecl();
+
+    virtual Type *get_type() const { return type; }
+    virtual void set_type(Type *newType) { type = newType; }
+
+    Initializer *get_init() const { return init; }
+    void set_init( Initializer *newValue ) { init = newValue; }
+    Expression *get_bitfieldWidth() const { return bitfieldWidth; }
+    void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
+    
+    virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual ObjectDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    virtual void printShort( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Type *type;
+    Initializer *init;
+    Expression *bitfieldWidth;
+};
+
+class FunctionDecl : public DeclarationWithType
+{
+    typedef DeclarationWithType Parent;
+
+public:
+    FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline );
+    FunctionDecl( const FunctionDecl &other );
+    virtual ~FunctionDecl();
+
+    Type *get_type() const;
+    virtual void set_type(Type *);
+
+    FunctionType *get_functionType() const { return type; }
+    void set_functionType( FunctionType *newValue ) { type = newValue; }
+    CompoundStmt *get_statements() const { return statements; }
+    void set_statements( CompoundStmt *newValue ) { statements = newValue; }
+    bool get_isInline() const { return isInline; }
+    void set_isInline( bool newValue ) { isInline = newValue; }
+    std::list< std::string >& get_oldIdents() { return oldIdents; }
+    std::list< Declaration* >& get_oldDecls() { return oldDecls; }
+    
+    virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    virtual void printShort( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    FunctionType *type;
+    CompoundStmt *statements;
+    bool isInline;
+    std::list< std::string > oldIdents;
+    std::list< Declaration* > oldDecls;
+};
+
+class NamedTypeDecl : public Declaration
+{
+    typedef Declaration Parent;
+
+public:
+    NamedTypeDecl( const std::string &name, StorageClass sc, Type *type );
+    NamedTypeDecl( const TypeDecl &other );
+    virtual ~NamedTypeDecl();
+
+    Type *get_base() const { return base; }
+    void set_base( Type *newValue ) { base = newValue; }
+    std::list< TypeDecl* >& get_parameters() { return parameters; }
+    std::list< DeclarationWithType* >& get_assertions() { return assertions; }
+
+    virtual NamedTypeDecl *clone() const = 0;
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    virtual void printShort( std::ostream &os, int indent = 0 ) const;
+    
+protected:
+    virtual std::string typeString() const = 0;
+    
+private:
+    Type *base;
+    std::list< TypeDecl* > parameters;
+    std::list< DeclarationWithType* > assertions;
+};
+
+class TypeDecl : public NamedTypeDecl
+{
+    typedef NamedTypeDecl Parent;
+
+public:
+    enum Kind { Any, Dtype, Ftype };
+
+    TypeDecl( const std::string &name, StorageClass sc, Type *type, Kind kind );
+    TypeDecl( const TypeDecl &other );
+    
+    Kind get_kind() const { return kind; }
+
+    virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+    Kind kind;
+};
+    
+class TypedefDecl : public NamedTypeDecl
+{
+    typedef NamedTypeDecl Parent;
+
+public:
+    TypedefDecl( const std::string &name, StorageClass sc, Type *type ) : Parent( name, sc, type ) {}
+    TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
+    
+    virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+    
+class AggregateDecl : public Declaration
+{
+    typedef Declaration Parent;
+
+public:
+    AggregateDecl( const std::string &name );
+    AggregateDecl( const AggregateDecl &other );
+    virtual ~AggregateDecl();
+
+    std::list<Declaration*>& get_members() { return members; }
+    std::list<TypeDecl*>& get_parameters() { return parameters; }
+    
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    virtual void printShort( std::ostream &os, int indent = 0 ) const;
+
+protected:
+    virtual std::string typeString() const = 0;
+    
+private:
+    std::list<Declaration*> members;
+    std::list<TypeDecl*> parameters;
+};
+
+class StructDecl : public AggregateDecl
+{
+    typedef AggregateDecl Parent;
+
+public:
+    StructDecl( const std::string &name ) : Parent( name ) {}
+    StructDecl( const StructDecl &other ) : Parent( other ) {}
+    
+    virtual StructDecl *clone() const { return new StructDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+    
+class UnionDecl : public AggregateDecl
+{
+    typedef AggregateDecl Parent;
+
+public:
+    UnionDecl( const std::string &name ) : Parent( name ) {}
+    UnionDecl( const UnionDecl &other ) : Parent( other ) {}
+    
+    virtual UnionDecl *clone() const { return new UnionDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+    
+class EnumDecl : public AggregateDecl
+{
+    typedef AggregateDecl Parent;
+
+public:
+    EnumDecl( const std::string &name ) : Parent( name ) {}
+    EnumDecl( const EnumDecl &other ) : Parent( other ) {}
+    
+    virtual EnumDecl *clone() const { return new EnumDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+    
+class ContextDecl : public AggregateDecl
+{
+    typedef AggregateDecl Parent;
+
+public:
+    ContextDecl( const std::string &name ) : Parent( name ) {}
+    ContextDecl( const ContextDecl &other ) : Parent( other ) {}
+    
+    virtual ContextDecl *clone() const { return new ContextDecl( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+    
+
+
+#endif /* #ifndef DECLARATION_H */
Index: translator/SynTree/DeclarationWithType.cc
===================================================================
--- translator/SynTree/DeclarationWithType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/DeclarationWithType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: DeclarationWithType.cc,v 1.9 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Declaration.h"
+#include "Type.h"
+#include "utility.h"
+
+
+DeclarationWithType::DeclarationWithType( const std::string &name, StorageClass sc, LinkageSpec::Type linkage )
+    : Declaration( name, sc, linkage )
+{
+}
+
+DeclarationWithType::DeclarationWithType( const DeclarationWithType &other )
+    : Declaration( other ), mangleName( other.mangleName )
+{
+}
+
+DeclarationWithType::~DeclarationWithType()
+{
+}
+
Index: translator/SynTree/Expression.cc
===================================================================
--- translator/SynTree/Expression.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Expression.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,368 @@
+#include <iostream>
+#include <cassert>
+#include <list>
+#include <algorithm>
+
+#include <iterator>
+
+#include "Type.h"
+#include "Expression.h"
+#include "Declaration.h"
+#include "Statement.h"
+#include "TypeSubstitution.h"
+#include "utility.h"
+
+
+//*** Expression
+Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
+Expression::Expression( const Expression &other )
+    : env( maybeClone( other.env ) )
+ {
+     cloneAll( other.results, results );
+     argName = other.get_argName();
+ }
+Expression::~Expression()
+{
+    delete env;
+    // delete argName;	// xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
+    deleteAll( results );
+}
+
+void
+Expression::add_result( Type *t )
+{
+    if( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) {
+	std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) );
+    } else {
+	results.push_back(t);
+    }
+}
+
+void Expression::print(std::ostream &os, int indent) const {
+    if( env ) {
+	os << std::string(indent, ' ') << "with environment:" << std::endl;
+	env->print( os, indent+2 );
+    }
+
+    if( argName ) {
+	os << std::string(indent, ' ') << "with designator:";
+	argName->print( os, indent+2 );
+    }
+}
+
+//*** ConstantExpr
+ConstantExpr::ConstantExpr(Constant _c, Expression *_aname ):
+    Expression( _aname ), constant(_c)
+{
+    add_result( constant.get_type()->clone() );
+}
+
+ConstantExpr::ConstantExpr( const ConstantExpr &other)
+    : Expression( other ), constant( other.constant )
+{}
+
+ConstantExpr::~ConstantExpr() {}
+
+void ConstantExpr::print(std::ostream &os, int indent) const {
+    os << std::string(indent, ' ') << "Constant Expression: " ;
+    constant.print(os);
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** VariableExpr
+VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var )
+{
+    add_result( var->get_type()->clone() );
+    for( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
+	(*i)->set_isLvalue( true );
+    }
+}
+
+VariableExpr::VariableExpr( const VariableExpr &other )
+    : Expression( other ), var( other.var )
+{
+}
+
+VariableExpr::~VariableExpr()
+{
+    // don't delete the declaration, since it points somewhere else in the tree
+}
+
+void VariableExpr::print(std::ostream &os, int indent) const {
+    os << std::string(indent, ' ') << "Variable Expression: ";
+
+    Declaration *decl = get_var();
+    // if( decl != 0) decl->print(os, indent + 2);
+    if( decl != 0) decl->printShort(os, indent + 2);
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** SizeofExpr
+SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
+    Expression( _aname ), expr(expr_), type(0), isType(false)
+{
+    add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
+}
+
+SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
+    Expression( _aname ), expr(0), type(type_), isType(true)
+{
+    add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
+}
+
+SizeofExpr::SizeofExpr( const SizeofExpr &other )
+    : Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType )
+{
+}
+
+SizeofExpr::~SizeofExpr(){
+    delete expr;
+    delete type;
+}
+
+void SizeofExpr::print( std::ostream &os, int indent) const {
+    os << std::string(indent, ' ') << "Sizeof Expression on: ";
+
+    if(isType)
+	type->print(os, indent + 2);
+    else
+	expr->print(os, indent + 2);
+
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** AttrExpr
+AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
+    Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false)
+{
+}
+
+AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) :
+    Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true)
+{
+}
+
+AttrExpr::AttrExpr( const AttrExpr &other )
+    : Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType )
+{
+}
+
+AttrExpr::~AttrExpr(){
+    delete attr;
+    delete expr;
+    delete type;
+}
+
+void AttrExpr::print( std::ostream &os, int indent) const {
+    os << std::string(indent, ' ') << "Attr ";
+    attr->print( os, indent + 2 );
+    if( isType || expr ) {
+	os << "applied to: ";
+
+	if(isType)
+	    type->print(os, indent + 2);
+	else
+	    expr->print(os, indent + 2);
+    }
+
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** CastExpr
+CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_)
+{
+    add_result(toType);
+}
+
+CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
+}
+
+CastExpr::CastExpr( const CastExpr &other )
+    : Expression( other ), arg( maybeClone( other.arg ) )
+{
+}
+
+CastExpr::~CastExpr() {
+    delete arg;
+}
+
+// CastExpr *CastExpr::clone() const { return 0; }
+
+void CastExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Cast of:" << std::endl;
+    arg->print(os, indent+2);
+    os << std::endl << std::string(indent, ' ') << "to:" << std::endl;
+    if( results.empty() ) {
+	os << std::string(indent+2, ' ') << "nothing" << std::endl;
+    } else {
+	printAll(results, os, indent+2);
+    }
+    Expression::print( os, indent );
+}
+
+//*** UntypedMemberExpr
+UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) :
+    Expression( _aname ), member(_member), aggregate(_aggregate) {}
+
+UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other )
+    : Expression( other ),   member( other.member ), aggregate( maybeClone( other.aggregate ) )
+{
+}
+
+UntypedMemberExpr::~UntypedMemberExpr() {
+    delete aggregate;
+}
+
+void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Member Expression, with field: " << get_member();
+
+    Expression *agg = get_aggregate();
+    os << std::string(indent, ' ') << "from aggregate: ";
+    if (agg != 0) agg->print(os, indent + 2);
+    Expression::print( os, indent );
+}
+
+
+//*** MemberExpr
+MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
+    Expression( _aname ), member(_member), aggregate(_aggregate)
+{
+    add_result( member->get_type()->clone() );
+    for( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
+	(*i)->set_isLvalue( true );
+    }
+}
+
+MemberExpr::MemberExpr( const MemberExpr &other )
+    : Expression( other ),   member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) )
+{
+}
+
+MemberExpr::~MemberExpr() {
+    delete member;
+    delete aggregate;
+}
+
+void MemberExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Member Expression, with field: " << std::endl;
+
+    assert( member );
+    os << std::string(indent + 2, ' ');
+    member->print( os, indent + 2 );
+    os << std::endl;
+
+    Expression *agg = get_aggregate();
+    os << std::string(indent, ' ') << "from aggregate: " << std::endl;
+    if (agg != 0) agg->print(os, indent + 2);
+    Expression::print( os, indent );
+}
+
+
+//*** UntypedExpr
+UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {}
+
+UntypedExpr::UntypedExpr( const UntypedExpr &other )
+    : Expression( other ), function( maybeClone( other.function ) )
+{
+    cloneAll( other.args, args );
+}
+
+UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :
+    Expression( _aname ), function(_function), args(_args) {}
+
+UntypedExpr::~UntypedExpr() {}
+
+void UntypedExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Applying untyped: " << std::endl;
+    function->print(os, indent + 4);
+    os << "\r" << std::string(indent, ' ') << "...to: " << std::endl;
+    printArgs(os, indent + 4);
+    Expression::print( os, indent );
+}
+
+void UntypedExpr::printArgs(std::ostream &os, int indent ) const {
+    std::list<Expression *>::const_iterator i;
+    for(i = args.begin(); i != args.end(); i++)
+	(*i)->print(os, indent);
+}
+
+//*** NameExpr
+NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) {}
+
+NameExpr::NameExpr( const NameExpr &other )
+    : Expression( other ), name( other.name )
+{
+}
+
+NameExpr::~NameExpr() {}
+
+void NameExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Name: " << get_name() << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** LogicalExpr
+LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
+    Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp)
+{
+    add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
+}
+
+LogicalExpr::LogicalExpr( const LogicalExpr &other )
+    : Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd )
+{
+}
+
+LogicalExpr::~LogicalExpr(){
+    delete arg1;
+    delete arg2;
+}
+
+void LogicalExpr::print( std::ostream &os, int indent )const {
+    os << std::string(indent, ' ') << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
+    arg1->print(os);
+    os << " and ";
+    arg2->print(os);
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** ConditionalExpr
+ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) :
+    Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {}
+
+ConditionalExpr::ConditionalExpr( const ConditionalExpr &other )
+     : Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) )
+ {
+ }
+
+ConditionalExpr::~ConditionalExpr() {
+    delete arg1;
+    delete arg2;
+    delete arg3;
+}
+
+void ConditionalExpr::print( std::ostream &os, int indent ) const {
+    os << std::string(indent, ' ') << "Conditional expression on: " << std::endl;
+    arg1->print( os, indent+2 );
+    os << std::string(indent, ' ') << "First alternative:" << std::endl;
+    arg2->print( os, indent+2 );
+    os << std::string(indent, ' ') << "Second alternative:" << std::endl;
+    arg3->print( os, indent+2 );
+    os << std::endl;
+    Expression::print( os, indent );
+}
+
+//*** UntypedValofExpr
+void UntypedValofExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string(indent, ' ') << "Valof Expression: " << std::endl;
+    if( get_body() != 0 )
+	get_body()->print( os, indent + 2 );
+}
+
+
Index: translator/SynTree/Expression.h
===================================================================
--- translator/SynTree/Expression.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Expression.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,507 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Expression.h,v 1.31 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#ifndef EXPRESSION_H
+#define EXPRESSION_H
+
+#include <map>
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+#include "Constant.h"
+
+
+class Expression
+{
+public:
+    Expression(Expression *_aname = 0 );
+    Expression( const Expression &other );
+    virtual ~Expression();
+
+    std::list<Type *>& get_results() { return results; }
+    void add_result(Type *t);
+
+    TypeSubstitution *get_env() const { return env; }
+    void set_env( TypeSubstitution *newValue ) { env = newValue; }
+    Expression *get_argName() const { return argName; }
+    void set_argName( Expression *name ) { argName = name; }
+
+    virtual Expression *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Expression *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+protected:
+    std::list<Type *> results;
+    TypeSubstitution *env;
+    Expression* argName; // if expression is used as an argument, it can be "designated" by this name
+};
+
+// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration,
+// but subject to decay-to-pointer and type parameter renaming
+struct ParamEntry
+{
+    ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}
+    ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {}
+    ParamEntry( const ParamEntry &other );
+    ~ParamEntry();
+    ParamEntry &operator=( const ParamEntry &other );
+
+    UniqueId decl;
+    Type *actualType;
+    Type *formalType;
+    Expression* expr;
+};
+
+typedef std::map< UniqueId, ParamEntry > InferredParams;
+
+// ApplicationExpr represents the application of a function to a set of parameters.  This is the
+// result of running an UntypedExpr through the expression analyzer.
+class ApplicationExpr : public Expression
+{
+public:
+    ApplicationExpr( Expression *function );
+    ApplicationExpr( const ApplicationExpr &other );
+    virtual ~ApplicationExpr();
+
+    Expression *get_function() const { return function; }
+    void set_function( Expression *newValue ) { function = newValue; }
+    std::list<Expression *>& get_args() { return args; }
+    InferredParams &get_inferParams() { return inferParams; }
+
+    virtual ApplicationExpr *clone() const { return new ApplicationExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *function;
+    std::list<Expression *> args;
+    InferredParams inferParams;
+};
+
+// UntypedExpr represents the application of a function to a set of parameters, but where the
+// particular overload for the function name has not yet been determined.  Most operators are
+// converted into functional form automatically, to permit operator overloading.
+class UntypedExpr : public Expression
+{
+public:
+    UntypedExpr( Expression *function, Expression *_aname = 0 );
+    UntypedExpr( const UntypedExpr &other );
+    UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = 0 );
+    virtual ~UntypedExpr();
+
+    Expression *get_function() const { return function; }
+    void set_function( Expression *newValue ) { function = newValue; }
+
+    void set_args( std::list<Expression *> &listArgs ) { args = listArgs; }
+    std::list<Expression*>::iterator begin_args() { return args.begin(); }
+    std::list<Expression*>::iterator end_args() { return args.end(); }
+    std::list<Expression*>& get_args() { return args; }
+
+    virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    virtual void printArgs(std::ostream &os, int indent = 0) const;
+    
+private:
+    
+    Expression *function;
+    std::list<Expression*> args;
+};
+
+// this class contains a name whose meaning is still not determined
+class NameExpr : public Expression
+{
+public:
+    NameExpr( std::string name, Expression *_aname = 0 );
+    NameExpr( const NameExpr &other );
+    virtual ~NameExpr();
+
+    std::string get_name() const { return name; }
+    void set_name( std::string newValue ) { name = newValue; }
+
+    virtual NameExpr *clone() const { return new NameExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    
+    std::string name;
+};
+
+// The following classes are used to represent expression types that cannot be converted into
+// function-call format.
+
+// AddressExpr represents a address-of expression, e.g. &e
+class AddressExpr : public Expression
+{
+public:
+    AddressExpr( Expression *arg, Expression *_aname = 0 );
+    AddressExpr( const AddressExpr &other );
+    virtual ~AddressExpr();
+
+    Expression *get_arg() const { return arg; }
+    void set_arg(Expression *newValue ) { arg = newValue; }
+
+    virtual AddressExpr *clone() const { return new AddressExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg;
+};
+
+class LabelAddressExpr : public Expression
+{
+public:
+    LabelAddressExpr( Expression *arg );
+    LabelAddressExpr( const AddressExpr &other );
+    virtual ~LabelAddressExpr();
+
+    Expression *get_arg() const { return arg; }
+    void set_arg(Expression *newValue ) { arg = newValue; }
+
+    virtual LabelAddressExpr *clone() const { return new LabelAddressExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg;
+};
+
+// CastExpr represents a type cast expression, e.g. (int)e
+class CastExpr : public Expression
+{
+public:
+    CastExpr( Expression *arg, Expression *_aname = 0 );
+    CastExpr( Expression *arg, Type *toType, Expression *_aname = 0 );
+    CastExpr( const CastExpr &other );
+    virtual ~CastExpr();
+
+    Expression *get_arg() const { return arg; }
+    void set_arg(Expression *newValue ) { arg = newValue; }
+
+    virtual CastExpr *clone() const { return new CastExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg;
+};
+
+// UntypedMemberExpr represents a member selection operation, e.g. q.p
+// before processing by the expression analyzer
+class UntypedMemberExpr : public Expression
+{
+public:
+    UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = 0 );
+    UntypedMemberExpr( const UntypedMemberExpr &other );
+    virtual ~UntypedMemberExpr();
+
+    std::string get_member() const { return member; }
+    void set_member( const std::string &newValue ) { member = newValue; }
+    Expression *get_aggregate() const { return aggregate; }
+    void set_aggregate( Expression *newValue ) { aggregate = newValue; }
+
+    virtual UntypedMemberExpr *clone() const { return new UntypedMemberExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    std::string member;
+    Expression *aggregate;
+};
+
+// MemberExpr represents a member selection operation, e.g. q.p
+// after processing by the expression analyzer
+class MemberExpr : public Expression
+{
+public:
+    MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = 0 );
+    MemberExpr( const MemberExpr &other );
+    virtual ~MemberExpr();
+
+    DeclarationWithType *get_member() const { return member; }
+    void set_member( DeclarationWithType *newValue ) { member = newValue; }
+    Expression *get_aggregate() const { return aggregate; }
+    void set_aggregate( Expression *newValue ) { aggregate = newValue; }
+
+    virtual MemberExpr *clone() const { return new MemberExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    DeclarationWithType *member;
+    Expression *aggregate;
+};
+
+// VariableExpr represents an expression that simply refers to the value of a named variable
+class VariableExpr : public Expression
+{
+public:
+    VariableExpr( DeclarationWithType *var, Expression *_aname = 0 );
+    VariableExpr( const VariableExpr &other );
+    virtual ~VariableExpr();
+
+    DeclarationWithType *get_var() const { return var; }
+    void set_var( DeclarationWithType *newValue ) { var = newValue; }
+
+    virtual VariableExpr *clone() const { return new VariableExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    DeclarationWithType *var;
+};
+
+// ConstantExpr represents an expression that simply refers to the value of a constant 
+class ConstantExpr : public Expression
+{
+public:
+    ConstantExpr( Constant constant, Expression *_aname = 0 );
+    ConstantExpr( const ConstantExpr &other );
+    virtual ~ConstantExpr();
+
+    Constant *get_constant() { return &constant; }
+    void set_constant( const Constant &newValue ) { constant = newValue; }
+
+    virtual ConstantExpr *clone() const { return new ConstantExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Constant constant;
+};
+
+// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4)
+class SizeofExpr : public Expression
+{
+public:
+    SizeofExpr( Expression *expr, Expression *_aname = 0 );
+    SizeofExpr( const SizeofExpr &other );
+    SizeofExpr( Type *type, Expression *_aname = 0 );
+    virtual ~SizeofExpr();
+
+    Expression *get_expr() const { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+    Type *get_type() const { return type; }
+    void set_type( Type *newValue ) { type = newValue; }
+    bool get_isType() const { return isType; }
+    void set_isType( bool newValue ) { isType = newValue; }
+
+    virtual SizeofExpr *clone() const { return new SizeofExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *expr;
+    Type *type;
+    bool isType;
+};
+
+// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
+class AttrExpr : public Expression
+{
+public:
+    AttrExpr(Expression *attr, Expression *expr, Expression *_aname = 0 );
+    AttrExpr( const AttrExpr &other );
+    AttrExpr( Expression *attr, Type *type, Expression *_aname = 0 );
+    virtual ~AttrExpr();
+
+    Expression *get_attr() const { return attr; }
+    void set_attr( Expression *newValue ) { attr = newValue; }
+    Expression *get_expr() const { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+    Type *get_type() const { return type; }
+    void set_type( Type *newValue ) { type = newValue; }
+    bool get_isType() const { return isType; }
+    void set_isType( bool newValue ) { isType = newValue; }
+
+    virtual AttrExpr *clone() const { return new AttrExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *attr;
+    Expression *expr;
+    Type *type;
+    bool isType;
+};
+
+// LogicalExpr represents a short-circuit boolean expression (&& or ||)
+class LogicalExpr : public Expression
+{
+public:
+    LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = 0 );
+    LogicalExpr( const LogicalExpr &other );
+    virtual ~LogicalExpr();
+
+    bool get_isAnd() const { return isAnd; }
+    Expression *get_arg1() { return arg1; }
+    void set_arg1( Expression *newValue ) { arg1 = newValue; }
+    Expression *get_arg2() const { return arg2; }
+    void set_arg2( Expression *newValue ) { arg2 = newValue; }
+
+    virtual LogicalExpr *clone() const { return new LogicalExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg1;
+    Expression *arg2;
+    bool isAnd;
+};
+
+// ConditionalExpr represents the three-argument conditional ( p ? a : b )
+class ConditionalExpr : public Expression
+{
+public:
+    ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = 0 );
+    ConditionalExpr( const ConditionalExpr &other );
+    virtual ~ConditionalExpr();
+
+    Expression *get_arg1() const { return arg1; }
+    void set_arg1( Expression *newValue ) { arg1 = newValue; }
+    Expression *get_arg2() const { return arg2; }
+    void set_arg2( Expression *newValue ) { arg2 = newValue; }
+    Expression *get_arg3() const { return arg3; }
+    void set_arg3( Expression *newValue ) { arg3 = newValue; }
+
+    virtual ConditionalExpr *clone() const { return new ConditionalExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg1;
+    Expression *arg2;
+    Expression *arg3;
+};
+
+// CommaExpr represents the sequence operator ( a, b )
+class CommaExpr : public Expression
+{
+public:
+    CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = 0 );
+    CommaExpr( const CommaExpr &other );
+    virtual ~CommaExpr();
+
+    Expression *get_arg1() const { return arg1; }
+    void set_arg1( Expression *newValue ) { arg1 = newValue; }
+    Expression *get_arg2() const { return arg2; }
+    void set_arg2( Expression *newValue ) { arg2 = newValue; }
+
+    virtual CommaExpr *clone() const { return new CommaExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Expression *arg1;
+    Expression *arg2;
+};
+
+// TupleExpr represents a tuple expression ( [a, b, c] )
+class TupleExpr : public Expression
+{
+public:
+    TupleExpr( Expression *_aname = 0 );
+    TupleExpr( const TupleExpr &other );
+    virtual ~TupleExpr();
+
+    void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
+    std::list<Expression*>& get_exprs() { return exprs; }
+
+    virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    std::list<Expression*> exprs;
+};
+
+// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
+class SolvedTupleExpr : public Expression
+{
+public:
+
+    SolvedTupleExpr( Expression *_aname = 0 ) : Expression( _aname ) {}
+    SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = 0 );
+    SolvedTupleExpr( const SolvedTupleExpr &other );
+    virtual ~SolvedTupleExpr() {}
+
+    std::list<Expression*> &get_exprs() { return exprs; }
+
+    virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+private:
+    std::list<Expression*> exprs;
+};
+
+// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
+class TypeExpr : public Expression
+{
+public:
+    TypeExpr( Type *type );
+    TypeExpr( const TypeExpr &other );
+    virtual ~TypeExpr();
+
+    Type *get_type() const { return type; }
+    void set_type( Type *newValue ) { type = newValue; }
+
+    virtual TypeExpr *clone() const { return new TypeExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Type *type;
+};
+
+// ValofExpr represents a GCC 'lambda expression'
+class UntypedValofExpr : public Expression
+{
+public:
+    UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
+    virtual ~UntypedValofExpr() {}
+
+    Expression *get_value();
+    Statement *get_body() const { return body; }
+
+    virtual UntypedValofExpr *clone() const { return new UntypedValofExpr( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+    
+private:
+    Statement *body;
+};
+
+
+#endif /* #ifndef EXPRESSION_H */
+
+/*
+    Local Variables:
+    mode: c++
+    End:
+*/
Index: translator/SynTree/FunctionDecl.cc
===================================================================
--- translator/SynTree/FunctionDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/FunctionDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,111 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: FunctionDecl.cc,v 1.15 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <cassert>
+
+#include "Declaration.h"
+#include "Statement.h"
+#include "Type.h"
+#include "utility.h"
+
+
+FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type,
+					    CompoundStmt *statements, bool isInline )
+    : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline )
+{
+    // this is a pretty brazen hack to force the function "main" to have C linkage
+    if( name == "main" ) {
+	set_linkage( LinkageSpec::C );
+    }
+}
+
+FunctionDecl::FunctionDecl( const FunctionDecl &other )
+    : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ),
+	isInline( other.isInline )
+{
+}
+
+FunctionDecl::~FunctionDecl()
+{
+    delete type;
+    delete statements;
+}
+
+Type*
+FunctionDecl::get_type() const
+{
+    return type;
+}
+
+void 
+FunctionDecl::set_type(Type *t)
+{
+    type = dynamic_cast< FunctionType* >( t );
+    assert( type );
+}
+
+void
+FunctionDecl::print( std::ostream &os, int indent ) const
+{
+    using std::endl;
+    using std::string;
+    
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( get_linkage() != LinkageSpec::Cforall ) {
+	os << LinkageSpec::toString( get_linkage() ) << " ";
+    }
+    if( isInline ) {
+	os << "inline ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    if( get_type() ) {
+	get_type()->print( os, indent );
+    } else {
+	os << "untyped entity ";
+    }
+    if( !oldIdents.empty() ) {
+	os << string( indent+2, ' ' ) << "with parameter names" << endl;
+	for( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
+	    os << string( indent+4, ' ' ) << *i << endl;
+	}
+    }
+    if( !oldDecls.empty() ) {
+	os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
+	printAll( oldDecls, os, indent+4 );
+    }
+    if( statements ) {
+	os << string( indent+2, ' ' ) << "with body " << endl;
+	statements->print( os, indent+4 );
+    }
+}
+
+void
+FunctionDecl::printShort( std::ostream &os, int indent ) const
+{
+    using std::endl;
+    using std::string;
+    
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( isInline ) {
+	os << "inline ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    if( get_type() ) {
+	get_type()->print( os, indent );
+    } else {
+	os << "untyped entity ";
+    }
+}
+
Index: translator/SynTree/FunctionType.cc
===================================================================
--- translator/SynTree/FunctionType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/FunctionType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: FunctionType.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <algorithm>
+
+#include "Type.h"
+#include "Declaration.h"
+#include "utility.h"
+
+
+FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs )
+    : Type( tq ), isVarArgs( isVarArgs )
+{
+}
+
+FunctionType::FunctionType( const FunctionType &other )
+    : Type( other ), isVarArgs( other.isVarArgs )
+{
+    cloneAll( other.returnVals, returnVals );
+    cloneAll( other.parameters, parameters );
+}
+
+FunctionType::~FunctionType()
+{
+    deleteAll( returnVals );
+    deleteAll( parameters );
+}
+
+void 
+FunctionType::print( std::ostream &os, int indent ) const
+{
+    using std::string;
+    using std::endl;
+
+    Type::print( os, indent );
+    os << "function" << endl;
+    if( !parameters.empty() ) {
+	os << string( indent+2, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+4 );
+	if( isVarArgs ) {
+	    os << string( indent+4, ' ' ) << "and a variable number of other arguments" << endl;
+	}
+    } else if( isVarArgs ) {
+	os << string( indent+4, ' ' ) << "accepting unspecified arguments" << endl;
+    }
+    os << string( indent+2, ' ' ) << "returning ";
+    if( returnVals.empty() ) {
+	os << endl << string( indent+4, ' ' ) << "nothing " << endl;
+    } else {
+	os << endl;
+	printAll( returnVals, os, indent+4 );
+    }
+
+}
+
Index: translator/SynTree/Initializer.cc
===================================================================
--- translator/SynTree/Initializer.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Initializer.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,113 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Initializer.cc,v 1.10 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Initializer.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+Initializer::Initializer( )
+{
+}
+
+Initializer::~Initializer( )
+{
+}
+
+std::string Initializer::designator_name( Expression *des ) {
+    if( NameExpr *n = dynamic_cast<NameExpr *>(des) )
+	return n->get_name();
+    else
+	throw 0;
+}
+
+void 
+Initializer::print( std::ostream &os, int indent )
+{
+}
+
+SingleInit::SingleInit ( Expression *v, std::list< Expression *> &_designators )
+    : value ( v ), designators( _designators )
+{ 
+}
+
+SingleInit::SingleInit ( const SingleInit &other )
+    : value ( other.value )
+{
+    cloneAll(other.designators, designators );
+}
+
+SingleInit::~SingleInit()
+{
+}
+
+SingleInit *SingleInit::clone() const { return new SingleInit( *this); }
+
+void SingleInit::print( std::ostream &os, int indent )
+{
+    os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: ";
+    value->print( os, indent+2 );
+
+    if ( ! designators.empty() )
+	{
+	    os << std::endl << std::string(indent + 2, ' ' ) << "designated by: "  ;
+	    for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ )
+		( *i )->print(os, indent + 4 );
+	}
+}
+
+MemberInit::MemberInit( Expression *_value, std::string _member )
+    : member ( _member ), value ( _value )
+{
+}
+
+MemberInit::~MemberInit()
+{
+}
+
+MemberInit * MemberInit::clone() const
+{
+    return new MemberInit( *this );
+}
+
+void MemberInit::print( std::ostream &os, int indent )
+{
+    os << "Member Initializer";
+    value->print( os, indent+2 );
+}
+
+ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
+    : initializers( _initializers ), designators( _designators )
+{
+}
+
+ListInit::~ListInit()
+{
+}
+
+ListInit *ListInit::clone() const
+{
+    return new ListInit( *this );
+}
+
+void ListInit::print( std::ostream &os, int indent )
+{
+    os << std::endl << std::string(indent, ' ') << "Compound initializer:  "; 
+    if( ! designators.empty() ) {
+	os << std::string(indent + 2, ' ' ) << "designated by: [";
+	for ( std::list < Expression * >::iterator i = designators.begin();
+		    i != designators.end(); i++ ) {
+	    ( *i )->print(os, indent + 4 ); 
+	}
+	
+	os << std::string(indent + 2, ' ' ) << "]";
+    }
+
+    for( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 
+	(*i)->print( os, indent + 2 );
+}
+
Index: translator/SynTree/Initializer.h
===================================================================
--- translator/SynTree/Initializer.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Initializer.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,154 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Initializer.h,v 1.14 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#ifndef INITIALIZER_H
+#define INITIALIZER_H
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+
+#include <cassert>
+
+
+// Initializer: base class for object initializers (provide default values)
+class Initializer
+{
+public:
+    //	Initializer( std::string _name = std::string(""), int _pos = 0 );
+    Initializer( );
+    virtual ~Initializer();
+
+    static std::string designator_name( Expression *designator );
+
+    //	void set_name( std::string newValue ) { name = newValue; }
+    //	std::string get_name() const { return name; }
+
+    //	void set_pos( int newValue ) { pos = newValue; }
+    //	int get_pos() const { return pos; }
+    virtual void set_designators( std::list<Expression *> & ) { assert(false); }
+    virtual std::list<Expression *> &get_designators() {
+	assert(false);
+	std::list<Expression *> *ret = 0; return *ret;	// never reached
+    }
+
+    virtual Initializer *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Initializer *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    //	std::string name;
+    //	int pos;
+};
+
+// SingleInit represents an initializer for a common object (e.g., int x = 4)
+class SingleInit : public Initializer
+{
+public:
+    SingleInit( Expression *value, std::list< Expression *> &designators );
+    SingleInit( const SingleInit &other );
+    virtual ~SingleInit();
+    
+    Expression *get_value() { return value; }
+    void set_value( Expression *newValue ) { value = newValue; }
+
+    void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
+    std::list<Expression *> &get_designators() { return designators; }
+
+    virtual SingleInit *clone() const;
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    //Constant *value;
+    Expression *value;	// has to be a compile-time constant
+    std::list< Expression * > designators;
+};
+
+// MemberInit represents an initializer for a member of an aggregate object
+// (e.g., struct q { int a } x = { a: 4 } )
+class MemberInit : public Initializer
+{
+public:
+    MemberInit( Expression *value, std::string member = std::string("") );
+    virtual ~MemberInit();
+    
+    std::string get_member() { return member; }
+    void set_member( std::string newValue ) { member = newValue; }
+    Expression *get_value() { return value; }
+    void set_value( Expression *newValue ) { value = newValue; }
+
+    virtual MemberInit *clone() const;
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    std::string member;
+    Expression *value;
+};
+
+// ElementInit represents an initializer of an element of an array
+// (e.g., [10] int x = { [7]: 4 }
+class ElementInit : public Initializer
+{
+public:
+    ElementInit( Expression *value );
+    virtual ~ElementInit();
+    
+    int get_index() { return index; }
+    void set_index( int newValue ) { index = newValue; }
+    Expression *get_value() { return value; }
+    void set_value( Expression *newValue ) { value = newValue; }
+
+    virtual ElementInit *clone() const;
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    int index;
+    Expression *value;
+};
+
+// ListInit represents an initializer that is composed recursively of a list of initializers; this
+// is used to initialize an array or aggregate
+class ListInit : public Initializer
+{
+public:
+    ListInit( std::list<Initializer*> &, 
+	    std::list<Expression *> &designators = *(new std::list<Expression *>()) );
+    virtual ~ListInit();
+
+    void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
+    std::list<Expression *> &get_designators() { return designators; }
+    void set_initializers( std::list<Initializer*> &newValue ) { initializers = newValue; }
+    std::list<Initializer*> &get_initializers() { return initializers; }
+
+    std::list<Initializer*>::iterator begin_initializers() { return initializers.begin(); }
+    std::list<Initializer*>::iterator end_initializers() { return initializers.end(); }
+
+    virtual ListInit *clone() const;
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    std::list<Initializer*> initializers;  // order *is* important
+    std::list<Expression *> designators;
+};
+
+
+#endif /* #ifndef INITIALIZER_H */
+
+/*
+    Local Variables:
+    mode: c++
+    End:
+*/
Index: translator/SynTree/Makefile
===================================================================
--- translator/SynTree/Makefile	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Makefile	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,22 @@
+CXX=g++
+CXXFLAGS=-g -Wall #-Wno-unused
+
+SRCS:=Type.cc Constant.cc Expression.cc Statement.cc CodeGenVisitor.cc translate.cc
+OBJECTS:=$(SRCS:.cc=.o)
+DEPS:=$(SRCS:.cc=.d)
+
+# libSynTree.a:  $(OBJECTS)
+# 	ar -rs $@ $(OBJECTS)
+#	$(CXX) $(CXXFLAGS) $(OBJS) -o $@ $(EXTRALIBS)
+
+%.d: %.cc
+	g++ -M $(CXXFLAGS) $< | sed -e '1s/^\(.*\)\.o/\1.d \1.o/' > $@
+
+all: $(OBJECTS)
+
+ifneq ($(MAKECMDGOALS),clean)
+include $(DEPS)
+endif
+
+clean:
+	rm -f cfa $(OBJECTS) $(DEPS) core
Index: translator/SynTree/Mutator.cc
===================================================================
--- translator/SynTree/Mutator.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Mutator.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,539 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Mutator.cc,v 1.30 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <cassert>
+#include "Mutator.h"
+#include "Initializer.h"
+#include "Statement.h"
+#include "Type.h"
+#include "Declaration.h"
+#include "Expression.h"
+#include "Constant.h"
+#include "utility.h"
+
+Mutator::Mutator()
+{
+}
+
+Mutator::~Mutator()
+{
+}
+
+ObjectDecl*
+Mutator::mutate(ObjectDecl *objectDecl)
+{
+    objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
+    objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
+    objectDecl->set_bitfieldWidth( maybeMutate( objectDecl->get_bitfieldWidth(), *this ) );
+    return objectDecl;
+}
+
+DeclarationWithType*
+Mutator::mutate(FunctionDecl *functionDecl)
+{
+    functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
+    mutateAll( functionDecl->get_oldDecls(), *this );
+    functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
+    return functionDecl;
+}
+
+Declaration*
+Mutator::handleAggregateDecl(AggregateDecl *aggregateDecl)
+{
+    mutateAll( aggregateDecl->get_parameters(), *this );
+    mutateAll( aggregateDecl->get_members(), *this );
+    return aggregateDecl;
+}
+
+Declaration* 
+Mutator::mutate(StructDecl *aggregateDecl)
+{
+    handleAggregateDecl( aggregateDecl );
+    return aggregateDecl;
+}
+
+Declaration* 
+Mutator::mutate(UnionDecl *aggregateDecl)
+{
+    handleAggregateDecl( aggregateDecl );
+    return aggregateDecl;
+}
+
+Declaration* 
+Mutator::mutate(EnumDecl *aggregateDecl)
+{
+    handleAggregateDecl( aggregateDecl );
+    return aggregateDecl;
+}
+
+Declaration* 
+Mutator::mutate(ContextDecl *aggregateDecl)
+{
+    handleAggregateDecl( aggregateDecl );
+    return aggregateDecl;
+}
+
+Declaration*
+Mutator::handleNamedTypeDecl(NamedTypeDecl *typeDecl)
+{
+    mutateAll( typeDecl->get_parameters(), *this );
+    mutateAll( typeDecl->get_assertions(), *this );
+    typeDecl->set_base( maybeMutate( typeDecl->get_base(), *this ) );
+    return typeDecl;
+}
+
+TypeDecl* 
+Mutator::mutate(TypeDecl *typeDecl)
+{
+    handleNamedTypeDecl( typeDecl );
+    return typeDecl;
+}
+
+Declaration* 
+Mutator::mutate(TypedefDecl *typeDecl)
+{
+    handleNamedTypeDecl( typeDecl );
+    return typeDecl;
+}
+
+CompoundStmt*
+Mutator::mutate(CompoundStmt *compoundStmt)
+{
+    mutateAll( compoundStmt->get_kids(), *this );
+    return compoundStmt;
+}
+
+Statement*
+Mutator::mutate(ExprStmt *exprStmt)
+{
+    exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
+    return exprStmt;
+}
+
+Statement*
+Mutator::mutate(IfStmt *ifStmt)
+{
+    ifStmt->set_condition(  maybeMutate( ifStmt->get_condition(), *this ) );
+    ifStmt->set_thenPart(  maybeMutate( ifStmt->get_thenPart(), *this ) );
+    ifStmt->set_elsePart(  maybeMutate( ifStmt->get_elsePart(), *this ) );
+    return ifStmt;
+}
+
+Statement*
+Mutator::mutate(WhileStmt *whileStmt)
+{
+    whileStmt->set_condition(  maybeMutate( whileStmt->get_condition(), *this ) );
+    whileStmt->set_body(    maybeMutate( whileStmt->get_body(), *this ) );
+    return whileStmt;
+}
+
+Statement*
+Mutator::mutate(ForStmt *forStmt)
+{
+    forStmt->set_initialization(    maybeMutate( forStmt->get_initialization(), *this ) );
+    forStmt->set_condition(  maybeMutate( forStmt->get_condition(), *this ) );
+    forStmt->set_increment(  maybeMutate( forStmt->get_increment(), *this ) );
+    forStmt->set_body(	maybeMutate( forStmt->get_body(), *this ) );
+    return forStmt;
+}
+
+Statement*
+Mutator::mutate(SwitchStmt *switchStmt)
+{
+    switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
+    mutateAll( switchStmt->get_branches(), *this );
+    return switchStmt;
+}
+
+Statement*
+Mutator::mutate(ChooseStmt *switchStmt)
+{
+    switchStmt->set_condition(	maybeMutate( switchStmt->get_condition(), *this ) );
+    mutateAll( switchStmt->get_branches(), *this );
+    return switchStmt;
+}
+
+Statement*
+Mutator::mutate(FallthruStmt *fallthruStmt)
+{
+    return fallthruStmt;
+}
+
+Statement*
+Mutator::mutate(CaseStmt *caseStmt)
+{
+    caseStmt->set_condition(	maybeMutate( caseStmt->get_condition(), *this ) );
+    mutateAll (caseStmt->get_statements(), *this );
+
+    return caseStmt;
+}
+
+Statement*
+Mutator::mutate(BranchStmt *branchStmt)
+{
+    return branchStmt;
+}
+
+Statement*
+Mutator::mutate(ReturnStmt *returnStmt)
+{
+    returnStmt->set_expr(  maybeMutate( returnStmt->get_expr(), *this ) );
+    return returnStmt;
+}
+
+Statement*
+Mutator::mutate(TryStmt *tryStmt)
+{
+    tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
+    mutateAll( tryStmt->get_catchers(), *this );
+    return tryStmt;
+}
+
+Statement*
+Mutator::mutate(CatchStmt *catchStmt)
+{
+    catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
+    catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
+    return catchStmt;
+}
+
+Statement*
+Mutator::mutate(FinallyStmt *finalStmt)
+{
+    finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
+    return finalStmt;
+}
+
+NullStmt*
+Mutator::mutate(NullStmt *nullStmt)
+{
+    return nullStmt;
+}
+
+Statement*
+Mutator::mutate(DeclStmt *declStmt)
+{
+    declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
+    return declStmt;
+}
+
+Expression*
+Mutator::mutate(ApplicationExpr *applicationExpr)
+{
+    mutateAll( applicationExpr->get_results(), *this );
+    applicationExpr->set_function(  maybeMutate( applicationExpr->get_function(), *this ) );
+    mutateAll( applicationExpr->get_args(), *this );
+    return applicationExpr;
+}
+
+Expression*
+Mutator::mutate(UntypedExpr *untypedExpr)
+{
+    mutateAll( untypedExpr->get_results(), *this );
+    mutateAll( untypedExpr->get_args(), *this );
+    return untypedExpr;
+}
+
+Expression*
+Mutator::mutate(NameExpr *nameExpr)
+{
+    mutateAll( nameExpr->get_results(), *this );
+    return nameExpr;
+}
+
+Expression*
+Mutator::mutate(AddressExpr *addressExpr)
+{
+    mutateAll( addressExpr->get_results(), *this );
+    addressExpr->set_arg(  maybeMutate( addressExpr->get_arg(), *this ) );
+    return addressExpr;
+}
+
+Expression*
+Mutator::mutate(LabelAddressExpr *labelAddressExpr)
+{
+    mutateAll( labelAddressExpr->get_results(), *this );
+    labelAddressExpr->set_arg(	maybeMutate( labelAddressExpr->get_arg(), *this ) );
+    return labelAddressExpr;
+}
+
+Expression*
+Mutator::mutate(CastExpr *castExpr)
+{
+    mutateAll( castExpr->get_results(), *this );
+    castExpr->set_arg(	maybeMutate( castExpr->get_arg(), *this ) );
+    return castExpr;
+}
+
+Expression*
+Mutator::mutate(UntypedMemberExpr *memberExpr)
+{
+    mutateAll( memberExpr->get_results(), *this );
+    memberExpr->set_aggregate(	maybeMutate( memberExpr->get_aggregate(), *this ) );
+    return memberExpr;
+}
+
+Expression*
+Mutator::mutate(MemberExpr *memberExpr)
+{
+    mutateAll( memberExpr->get_results(), *this );
+    memberExpr->set_aggregate(	maybeMutate( memberExpr->get_aggregate(), *this ) );
+    return memberExpr;
+}
+
+Expression*
+Mutator::mutate(VariableExpr *variableExpr)
+{
+    mutateAll( variableExpr->get_results(), *this );
+    return variableExpr;
+}
+
+Expression*
+Mutator::mutate(ConstantExpr *constantExpr)
+{
+    mutateAll( constantExpr->get_results(), *this );
+//  maybeMutate( constantExpr->get_constant(), *this )
+    return constantExpr;
+}
+
+Expression*
+Mutator::mutate(SizeofExpr *sizeofExpr)
+{
+    mutateAll( sizeofExpr->get_results(), *this );
+    if( sizeofExpr->get_isType() ) {
+	sizeofExpr->set_type(	 maybeMutate( sizeofExpr->get_type(), *this ) );
+    } else {
+	sizeofExpr->set_expr(	 maybeMutate( sizeofExpr->get_expr(), *this ) );
+    }
+    return sizeofExpr;
+}
+
+Expression*
+Mutator::mutate(AttrExpr *attrExpr)
+{
+    mutateAll( attrExpr->get_results(), *this );
+    if( attrExpr->get_isType() ) {
+	attrExpr->set_type(	 maybeMutate( attrExpr->get_type(), *this ) );
+    } else {
+	attrExpr->set_expr(	 maybeMutate( attrExpr->get_expr(), *this ) );
+    }
+    return attrExpr;
+}
+
+Expression*
+Mutator::mutate(LogicalExpr *logicalExpr)
+{
+    mutateAll( logicalExpr->get_results(), *this );
+    logicalExpr->set_arg1(  maybeMutate( logicalExpr->get_arg1(), *this ) );
+    logicalExpr->set_arg2(  maybeMutate( logicalExpr->get_arg2(), *this ) );
+    return logicalExpr;
+}
+
+Expression*
+Mutator::mutate(ConditionalExpr *conditionalExpr)
+{
+    mutateAll( conditionalExpr->get_results(), *this );
+    conditionalExpr->set_arg1(	maybeMutate( conditionalExpr->get_arg1(), *this ) );
+    conditionalExpr->set_arg2(	maybeMutate( conditionalExpr->get_arg2(), *this ) );
+    conditionalExpr->set_arg3(	maybeMutate( conditionalExpr->get_arg3(), *this ) );
+    return conditionalExpr;
+}
+
+Expression*
+Mutator::mutate(CommaExpr *commaExpr)
+{
+    mutateAll( commaExpr->get_results(), *this );
+    commaExpr->set_arg1(    maybeMutate( commaExpr->get_arg1(), *this ) );
+    commaExpr->set_arg2(    maybeMutate( commaExpr->get_arg2(), *this ) );
+    return commaExpr;
+}
+
+Expression*
+Mutator::mutate(TupleExpr *tupleExpr)
+{
+    mutateAll( tupleExpr->get_results(), *this );
+    mutateAll( tupleExpr->get_exprs(), *this );
+    return tupleExpr;
+}
+
+Expression*
+Mutator::mutate(SolvedTupleExpr *tupleExpr)
+{
+    mutateAll( tupleExpr->get_results(), *this );
+    mutateAll( tupleExpr->get_exprs(), *this );
+    return tupleExpr;
+}
+
+Expression*
+Mutator::mutate(TypeExpr *typeExpr)
+{
+    mutateAll( typeExpr->get_results(), *this );
+    typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
+    return typeExpr;
+}
+
+Expression*
+Mutator::mutate(UntypedValofExpr *valofExpr)
+{
+    mutateAll( valofExpr->get_results(), *this );
+    return valofExpr;
+}
+
+Type*
+Mutator::mutate(VoidType *voidType)
+{
+    mutateAll( voidType->get_forall(), *this );
+    return voidType;
+}
+
+Type*
+Mutator::mutate(BasicType *basicType)
+{
+    mutateAll( basicType->get_forall(), *this );
+    return basicType;
+}
+
+Type*
+Mutator::mutate(PointerType *pointerType)
+{
+    mutateAll( pointerType->get_forall(), *this );
+    pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
+    return pointerType;
+}
+
+Type*
+Mutator::mutate(ArrayType *arrayType)
+{
+    mutateAll( arrayType->get_forall(), *this );
+    arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
+    arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
+    return arrayType;
+}
+
+Type*
+Mutator::mutate(FunctionType *functionType)
+{
+    mutateAll( functionType->get_forall(), *this );
+    mutateAll( functionType->get_returnVals(), *this );
+    mutateAll( functionType->get_parameters(), *this );
+    return functionType;
+}
+
+Type*
+Mutator::handleReferenceToType(ReferenceToType *aggregateUseType)
+{
+    mutateAll( aggregateUseType->get_forall(), *this );
+    mutateAll( aggregateUseType->get_parameters(), *this );
+    return aggregateUseType;
+}
+
+Type* 
+Mutator::mutate(StructInstType *aggregateUseType)
+{
+    handleReferenceToType( aggregateUseType );
+    return aggregateUseType;
+}
+
+Type* 
+Mutator::mutate(UnionInstType *aggregateUseType)
+{
+    handleReferenceToType( aggregateUseType );
+    return aggregateUseType;
+}
+
+Type* 
+Mutator::mutate(EnumInstType *aggregateUseType)
+{
+    handleReferenceToType( aggregateUseType );
+    return aggregateUseType;
+}
+
+Type* 
+Mutator::mutate(ContextInstType *aggregateUseType)
+{
+    handleReferenceToType( aggregateUseType );
+    mutateAll( aggregateUseType->get_members(), *this );
+    return aggregateUseType;
+}
+
+Type* 
+Mutator::mutate(TypeInstType *aggregateUseType)
+{
+    handleReferenceToType( aggregateUseType );
+    return aggregateUseType;
+}
+
+Type*
+Mutator::mutate(TupleType *tupleType)
+{
+    mutateAll( tupleType->get_forall(), *this );
+    mutateAll( tupleType->get_types(), *this );
+    return tupleType;
+}
+
+Type*
+Mutator::mutate(TypeofType *typeofType)
+{
+    assert( typeofType->get_expr() );
+    typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
+    return typeofType;
+}
+
+Type*
+Mutator::mutate(AttrType *attrType)
+{
+    if( attrType->get_isType() ) {
+	assert( attrType->get_type() );
+	attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
+    } else {
+	assert( attrType->get_expr() );
+	attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
+    }
+    return attrType;
+}
+
+Initializer*
+Mutator::mutate(MemberInit *memberInit)
+{
+    memberInit->set_value( memberInit->get_value()->acceptMutator( *this ) );
+    return memberInit;
+}
+
+Initializer*
+Mutator::mutate(ElementInit *elementInit)
+{
+    elementInit->set_value( elementInit->get_value()->acceptMutator( *this ) );
+    return elementInit;
+}
+
+Initializer*
+Mutator::mutate(SingleInit *singleInit)
+{
+    singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
+    return singleInit;
+}
+
+Initializer*
+Mutator::mutate(ListInit *listInit)
+{
+    mutateAll( listInit->get_designators(), *this );
+    mutateAll( listInit->get_initializers(), *this );
+    return listInit;
+}
+
+Subrange *
+Mutator::mutate(Subrange *subrange)
+{
+    return subrange;
+}
+
+Constant *
+Mutator::mutate(Constant *constant)
+{
+    return constant;
+}
+
Index: translator/SynTree/Mutator.h
===================================================================
--- translator/SynTree/Mutator.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Mutator.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,140 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Mutator.h,v 1.19 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include <cassert>
+
+#include "SynTree.h"
+#include "SemanticError.h"
+
+#ifndef SYNTREE_MUTATOR_H
+#define SYNTREE_MUTATOR_H
+
+
+class Mutator
+{
+protected:
+    Mutator();
+    virtual ~Mutator();
+
+public:
+    virtual ObjectDecl* mutate(ObjectDecl *objectDecl);
+    virtual DeclarationWithType* mutate(FunctionDecl *functionDecl);
+    virtual Declaration* mutate(StructDecl *aggregateDecl);
+    virtual Declaration* mutate(UnionDecl *aggregateDecl);
+    virtual Declaration* mutate(EnumDecl *aggregateDecl);
+    virtual Declaration* mutate(ContextDecl *aggregateDecl);
+    virtual TypeDecl* mutate(TypeDecl *typeDecl);
+    virtual Declaration* mutate(TypedefDecl *typeDecl);
+
+    virtual CompoundStmt* mutate(CompoundStmt *compoundStmt);
+    virtual Statement* mutate(ExprStmt *exprStmt);
+    virtual Statement* mutate(IfStmt *ifStmt);
+    virtual Statement* mutate(WhileStmt *whileStmt);
+    virtual Statement* mutate(ForStmt *forStmt);
+    virtual Statement* mutate(SwitchStmt *switchStmt);
+    virtual Statement* mutate(ChooseStmt *chooseStmt);
+    virtual Statement* mutate(FallthruStmt *fallthruStmt);
+    virtual Statement* mutate(CaseStmt *caseStmt);
+    virtual Statement* mutate(BranchStmt *branchStmt);
+    virtual Statement* mutate(ReturnStmt *returnStmt);
+    virtual Statement* mutate(TryStmt *returnStmt);
+    virtual Statement* mutate(CatchStmt *catchStmt);
+    virtual Statement* mutate(FinallyStmt *catchStmt);
+    virtual NullStmt* mutate(NullStmt *nullStmt);
+    virtual Statement* mutate(DeclStmt *declStmt);
+
+    virtual Expression* mutate(ApplicationExpr *applicationExpr);
+    virtual Expression* mutate(UntypedExpr *untypedExpr);
+    virtual Expression* mutate(NameExpr *nameExpr);
+    virtual Expression* mutate(AddressExpr *castExpr);
+    virtual Expression* mutate(LabelAddressExpr *labAddressExpr);
+    virtual Expression* mutate(CastExpr *castExpr);
+    virtual Expression* mutate(UntypedMemberExpr *memberExpr);
+    virtual Expression* mutate(MemberExpr *memberExpr);
+    virtual Expression* mutate(VariableExpr *variableExpr);
+    virtual Expression* mutate(ConstantExpr *constantExpr); 
+    virtual Expression* mutate(SizeofExpr *sizeofExpr);
+    virtual Expression* mutate(AttrExpr *attrExpr);
+    virtual Expression* mutate(LogicalExpr *logicalExpr);
+    virtual Expression* mutate(ConditionalExpr *conditionalExpr);
+    virtual Expression* mutate(CommaExpr *commaExpr);
+    virtual Expression* mutate(TupleExpr *tupleExpr);
+    virtual Expression* mutate(SolvedTupleExpr *tupleExpr);
+    virtual Expression* mutate(TypeExpr *typeExpr);
+    virtual Expression* mutate(UntypedValofExpr *valofExpr);
+
+    virtual Type* mutate(VoidType *basicType);
+    virtual Type* mutate(BasicType *basicType);
+    virtual Type* mutate(PointerType *pointerType);
+    virtual Type* mutate(ArrayType *arrayType);
+    virtual Type* mutate(FunctionType *functionType);
+    virtual Type* mutate(StructInstType *aggregateUseType);
+    virtual Type* mutate(UnionInstType *aggregateUseType);
+    virtual Type* mutate(EnumInstType *aggregateUseType);
+    virtual Type* mutate(ContextInstType *aggregateUseType);
+    virtual Type* mutate(TypeInstType *aggregateUseType);
+    virtual Type* mutate(TupleType *tupleType);
+    virtual Type* mutate(TypeofType *typeofType);
+    virtual Type* mutate(AttrType *attrType);
+
+    virtual Initializer* mutate(MemberInit *memberInit);
+    virtual Initializer* mutate(ElementInit *elementInit);
+    virtual Initializer* mutate(SingleInit *singleInit);
+    virtual Initializer* mutate(ListInit *listInit);
+
+    virtual Subrange *mutate(Subrange *subrange);
+
+    virtual Constant *mutate(Constant *constant);
+
+private:
+    virtual Declaration* handleAggregateDecl(AggregateDecl *aggregateDecl);
+    virtual Declaration* handleNamedTypeDecl(NamedTypeDecl *typeDecl);
+    virtual Type* handleReferenceToType(ReferenceToType *aggregateUseType);
+};
+
+template< typename TreeType, typename MutatorType >
+inline TreeType *
+maybeMutate( TreeType *tree, MutatorType &mutator )
+{
+    if( tree ) {
+	TreeType *newnode = dynamic_cast< TreeType* >( tree->acceptMutator( mutator ) );
+	assert( newnode );
+	return newnode;
+///	    return tree->acceptMutator( mutator );
+    } else {
+	return 0;
+    }
+}
+
+template< typename Container, typename MutatorType >
+inline void
+mutateAll( Container &container, MutatorType &mutator )
+{
+    SemanticError errors;
+    for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
+	try {
+	    if( *i ) {
+///		    *i = (*i)->acceptMutator( mutator );
+		*i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
+		assert( *i );
+	    }
+	} catch( SemanticError &e ) {
+	    errors.append( e );
+	}
+    }
+    if( !errors.isEmpty() ) {
+	throw errors;
+    }
+}
+
+
+
+#endif /* #ifndef SYNTREE_MUTATOR_H */
+
+// Local Variables: //
+// mode: c++ //
+// End:  //
Index: translator/SynTree/NamedTypeDecl.cc
===================================================================
--- translator/SynTree/NamedTypeDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/NamedTypeDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,74 @@
+#include "Declaration.h"
+#include "Type.h"
+#include "utility.h"
+
+
+NamedTypeDecl::NamedTypeDecl( const std::string &name, StorageClass sc, Type *base )
+    : Parent( name, sc, LinkageSpec::Cforall ), base( base )
+{
+}
+
+NamedTypeDecl::NamedTypeDecl( const TypeDecl &other )
+    : Parent( other ), base( maybeClone( other.base ) )
+{
+    cloneAll( other.parameters, parameters );
+    cloneAll( other.assertions, assertions );
+}
+
+NamedTypeDecl::~NamedTypeDecl()
+{
+    delete base;
+    deleteAll( parameters );
+    deleteAll( assertions );
+}
+
+void 
+NamedTypeDecl::print( std::ostream &os, int indent ) const
+{
+    using namespace std;
+    
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    os << typeString();
+    if( base ) {
+	os << " for ";
+	base->print( os, indent );
+    }
+    if( !parameters.empty() ) {
+	os << endl << string( indent, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+2 );
+    }
+    if( !assertions.empty() ) {
+	os << endl << string( indent, ' ' ) << "with assertions" << endl;
+	printAll( assertions, os, indent+2 );
+    }
+}
+
+void 
+NamedTypeDecl::printShort( std::ostream &os, int indent ) const
+{
+    using namespace std;
+    
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    os << typeString();
+    if( base ) {
+	os << " for ";
+	base->print( os, indent );
+    }
+    if( !parameters.empty() ) {
+	os << endl << string( indent, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+2 );
+    }
+}
+
+std::string TypedefDecl::typeString() const { return "typedef"; }
+    
Index: translator/SynTree/ObjectDecl.cc
===================================================================
--- translator/SynTree/ObjectDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/ObjectDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: ObjectDecl.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
+ *
+ */
+
+#include "Declaration.h"
+#include "Type.h"
+#include "Initializer.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+ObjectDecl::ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init )
+    : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth )
+{
+}
+
+ObjectDecl::ObjectDecl( const ObjectDecl &other )
+    : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) )
+{
+}
+
+ObjectDecl::~ObjectDecl()
+{
+    delete type;
+    delete init;
+    delete bitfieldWidth;
+}
+
+void 
+ObjectDecl::print( std::ostream &os, int indent ) const
+{
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( get_linkage() != LinkageSpec::Cforall ) {
+	os << LinkageSpec::toString( get_linkage() ) << " ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    if( get_type() ) {
+	get_type()->print( os, indent );
+    } else {
+	os << "untyped entity ";
+    }
+    if( init ) {
+	os << "with initializer ";
+	init->print( os, indent );
+    }
+    if( bitfieldWidth ) {
+	os << "with bitfield width ";
+	bitfieldWidth->print( os );
+    }
+}
+
+void 
+ObjectDecl::printShort( std::ostream &os, int indent ) const
+{
+    if( get_name() != "" ) {
+	os << get_name() << ": a ";
+    }
+    if( get_storageClass() != NoStorageClass ) {
+	os << storageClassName[ get_storageClass() ] << ' ';
+    }
+    if( get_type() ) {
+	get_type()->print( os, indent );
+    } else {
+	os << "untyped entity ";
+    }
+    if( bitfieldWidth ) {
+	os << "with bitfield width ";
+	bitfieldWidth->print( os );
+    }
+}
+
Index: translator/SynTree/PointerType.cc
===================================================================
--- translator/SynTree/PointerType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/PointerType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: PointerType.cc,v 1.8 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+PointerType::PointerType( const Type::Qualifiers &tq, Type *base )
+    : Type( tq ), base( base ), dimension( 0 ), isVarLen( false ), isStatic( false )
+{
+    base->set_isLvalue( false );
+}
+
+PointerType::PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic )
+    : Type( tq ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic )
+{
+    base->set_isLvalue( false );
+}
+
+PointerType::PointerType( const PointerType &other )
+    : Type( other ), base( maybeClone( other.base ) ), dimension( maybeClone( other.dimension ) ),
+	isVarLen( other.isVarLen ), isStatic( other.isStatic )
+{
+}
+
+PointerType::~PointerType()
+{
+    delete base;
+    delete dimension;
+}
+
+void
+PointerType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    os << "pointer to ";
+    if( isStatic ) {
+	os << "static ";
+    }
+    if( isVarLen ) {
+	os << "variable length array of ";
+    } else if( dimension ) {
+	os << "array of ";
+	dimension->print( os, indent );
+    }
+    if( base ) {
+	base->print( os, indent );
+    }
+}
+
Index: translator/SynTree/ReferenceToType.cc
===================================================================
--- translator/SynTree/ReferenceToType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/ReferenceToType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,125 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: ReferenceToType.cc,v 1.16 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include <string>
+#include <cassert>
+
+#include "Type.h"
+#include "Declaration.h"
+#include "Expression.h"
+#include "TypeSubstitution.h"
+#include "utility.h"
+
+
+ReferenceToType::ReferenceToType( const Type::Qualifiers &tq, const std::string &name )
+    : Type( tq ), name( name )
+{
+}
+
+ReferenceToType::ReferenceToType( const ReferenceToType &other )
+    : Type( other ), name( other.name )
+{
+    cloneAll( other.parameters, parameters );
+}
+
+ReferenceToType::~ReferenceToType()
+{
+    deleteAll( parameters );
+}
+
+void 
+ReferenceToType::print( std::ostream &os, int indent ) const
+{
+    using std::endl;
+    
+    Type::print( os, indent );
+    os << "instance of " << typeString() << " " << name << " ";
+    if( !parameters.empty() ) {
+	os << endl << std::string( indent, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+2 );
+    }
+}
+
+namespace {
+
+void
+doLookup( const std::list< Declaration* > &members, const std::list< TypeDecl* > &parms, const std::list< Expression* > &args, const std::string &name, std::list< Declaration* > &foundDecls )
+{
+    std::list< Declaration* > found;
+    for( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
+	if( (*i)->get_name() == name ) {
+	    found.push_back( *i );
+	}
+    }
+    applySubstitution( parms.begin(), parms.end(), args.begin(), found.begin(), found.end(), back_inserter( foundDecls ) );
+}
+
+} // namespace
+
+std::string StructInstType::typeString() const { return "struct"; }
+
+void
+StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const
+{
+    assert( baseStruct );
+    doLookup( baseStruct->get_members(), baseStruct->get_parameters(), parameters, name, foundDecls );
+}
+
+std::string UnionInstType::typeString() const { return "union"; }
+
+void
+UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const
+{
+    assert( baseUnion );
+    doLookup( baseUnion->get_members(), baseUnion->get_parameters(), parameters, name, foundDecls );
+}
+
+std::string EnumInstType::typeString() const { return "enum"; }
+
+std::string ContextInstType::typeString() const { return "context"; }
+
+ContextInstType::ContextInstType( const ContextInstType &other )
+    : Parent( other )
+{
+    cloneAll( other.members, members );
+}
+
+ContextInstType::~ContextInstType()
+{
+    deleteAll( members );
+}
+
+TypeInstType::TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType ) : Parent( tq, name )
+{
+    set_baseType( baseType );
+}
+
+TypeInstType::TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype ) : Parent( tq, name ), baseType( 0 ), isFtype( isFtype )
+{
+}
+
+void TypeInstType::set_baseType( TypeDecl *newValue )
+{
+    baseType = newValue;
+    isFtype = newValue->get_kind() == TypeDecl::Ftype;
+}
+
+std::string TypeInstType::typeString() const { return "type"; }
+
+void 
+TypeInstType::print( std::ostream &os, int indent ) const
+{
+    using std::endl;
+    
+    Type::print( os, indent );
+    os << "instance of " << typeString() << " " << get_name() << " (" << ( isFtype ? "" : "not" ) << " a function type) ";
+    if( !parameters.empty() ) {
+	os << endl << std::string( indent, ' ' ) << "with parameters" << endl;
+	printAll( parameters, os, indent+2 );
+    }
+}
+
Index: translator/SynTree/Statement.cc
===================================================================
--- translator/SynTree/Statement.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Statement.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,324 @@
+#include <functional>
+#include <algorithm>
+#include <iostream>
+#include <list>
+#include <cassert>
+
+#include "Statement.h"
+#include "Expression.h"
+#include "Declaration.h"
+#include "Common/SemanticError.h"
+
+using std::string;
+using std::endl;
+
+
+// *** Statement
+Statement::Statement(std::list<Label> _labels):
+    labels(_labels) {}
+
+void Statement::print(std::ostream &, int indent) {}
+
+Statement::~Statement() {}
+
+//*** ExprStmt
+ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ):
+    Statement(_labels), expr(_expr) {}
+
+ExprStmt::~ExprStmt() {}
+
+void ExprStmt::print( std::ostream &os, int indent ) {
+    os << "\r" << string(indent, ' ') << "Expression Statement:" << endl;
+    expr->print(os, indent + 2);
+} 
+
+//*** BranchStmt
+const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
+
+BranchStmt::BranchStmt( std::list<Label> labels, Label _target, Type _type ) 
+    throw (SemanticError) :
+    Statement(labels), target(_target), type(_type)
+{
+    //actually this is a syntactic error signaled by the parser
+    if(type == BranchStmt::Goto && target.size() == 0)
+	throw SemanticError("goto without target");
+}
+
+BranchStmt::BranchStmt( std::list<Label> labels, Expression *_computedTarget, Type _type)
+    throw (SemanticError) :
+    Statement(labels), computedTarget(_computedTarget), type(_type)
+{
+    if(type != BranchStmt::Goto || computedTarget == 0)
+	throw SemanticError("Computed target not valid in branch statement");
+}
+
+void BranchStmt::print( std::ostream &os, int indent ){
+    os << "\r" << string(indent, ' ') << "Branch (" << brType[type] << ")" << endl ;
+}
+
+//*** ReturnStmt
+ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) :
+    Statement( labels ), expr( _expr ), isThrow( throwP ) {}
+
+ReturnStmt::~ReturnStmt() {
+    delete expr;
+}
+
+void ReturnStmt::print( std::ostream &os, int indent ){
+    os << "\r" << std::string(indent, ' ') << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
+    if(expr != 0) expr->print(os);
+    os << endl;
+}
+
+
+// *** IfStmt
+IfStmt::IfStmt( std::list<Label> _labels, Expression *_condition, Statement *_thenPart, Statement *_elsePart ):
+    Statement(_labels), condition(_condition), thenPart(_thenPart), elsePart(_elsePart) {}
+
+IfStmt::~IfStmt() {}
+
+void IfStmt::print( std::ostream &os, int indent ){
+    os << "\r" << string(indent, ' ') << "If on condition: " << endl ;
+    condition->print(os, indent + 4);
+
+    os << string(indent, ' ') << ".... and branches: " << endl;
+
+    thenPart->print(os, indent + 4);
+
+    if(elsePart != 0){
+	elsePart->print(os, indent + 4);
+    }
+}
+
+// *** SwitchStmt
+SwitchStmt::SwitchStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
+    Statement(_labels), condition(_condition), branches(_branches)
+{ }
+
+SwitchStmt::~SwitchStmt() {
+    delete condition;
+    // destroy branches
+}
+
+void SwitchStmt::add_case(CaseStmt *c) {}
+
+void SwitchStmt::print(std::ostream &os, int indent) {
+    os << "\r" << string(indent, ' ') << "Switch on condition: ";
+    condition->print(os);
+    os << endl;
+
+    // branches
+    std::list<Statement *>::iterator i;
+    for(i = branches.begin(); i != branches.end(); i++)
+	(*i)->print(os, indent + 4);
+
+    //for_each(branches.begin(), branches.end(), mem_fun(bind1st(&Statement::print), os));
+}
+
+// *** CaseStmt
+CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition,
+					std::list<Statement *> &_statements, bool deflt )
+    throw (SemanticError) : 
+    Statement(_labels), condition(_condition), stmts(_statements), _isDefault(deflt)
+{
+    if(isDefault() && condition != 0)
+	throw SemanticError("default with conditions");
+}
+
+CaseStmt::~CaseStmt() {
+    delete condition;
+}
+
+void CaseStmt::print(std::ostream &os, int indent) {
+    os << "\r" << string(indent, ' ');
+
+    if(isDefault())
+	os << "Default ";
+    else {
+	os << "Case ";
+	condition->print(os);
+    }
+
+    os << endl;
+
+    std::list<Statement *>::iterator i;
+    for(i = stmts.begin(); i != stmts.end(); i++)
+	(*i)->print(os, indent + 4);
+}
+
+//*** ChooseStmt
+//ChooseStmt::ChooseStmt( std::list<Label> labels, Expression *condition, Statement *body ) {}
+ChooseStmt::ChooseStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
+    Statement(_labels), condition(_condition), branches(_branches)
+{ }
+
+ChooseStmt::~ChooseStmt() {
+    delete condition;
+}
+
+void ChooseStmt::add_case(CaseStmt *c) {}
+
+void ChooseStmt::print(std::ostream &os, int indent) {
+    os << "\r" << string(indent, ' ') << "Choose on condition: ";
+    condition->print(os);
+    os << endl;
+
+    // branches
+    std::list<Statement *>::iterator i;
+    for(i = branches.begin(); i != branches.end(); i++)
+	(*i)->print(os, indent + 4);
+
+    //for_each(branches.begin(), branches.end(), mem_fun(bind1st(&Statement::print), os));
+}
+
+//*** FallthruStmt
+void FallthruStmt::print(std::ostream &os, int indent) {
+    os << "\r" << string(indent, ' ') << "Fall-through statement" << endl;
+}
+
+//*** WhileStmt
+WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition_,
+					    Statement *body_, bool isDoWhile_ ):
+    Statement( labels ), condition(condition_), body(body_), isDoWhile(isDoWhile_)
+{}
+
+WhileStmt::~WhileStmt(){
+    delete body;
+}
+
+void WhileStmt::print( std::ostream &os, int indent ){
+    os << "\r" << string(indent, ' ') << "While on condition: " << endl ;
+    condition->print(os, indent + 4);
+
+    os << string(indent, ' ') << ".... with body: " << endl;
+
+    if(body != 0) body->print(os, indent + 4);
+}
+
+//*** ForStmt
+ForStmt::ForStmt( std::list<Label> labels, Statement *initialization_,
+				    Expression *condition_, Expression *increment_, Statement *body_ ):
+    Statement( labels ), initialization( initialization_ ),
+    condition( condition_ ), increment( increment_ ), body( body_ )
+{ }
+
+
+ForStmt::~ForStmt() {
+    delete initialization;
+    delete condition;
+    delete increment;
+    delete body;
+}
+
+void ForStmt::print( std::ostream &os, int indent ){
+    os << "\r" << string(indent, ' ') << "For Statement" << endl ;
+
+    os << "\r" << string(indent + 2, ' ') << "initialization: \n"; 
+    if (initialization != 0)
+	initialization->print(os, indent + 4);
+
+    os << "\n\r" << string(indent + 2, ' ') << "condition: \n"; 
+    if (condition != 0)
+	condition->print(os, indent + 4);
+
+    os << "\n\r" << string(indent + 2, ' ') << "increment: \n"; 
+    if (increment != 0)
+	increment->print(os, indent + 4);
+
+    os << "\n\r" << string(indent + 2, ' ') << "statement block: \n"; 
+    if(body != 0)
+	body->print(os, indent + 4);
+
+    os << endl;
+}
+
+//*** TryStmt
+TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
+    Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock )
+{ }
+
+TryStmt::TryStmt( const TryStmt &other) : Statement( other.labels ) {
+    block = other.block;
+    std::copy( other.handlers.begin(), other.handlers.end(), back_inserter(handlers) );
+    finallyBlock = other.finallyBlock;
+}
+
+TryStmt::~TryStmt(){
+    delete block;
+}
+
+void TryStmt::print( std::ostream &os, int indent ) {
+    os << "\r" << string(indent, ' ') << "Try Statement" << endl;
+    os << string(indent + 2, ' ') << "with block: " << endl;
+    block->print(os, indent + 4);
+
+    // handlers
+    os << string(indent + 2, ' ') << "and handlers: " << endl;
+    std::list<Statement *>::iterator i;
+    for(i = handlers.begin(); i != handlers.end(); i++)
+	(*i)->print(os, indent + 4);
+
+    // finally block
+    if ( finallyBlock != 0 ) {
+	os << string(indent + 2, ' ') << "Finally block: " << endl;
+	finallyBlock->print(os, indent + 4 );
+    }
+}
+
+//*** CatchStmt
+CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
+    Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest )
+{ }
+
+CatchStmt::~CatchStmt(){
+    delete decl;
+    delete body;
+}
+
+void CatchStmt::print( std::ostream &os, int indent ) {
+    os << "\r" << string(indent, ' ') << "Catch Statement" << endl;
+
+    os << "\r" << string(indent, ' ') << "... catching" << endl;
+    if( decl ) {
+	decl->printShort( os, indent + 4 );
+	os << endl;
+    } else if ( catchRest )
+	os << "\r" << string(indent + 4 , ' ') << "the rest" << endl;
+    else
+	os << "\r" << string(indent + 4 , ' ') << ">>> Error:  this catch clause must have a declaration <<<" << endl;
+}
+
+
+//*** FinallyStmt
+FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *_block ) :
+    Statement( labels ), block( _block )
+{
+    assert( labels.empty() ); // finally statement cannot be labeled
+}
+
+FinallyStmt::~FinallyStmt(){
+    delete block;
+}
+
+void FinallyStmt::print( std::ostream &os, int indent ) {
+    os << "\r" << string(indent, ' ') << "Finally Statement" << endl;
+    os << string(indent + 2, ' ') << "with block: " << endl;
+    block->print(os, indent + 4);
+}
+
+//*** NullStmt
+NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
+NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
+NullStmt::~NullStmt() {}
+
+void NullStmt::print( std::ostream &os, int indent ) {
+    os << "\r" << string(indent, ' ') << "Null Statement" << endl ;
+}
+
+
+
+/*
+Local Variables:
+compile-command: "cd ..; gmake"
+End:
+*/
Index: translator/SynTree/Statement.h
===================================================================
--- translator/SynTree/Statement.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Statement.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,394 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Statement.h,v 1.18 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#ifndef STATEMENT_H
+#define STATEMENT_H
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+#include "Common/SemanticError.h"
+
+
+class Statement
+{
+public:
+    Statement( std::list<Label> labels );
+    virtual ~Statement();
+
+    std::list<Label> & get_labels() { return labels; }
+
+    virtual Statement *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Statement *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+protected:
+    std::list<Label> labels;
+};
+
+class CompoundStmt : public Statement
+{
+public:
+    CompoundStmt( std::list<Label> labels );
+    CompoundStmt( const CompoundStmt &other );
+    virtual ~CompoundStmt();
+
+    std::list<Statement*>& get_kids() { return kids; }
+
+    virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    std::list<Statement*> kids;
+};
+
+class ExprStmt : public Statement
+{
+public:
+    ExprStmt( std::list<Label> labels, Expression *expr );
+    virtual ~ExprStmt();
+
+    Expression *get_expr() { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+
+    virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression *expr;
+};
+
+class IfStmt : public Statement
+{
+public:
+    IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
+    virtual ~IfStmt();
+
+    Expression *get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+    Statement *get_thenPart() { return thenPart; }
+    void set_thenPart( Statement *newValue ) { thenPart = newValue; }
+    Statement *get_elsePart() { return elsePart; }
+    void set_elsePart( Statement *newValue ) { elsePart = newValue; }
+    
+    virtual IfStmt *clone() const { return new IfStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression *condition;
+    Statement *thenPart;
+    Statement *elsePart;
+};
+
+class SwitchStmt : public Statement
+{
+public:
+    SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
+    virtual ~SwitchStmt();
+
+    Expression *get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+
+    std::list<Statement *>& get_branches() { return branches; }
+    void add_case( CaseStmt * );
+
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+    virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression * condition;
+    std::list<Statement *> branches; // should be list of CaseStmt
+};
+
+class ChooseStmt : public Statement
+{
+public:
+    ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
+    virtual ~ChooseStmt();
+
+    Expression *get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+
+    std::list<Statement *>& get_branches() { return branches; }
+    void add_case( CaseStmt * );
+    
+
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+    virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression *condition;
+    std::list<Statement *> branches; // should be list of CaseStmt
+};
+
+class FallthruStmt : public Statement {
+public:
+    FallthruStmt( std::list<Label> labels ) : Statement( labels ) { }
+
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+    virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+};
+
+class CaseStmt : public Statement
+{
+public:
+    CaseStmt( std::list<Label> labels, Expression *conditions, 
+	    std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
+    virtual ~CaseStmt();
+
+    bool isDefault() { return _isDefault; }
+    void set_default(bool b) { _isDefault = b; }
+
+    Expression * &get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+
+    std::list<Statement *> &get_statements() { return stmts; }
+    void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
+    
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+    virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+
+private:
+    Expression * condition;
+    std::list<Statement *> stmts;
+    bool _isDefault;
+};
+
+class WhileStmt : public Statement
+{
+public:
+    WhileStmt( std::list<Label> labels, Expression *condition,
+				    Statement *body, bool isDoWhile = false );
+    virtual ~WhileStmt();
+
+    Expression *get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+    Statement *get_body() { return body; }
+    void set_body( Statement *newValue ) { body = newValue; }
+    bool get_isDoWhile() { return isDoWhile; }
+    void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
+    
+    virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression *condition;
+    Statement *body;
+    bool isDoWhile;
+};
+
+class ForStmt : public Statement
+{
+public:
+    ForStmt( std::list<Label> labels, Statement *initialization = 0,
+	 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
+    virtual ~ForStmt();
+
+    Statement *get_initialization() { return initialization; }
+    void set_initialization( Statement *newValue ) { initialization = newValue; }
+    Expression *get_condition() { return condition; }
+    void set_condition( Expression *newValue ) { condition = newValue; }
+    Expression *get_increment() { return increment; }
+    void set_increment( Expression *newValue ) { increment = newValue; }
+    Statement *get_body() { return body; }
+    void set_body( Statement *newValue ) { body = newValue; }
+    
+    virtual ForStmt *clone() const { return new ForStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Statement *initialization;
+    Expression *condition;
+    Expression *increment;
+    Statement *body;
+};
+
+class BranchStmt : public Statement
+{
+public:
+
+    enum Type { Goto = 0 , Break, Continue };
+
+    BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
+    BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
+    virtual ~BranchStmt() {}
+
+    Label get_target() { return target; }
+    void set_target( Label newValue ) { target = newValue; }
+    
+    Expression *get_computedTarget() { return computedTarget; }
+    void set_target( Expression * newValue ) { computedTarget = newValue; }
+
+    Type get_type() { return type; }
+    const char *get_typename() { return brType[ type ]; }
+
+    virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    static const char *brType[];
+    Label target;
+    Expression *computedTarget;
+    Type type;
+};
+
+class ReturnStmt : public Statement
+{
+public:
+    ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
+    virtual ~ReturnStmt();
+
+    Expression *get_expr() { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+    
+    virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Expression *expr;
+    bool isThrow;
+};
+
+
+class NullStmt : public CompoundStmt
+{
+public:
+    NullStmt();
+    NullStmt( std::list<Label> labels );
+    virtual ~NullStmt();
+
+    virtual NullStmt *clone() const { return new NullStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+};
+
+class TryStmt : public Statement
+{ 
+public:
+    TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
+    TryStmt( const TryStmt &other );
+    virtual ~TryStmt();
+
+    CompoundStmt *get_block() const { return block; }
+    void set_block( CompoundStmt *newValue ) { block = newValue; }
+    std::list<Statement *>& get_catchers() { return handlers; }
+
+    FinallyStmt *get_finally() const { return finallyBlock; }
+    void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
+
+    virtual TryStmt *clone() const { return new TryStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    CompoundStmt *block;
+    std::list<Statement *> handlers;
+    FinallyStmt *finallyBlock;
+}; 
+
+class CatchStmt : public Statement
+{
+public:
+    CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
+    virtual ~CatchStmt();
+
+    Declaration *get_decl() { return decl; }
+    void set_decl( Declaration *newValue ) { decl = newValue; }
+
+    Statement *get_body() { return body; }
+    void set_body( Statement *newValue ) { body = newValue; }
+    
+    virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Declaration *decl;
+    Statement *body;
+    bool catchRest;
+};
+
+class FinallyStmt : public Statement
+{ 
+public:
+    FinallyStmt( std::list<Label> labels, CompoundStmt *block );
+    virtual ~FinallyStmt();
+
+    CompoundStmt *get_block() const { return block; }
+    void set_block( CompoundStmt *newValue ) { block = newValue; }
+    
+    virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    CompoundStmt *block;
+}; 
+
+
+// represents a declaration that occurs as part of a compound statement
+class DeclStmt : public Statement
+{
+public:
+    DeclStmt( std::list<Label> labels, Declaration *decl );
+    DeclStmt( const DeclStmt &other );
+    virtual ~DeclStmt();
+
+    Declaration *get_decl() { return decl; }
+    void set_decl( Declaration *newValue ) { decl = newValue; }
+
+    virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 );
+    
+private:
+    Declaration *decl;
+};
+
+
+
+#endif /* #ifndef STATEMENT_H */
+
+/*
+    Local Variables:
+    mode: c++
+    End:
+*/
Index: translator/SynTree/SynTree.h
===================================================================
--- translator/SynTree/SynTree.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/SynTree.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,107 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: SynTree.h,v 1.22 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ * Forward declarations for syntax tree classes, so that they can be mutually
+ * interdependent
+ */
+
+#ifndef SYNTREE_H
+#define SYNTREE_H
+
+#include <string>
+#include <list>
+#include <map>
+#include <iostream>
+
+
+class Declaration;
+class DeclarationWithType;
+class ObjectDecl;
+class FunctionDecl;
+class AggregateDecl;
+class StructDecl;
+class UnionDecl;
+class EnumDecl;
+class ContextDecl;
+class NamedTypeDecl;
+class TypeDecl;
+class FtypeDecl;
+class DtypeDecl;
+class TypedefDecl;
+
+class Statement;
+class CompoundStmt;
+class ExprStmt;
+class IfStmt;
+class WhileStmt;
+class ForStmt;
+class SwitchStmt;
+class ChooseStmt;
+class FallthruStmt;
+class CaseStmt;
+class BranchStmt;
+class ReturnStmt;
+class TryStmt;
+class CatchStmt;
+class FinallyStmt;
+class NullStmt;
+class DeclStmt;
+class NullStmt;
+
+class Expression;
+class ApplicationExpr;
+class UntypedExpr;
+class NameExpr;
+class AddressExpr;
+class LabelAddressExpr;
+class CastExpr;
+class MemberExpr;
+class UntypedMemberExpr;
+class VariableExpr;
+class ConstantExpr;
+class SizeofExpr;
+class AttrExpr;
+class LogicalExpr;
+class ConditionalExpr;
+class CommaExpr;
+class TupleExpr;
+class SolvedTupleExpr;
+class TypeExpr;
+class UntypedValofExpr;
+
+class Type;
+class VoidType;
+class BasicType;
+class PointerType;
+class ArrayType;
+class FunctionType;
+class ReferenceToType;
+class StructInstType;
+class UnionInstType;
+class EnumInstType;
+class ContextInstType;
+class TypeInstType;
+class TupleType;
+class TypeofType;
+class AttrType;
+
+class Initializer;
+class MemberInit;
+class ElementInit;
+class SingleInit;
+class ListInit;
+
+class Subrange;
+
+//template <class T>	// emulate a union with templates?
+class Constant;
+
+typedef std::string Label;
+typedef unsigned int UniqueId;
+
+class TypeSubstitution;
+
+
+#endif /* #ifndef SYNTREE_H */
Index: translator/SynTree/TupleExpr.cc
===================================================================
--- translator/SynTree/TupleExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TupleExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TupleExpr.cc,v 1.11 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "Expression.h"
+#include "utility.h"
+
+
+TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname )
+{
+}
+
+TupleExpr::TupleExpr( const TupleExpr &other )
+    : Expression( other )
+{
+    cloneAll( other.exprs, exprs );
+}
+
+TupleExpr::~TupleExpr()
+{
+    deleteAll( exprs );
+}
+
+void 
+TupleExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
+    printAll( exprs, os, indent+2 );
+    Expression::print( os, indent );
+}
+
+SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname )
+    :  Expression( _aname )
+{
+    std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
+}
+
+SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other )
+    : Expression( other )
+{
+    cloneAll( other.exprs, exprs );
+}
+
+void
+SolvedTupleExpr::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl;
+    printAll( exprs, os, indent+2 );
+    Expression::print( os, indent );
+}
+
Index: translator/SynTree/TupleType.cc
===================================================================
--- translator/SynTree/TupleType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TupleType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TupleType.cc,v 1.6 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "utility.h"
+
+
+TupleType::TupleType( const Type::Qualifiers &tq )
+    : Type( tq )
+{
+}
+
+TupleType::TupleType( const TupleType& other )
+    : Type( other )
+{
+    cloneAll( other.types, types );
+}
+
+TupleType::~TupleType()
+{
+    deleteAll( types );
+}
+
+void 
+TupleType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    os << "tuple of types" << std::endl;
+    printAll( types, os, indent+2 );
+}
+
Index: translator/SynTree/Type.cc
===================================================================
--- translator/SynTree/Type.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Type.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Type.cc,v 1.6 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Type.h"
+#include "Declaration.h"
+#include "utility.h"
+
+
+Type::Type( const Qualifiers &tq )
+    : tq( tq )
+{
+}
+
+Type::Type( const Type &other )
+    : tq( other.tq )
+{
+    cloneAll( other.forall, forall );
+}
+
+Type::~Type()
+{
+    deleteAll( forall );
+}
+
+void
+Type::print( std::ostream &os, int indent ) const
+{
+    if( !forall.empty() ) {
+	os << "forall" << std::endl;
+	printAll( forall, os, indent + 4 );
+	os << std::string( indent+2, ' ' );
+    }
+    if( tq.isConst ) {
+	os << "const ";
+    }
+    if( tq.isVolatile ) {
+	os << "volatile ";
+    }
+    if( tq.isRestrict ) {
+	os << "restrict ";
+    }
+    if( tq.isLvalue ) {
+	os << "lvalue ";
+    }
+}
+
Index: translator/SynTree/Type.h
===================================================================
--- translator/SynTree/Type.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Type.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,495 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Type.h,v 1.30 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#ifndef TYPE_H
+#define TYPE_H
+
+#include "SynTree.h"
+#include "Visitor.h"
+#include "Mutator.h"
+
+
+class Type
+{
+public:
+    struct Qualifiers
+    {  
+	Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ) {}
+	Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ) {}
+	
+	Qualifiers &operator+=( const Qualifiers &other);
+	Qualifiers &operator-=( const Qualifiers &other);
+	Qualifiers operator+( const Type::Qualifiers &other );
+	bool operator==( const Qualifiers &other);
+	bool operator!=( const Qualifiers &other);
+	bool operator<=( const Qualifiers &other );
+	bool operator>=( const Qualifiers &other );
+	bool operator<( const Qualifiers &other );
+	bool operator>( const Qualifiers &other );
+	
+	bool isConst;
+	bool isVolatile;
+	bool isRestrict;
+	bool isLvalue;
+    };	
+
+    Type( const Qualifiers &tq );
+    Type( const Type &other );
+    virtual ~Type();
+
+    Qualifiers &get_qualifiers() { return tq; }
+    bool get_isConst() { return tq.isConst; }
+    bool get_isVolatile() { return tq.isVolatile; }
+    bool get_isRestrict() { return tq.isRestrict; }
+    bool get_isLvalue() { return tq.isLvalue; }
+    void set_isConst( bool newValue ) { tq.isConst = newValue; }
+    void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; }
+    void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; }
+    void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
+    std::list<TypeDecl*>& get_forall() { return forall; }
+
+    virtual Type *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Type *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    Qualifiers tq;
+    std::list<TypeDecl*> forall;
+};
+
+class VoidType : public Type
+{
+public:
+    VoidType( const Type::Qualifiers &tq );
+
+    virtual VoidType *clone() const { return new VoidType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+};
+
+class BasicType : public Type
+{
+public:
+    enum Kind
+	{  
+	    Bool,
+	    Char,
+	    SignedChar,
+	    UnsignedChar,
+	    ShortSignedInt,
+	    ShortUnsignedInt,
+	    SignedInt,
+	    UnsignedInt,
+	    LongSignedInt,
+	    LongUnsignedInt,
+	    LongLongSignedInt,
+	    LongLongUnsignedInt,
+	    Float,
+	    Double,
+	    LongDouble,
+	    FloatComplex,
+	    DoubleComplex,
+	    LongDoubleComplex,
+	    FloatImaginary,
+	    DoubleImaginary,
+	    LongDoubleImaginary,
+	    NUMBER_OF_BASIC_TYPES
+	};  
+
+    BasicType( const Type::Qualifiers &tq, Kind bt );
+
+    Kind get_kind() { return kind; }
+    void set_kind( Kind newValue ) { kind = newValue; }
+
+    virtual BasicType *clone() const { return new BasicType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+    bool isInteger() const;
+
+private:
+    Kind kind;
+};
+
+class PointerType : public Type
+{
+public:
+    PointerType( const Type::Qualifiers &tq, Type *base );
+    PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
+    PointerType( const PointerType& );
+    virtual ~PointerType();
+
+    Type *get_base() { return base; }
+    void set_base( Type *newValue ) { base = newValue; }
+    Expression *get_dimension() { return dimension; }
+    void set_dimension( Expression *newValue ) { dimension = newValue; }
+    bool get_isVarLen() { return isVarLen; }
+    void set_isVarLen( bool newValue ) { isVarLen = newValue; }
+    bool get_isStatic() { return isStatic; }
+    void set_isStatic( bool newValue ) { isStatic = newValue; }
+
+    virtual PointerType *clone() const { return new PointerType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    Type *base;
+    
+    // in C99, pointer types can be qualified in many ways
+    // e.g., int f( int a[ static 3 ] )
+    Expression *dimension;
+    bool isVarLen;
+    bool isStatic;
+};
+
+class ArrayType : public Type
+{
+public:
+    ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
+    ArrayType( const ArrayType& );
+    virtual ~ArrayType();
+
+    Type *get_base() { return base; }
+    void set_base( Type *newValue ) { base = newValue; }
+    Expression *get_dimension() { return dimension; }
+    void set_dimension( Expression *newValue ) { dimension = newValue; }
+    bool get_isVarLen() { return isVarLen; }
+    void set_isVarLen( bool newValue ) { isVarLen = newValue; }
+    bool get_isStatic() { return isStatic; }
+    void set_isStatic( bool newValue ) { isStatic = newValue; }
+
+    virtual ArrayType *clone() const { return new ArrayType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    Type *base;
+    Expression *dimension;
+    bool isVarLen;
+    bool isStatic;
+};
+
+class FunctionType : public Type
+{
+public:
+    FunctionType( const Type::Qualifiers &tq, bool isVarArgs );
+    FunctionType( const FunctionType& );
+    virtual ~FunctionType();
+
+    std::list<DeclarationWithType*>& get_returnVals() { return returnVals; }
+    std::list<DeclarationWithType*>& get_parameters() { return parameters; }
+    bool get_isVarArgs() { return isVarArgs; }
+    void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
+
+    virtual FunctionType *clone() const { return new FunctionType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    std::list<DeclarationWithType*> returnVals;
+    std::list<DeclarationWithType*> parameters;
+
+    // does the function accept a variable number of arguments following the arguments
+    // specified in the parameters list.    This could be because of
+    // - an ellipsis in a prototype declaration
+    // - an unprototyped declaration
+    bool isVarArgs;
+};
+
+class ReferenceToType : public Type
+{
+public:
+    ReferenceToType( const Type::Qualifiers &tq, const std::string &name );
+    ReferenceToType( const ReferenceToType &other );
+    virtual ~ReferenceToType();
+
+    std::string get_name() const { return name; }
+    void set_name( std::string newValue ) { name = newValue; }
+    std::list< Expression* >& get_parameters() { return parameters; }
+    
+    virtual ReferenceToType *clone() const = 0;
+    virtual void accept( Visitor &v ) = 0;
+    virtual Type *acceptMutator( Mutator &m ) = 0;
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+protected:
+    virtual std::string typeString() const = 0;
+    std::list< Expression* > parameters;
+    
+private:
+    std::string name;
+    
+};
+
+class StructInstType : public ReferenceToType
+{
+    typedef ReferenceToType Parent;
+    
+public:
+    StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
+    StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
+
+    StructDecl *get_baseStruct() const { return baseStruct; }
+    void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
+    
+    // a utility function
+    void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
+
+    virtual StructInstType *clone() const { return new StructInstType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+    
+    // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
+    // where the structure used in this type is actually defined
+    StructDecl *baseStruct;
+};
+
+class UnionInstType : public ReferenceToType
+{
+    typedef ReferenceToType Parent;
+    
+public:
+    UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {}
+    UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {}
+
+    UnionDecl *get_baseUnion() const { return baseUnion; }
+    void set_baseUnion( UnionDecl *newValue ) { baseUnion = newValue; }
+    
+    // a utility function
+    void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
+
+    virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+    
+    // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
+    // where the union used in this type is actually defined
+    UnionDecl *baseUnion;
+};
+
+class EnumInstType : public ReferenceToType
+{
+    typedef ReferenceToType Parent;
+    
+public:
+    EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
+    EnumInstType( const EnumInstType &other ) : Parent( other ) {}
+
+    virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+};
+
+class ContextInstType : public ReferenceToType
+{
+    typedef ReferenceToType Parent;
+    
+public:
+    ContextInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
+    ContextInstType( const ContextInstType &other );
+    ~ContextInstType();
+
+    std::list< Declaration* >& get_members() { return members; }
+
+    virtual ContextInstType *clone() const { return new ContextInstType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+
+private:
+    virtual std::string typeString() const;
+    
+    // this member is filled in by the validate pass, which instantiates the members of the correponding
+    // aggregate with the actual type parameters specified for this use of the context
+    std::list< Declaration* > members;
+};
+
+class TypeInstType : public ReferenceToType
+{
+    typedef ReferenceToType Parent;
+    
+public:
+    TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
+    TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
+    TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {}
+
+    TypeDecl *get_baseType() const { return baseType; }
+    void set_baseType( TypeDecl *newValue );
+    bool get_isFtype() const { return isFtype; }
+    void set_isFtype( bool newValue ) { isFtype = newValue; }
+    
+    virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    virtual std::string typeString() const;
+    
+    // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
+    // where the type used here is actually defined
+    TypeDecl *baseType;
+    bool isFtype;
+};
+
+class TupleType : public Type
+{
+public:
+    TupleType( const Type::Qualifiers &tq );
+    TupleType( const TupleType& );
+    virtual ~TupleType();
+
+    std::list<Type*>& get_types() { return types; }
+
+    virtual TupleType *clone() const { return new TupleType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    std::list<Type*> types;
+};
+
+class TypeofType : public Type
+{
+public:
+    TypeofType( const Type::Qualifiers &tq, Expression *expr );
+    TypeofType( const TypeofType& );
+    virtual ~TypeofType();
+
+    Expression *get_expr() const { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+
+    virtual TypeofType *clone() const { return new TypeofType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    Expression *expr;
+};
+
+class AttrType : public Type
+{
+public:
+    AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr );
+    AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type );
+    AttrType( const AttrType& );
+    virtual ~AttrType();
+
+    std::string get_name() const { return name; }
+    void set_name( const std::string &newValue ) { name = newValue; }
+    Expression *get_expr() const { return expr; }
+    void set_expr( Expression *newValue ) { expr = newValue; }
+    Type *get_type() const { return type; }
+    void set_type( Type *newValue ) { type = newValue; }
+    bool get_isType() const { return isType; }
+    void set_isType( bool newValue ) { isType = newValue; }
+
+    virtual AttrType *clone() const { return new AttrType( *this ); }
+    virtual void accept( Visitor &v ) { v.visit( this ); }
+    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
+    virtual void print( std::ostream &os, int indent = 0 ) const;
+
+private:
+    std::string name;
+    Expression *expr;
+    Type *type;
+    bool isType;
+};
+
+inline Type::Qualifiers &
+Type::Qualifiers::operator+=( const Type::Qualifiers &other )
+{
+    isConst |= other.isConst;
+    isVolatile |= other.isVolatile;
+    isRestrict |= other.isRestrict;
+    isLvalue |= other.isLvalue;
+    return *this;
+}
+
+inline Type::Qualifiers &
+Type::Qualifiers::operator-=( const Type::Qualifiers &other )
+{
+    if( other.isConst ) isConst = 0;
+    if( other.isVolatile ) isVolatile = 0;
+    if( other.isRestrict ) isRestrict = 0;
+    return *this;
+}
+
+inline Type::Qualifiers
+Type::Qualifiers::operator+( const Type::Qualifiers &other )
+{
+    Qualifiers q = other;
+    q += *this;
+    return q;
+}
+
+inline bool 
+Type::Qualifiers::operator==( const Qualifiers &other)
+{
+    return isConst == other.isConst
+	&& isVolatile == other.isVolatile
+	&& isRestrict == other.isRestrict;
+///	    && isLvalue == other.isLvalue;
+}
+
+inline bool 
+Type::Qualifiers::operator!=( const Qualifiers &other)
+{
+    return isConst != other.isConst
+	|| isVolatile != other.isVolatile
+	|| isRestrict != other.isRestrict;
+///	    && isLvalue == other.isLvalue;
+}
+
+inline bool 
+Type::Qualifiers::operator<=( const Type::Qualifiers &other )
+{
+    return isConst <= other.isConst
+	&& isVolatile <= other.isVolatile
+	&& isRestrict <= other.isRestrict;
+///	    && isLvalue >= other.isLvalue;
+}
+
+inline bool 
+Type::Qualifiers::operator>=( const Type::Qualifiers &other )
+{
+    return isConst >= other.isConst
+	&& isVolatile >= other.isVolatile
+	&& isRestrict >= other.isRestrict;
+///	    && isLvalue <= other.isLvalue;
+}
+
+inline bool 
+Type::Qualifiers::operator<( const Type::Qualifiers &other )
+{
+    return operator!=( other ) && operator<=( other );
+}
+
+inline bool 
+Type::Qualifiers::operator>( const Type::Qualifiers &other )
+{
+    return operator!=( other ) && operator>=( other );
+}
+
+
+#endif /* #ifndef TYPE_H */
Index: translator/SynTree/TypeDecl.cc
===================================================================
--- translator/SynTree/TypeDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TypeDecl.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,22 @@
+#include "Declaration.h"
+#include "Type.h"
+#include "utility.h"
+
+
+TypeDecl::TypeDecl( const std::string &name, StorageClass sc, Type *type, Kind kind )
+    : Parent( name, sc, type ), kind( kind )
+{
+}
+
+TypeDecl::TypeDecl( const TypeDecl &other )
+    : Parent( other ), kind( other.kind )
+{
+}
+
+std::string
+TypeDecl::typeString() const
+{
+    static const char *kindNames[] = { "type", "incomplete type", "function type" };
+    return kindNames[ kind ];
+}
+
Index: translator/SynTree/TypeExpr.cc
===================================================================
--- translator/SynTree/TypeExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TypeExpr.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TypeExpr.cc,v 1.4 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "Expression.h"
+#include "Type.h"
+#include "utility.h"
+
+
+TypeExpr::TypeExpr( Type *type )
+    : type( type )
+{
+}
+
+TypeExpr::TypeExpr( const TypeExpr &other )
+    : type( maybeClone( other.type ) )
+{
+}
+
+TypeExpr::~TypeExpr()
+{
+    delete type;
+}
+
+void 
+TypeExpr::print( std::ostream &os, int indent ) const
+{
+    if( type ) type->print( os, indent );
+    Expression::print( os, indent );
+}
+
Index: translator/SynTree/TypeSubstitution.cc
===================================================================
--- translator/SynTree/TypeSubstitution.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TypeSubstitution.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,232 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TypeSubstitution.cc,v 1.9 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "TypeSubstitution.h"
+
+
+TypeSubstitution::TypeSubstitution()
+{
+}
+
+TypeSubstitution::TypeSubstitution( const TypeSubstitution &other )
+{
+    initialize( other, *this );
+}
+
+TypeSubstitution::~TypeSubstitution()
+{
+    for( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {
+	delete( i->second );
+    }
+    for( VarEnvType::iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {
+	delete( i->second );
+    }
+}
+
+TypeSubstitution &
+TypeSubstitution::operator=( const TypeSubstitution &other )
+{
+    if( this == &other ) return *this;
+    initialize( other, *this );
+    return *this;
+}
+
+void 
+TypeSubstitution::initialize( const TypeSubstitution &src, TypeSubstitution &dest )
+{
+    dest.typeEnv.clear();
+    dest.varEnv.clear();
+    dest.add( src );
+}
+
+void 
+TypeSubstitution::add( const TypeSubstitution &other )
+{
+    for( TypeEnvType::const_iterator i = other.typeEnv.begin(); i != other.typeEnv.end(); ++i ) {
+	typeEnv[ i->first ] = i->second->clone();
+    }
+    for( VarEnvType::const_iterator i = other.varEnv.begin(); i != other.varEnv.end(); ++i ) {
+	varEnv[ i->first ] = i->second->clone();
+    }
+}
+
+void 
+TypeSubstitution::add( std::string formalType, Type *actualType )
+{
+    TypeEnvType::iterator i = typeEnv.find( formalType );
+    if( i != typeEnv.end() ) {
+	delete i->second;
+    }
+    typeEnv[ formalType ] = actualType->clone();
+}
+
+void 
+TypeSubstitution::remove( std::string formalType )
+{
+    TypeEnvType::iterator i = typeEnv.find( formalType );
+    if( i != typeEnv.end() ) {
+	delete i->second;
+	typeEnv.erase( formalType );
+    }
+}
+
+Type *
+TypeSubstitution::lookup( std::string formalType ) const
+{
+    TypeEnvType::const_iterator i = typeEnv.find( formalType );
+    if( i == typeEnv.end() ) {
+	return 0;
+    } else {
+	return i->second;
+    }
+}
+
+bool 
+TypeSubstitution::empty() const
+{
+    return typeEnv.empty() && varEnv.empty();
+}
+
+void
+TypeSubstitution::normalize()
+{
+    do {
+	subCount = 0;
+	freeOnly = true;
+	for( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {
+	    i->second = i->second->acceptMutator( *this );
+	}
+    } while( subCount );
+}
+
+Type* 
+TypeSubstitution::mutate(TypeInstType *inst)
+{
+    BoundVarsType::const_iterator bound = boundVars.find( inst->get_name() );
+    if( bound != boundVars.end() ) return inst;
+    
+    TypeEnvType::const_iterator i = typeEnv.find( inst->get_name() );
+    if( i == typeEnv.end() ) {
+	return inst;
+    } else {
+///	    std::cout << "found " << inst->get_name() << ", replacing with ";
+///	    i->second->print( std::cout );
+///	    std::cout << std::endl;
+	subCount++;
+	Type *newtype = i->second->clone();
+	newtype->get_qualifiers() += inst->get_qualifiers();
+	delete inst;
+	return newtype;
+    }
+}
+
+Expression* 
+TypeSubstitution::mutate(NameExpr *nameExpr)
+{
+    VarEnvType::const_iterator i = varEnv.find( nameExpr->get_name() );
+    if( i == varEnv.end() ) {
+	return nameExpr;
+    } else {
+	subCount++;
+	delete nameExpr;
+	return i->second->clone();
+    }
+}
+
+template< typename TypeClass >
+Type *
+TypeSubstitution::handleType( TypeClass *type )
+{
+    BoundVarsType oldBoundVars( boundVars );
+    if( freeOnly ) {
+	for( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
+	    boundVars.insert( (*tyvar)->get_name() );
+	}
+    }
+    Type *ret = Mutator::mutate( type );
+    boundVars = oldBoundVars;
+    return ret;
+}
+
+Type* 
+TypeSubstitution::mutate(VoidType *basicType)
+{
+    return handleType( basicType );
+}
+
+Type* 
+TypeSubstitution::mutate(BasicType *basicType)
+{
+    return handleType( basicType );
+}
+
+Type* 
+TypeSubstitution::mutate(PointerType *pointerType)
+{
+    return handleType( pointerType );
+}
+
+Type* 
+TypeSubstitution::mutate(ArrayType *arrayType)
+{
+    return handleType( arrayType );
+}
+
+Type* 
+TypeSubstitution::mutate(FunctionType *functionType)
+{
+    return handleType( functionType );
+}
+
+Type* 
+TypeSubstitution::mutate(StructInstType *aggregateUseType)
+{
+    return handleType( aggregateUseType );
+}
+
+Type* 
+TypeSubstitution::mutate(UnionInstType *aggregateUseType)
+{
+    return handleType( aggregateUseType );
+}
+
+Type* 
+TypeSubstitution::mutate(EnumInstType *aggregateUseType)
+{
+    return handleType( aggregateUseType );
+}
+
+Type* 
+TypeSubstitution::mutate(ContextInstType *aggregateUseType)
+{
+    return handleType( aggregateUseType );
+}
+
+Type* 
+TypeSubstitution::mutate(TupleType *tupleType)
+{
+    return handleType( tupleType );
+}
+
+void 
+TypeSubstitution::print( std::ostream &os, int indent ) const
+{
+    os << std::string( indent, ' ' ) << "Types:" << std::endl;
+    for( TypeEnvType::const_iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {
+	os << std::string( indent+2, ' ' ) << i->first << " -> ";
+	i->second->print( os, indent+4 );
+	os << std::endl;
+    }
+    os << std::string( indent, ' ' ) << "Non-types:" << std::endl;
+    for( VarEnvType::const_iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {
+	os << std::string( indent+2, ' ' ) << i->first << " -> ";
+	i->second->print( os, indent+4 );
+	os << std::endl;
+    }
+}
+
Index: translator/SynTree/TypeSubstitution.h
===================================================================
--- translator/SynTree/TypeSubstitution.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TypeSubstitution.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,180 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TypeSubstitution.h,v 1.9 2005/08/29 20:59:26 rcbilson Exp $
+ *
+ */
+
+#ifndef SYNTREE_TYPESUBSTITUTION_H
+#define SYNTREE_TYPESUBSTITUTION_H
+
+#include <map>
+#include <set>
+#include <cassert>
+
+#include "SynTree/Mutator.h"
+#include "SynTree/Declaration.h"
+#include "SynTree/Expression.h"
+
+
+class TypeSubstitution : public Mutator
+{
+    typedef Mutator Parent;
+    
+public:
+    TypeSubstitution();
+    template< typename FormalIterator, typename ActualIterator >
+    TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );
+    TypeSubstitution( const TypeSubstitution &other );
+    virtual ~TypeSubstitution();
+    
+    TypeSubstitution &operator=( const TypeSubstitution &other );
+    
+    template< typename SynTreeClass > int apply( SynTreeClass *&input );
+    template< typename SynTreeClass > int applyFree( SynTreeClass *&input );
+    
+    void add( std::string formalType, Type *actualType );
+    void add( const TypeSubstitution &other );
+    void remove( std::string formalType );
+    Type *lookup( std::string formalType ) const;
+    bool empty() const;
+    
+    template< typename FormalIterator, typename ActualIterator >
+    void add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );
+    
+    template< typename TypeInstListIterator >
+    void extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result );
+    
+    void normalize();
+
+    void print( std::ostream &os, int indent = 0 ) const;
+    TypeSubstitution *clone() const { return new TypeSubstitution( *this ); }
+    
+private:
+    virtual Type* mutate(TypeInstType *aggregateUseType);
+    virtual Expression* mutate(NameExpr *nameExpr);
+    
+    template< typename TypeClass > Type *handleType( TypeClass *type );
+    
+    virtual Type* mutate(VoidType *basicType);
+    virtual Type* mutate(BasicType *basicType);
+    virtual Type* mutate(PointerType *pointerType);
+    virtual Type* mutate(ArrayType *arrayType);
+    virtual Type* mutate(FunctionType *functionType);
+    virtual Type* mutate(StructInstType *aggregateUseType);
+    virtual Type* mutate(UnionInstType *aggregateUseType);
+    virtual Type* mutate(EnumInstType *aggregateUseType);
+    virtual Type* mutate(ContextInstType *aggregateUseType);
+    virtual Type* mutate(TupleType *tupleType);
+    
+    // TODO: worry about traversing into a forall-qualified function type or type decl with assertions
+    
+    void initialize( const TypeSubstitution &src, TypeSubstitution &dest );
+
+    typedef std::map< std::string, Type* > TypeEnvType;
+    typedef std::map< std::string, Expression* > VarEnvType;
+    typedef std::set< std::string > BoundVarsType;
+    TypeEnvType typeEnv;
+    VarEnvType varEnv;
+    BoundVarsType boundVars;
+    int subCount;
+    bool freeOnly;
+};
+
+template< typename FormalIterator, typename ActualIterator >
+void 
+TypeSubstitution::add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin )
+{
+    // FormalIterator points to a TypeDecl
+    // ActualIterator points to a Type
+    FormalIterator formalIt = formalBegin;
+    ActualIterator actualIt = actualBegin;
+    for( ; formalIt != formalEnd; ++formalIt, ++actualIt ) {
+	if( TypeDecl *formal = dynamic_cast< TypeDecl* >( *formalIt ) ) {
+	    if( TypeExpr *actual = dynamic_cast< TypeExpr* >( *actualIt ) ) {
+		if( formal->get_name() != "" ) {
+		    TypeEnvType::iterator i = typeEnv.find( formal->get_name() );
+		    if( i != typeEnv.end() ) {
+			delete i->second;
+		    }
+		    typeEnv[ formal->get_name() ] = actual->get_type()->clone();
+		}
+	    } else {
+		throw SemanticError( "Attempt to provide non-type parameter for type parameter", formal );
+	    }
+	} else {
+	    // TODO: type check the formal and actual parameters
+	    if( (*formalIt)->get_name() != "" ) {
+		varEnv[ (*formalIt)->get_name() ] = (*actualIt)->clone();
+	    }
+	}
+    }
+}
+
+template< typename FormalIterator, typename ActualIterator >
+TypeSubstitution::TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin )
+{
+    add( formalBegin, formalEnd, actualBegin );
+}
+
+template< typename SynTreeClass >
+int
+TypeSubstitution::apply( SynTreeClass *&input )
+{
+    assert( input );
+    subCount = 0;
+    freeOnly = false;
+    input = dynamic_cast< SynTreeClass *>( input->acceptMutator( *this ) );
+    assert( input );
+///	std::cout << "substitution result is: ";
+///	newType->print( std::cout );
+///	std::cout << std::endl;
+    return subCount;
+}
+    
+template< typename SynTreeClass >
+int
+TypeSubstitution::applyFree( SynTreeClass *&input )
+{
+    assert( input );
+    subCount = 0;
+    freeOnly = true;
+    input = dynamic_cast< SynTreeClass *>( input->acceptMutator( *this ) );
+    assert( input );
+///	std::cout << "substitution result is: ";
+///	newType->print( std::cout );
+///	std::cout << std::endl;
+    return subCount;
+}
+    
+template< typename TypeInstListIterator >
+void
+TypeSubstitution::extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result )
+{
+    while( begin != end ) {
+	TypeEnvType::iterator cur = typeEnv.find( (*begin++)->get_name() );
+	if( cur != typeEnv.end() ) {
+	    result.typeEnv[ cur->first ] = cur->second;
+	    typeEnv.erase( cur );
+	}
+    }
+}
+
+// helper function
+template< typename FormalIterator, typename ActualIterator, typename MemberIterator, typename OutputIterator >
+void
+applySubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actual, MemberIterator memberBegin, MemberIterator memberEnd, OutputIterator out )
+{
+    // Instantiate each member of the context given the actual parameters specified, and store the
+    // instantiations for use by the indexer
+
+    TypeSubstitution sub = TypeSubstitution( formalBegin, formalEnd, actual );
+    for( std::list< Declaration* >::iterator i = memberBegin; i != memberEnd; ++i ) {
+	Declaration *newdecl = (*i)->clone();
+	sub.apply( newdecl );
+	*out++ = newdecl;
+    }
+}
+
+
+#endif /* #ifndef SYNTREE_TYPESUBSTITUTION_H */
Index: translator/SynTree/TypeofType.cc
===================================================================
--- translator/SynTree/TypeofType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/TypeofType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: TypeofType.cc,v 1.3 2005/08/29 20:59:27 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+#include "Expression.h"
+#include "utility.h"
+
+
+TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr )
+    : Type( tq ), expr( expr )
+{
+}
+
+TypeofType::TypeofType( const TypeofType &other )
+    : Type( other ), expr( maybeClone( other.expr ) )
+{
+}
+
+TypeofType::~TypeofType()
+{
+    delete expr;
+}
+
+void 
+TypeofType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    os << "type-of expression ";
+    if( expr ) {
+	expr->print( os, indent );
+    }
+}
+
Index: translator/SynTree/Visitor.cc
===================================================================
--- translator/SynTree/Visitor.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Visitor.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,473 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Visitor.cc,v 1.30 2005/08/29 20:59:27 rcbilson Exp $
+ *
+ */
+
+#include <cassert>
+#include "Visitor.h"
+#include "Initializer.h"
+#include "Statement.h"
+#include "Type.h"
+#include "Declaration.h"
+#include "Expression.h"
+#include "Constant.h"
+
+
+Visitor::Visitor()
+{
+}
+
+Visitor::~Visitor()
+{
+}
+
+void
+Visitor::visit(ObjectDecl *objectDecl)
+{
+    maybeAccept( objectDecl->get_type(), *this );
+    maybeAccept( objectDecl->get_init(), *this );
+    maybeAccept( objectDecl->get_bitfieldWidth(), *this );
+}
+
+void
+Visitor::visit(FunctionDecl *functionDecl)
+{
+    maybeAccept( functionDecl->get_functionType(), *this );
+    acceptAll( functionDecl->get_oldDecls(), *this );
+    maybeAccept( functionDecl->get_statements(), *this );
+}
+
+void
+Visitor::visit(AggregateDecl *aggregateDecl)
+{
+    acceptAll( aggregateDecl->get_parameters(), *this );
+    acceptAll( aggregateDecl->get_members(), *this );
+}
+
+void 
+Visitor::visit(StructDecl *aggregateDecl)
+{
+    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
+}
+
+void 
+Visitor::visit(UnionDecl *aggregateDecl)
+{
+    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
+}
+
+void 
+Visitor::visit(EnumDecl *aggregateDecl)
+{
+    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
+}
+
+void 
+Visitor::visit(ContextDecl *aggregateDecl)
+{
+    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
+}
+
+void
+Visitor::visit(NamedTypeDecl *typeDecl)
+{
+    acceptAll( typeDecl->get_parameters(), *this );
+    acceptAll( typeDecl->get_assertions(), *this );
+    maybeAccept( typeDecl->get_base(), *this );
+}
+
+void 
+Visitor::visit(TypeDecl *typeDecl)
+{
+    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
+}
+
+void 
+Visitor::visit(TypedefDecl *typeDecl)
+{
+    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
+}
+
+void
+Visitor::visit(CompoundStmt *compoundStmt)
+{
+    acceptAll( compoundStmt->get_kids(), *this );
+}
+
+void
+Visitor::visit(ExprStmt *exprStmt)
+{
+    maybeAccept( exprStmt->get_expr(), *this );
+}
+
+void
+Visitor::visit(IfStmt *ifStmt)
+{
+    maybeAccept( ifStmt->get_condition(), *this );
+    maybeAccept( ifStmt->get_thenPart(), *this );
+    maybeAccept( ifStmt->get_elsePart(), *this );
+}
+
+void
+Visitor::visit(WhileStmt *whileStmt)
+{
+    maybeAccept( whileStmt->get_condition(), *this );
+    maybeAccept( whileStmt->get_body(), *this );
+}
+
+void
+Visitor::visit(ForStmt *forStmt)
+{
+    // ForStmt still needs to be fixed
+    maybeAccept( forStmt->get_initialization(), *this );
+    maybeAccept( forStmt->get_condition(), *this );
+    maybeAccept( forStmt->get_increment(), *this );
+    maybeAccept( forStmt->get_body(), *this );
+}
+
+void
+Visitor::visit(SwitchStmt *switchStmt)
+{
+    maybeAccept( switchStmt->get_condition(), *this );
+    acceptAll( switchStmt->get_branches(), *this );
+}
+
+void
+Visitor::visit(ChooseStmt *switchStmt)
+{
+    maybeAccept( switchStmt->get_condition(), *this );
+    acceptAll( switchStmt->get_branches(), *this );
+}
+
+void
+Visitor::visit(FallthruStmt *fallthruStmt){}
+
+void
+Visitor::visit(CaseStmt *caseStmt)
+{
+    maybeAccept( caseStmt->get_condition(), *this );
+    acceptAll( caseStmt->get_statements(), *this );
+}
+
+void
+Visitor::visit(BranchStmt *branchStmt)
+{
+}
+
+void
+Visitor::visit(ReturnStmt *returnStmt)
+{
+    maybeAccept( returnStmt->get_expr(), *this );
+}
+
+void
+Visitor::visit(TryStmt *tryStmt)
+{
+    maybeAccept( tryStmt->get_block(), *this );
+    acceptAll( tryStmt->get_catchers(), *this );
+}
+
+void
+Visitor::visit(CatchStmt *catchStmt)
+{
+    maybeAccept( catchStmt->get_decl(), *this );
+    maybeAccept( catchStmt->get_body(), *this );
+}
+
+void
+Visitor::visit(FinallyStmt *finalStmt)
+{
+    maybeAccept( finalStmt->get_block(), *this );
+}
+
+void
+Visitor::visit(NullStmt *nullStmt)
+{
+}
+
+void
+Visitor::visit(DeclStmt *declStmt)
+{
+    maybeAccept( declStmt->get_decl(), *this );
+}
+
+void
+Visitor::visit(ApplicationExpr *applicationExpr)
+{
+    acceptAll( applicationExpr->get_results(), *this );
+    maybeAccept( applicationExpr->get_function(), *this );
+    acceptAll( applicationExpr->get_args(), *this );
+}
+
+void
+Visitor::visit(UntypedExpr *untypedExpr)
+{
+    acceptAll( untypedExpr->get_results(), *this );
+    acceptAll( untypedExpr->get_args(), *this );
+}
+
+void
+Visitor::visit(NameExpr *nameExpr)
+{
+    acceptAll( nameExpr->get_results(), *this );
+}
+
+void
+Visitor::visit(AddressExpr *addressExpr)
+{
+    acceptAll( addressExpr->get_results(), *this );
+    maybeAccept( addressExpr->get_arg(), *this );
+}
+
+void
+Visitor::visit(LabelAddressExpr *labAddressExpr)
+{
+    acceptAll( labAddressExpr->get_results(), *this );
+    maybeAccept( labAddressExpr->get_arg(), *this );
+}
+
+void
+Visitor::visit(CastExpr *castExpr)
+{
+    acceptAll( castExpr->get_results(), *this );
+    maybeAccept( castExpr->get_arg(), *this );
+}
+
+void
+Visitor::visit(UntypedMemberExpr *memberExpr)
+{
+    acceptAll( memberExpr->get_results(), *this );
+    maybeAccept( memberExpr->get_aggregate(), *this );
+}
+
+void
+Visitor::visit(MemberExpr *memberExpr)
+{
+    acceptAll( memberExpr->get_results(), *this );
+    maybeAccept( memberExpr->get_aggregate(), *this );
+}
+
+void
+Visitor::visit(VariableExpr *variableExpr)
+{
+    acceptAll( variableExpr->get_results(), *this );
+}
+
+void
+Visitor::visit(ConstantExpr *constantExpr)
+{
+    acceptAll( constantExpr->get_results(), *this );
+    maybeAccept( constantExpr->get_constant(), *this );
+}
+
+void
+Visitor::visit(SizeofExpr *sizeofExpr)
+{
+    acceptAll( sizeofExpr->get_results(), *this );
+    if( sizeofExpr->get_isType() ) {
+	maybeAccept( sizeofExpr->get_type(), *this );
+    } else {
+	maybeAccept( sizeofExpr->get_expr(), *this );
+    }
+}
+
+void
+Visitor::visit(AttrExpr *attrExpr)
+{
+    acceptAll( attrExpr->get_results(), *this );
+    if( attrExpr->get_isType() ) {
+	maybeAccept( attrExpr->get_type(), *this );
+    } else {
+	maybeAccept( attrExpr->get_expr(), *this );
+    }
+}
+
+void
+Visitor::visit(LogicalExpr *logicalExpr)
+{
+    acceptAll( logicalExpr->get_results(), *this );
+    maybeAccept( logicalExpr->get_arg1(), *this );
+    maybeAccept( logicalExpr->get_arg2(), *this );
+}
+
+void
+Visitor::visit(ConditionalExpr *conditionalExpr)
+{
+    acceptAll( conditionalExpr->get_results(), *this );
+    maybeAccept( conditionalExpr->get_arg1(), *this );
+    maybeAccept( conditionalExpr->get_arg2(), *this );
+    maybeAccept( conditionalExpr->get_arg3(), *this );
+}
+
+void
+Visitor::visit(CommaExpr *commaExpr)
+{
+    acceptAll( commaExpr->get_results(), *this );
+    maybeAccept( commaExpr->get_arg1(), *this );
+    maybeAccept( commaExpr->get_arg2(), *this );
+}
+
+void
+Visitor::visit(TupleExpr *tupleExpr)
+{
+    acceptAll( tupleExpr->get_results(), *this );
+    acceptAll( tupleExpr->get_exprs(), *this );
+}
+
+void
+Visitor::visit(SolvedTupleExpr *tupleExpr)
+{
+    acceptAll( tupleExpr->get_results(), *this );
+    acceptAll( tupleExpr->get_exprs(), *this );
+}
+
+void
+Visitor::visit(TypeExpr *typeExpr)
+{
+    acceptAll( typeExpr->get_results(), *this );
+    maybeAccept( typeExpr->get_type(), *this );
+}
+
+void
+Visitor::visit(UntypedValofExpr *valofExpr)
+{
+    acceptAll( valofExpr->get_results(), *this );
+    maybeAccept( valofExpr->get_body(), *this );
+}
+
+void
+Visitor::visit(VoidType *voidType)
+{
+    acceptAll( voidType->get_forall(), *this );
+}
+
+void
+Visitor::visit(BasicType *basicType)
+{
+    acceptAll( basicType->get_forall(), *this );
+}
+
+void
+Visitor::visit(PointerType *pointerType)
+{
+    acceptAll( pointerType->get_forall(), *this );
+    maybeAccept( pointerType->get_base(), *this );
+}
+
+void
+Visitor::visit(ArrayType *arrayType)
+{
+    acceptAll( arrayType->get_forall(), *this );
+    maybeAccept( arrayType->get_dimension(), *this );
+    maybeAccept( arrayType->get_base(), *this );
+}
+
+void
+Visitor::visit(FunctionType *functionType)
+{
+    acceptAll( functionType->get_forall(), *this );
+    acceptAll( functionType->get_returnVals(), *this );
+    acceptAll( functionType->get_parameters(), *this );
+}
+
+void
+Visitor::visit(ReferenceToType *aggregateUseType)
+{
+    acceptAll( aggregateUseType->get_forall(), *this );
+    acceptAll( aggregateUseType->get_parameters(), *this );
+}
+
+void 
+Visitor::visit(StructInstType *aggregateUseType)
+{
+    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
+}
+
+void 
+Visitor::visit(UnionInstType *aggregateUseType)
+{
+    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
+}
+
+void 
+Visitor::visit(EnumInstType *aggregateUseType)
+{
+    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
+}
+
+void 
+Visitor::visit(ContextInstType *aggregateUseType)
+{
+    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
+    acceptAll( aggregateUseType->get_members(), *this );
+}
+
+void 
+Visitor::visit(TypeInstType *aggregateUseType)
+{
+    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
+}
+
+void
+Visitor::visit(TupleType *tupleType)
+{
+    acceptAll( tupleType->get_forall(), *this );
+    acceptAll( tupleType->get_types(), *this );
+}
+
+void
+Visitor::visit(TypeofType *typeofType)
+{
+    assert( typeofType->get_expr() );
+    typeofType->get_expr()->accept( *this );
+}
+
+void
+Visitor::visit(AttrType *attrType)
+{
+    if( attrType->get_isType() ) {
+	assert( attrType->get_type() );
+	attrType->get_type()->accept( *this );
+    } else {
+	assert( attrType->get_expr() );
+	attrType->get_expr()->accept( *this );
+    }
+}
+
+void
+Visitor::visit(MemberInit *memberInit)
+{
+    memberInit->get_value()->accept( *this );
+}
+
+void
+Visitor::visit(ElementInit *elementInit)
+{
+    elementInit->get_value()->accept( *this );
+}
+
+void
+Visitor::visit(SingleInit *singleInit)
+{
+    singleInit->get_value()->accept( *this );
+}
+
+void
+Visitor::visit(ListInit *listInit)
+{
+    acceptAll( listInit->get_designators(), *this );
+    acceptAll( listInit->get_initializers(), *this );
+}
+
+void
+Visitor::visit(Subrange *subrange)
+{
+}
+
+void
+Visitor::visit(Constant *constant)
+{
+}
+
Index: translator/SynTree/Visitor.h
===================================================================
--- translator/SynTree/Visitor.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/Visitor.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,162 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: Visitor.h,v 1.23 2005/08/29 20:59:27 rcbilson Exp $
+ *
+ */
+
+#ifndef VISITOR_H
+#define VISITOR_H
+
+#include "SynTree.h"
+#include "SemanticError.h"
+#include "CompilerError.h"
+
+
+class Visitor
+{
+protected:
+    Visitor();
+    virtual ~Visitor();
+
+public:
+    virtual void visit(ObjectDecl *objectDecl);
+    virtual void visit(FunctionDecl *functionDecl);
+    virtual void visit(StructDecl *aggregateDecl);
+    virtual void visit(UnionDecl *aggregateDecl);
+    virtual void visit(EnumDecl *aggregateDecl);
+    virtual void visit(ContextDecl *aggregateDecl);
+    virtual void visit(TypeDecl *typeDecl);
+    virtual void visit(TypedefDecl *typeDecl);
+
+    virtual void visit(CompoundStmt *compoundStmt);
+    virtual void visit(ExprStmt *exprStmt);
+    virtual void visit(IfStmt *ifStmt);
+    virtual void visit(WhileStmt *whileStmt);
+    virtual void visit(ForStmt *forStmt);
+    virtual void visit(SwitchStmt *switchStmt);
+    virtual void visit(ChooseStmt *switchStmt);
+    virtual void visit(FallthruStmt *switchStmt);
+    virtual void visit(CaseStmt *caseStmt);
+    virtual void visit(BranchStmt *branchStmt);
+    virtual void visit(ReturnStmt *returnStmt);
+    virtual void visit(TryStmt *tryStmt);
+    virtual void visit(CatchStmt *catchStmt);
+    virtual void visit(FinallyStmt *finallyStmt);
+    virtual void visit(NullStmt *nullStmt);
+    virtual void visit(DeclStmt *declStmt);
+
+    virtual void visit(ApplicationExpr *applicationExpr);
+    virtual void visit(UntypedExpr *untypedExpr);
+    virtual void visit(NameExpr *nameExpr);
+    virtual void visit(CastExpr *castExpr);
+    virtual void visit(AddressExpr *addressExpr);
+    virtual void visit(LabelAddressExpr *labAddressExpr);
+    virtual void visit(UntypedMemberExpr *memberExpr);
+    virtual void visit(MemberExpr *memberExpr);
+    virtual void visit(VariableExpr *variableExpr);
+    virtual void visit(ConstantExpr *constantExpr); 
+    virtual void visit(SizeofExpr *sizeofExpr);
+    virtual void visit(AttrExpr *attrExpr);
+    virtual void visit(LogicalExpr *logicalExpr);
+    virtual void visit(ConditionalExpr *conditionalExpr);
+    virtual void visit(CommaExpr *commaExpr);
+    virtual void visit(TupleExpr *tupleExpr);
+    virtual void visit(SolvedTupleExpr *tupleExpr);
+    virtual void visit(TypeExpr *typeExpr);
+    virtual void visit(UntypedValofExpr *valofExpr);
+
+    virtual void visit(VoidType *basicType);
+    virtual void visit(BasicType *basicType);
+    virtual void visit(PointerType *pointerType);
+    virtual void visit(ArrayType *arrayType);
+    virtual void visit(FunctionType *functionType);
+    virtual void visit(StructInstType *aggregateUseType);
+    virtual void visit(UnionInstType *aggregateUseType);
+    virtual void visit(EnumInstType *aggregateUseType);
+    virtual void visit(ContextInstType *aggregateUseType);
+    virtual void visit(TypeInstType *aggregateUseType);
+    virtual void visit(TupleType *tupleType);
+    virtual void visit(TypeofType *typeofType);
+    virtual void visit(AttrType *attrType);
+
+    virtual void visit(MemberInit *memberInit);
+    virtual void visit(ElementInit *elementInit);
+    virtual void visit(SingleInit *singleInit);
+    virtual void visit(ListInit *listInit);
+
+    virtual void visit(Subrange *subrange);
+
+    virtual void visit(Constant *constant);
+
+private:
+    virtual void visit(AggregateDecl *aggregateDecl);
+    virtual void visit(NamedTypeDecl *typeDecl);
+    virtual void visit(ReferenceToType *aggregateUseType);
+};
+
+template< typename TreeType, typename VisitorType >
+inline void
+maybeAccept( TreeType *tree, VisitorType &visitor )
+{
+    if( tree ) {
+	tree->accept( visitor );
+    }
+}
+
+template< typename Container, typename VisitorType >
+inline void
+acceptAll( Container &container, VisitorType &visitor )
+{
+    SemanticError errors;
+    for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
+	try {
+	    if( *i ) {
+		(*i)->accept( visitor );
+	    }
+	} catch( SemanticError &e ) {
+	    errors.append( e );
+	}
+    }
+    if( !errors.isEmpty() ) {
+	throw errors;
+    }
+}
+
+template< typename Container, typename VisitorType >
+void
+acceptAllFold( Container &container, VisitorType &visitor, VisitorType &around )
+{
+    SemanticError errors;
+    for( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
+	try {
+	    if( *i ) {
+    VisitorType *v = new VisitorType;
+		(*i)->accept( *v );
+
+    typename Container::iterator nxt = i; nxt++; // forward_iterator
+    if( nxt == container.end() )
+	visitor += *v;
+    else
+	visitor += *v + around;
+
+    delete v;
+	    }
+	} catch( SemanticError &e ) {
+	    errors.append( e );
+	}
+    }
+    if( !errors.isEmpty() ) {
+	throw errors;
+    }
+}
+
+
+#endif /* #ifndef VISITOR_H */
+
+
+/*
+    Local Variables:
+    mode: c++
+    End:
+*/
Index: translator/SynTree/VoidType.cc
===================================================================
--- translator/SynTree/VoidType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/VoidType.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,22 @@
+/*
+ * This file is part of the Cforall project
+ *
+ * $Id: VoidType.cc,v 1.3 2005/08/29 20:59:27 rcbilson Exp $
+ *
+ */
+
+#include "Type.h"
+
+
+VoidType::VoidType( const Type::Qualifiers &tq )
+    : Type( tq )
+{
+}
+
+void
+VoidType::print( std::ostream &os, int indent ) const
+{
+    Type::print( os, indent );
+    os << "void ";
+}
+
Index: translator/SynTree/module.mk
===================================================================
--- translator/SynTree/module.mk	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/module.mk	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,34 @@
+SRC += SynTree/Type.cc \
+       SynTree/VoidType.cc \
+       SynTree/BasicType.cc \
+       SynTree/PointerType.cc \
+       SynTree/ArrayType.cc \
+       SynTree/FunctionType.cc \
+       SynTree/ReferenceToType.cc \
+       SynTree/TupleType.cc \
+       SynTree/TypeofType.cc \
+       SynTree/AttrType.cc \
+       SynTree/Constant.cc \
+       SynTree/Expression.cc \
+       SynTree/TupleExpr.cc \
+       SynTree/CommaExpr.cc \
+       SynTree/TypeExpr.cc \
+       SynTree/ApplicationExpr.cc \
+       SynTree/AddressExpr.cc \
+       SynTree/Statement.cc \
+       SynTree/CompoundStmt.cc \
+       SynTree/DeclStmt.cc \
+       SynTree/Declaration.cc \
+       SynTree/DeclarationWithType.cc \
+       SynTree/ObjectDecl.cc \
+       SynTree/FunctionDecl.cc \
+       SynTree/AggregateDecl.cc \
+       SynTree/NamedTypeDecl.cc \
+       SynTree/TypeDecl.cc \
+       SynTree/Initializer.cc \
+       SynTree/Visitor.cc \
+       SynTree/Mutator.cc \
+       SynTree/CodeGenVisitor.cc \
+       SynTree/TypeSubstitution.cc \
+	$(NULL)
+
Index: translator/SynTree/translate.cc
===================================================================
--- translator/SynTree/translate.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/translate.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,158 @@
+#include "translate.h"
+#include "../Parser/ParseNode.h"
+
+
+#include "Statement.h"
+#include "Expression.h"
+#include "Constant.h"
+#include "Type.h"
+
+int translate_driver(ParseNode *pn){
+    // in effect, this function is a visitor of sorts
+
+    if (pn == 0)
+	exit(1);
+
+    /* Type switching considered harmful */
+
+    switch(pn->what_kind()){
+    case ParseNode::Statement:
+	translate((StatementNode *)pn);
+	break;
+    case ParseNode::Expression:
+	translate((ExpressionNode *)pn);
+	break;
+    default:
+	translate(pn);
+	break;
+    }
+
+    return 0;
+}
+
+Expression *translate(ExpressionNode *en){
+    Expression *expr;
+
+    switch(en->what_kind()){
+    case ParseNode::CompositeExpression:
+	break;
+    case ParseNode::Constant:
+	expr = translate((ConstantNode *)en);
+	break;
+    case ParseNode::VarRef:
+	cout << "It's a varref" << endl;
+	break;
+    case ParseNode::Operator:
+	cout << "It's an operator" << endl;
+	break;
+    default:
+	break;
+    }
+
+    return expr;
+}
+
+Statement *translate(StatementNode *sn){
+    Statement *stmt = 0;
+
+    switch(sn->get_type()){
+    case StatementNode::Exp:
+	translate(sn->get_control());
+	break;
+    case StatementNode::If:
+	cout << "if" << endl;
+	translate(sn->get_control());
+	break;
+    case StatementNode::Switch:
+	cout << "switch" << endl;
+	break;
+    case StatementNode::Case:
+	cout << "case" << endl;
+	break;
+    case StatementNode::Default:
+	cout << "default" << endl;
+	break;
+    case StatementNode::Choose:
+	cout << "choose" << endl;
+	break;
+    case StatementNode::Fallthru:
+	cout << "fallthru" << endl;
+	break;
+    case StatementNode::While:
+	cout << "while" << endl;
+	break;
+    case StatementNode::Do:
+	cout << "do" << endl;
+	break;
+    case StatementNode::For:
+	cout << "for" << endl;
+	break;
+    case StatementNode::Goto:
+	cout << "goto" << endl;
+	break;
+    case StatementNode::Continue:
+	cout << "continue" << endl;
+	break;
+    case StatementNode::Break:
+	cout << "break" << endl;
+	break;
+    case StatementNode::Return:
+	cout << "return" << endl;
+	break;
+    case StatementNode::Throw:
+	cout << "throw" << endl;
+	break;
+    case StatementNode::Try:
+	cout << "try" << endl;
+	break;
+    case StatementNode::Catch:
+	cout << "catch" << endl;
+	break;
+    case StatementNode::Asm:
+	cout << "asm" << endl;
+	break;
+    default:
+	break;
+    }
+
+    return stmt;
+}
+
+ConstantExpr *translate(ConstantNode *cn){
+    ConstantExpr *cnst;
+    BasicType::Kind knd;
+
+    struct Type::Qualifiers tq = {0,0,0};
+    struct BasicType::Modifiers tm = {0,0,0,0};
+
+    switch(cn->get_type()){
+    case ConstantNode::Integer:
+	knd = BasicType::Int;
+	break;
+    case ConstantNode::Float:
+	knd = BasicType::Float;
+	break;
+    case ConstantNode::Character:
+	knd = BasicType::Char;
+	break;
+    case ConstantNode::String:
+	break;
+    default:
+	break;
+    }
+
+    Constant *c = new Constant(new BasicType(tq,tm,knd), cn->get_name());
+    cnst = new ConstantExpr(*c);
+
+    return cnst;
+}
+
+Expression *translate(CompositeExprNode *ce){
+    return 0;
+}
+
+int translate(ParseNode *pn){
+    cout << "In translate - parsenode" << endl;
+
+    return 0;
+}
Index: translator/SynTree/translate.h
===================================================================
--- translator/SynTree/translate.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/SynTree/translate.h	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
@@ -0,0 +1,14 @@
+#ifndef __TRANSLATE_H_
+#define __TRANSLATE_H_
+
+#include "SynTree.h"
+#include "../Parser/ParseNode.h"
+
+int translate_driver(ParseNode *);
+int translate(ParseNode *);
+Expression *translate(ExpressionNode *);
+Expression *translate(CompositeExprNode *);
+ConstantExpr *translate(ConstantNode *);
+Statement *translate(StatementNode *);
+
+#endif	/* #define __TRANSLATE_H_ */
