bito.cxx

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright (C) 2008, Johns Hopkins University.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or
00007  * without modification, are permitted provided that the following
00008  * conditions are met:
00009  *
00010  *   - Redistributions of source code must contain the above
00011  *     copyright notice, this list of conditions, and the following
00012  *     disclaimer.
00013  *
00014  *   - Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions, and the following
00016  *     disclaimer in the documentation and/or other materials
00017  *     provided with the distribution.
00018  *
00019  *   - Neither the names of the copyright holders nor the names of any
00020  *     of any contributors may be used to endorse or promote products
00021  *     derived from this software without specific prior written
00022  *     permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00027  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00028  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00029  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00030  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00031  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00032  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00033  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  **************************************************************************/
00037 
00044 
00045 #include <stdint.h>
00046 #include <stdlib.h>
00047 #include <dirent.h>
00048 #include <fstream>
00049 #include <iostream>
00050 #include <string>
00051 #include <sstream>
00052 
00053 #include "Version.hxx"
00054 #include "Options.hxx"
00055 #include "UocInfo.hxx"
00056 #include "AST.hxx"
00057 
00058 using namespace boost;
00059 using namespace sherpa;
00060 
00061 bool
00062 EmitBitO(std::ostream &optStream, std::ostream &errStream)
00063 {
00064   std::ofstream out(Options::outputFileName.c_str(),
00065                     std::ios_base::out|std::ios_base::trunc);
00066 
00067   if (!out.is_open())
00068     errStream << "Couldn't open output file \""
00069               << Options::outputFileName
00070               << "\" -- "
00071               << strerror(errno)
00072               << std::endl;
00073 
00074 
00075   out << "bitc version " << BITC_VERSION << std::endl
00076       << std::endl;
00077 
00078   for (UocMap::iterator itr = UocInfo::srcList.begin();
00079       itr != UocInfo::srcList.end(); ++itr) {
00080     shared_ptr<UocInfo> uoc = itr->second;
00081 
00082     uoc->PrettyPrint(out, false);
00083     out << std::endl;
00084   }
00085 
00086   return true;
00087 }
00088 

Generated on Sat Feb 4 23:59:28 2012 for BitC Compiler by  doxygen 1.4.7