//
// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// CodeGenVisitor.cc -- 
//
// Author           : Richard C. Bilson
// Created On       : Mon May 18 07:44:20 2015
// Last Modified By : Peter A. Buhr
// Last Modified On : Mon May 18 07:57:51 2015
// Update Count     : 3
//

#include <iostream>
#include <list>

#include "Statement.h"
#include "Expression.h"
#include "CodeGenVisitor.h"
using namespace std;

void CodeGenVisitor::visit( Type *type ) { }
void CodeGenVisitor::visit( BasicType *basicType ) { }

void CodeGenVisitor::visit( Constant *constant ) { 
	cout << constant->get_value() << endl;
}

void CodeGenVisitor::visit( Expression *expr ) { }

void CodeGenVisitor::visit( ConstantExpr *cnst ) {
	if ( cnst != 0 )
		visit(cnst->get_constant());
}

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;	
}

// Local Variables: //
// tab-width: 4 //
// mode: c++ //
// compile-command: "make install" //
// End: //
