|
OpenADFortTk (basic)
|
00001 // -*-Mode: C++;-*- 00002 // $Header: /Volumes/cvsrep/developer/OpenADFortTk/src/xaif2whirl/XlationContext.cxx,v 1.10 2006/05/12 16:12:24 utke Exp $ 00003 00004 00005 #include <iostream> 00006 #include <sstream> 00007 #include "Open64IRInterface/SymTab.h" 00008 #include "Diagnostics.h" 00009 #include "XlationContext.h" 00010 00011 namespace xaif2whirl{ 00012 00013 XlationContext::XlationContext() : 00014 myFlags(0) { 00015 } 00016 00017 XlationContext::~XlationContext() { 00018 } 00019 00020 bool XlationContext::isFlag(XlationContext::Flags_E f) const { 00021 return (myFlags & f); 00022 } 00023 00024 void XlationContext::setFlag(XlationContext::Flags_E f) { 00025 if (VALUESELECTOR & f) { 00026 if (DERIVSELECTOR & myFlags) { 00027 std::ostringstream ctxt_contents; 00028 dump(ctxt_contents,""); 00029 FORTTK_MSG(2,"XlationContext::setFlag: cannot set VALUESELECTOR while DERIVSELECTOR " 00030 << ctxt_contents.str().c_str()); 00031 } 00032 } 00033 if (DERIVSELECTOR & f) { 00034 if (VALUESELECTOR & myFlags) { 00035 std::ostringstream ctxt_contents; 00036 dump(ctxt_contents,""); 00037 FORTTK_MSG(2,"XlationContext::setFlag: cannot set DERIVSELECTOR while VALUESELECTOR " 00038 << ctxt_contents.str().c_str()); 00039 } 00040 } 00041 myFlags = myFlags | f; 00042 } 00043 00044 void XlationContext::unsetFlag(XlationContext::Flags_E f) { 00045 myFlags = myFlags & ~f; 00046 } 00047 00048 void XlationContext::inheritFlagsDown(const XlationContext& parentContext) { 00049 myFlags = myFlags | (parentContext.myFlags & (VALUESELECTOR|DERIVSELECTOR|SUPPRESSSELECTOR|VARREF|LVALUE|ARRAY|ARRAYIDX|EXPRSIMPLE)); 00050 } 00051 void XlationContext::inheritFlagsUp(const XlationContext& childContext) { 00052 myFlags = myFlags | (childContext.myFlags & ACTIVETYPE); 00053 } 00054 00055 void XlationContext::dump(std::ostream& o, const std::string& indent) const { 00056 o << indent.c_str() << "("; 00057 if (isFlag(ACTIVETYPE)) o << " active"; 00058 if (isFlag(VALUESELECTOR)) o << " value_sel"; 00059 if (isFlag(DERIVSELECTOR)) o << " deriv_sel"; 00060 if (isFlag(SUPPRESSSELECTOR)) o << " suppr_sel"; 00061 if (isFlag(VARREF)) o << " varref"; 00062 if (isFlag(LVALUE)) o << " lvalue"; 00063 if (isFlag(ARRAY)) o << " array"; 00064 if (isFlag(ARRAYIDX)) o << " arrayidx"; 00065 if (isFlag(EXPRSIMPLE)) o << " exprsimple"; 00066 o << ")" << std::endl; 00067 } 00068 00069 void 00070 XlationContext::ddump() const { 00071 dump(std::cerr,""); 00072 } 00073 00074 }