Special.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 
00038 #include <assert.h>
00039 #include <string>
00040 
00041 #include "Special.hxx"
00042 
00043 using namespace boost;
00044 using namespace sherpa;
00045 
00046 SpecialNames SpecialNames::spNames;
00047 
00048 SpecialNames::SpecialNames()
00049 {
00050   sp_integral          = "IntLit";
00051   sp_fp                = "FloatLit";
00052   sp_iob               = "IndexBoundsError";
00053   sp_lt                = "__index_lt";
00054   sp_ref_types         = "RefTypes";
00055   sp_copy_compat       = "CopyCompat";
00056   sp_copy_from_to      = "CopyFromTo";
00057   sp_has_field         = "HasField";
00058 }
00059 
00060 std::string
00061 SpecialNames::getSpName(SpNameId name) {
00062   switch(name) {
00063     
00064   case SP_NAME_INTEGER:
00065     return sp_integral;
00066     
00067   case SP_NAME_FP:
00068       return sp_fp;
00069       
00070   case SP_NAME_IOB:
00071     return sp_iob;
00072 
00073   case SP_NAME_LT:
00074     return sp_lt;
00075 
00076   case SP_NAME_REF_TYPES:
00077     return sp_ref_types;
00078 
00079   case SP_NAME_COPY_COMPAT:
00080     return sp_copy_compat;
00081 
00082   case SP_NAME_COPY_FROM_TO:
00083     return sp_copy_from_to;
00084   
00085   case SP_NAME_HAS_FIELD:
00086     return sp_has_field;
00087   
00088   default:
00089     assert(false);
00090     return "unknown";
00091   }    
00092 }
00093 
00094 // In front-end passes, the passed UOC will be the prelude. In the
00095 // backend we will be called with the UOC of the bigAST
00096 void 
00097 SpecialNames::fixUpSpNames(shared_ptr<UocInfo> theUoc)
00098 {
00099   sp_integral = theUoc->env->getBinding(sp_integral)->s;
00100   sp_fp = theUoc->env->getBinding(sp_fp)->s;
00101   sp_iob = theUoc->env->getBinding(sp_iob)->s;
00102   sp_lt = theUoc->env->getBinding(sp_lt)->s;
00103   sp_ref_types = theUoc->env->getBinding(sp_ref_types)->s;
00104   sp_copy_compat = theUoc->env->getBinding(sp_copy_compat)->s;
00105   sp_copy_from_to = theUoc->env->getBinding(sp_copy_from_to)->s;
00106   sp_has_field = theUoc->env->getBinding(sp_has_field)->s;
00107 }

Generated on Thu May 17 23:59:16 2012 for BitC Compiler by  doxygen 1.4.7