Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Symbol Class Reference

#include <cmt_symbol.h>

Collaboration diagram for Symbol:

Collaboration graph
[legend]
List of all members.

Public Types

typedef cmt_vector< SymbolSymbolVector
typedef cmt_map< cmt_string,
Symbol
SymbolMap
enum  SymbolType {
  SymbolUndefined, SymbolAction, SymbolAlias, SymbolMacro,
  SymbolSetupScript, SymbolCleanupScript, SymbolSet, SymbolPath
}

Public Member Functions

 Symbol ()
 ~Symbol ()
bool value_is_reflexive (const cmt_string &text) const
 Characterizes if a value is provided as the reference to itself.

void add_value_to_list (CommandType command_type, Use *use, Tag *tag, const cmt_string &text)
int print_clean (PrintMode mode)
int print (PrintMode mode)
cmt_string build_macro_value (bool display_it=false) const
cmt_string clean_macro_value () const
cmt_string resolve_macro_value (const cmt_string &tag_name="")
 Attempt to substitute into the symbol value all occurrences of.

void show_macro (PrintMode mode)

Static Public Member Functions

Symbolcreate (const cmt_string &name, CommandType command, Use *use=0)
Symbolfind (const cmt_string &name)
void action (const CmtSystem::cmt_string_vector &words, CommandType command_type, Use *use)
int is_selected (const cmt_string &name)
void all_set ()
 Compute the current value of all environment variables and set them to the shell.

void all_print (PrintMode mode)
void all_print_clean (PrintMode mode)
int symbol_number ()
SymbolVectorsymbols ()
SymbolMapsymbol_map ()
Symbolsymbol (int index)
void clear_all ()
void expand (cmt_string &text)
bool check_tag_used (Tag *tag)

Public Attributes

ValueBuilderbuilder
cmt_string name
ScopeType scope
SymbolType type
SymbolValueList::SymbolValueListVector value_lists
int selected_value

Member Typedef Documentation

typedef cmt_map<cmt_string, Symbol> Symbol::SymbolMap
 

Definition at line 64 of file cmt_symbol.h.

Referenced by clear_all(), create(), find(), symbol_map(), and Database::symbol_map().

typedef cmt_vector<Symbol> Symbol::SymbolVector
 

Definition at line 63 of file cmt_symbol.h.

Referenced by all_print(), all_print_clean(), all_set(), check_tag_used(), clear_all(), create(), symbol(), symbol_number(), symbols(), and Database::symbols().


Member Enumeration Documentation

enum Symbol::SymbolType
 

Enumeration values:
SymbolUndefined 
SymbolAction 
SymbolAlias 
SymbolMacro 
SymbolSetupScript 
SymbolCleanupScript 
SymbolSet 
SymbolPath 

Definition at line 66 of file cmt_symbol.h.

Referenced by create().

00067     {
00068       SymbolUndefined,
00069       SymbolAction,
00070       SymbolAlias,
00071       SymbolMacro,
00072       SymbolSetupScript,
00073       SymbolCleanupScript,
00074       SymbolSet,
00075       SymbolPath
00076     } SymbolType;


Constructor & Destructor Documentation

Symbol::Symbol  ) 
 

Definition at line 1064 of file cmt_symbol.cxx.

References name.

01065 {
01066   name = "";
01067 }

Symbol::~Symbol  ) 
 

Definition at line 1070 of file cmt_symbol.cxx.

01071 {
01072 }


Member Function Documentation

void Symbol::action const CmtSystem::cmt_string_vector words,
CommandType  command_type,
Use use
[static]
 

Definition at line 867 of file cmt_symbol.cxx.

References CmtSystem::absolute_path(), Tag::add(), add_value_to_list(), CmtSystem::cmt_string_vector, cmt_style, CommandCleanupScript, CommandSetupScript, Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), create(), expand(), CmtSystem::file_separator(), cmt_string::find(), Tag::find(), Cmt::get_current_access(), Use::get_current_scope(), Cmt::get_debug(), Use::get_package_name(), name, no_version_style, Use::prefix, PriorityUserTag, ScopePrivate, Use::set_native_version(), cmt_string::size(), cmt_vector< T >::size(), Use::style, symbol(), and UserMode.

Referenced by KwdSetupScript::action(), KwdSetRemoveRegexp::action(), KwdSetRemove::action(), KwdSetPrepend::action(), KwdSetAppend::action(), KwdSet::action(), KwdPathRemoveRegexp::action(), KwdPathRemove::action(), KwdPathPrepend::action(), KwdPathAppend::action(), KwdPath::action(), KwdMacroRemoveAllRegexp::action(), KwdMacroRemoveAll::action(), KwdMacroRemoveRegexp::action(), KwdMacroRemove::action(), KwdMacroAppend::action(), KwdMacroPrepend::action(), KwdMacro::action(), KwdCleanupScript::action(), KwdAlias::action(), KwdAction::action(), create(), and show_macro().

00870 {
00871   int number;
00872   Symbol* symbol;
00873   Tag* tag;
00874 
00875   if (words.size () < 1) return;
00876   cmt_string name = words[1];
00877 
00878   if ((command_type == CommandSetupScript) ||
00879       (command_type == CommandCleanupScript))
00880     {
00881       cmt_string full_name;
00882 
00883       Symbol::expand (name);
00884 
00885       if (name != "")
00886         {
00887           if (CmtSystem::absolute_path (name)) 
00888             {
00889               full_name = name;
00890             }
00891           else
00892             {
00893 #ifdef WIN32
00894               full_name = "%";
00895 #else
00896               full_name = "${";
00897 #endif
00898               full_name += use->prefix;
00899               full_name += "ROOT";
00900 #ifdef WIN32
00901               full_name += "%";
00902 #else
00903               full_name += "}";
00904 #endif
00905               full_name += CmtSystem::file_separator ();
00906               if (use->style == cmt_style) full_name += "cmt";
00907               else if (use->style == no_version_style) full_name += "cmt";
00908               else full_name += "mgr";
00909               full_name += CmtSystem::file_separator ();
00910               full_name += name;
00911             }
00912 
00913           symbol = create (full_name, command_type, use);
00914           symbol->add_value_to_list (command_type, use,
00915                                      Tag::get_default (), full_name);
00916         }
00917     }
00918   else
00919     {
00920       if (words.size () < 2) return;
00921       const cmt_string& default_value = words[2];
00922 
00923       if (Cmt::get_debug ())
00924         {
00925           cout << "Symbol::action> name:" << name 
00926                << " access:" << Cmt::get_current_access () 
00927                << " scope:" << use->get_current_scope () << endl;
00928         }
00929 
00930       if (Cmt::get_current_access () == UserMode)
00931         {
00932           if (name == "constituents") return;
00933           if (name == "constituentscclean") return;
00934 
00935           if (use->get_current_scope () == ScopePrivate) return;
00936         }
00937 
00938       symbol = create (name, command_type, use);
00939 
00940       /*
00941         Parse the default value.
00942       */
00943       
00944       symbol->add_value_to_list (command_type, use,
00945                                  Tag::get_default (), default_value);
00946       
00947       /*
00948         Then parse all specific values
00949         
00950         <tag> <value>
00951         ...
00952       */
00953       
00954       number = 3;
00955       while (number < (words.size () - 1))
00956         {
00957           cmt_string tag_name = words[number];
00958           const cmt_string& value = words[number + 1];
00959 
00960           expand (tag_name);
00961 
00962           if (Cmt::get_debug ())
00963             {
00964               cout << "Symbol::action> tag_name=" << tag_name << endl;
00965             }
00966 
00967           tag = Tag::find (tag_name);
00968           if (tag == 0)
00969             {
00970               tag = Tag::add (tag_name, PriorityUserTag, "use", use);
00971             }
00972 
00973           symbol->add_value_to_list (command_type, use, tag, value);
00974           
00975           number += 2;
00976         }
00977 
00978       if (name == "CMTPATH")
00979         {
00980           Cmt::configure_cmt_path (use);
00981         }
00982       else if (name == "CMTSITE")
00983         {
00984           Cmt::configure_site_tag (use);
00985         }
00986       else if (name == "CMTCONFIG")
00987         {
00988             //cerr << "redefining CMTCONFIG" << endl;
00989           Cmt::configure_tags (use);
00990         }
00991       else if (name == "CMTHOME")
00992         {
00993           Cmt::configure_home (use);
00994         }
00995       else if (name == "CMTUSERCONTEXT")
00996         {
00997           Cmt::configure_user_context (use);
00998         }
00999       else if (name.find ("_native_version") != cmt_string::npos)
01000         {
01001           cmt_string n = use->get_package_name ();
01002           n += "_native_version";
01003 
01004           if (name == n)
01005             {
01006               use->set_native_version (true);
01007             }
01008         }
01009     }
01010 }

void Symbol::add_value_to_list CommandType  command_type,
Use use,
Tag tag,
const cmt_string text
 

Definition at line 1130 of file cmt_symbol.cxx.

References cmt_vector< T >::add(), cmt_vector< T >::back(), cmt_vector< T >::clear(), SymbolValueList::command_type, CommandAction, CommandMacro, CommandPath, CommandSet, Use::discarded, SymbolValueList::discarded, Tag::get_default(), SymbolValueList::is_reflexive, SymbolValue::selected, cmt_vector< T >::size(), SymbolValue::tag, SymbolValue::text, SymbolValueList::use, value_is_reflexive(), value_lists, and SymbolValueList::values.

Referenced by action().

01134 {
01135   SymbolValueList* value_list = 0;
01136   bool is_reflexive = false;
01137 
01138     //
01139     // First pickup the most recent value_list
01140     //
01141   if (value_lists.size () > 0) value_list = &(value_lists.back ());
01142 
01143     //
01144     //  Create a new value list is we switch to another use or
01145     //  if we switch to a new command_type (eg. switching from
01146     //  macro to macro_append).
01147     //
01148   if ((value_list == 0) ||
01149       (use != value_list->use) ||
01150       (command_type != value_list->command_type) ||
01151       (tag == Tag::get_default ()))
01152     {
01153       value_list = &(value_lists.add ());
01154       value_list->use = use;
01155       value_list->command_type = command_type;
01156       value_list->values.clear ();
01157       value_list->discarded = false;
01158       value_list->is_reflexive = false;
01159     }
01160 
01161 /*
01162   else
01163     {
01164         value_list = &(value_lists[value_lists.size () - 1]);
01165     }
01166 */
01167 
01168   is_reflexive = value_list->is_reflexive;
01169 
01170     //
01171     //  If the command_type is command_macro or command_set, 
01172     // this is considered as a full re-set of this symbol 
01173     //   In this case, we have to discard all previous values
01174     //
01175     //  However, we'd like to exclude from this logic the cases where
01176     //  the value is **exactly* 
01177     //
01178     //     $(<symbol>)
01179     //     ${<symbol>}
01180     //     %<symbol>%
01181     //
01182     //   which would then mean that we do not reset the value but rather
01183     //  override it.
01184     //
01185 
01186     //
01187     // Inside this value_list, we add this new tag-value pair.
01188     //
01189 
01190   if ((command_type == CommandMacro) ||
01191       (command_type == CommandSet) ||
01192       (command_type == CommandPath) ||
01193       (command_type == CommandAction))
01194     {
01195         //
01196         // Check whether we have to hide previous settings by this new definition
01197         //  (of course this is only useful if there WERE previous settings)
01198         //
01199       if ((value_lists.size () >= 1) && (!is_reflexive))
01200         {
01201           if (value_is_reflexive (text))
01202             {
01203               value_list->is_reflexive = true;
01204               is_reflexive = true;
01205             }
01206           else
01207             {
01208               //cout << "...discarding old values for symbol " << name << " text=[" << text << "]" << endl;
01209                   
01210               for (int i = 0; i < (value_lists.size () - 1); i++)
01211                 {
01212                   SymbolValueList& vl = value_lists[i];
01213                   
01214                   if ((vl.use != 0) &&
01215                       (vl.use->discarded))
01216                     {
01217                       //vl.discarded = true;
01218                     }
01219                 }
01220             }
01221         }
01222     }
01223 
01224   SymbolValue& value = value_list->values.add ();
01225 
01226   value.tag = tag;
01227   value.text = text;
01228   value.selected = 0;
01229 }

void Symbol::all_print PrintMode  mode  )  [static]
 

Definition at line 1318 of file cmt_symbol.cxx.

References Bat, print(), cmt_vector< T >::size(), symbol(), symbol_number(), SymbolAlias, SymbolPath, symbols(), SymbolSet, SymbolSetupScript, SymbolVector, and type.

Referenced by Cmt::print().

01319 {
01320   static SymbolVector& Symbols = symbols ();
01321 
01322   int number;
01323 
01324   if (Symbols.size () == 0) return;
01325 
01326   for (number = 0; number < Symbol::symbol_number (); number++)
01327     {
01328       Symbol& symbol = Symbol::symbol (number);
01329 
01330       if ((symbol.type == SymbolSet) ||
01331           (symbol.type == SymbolAlias) ||
01332           (symbol.type == SymbolSetupScript))
01333         {
01334           if (symbol.print (mode))
01335             {
01336               if (mode == Bat)
01337                 {
01338                   cout << endl;
01339                 }
01340               else
01341                 {
01342                   //cout << "; ";
01343                   cout << endl;
01344                 }
01345             }
01346         }
01347     }
01348 
01349   for (number = 0; number < Symbol::symbol_number (); number++)
01350     {
01351       Symbol& symbol = Symbol::symbol (number);
01352 
01353       if ((symbol.type != SymbolPath)) continue;
01354 
01355       if (symbol.print (mode))
01356         {
01357           if (mode == Bat)
01358             {
01359               cout << endl;
01360             }
01361           else
01362             {
01363               //cout << "; ";
01364               cout << endl;
01365             }
01366         }
01367     }
01368 }

void Symbol::all_print_clean PrintMode  mode  )  [static]
 

Definition at line 1371 of file cmt_symbol.cxx.

References print_clean(), cmt_vector< T >::size(), symbol(), SymbolAlias, SymbolCleanupScript, SymbolPath, symbols(), SymbolSet, SymbolVector, and type.

Referenced by Cmt::print_clean().

01372 {
01373   static SymbolVector& Symbols = symbols ();
01374 
01375   int number;
01376 
01377   if (Symbols.size () == 0) return;
01378 
01379   for (number = Symbols.size () - 1; number >= 0; number--)
01380     {
01381       Symbol& symbol = Symbols[number];
01382 
01383       if ((symbol.type == SymbolSet) ||
01384           (symbol.type == SymbolAlias) ||
01385           (symbol.type == SymbolCleanupScript))
01386         {
01387           if (symbol.print_clean (mode))
01388             {
01389               cout << endl;
01390             }
01391         }
01392     }
01393 
01394   for (number = Symbols.size () - 1; number >= 0; number--)
01395     {
01396       Symbol& symbol = Symbols[number];
01397 
01398       if ((symbol.type != SymbolPath)) continue;
01399 
01400       if (symbol.print_clean (mode))
01401         {
01402           cout << endl;
01403         }
01404     }
01405 }

void Symbol::all_set  )  [static]
 

Compute the current value of all environment variables and set them to the shell.

Definition at line 1235 of file cmt_symbol.cxx.

References cmt_vector< T >::add(), build_macro_value(), cmt_vector< T >::clear(), CmtSystem::cmt_string_vector, expand(), Cmt::get_all_sets_done(), Cmt::get_debug(), name, CmtSystem::putenv(), cmt_string::replace_all(), Cmt::set_all_sets_done(), cmt_vector< T >::size(), symbol(), symbol_number(), SymbolPath, symbols(), SymbolSet, SymbolVector, and type.

Referenced by Cmt::do_broadcast(), Cmt::do_do(), Cmt::do_run(), resolve_value(), resolve_value_for_macros(), and suppress_OS_delimiters().

01236 {
01237   //cerr << "all_set" << endl;
01238 
01239   if (Cmt::get_debug ())
01240     {
01241       cout << "Symbol::all_set> done" << Cmt::get_all_sets_done () << endl;
01242     }
01243 
01244   if (Cmt::get_all_sets_done ()) return;
01245 
01246   Cmt::set_all_sets_done ();
01247 
01248   static SymbolVector& Symbols = symbols ();
01249 
01250   static CmtSystem::cmt_string_vector envs;
01251 
01252   envs.clear ();
01253 
01254   int number;
01255 
01256   if (Symbols.size () == 0) 
01257     {
01258         //running = false;
01259       return;
01260     }
01261 
01262   cmt_string value;
01263 
01264   for (number = 0; number < Symbol::symbol_number (); number++)
01265     {
01266       Symbol& symbol = Symbol::symbol (number);
01267 
01268       if (symbol.type != SymbolSet) continue;
01269 
01270       value = symbol.build_macro_value ();
01271       if (value != "")
01272         {
01273           cmt_string& temp = envs.add ();
01274 
01275           temp = symbol.name;
01276           temp += '=';
01277           temp += value;
01278         }
01279     }
01280 
01281   for (number = 0; number < Symbol::symbol_number (); number++)
01282     {
01283       Symbol& symbol = Symbol::symbol (number);
01284 
01285       if ((symbol.type != SymbolPath)) continue;
01286 
01287       value = symbol.build_macro_value ();
01288       if (value != "")
01289         {
01290           cmt_string& temp = envs.add ();
01291 
01292           temp = symbol.name;
01293           temp += '=';
01294           temp += value;
01295         }
01296     }
01297 
01298   for (number = 0; number < envs.size (); number++)
01299     {
01300       cmt_string& env = envs[number];
01301       Symbol::expand (env);
01302 
01303 #ifdef WIN32
01304       env.replace_all ("/", "\\");
01305 #endif
01306 
01307       if (Cmt::get_debug ())
01308         {
01309           cout << "Symbol::all_set> " << env << endl;
01310         }
01311       CmtSystem::putenv (env);
01312     }
01313 
01314     //running = false;
01315 }

cmt_string Symbol::build_macro_value bool  display_it = false  )  const
 

Definition at line 1591 of file cmt_symbol.cxx.

References ValueBuilder::build(), ValueBuilder::build_and_display(), and builder.

Referenced by all_set(), Use::build_library_links(), CvsImplementation::clear(), CmtInstallAreaMgr::config(), Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), Cmt::do_build_library_links(), Cmt::do_do(), Cmt::do_remove_library_links(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), CmtLock::lock(), Constituent::parse_all(), print(), Cmt::set_standard_macros(), CmtInstallAreaMgr::setup_current_installarea(), show_macro(), and CmtLock::unlock().

01592 {
01593   cmt_string temp;
01594 
01595   if (display_it)
01596     {
01597       temp = builder->build_and_display (*this);
01598     }
01599   else
01600     {
01601       temp = builder->build (*this);
01602     }
01603 
01604   return (temp);
01605 }

bool Symbol::check_tag_used Tag tag  )  [static]
 

Definition at line 2839 of file cmt_symbol.cxx.

References cmt_vector< T >::size(), symbol(), symbol_number(), symbols(), SymbolVector, SymbolValue::tag, Tag::use_operand(), value_lists, and SymbolValueList::values.

Referenced by Cmt::do_check_configuration().

02840 {
02841   if (tag == 0) return (false);
02842 
02843   static SymbolVector& Symbols = symbols ();
02844 
02845   if (Symbols.size () == 0) 
02846     {
02847       return (false);
02848     }
02849 
02850   for (int number = 0; number < Symbol::symbol_number (); number++)
02851     {
02852       Symbol& symbol = Symbol::symbol (number);
02853 
02854       for (int i = 0; i < symbol.value_lists.size (); i++)
02855         {
02856           const SymbolValueList& value_list = symbol.value_lists[i];
02857 
02858           for (int j = 0; j < value_list.values.size (); j++)
02859             {
02860               const SymbolValue& value = value_list.values[j];
02861               Tag* t = value.tag;
02862 
02863               if (t != 0)
02864                 {
02865                   if (t->use_operand (tag)) return (true);
02866                 }
02867             }
02868         }
02869     }
02870 
02871   return (false);
02872 }

cmt_string Symbol::clean_macro_value  )  const
 

Definition at line 1608 of file cmt_symbol.cxx.

References builder, and ValueBuilder::clean().

Referenced by print_clean().

01609 {
01610   cmt_string temp;
01611 
01612   temp = builder->clean (*this);
01613 
01614   return (temp);
01615 }

void Symbol::clear_all  )  [static]
 

Definition at line 1742 of file cmt_symbol.cxx.

References cmt_vector< T >::clear(), cmt_map< K, T >::clear(), symbol_map(), SymbolMap, symbols(), and SymbolVector.

Referenced by Database::clear().

01743 {
01744   static SymbolVector& Symbols = symbols ();
01745   static SymbolMap& SymbolMap = symbol_map ();
01746 
01747   SymbolMap.clear ();
01748   Symbols.clear ();
01749 }

Symbol * Symbol::create const cmt_string name,
CommandType  command,
Use use = 0
[static]
 

Definition at line 652 of file cmt_symbol.cxx.

References action(), action_build_tag_makefile, ActionType, cmt_map< K, T >::add(), cmt_vector< T >::add(), builder, cmt_vector< T >::clear(), CommandAction, CommandAlias, CommandCleanupScript, CommandMacro, CommandMacroAppend, CommandMacroPrepend, CommandMacroRemove, CommandMacroRemoveAll, CommandMacroRemoveAllRegexp, CommandMacroRemoveRegexp, CommandPath, CommandPathAppend, CommandPathPrepend, CommandPathRemove, CommandPathRemoveRegexp, CommandSet, CommandSetAppend, CommandSetPrepend, CommandSetRemove, CommandSetRemoveRegexp, CommandSetupScript, find(), Cmt::get_action(), Use::get_current_scope(), Use::get_package_name(), Cmt::get_quiet(), name, scope, selected_value, symbol(), symbol_map(), SymbolAction, SymbolAlias, SymbolCleanupScript, SymbolMacro, SymbolMap, SymbolPath, symbols(), SymbolSet, SymbolSetupScript, SymbolType, SymbolUndefined, SymbolVector, type, and value_lists.

Referenced by action().

00655 {
00656   static SetBuilder Set;
00657   static PathBuilder Path;
00658   static MacroBuilder Macro;
00659   static ScriptBuilder Script;
00660   static ActionBuilder Action;
00661 
00662   static SymbolVector& Symbols = symbols ();
00663   static SymbolMap& SymbolMap = symbol_map ();
00664 
00665   SymbolType type = SymbolUndefined;
00666 
00667   switch (command)
00668     {
00669     case CommandSet:
00670     case CommandSetAppend:
00671     case CommandSetPrepend:
00672     case CommandSetRemove:
00673     case CommandSetRemoveRegexp:
00674       type = SymbolSet;
00675       break;
00676     case CommandPath:
00677     case CommandPathAppend:
00678     case CommandPathPrepend:
00679     case CommandPathRemove:
00680     case CommandPathRemoveRegexp:
00681       type = SymbolPath;
00682       break;
00683     case CommandMacro:
00684     case CommandMacroAppend:
00685     case CommandMacroPrepend:
00686     case CommandMacroRemove:
00687     case CommandMacroRemoveRegexp:
00688     case CommandMacroRemoveAll:
00689     case CommandMacroRemoveAllRegexp:
00690       type = SymbolMacro;
00691       break;
00692     case CommandAction:
00693       type = SymbolAction;
00694       break;
00695     case CommandAlias:
00696       type = SymbolAlias;
00697       break;
00698     case CommandSetupScript:
00699       type = SymbolSetupScript;
00700       break;
00701     case CommandCleanupScript:
00702       type = SymbolCleanupScript;
00703       break;
00704     }
00705 
00706   {
00707     Symbol* symbol;
00708 
00709     symbol = find (name);
00710     if (symbol != 0) 
00711       {
00712         if (symbol->type != type)
00713           {
00714             ActionType action = Cmt::get_action ();
00715 
00716             if ((!Cmt::get_quiet ()) &&
00717                 (action != action_build_tag_makefile))
00718               {
00719                 cmt_string s1;
00720                 cmt_string s2;
00721 
00722                 switch (symbol->type)
00723                   {
00724                   case SymbolSet:
00725                     s1 = "set";
00726                     break;
00727                   case SymbolPath:
00728                     s1 = "path";
00729                     break;
00730                   case SymbolMacro:
00731                     s1 = "macro";
00732                     break;
00733                   case SymbolSetupScript:
00734                     s1 = "setup_script";
00735                     break;
00736                   case SymbolCleanupScript:
00737                     s1 = "cleanup_script";
00738                     break;
00739                   case SymbolAction:
00740                     s1 = "action";
00741                     break;
00742                   case SymbolAlias:
00743                     s1 = "alias";
00744                     break;
00745                   } 
00746 
00747                 switch (type)
00748                   {
00749                   case SymbolSet:
00750                     s2 = "set";   
00751                     break;
00752                   case SymbolPath:
00753                     s2 = "path";   
00754                     break;
00755                   case SymbolMacro:
00756                     s2 = "macro";   
00757                     break;
00758                   case SymbolSetupScript:
00759                     s2 = "setup_script";  
00760                     break;
00761                   case SymbolCleanupScript:
00762                     s2 = "cleanup_script";  
00763                     break;
00764                   case SymbolAction:
00765                     s2 = "action";
00766                     break;
00767                   case SymbolAlias:
00768                     s2 = "alias";
00769                     break;
00770                   } 
00771 
00772                 cerr << "#CMT> Warning: Symbol " << name 
00773                      << " inconsistently redeclared from " << s1 << " to " << s2;
00774                 if (use != 0) cerr << " in package " << use->get_package_name ();
00775                 cerr << endl;
00776               }
00777           }
00778 
00779         return (symbol);
00780       }
00781   }
00782 
00783   Symbol& symbol = Symbols.add ();
00784   SymbolMap.add (name, symbol);
00785 
00786   symbol.name  = name;
00787   symbol.scope = use->get_current_scope ();
00788   symbol.type  = type;
00789 
00790   symbol.value_lists.clear ();
00791 
00792   switch (type)
00793     {
00794     case SymbolSet:
00795       symbol.builder = &Set;
00796       break;
00797     case SymbolPath:
00798       symbol.builder = &Path;
00799       break;
00800     case SymbolAlias:
00801       symbol.builder = &Set;
00802       break;
00803     case SymbolMacro:
00804       symbol.builder = &Macro;
00805       break;
00806     case SymbolSetupScript:
00807     case SymbolCleanupScript:
00808       symbol.builder = &Script;
00809       break;
00810     case SymbolAction:
00811       symbol.builder = &Action;
00812       break;
00813     }
00814 
00815   symbol.selected_value = -1;
00816 
00817   return (&symbol);
00818 }

void Symbol::expand cmt_string text  )  [static]
 

Definition at line 1752 of file cmt_symbol.cxx.

References cmt_regexp::match(), and resolve_value().

Referenced by Use::action(), action(), ApplyPattern::action(), Fragment::action(), Tag::action_apply(), all_set(), DependencyGenerator::build(), MakeSetupGenerator::build(), Use::build_library_links(), CvsImplementation::clear(), CmtInstallAreaMgr::config(), Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), CmtModel::display(), Cmt::do_build_library_links(), Cmt::do_do(), Cmt::do_filter(), Cmt::do_remove_library_links(), install_library(), Constituent::parse(), CmtGenerator::prepare_use_context(), Use::set(), CmtGenerator::set_full_name(), and show_macro().

01753 {
01754   static cmt_regexp reg ("[$%`]");
01755 
01756   if (!reg.match (text)) return;
01757 
01758   resolve_value (text);
01759 }

Symbol * Symbol::find const cmt_string name  )  [static]
 

Definition at line 821 of file cmt_symbol.cxx.

References cmt_map< K, T >::find(), symbol_map(), and SymbolMap.

Referenced by DepsBuilder::add_includes(), Use::build_library_links(), CvsImplementation::clear(), CmtInstallAreaMgr::config(), Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), create(), Cmt::do_build_library_links(), Cmt::do_do(), Cmt::do_remove_library_links(), Cmt::do_show_action(), Cmt::do_show_macro(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), is_selected(), CmtLock::lock(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), Cmt::set_standard_macros(), CmtInstallAreaMgr::setup_current_installarea(), Use::show_sub_uses(), CmtLock::unlock(), and Fragment::wincopy().

00822 {
00823   static SymbolMap& SymbolMap = symbol_map ();
00824 
00825   Symbol* result = 0;
00826 
00827   result = SymbolMap.find (name);
00828 
00829   return (result);
00830 }

int Symbol::is_selected const cmt_string name  )  [static]
 

Definition at line 1013 of file cmt_symbol.cxx.

References SymbolValueList::command_type, CommandAction, CommandAlias, CommandMacro, CommandSet, CommandSetAppend, CommandSetPrepend, CommandSetRemove, CommandSetRemoveRegexp, SymbolValueList::discarded, find(), Tag::get_default(), Tag::is_selected(), cmt_vector< T >::size(), symbol(), SymbolValue::tag, value_lists, and SymbolValueList::values.

Referenced by StandardMacroBuilder::fill_for_branches(), StandardMacroBuilder::fill_for_constituent_macros(), StandardMacroBuilder::fill_for_fincludes(), StandardMacroBuilder::fill_for_includes(), StandardMacroBuilder::fill_for_package(), StandardMacroBuilder::fill_for_tag(), StandardMacroBuilder::fill_for_use_cflags(), StandardMacroBuilder::fill_for_use_cppflags(), StandardMacroBuilder::fill_for_use_fflags(), StandardMacroBuilder::fill_for_use_fincludes(), StandardMacroBuilder::fill_for_use_includes(), StandardMacroBuilder::fill_for_use_libraries(), StandardMacroBuilder::fill_for_use_linkopts(), StandardMacroBuilder::fill_for_use_pp_cflags(), StandardMacroBuilder::fill_for_use_pp_cppflags(), StandardMacroBuilder::fill_for_use_pp_fflags(), StandardMacroBuilder::fill_for_use_requirements(), StandardMacroBuilder::fill_for_use_stamps(), Cmt::set_standard_macros(), and CmtInstallAreaMgr::setup_current_installarea().

01014 {
01015   Symbol* symbol;
01016   int number;
01017   int value_number;
01018 
01019   symbol = find (name);
01020   if (symbol == 0) return (0);
01021 
01022   if (symbol->value_lists.size () == 0) return (0);
01023 
01024   for (number = 0;
01025        number < symbol->value_lists.size ();
01026        number++)
01027     {
01028       const SymbolValueList& value_list = symbol->value_lists[number];
01029 
01030       if (value_list.discarded) continue;
01031 
01032       if ((value_list.command_type == CommandMacro) ||
01033           (value_list.command_type == CommandSet) ||
01034           (value_list.command_type == CommandSetAppend) ||
01035           (value_list.command_type == CommandSetPrepend) ||
01036           (value_list.command_type == CommandSetRemove) ||
01037           (value_list.command_type == CommandSetRemoveRegexp) ||
01038           (value_list.command_type == CommandAlias) ||
01039           (value_list.command_type == CommandAction))
01040         {
01041           for (value_number = 0;
01042                value_number < value_list.values.size ();
01043                value_number++)
01044             {
01045               Tag* tag;
01046 
01047               SymbolValue& value = value_list.values[value_number];
01048 
01049               tag = value.tag;
01050               if ((tag == 0) ||
01051                   (tag == Tag::get_default ()) ||
01052                   (tag->is_selected () != 0))
01053                 {
01054                   return (1);
01055                 }
01056             }
01057         }
01058     }
01059 
01060   return (0);
01061 }

int Symbol::print PrintMode  mode  ) 
 

Definition at line 1499 of file cmt_symbol.cxx.

References Bat, build_macro_value(), Csh, name, Sh, cmt_string::size(), SymbolAlias, SymbolPath, SymbolSet, SymbolSetupScript, and type.

Referenced by all_print().

01500 {
01501   int result = 0;
01502   cmt_string temp;
01503 
01504   temp = build_macro_value ();
01505 
01506   bool empty = (temp.size () == 0) ? true : false;
01507 
01508   switch (type)
01509     {
01510       case SymbolSet :
01511       case SymbolPath :
01512         switch (mode)
01513           {
01514             case Csh :
01515               if (empty) cout << "unsetenv " << name;
01516               else cout << "setenv " << name << " \"" << temp << "\"";
01517 
01518               result = 1;
01519               break;
01520             case Sh :
01521               if (empty) cout << "unset " << name;
01522               else cout << name << "=\"" << temp << "\"; export " << name;
01523 
01524               result = 1;
01525               break;
01526             case Bat :
01527               temp.replace_all ("/", "\\");
01528               cout << "set " << name << "=" << temp;
01529               result = 1;
01530               break;
01531           }
01532         break;
01533       case SymbolAlias :
01534         switch (mode)
01535           {
01536             case Csh :
01537               cout << "alias " << name <<
01538                   " \"" << temp << "\"";
01539               result = 1;
01540               break;
01541             case Sh :
01542               cout << "alias " << name <<
01543                   "=\"" << temp << "\"";
01544               result = 1;
01545               break;
01546             case Bat :
01547               cout << "set " << name <<
01548                   "=" << temp;
01549               result = 1;
01550               break;
01551           }
01552         break;
01553       default :
01554         break;
01555     }
01556 
01557   if (temp != "")
01558     {
01559       switch (type)
01560         {
01561           case SymbolSetupScript :
01562             switch (mode)
01563               {
01564                 case Csh :
01565                   cout << "if ( -f " << name << ".csh ) then" << endl;
01566                   cout << "  source " << name << ".csh" << endl;
01567                   cout << "endif" << endl;
01568                   result = 1;
01569                   break;
01570                 case Sh :
01571                   cout << "if test -f " << name << ".sh; then" << endl;
01572                   cout << "  . " << name << ".sh" << endl;
01573                   cout << "fi" << endl;
01574                   result = 1;
01575                   break;
01576                 case Bat :
01577                   cout << "call " << name;
01578                   result = 1;
01579                   break;
01580               }
01581             break;
01582           default:
01583             break;
01584         }
01585     }
01586 
01587   return (result);
01588 }

int Symbol::print_clean PrintMode  mode  ) 
 

Definition at line 1408 of file cmt_symbol.cxx.

References Bat, clean_macro_value(), Csh, name, Sh, SymbolAlias, SymbolCleanupScript, SymbolPath, SymbolSet, and type.

Referenced by all_print_clean().

01409 {
01410   int result = 0;
01411   static cmt_string temp;
01412 
01413   if (name == "CMTCONFIG") return (0);
01414 
01415   switch (type)
01416     {
01417     case SymbolSet :
01418       switch (mode)
01419         {
01420         case Csh :
01421           cout << "unsetenv " << name;
01422           result = 1;
01423           break;
01424         case Sh :
01425           cout << "unset " << name;
01426           result = 1;
01427           break;
01428         case Bat :
01429           cout << "set " << name << "=";
01430           result = 1;
01431           break;
01432         }
01433       break;
01434     case SymbolAlias :
01435       switch (mode)
01436         {
01437           case Csh :
01438             cout << "unalias " << name;
01439             result = 1;
01440             break;
01441           case Sh :
01442             cout << "unset " << name;
01443             result = 1;
01444             break;
01445         }
01446       break;
01447     case SymbolPath :
01448       temp = clean_macro_value ();
01449       switch (mode)
01450         {
01451         case Csh :
01452           if (temp == "")
01453             {
01454               cout << "unsetenv " << name;
01455             }
01456           else
01457             {
01458               cout << "setenv " << name << " " << temp;
01459             }
01460           result = 1;
01461           break;
01462         case Sh :
01463           cout << name << "=" << temp << "; export " << name;
01464           result = 1;
01465           break;
01466         case Bat :
01467           cout << "set " << name << "=" << temp;
01468           result = 1;
01469           break;
01470         }
01471       break;
01472     case SymbolCleanupScript :
01473       switch (mode)
01474         {
01475         case Csh :
01476           cout << "if ( -f " << name << ".csh ) then" << endl;
01477           cout << "  source " << name << ".csh" << endl;
01478           cout << "endif" << endl;
01479           result = 1;
01480           break;
01481         case Sh :
01482           cout << "if test -f " << name << ".sh; then" << endl;
01483           cout << "  . " << name << ".sh" << endl;
01484           cout << "fi" << endl;
01485           result = 1;
01486           break;
01487         case Bat :
01488           cout << "call " << name;
01489           result = 1;
01490           break;
01491         }
01492       break;
01493     }
01494 
01495   return (result);
01496 }

cmt_string Symbol::resolve_macro_value const cmt_string tag_name = ""  ) 
 

Attempt to substitute into the symbol value all occurrences of.

${xxx} `xxx` xxx% [on Windows only]

by the appropriate value:

for `xxx` :

xxx is considered as a shell command. Value is the result of its execution

for other patterns:

if xxx is a symbol name, its value is substituted to the pattern otherwise, xxx is tried as an environment variable

===> In all cases, the pattern is filtered away.

Definition at line 1641 of file cmt_symbol.cxx.

References ValueBuilder::build(), builder, and resolve_value().

Referenced by DepsBuilder::add_includes(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), Use::show_sub_uses(), and Fragment::wincopy().

01642 {
01643   cmt_string temp = builder->build (*this, tag_name);
01644 
01645   resolve_value (temp);
01646 
01647   return (temp);
01648 }

void Symbol::show_macro PrintMode  mode  ) 
 

Definition at line 1651 of file cmt_symbol.cxx.

References action(), action_build_tag_makefile, action_load, action_show_action, action_show_action_value, action_show_actions, action_show_macro, action_show_macro_value, action_show_macros, action_show_set, action_show_set_value, action_show_sets, ActionType, build_macro_value(), expand(), Cmt::get_action(), Cmt::get_debug(), Cmt::get_quiet(), Make, name, cmt_string::size(), and suppress_OS_delimiters().

Referenced by Cmt::do_show_action(), Cmt::do_show_macro(), and Cmt::print_macros().

01652 {
01653   if (Cmt::get_debug ())
01654     {
01655       cout << "Symbol::show_macro> " << name << endl;
01656     }
01657 
01658   ActionType action = Cmt::get_action ();
01659 
01660   cmt_string value = build_macro_value (true);
01661 
01662   if ((!Cmt::get_quiet ()) &&
01663       (action != action_build_tag_makefile) &&
01664       (action != action_show_macros) &&
01665       (action != action_show_actions) &&
01666       (action != action_show_sets))
01667     {
01668       cout << "#" << endl;
01669       cout << "# Selection : " << endl;
01670     }
01671 
01672   if (value.size () > 0)
01673     {
01674       if ((action == action_show_macro) ||
01675           (action == action_show_macros) ||
01676           (action == action_show_sets) ||
01677           (action == action_show_set) ||
01678           (action == action_show_actions) ||
01679           (action == action_show_action) ||
01680           (action == action_build_tag_makefile) ||
01681           (action == action_load) ||
01682           (!Cmt::get_quiet ()))
01683         {
01684           if (mode == Make)
01685             {
01686               cout << name << "=";
01687             }
01688           else
01689             {
01690               cout << name << "='";
01691             }
01692         }
01693 
01694       if ((action == action_show_macro_value) ||
01695           (action == action_show_set_value) ||
01696           (action == action_show_action_value))
01697         {
01698           expand (value);
01699         }
01700       else if (action == action_build_tag_makefile)
01701         {
01702             /* 
01703                Unfortunately, the %xxx% pattern has to be kept on Unix. Therefore
01704                we cannot force all patterns to become $(xxx)
01705 
01706                This was useful on Windows so as to only keep $(xxx)
01707              */
01708 #ifdef WIN32
01709           suppress_OS_delimiters (value);
01710 #endif
01711         }
01712 
01713       cout << value;
01714 
01715       if ((action == action_show_macro) ||
01716           (action == action_show_macros) ||
01717           (action == action_show_sets) ||
01718           (action == action_show_set) ||
01719           (action == action_show_actions) ||
01720           (action == action_show_action) ||
01721           (action == action_build_tag_makefile) ||
01722           (action == action_load) ||
01723           (!Cmt::get_quiet ()))
01724         {
01725           if (mode != Make)
01726             {
01727               cout << "'";
01728             }
01729 #ifdef WIN32
01730           else
01731             {
01732               cout << " ";
01733             }
01734 #endif
01735         }
01736 
01737       cout << endl;
01738     }
01739 }

Symbol & Symbol::symbol int  index  )  [static]
 

Definition at line 859 of file cmt_symbol.cxx.

References symbols(), and SymbolVector.

Referenced by action(), all_print(), all_print_clean(), all_set(), check_tag_used(), create(), is_selected(), Constituent::parse_all(), Cmt::print_macros(), and Cmt::print_symbol_names().

00860 {
00861   static SymbolVector& Symbols = symbols ();
00862 
00863   return (Symbols[index]);
00864 }

Symbol::SymbolMap & Symbol::symbol_map  )  [static]
 

Definition at line 850 of file cmt_symbol.cxx.

References Database::instance(), Database::symbol_map(), and SymbolMap.

Referenced by clear_all(), create(), and find().

00851 {
00852   static Database& db = Database::instance ();
00853   static SymbolMap& SymbolMap = db.symbol_map ();
00854 
00855   return (SymbolMap);
00856 }

int Symbol::symbol_number  )  [static]
 

Definition at line 833 of file cmt_symbol.cxx.

References cmt_vector< T >::size(), symbols(), and SymbolVector.

Referenced by all_print(), all_set(), check_tag_used(), Constituent::parse_all(), Cmt::print_macros(), and Cmt::print_symbol_names().

00834 {
00835   static SymbolVector& Symbols = symbols ();
00836 
00837   return (Symbols.size ());
00838 }

Symbol::SymbolVector & Symbol::symbols  )  [static]
 

Definition at line 841 of file cmt_symbol.cxx.

References Database::instance(), Database::symbols(), and SymbolVector.

Referenced by all_print(), all_print_clean(), all_set(), check_tag_used(), clear_all(), create(), symbol(), and symbol_number().

00842 {
00843   static Database& db = Database::instance ();
00844   static SymbolVector& Symbols = db.symbols ();
00845 
00846   return (Symbols);
00847 }

bool Symbol::value_is_reflexive const cmt_string text  )  const
 

Characterizes if a value is provided as the reference to itself.

Definition at line 1077 of file cmt_symbol.cxx.

References name, and cmt_string::size().

Referenced by add_value_to_list(), ActionBuilder::build(), MacroBuilder::build(), PathBuilder::build(), and SetBuilder::build().

01078 {
01079   bool result = false;
01080   int text_length = text.size ();
01081 
01082   if (text_length == (name.size () + 3))
01083     {
01084       static cmt_string temp;
01085               
01086       if (text[0] == '$')
01087         {
01088           if (text[1] == '(')
01089             {
01090               temp = "$(";
01091               temp += name;
01092               temp += ")";
01093               
01094               if (text == temp)
01095                 {
01096                   result = true;
01097                 }
01098             }
01099           else if (text[1] == '{')
01100             {
01101               temp = "${";
01102               temp += name;
01103               temp += "}";
01104               
01105               if (text == temp)
01106                 {
01107                   result = true;
01108                 }
01109             }
01110         }
01111     }
01112   else if (text_length == (name.size () + 2))
01113     {
01114       static cmt_string temp;
01115 
01116       temp = "%";
01117       temp += name;
01118       temp += "%";
01119 
01120       if (text == temp)
01121         {
01122           result = true;
01123         }
01124     }
01125 
01126   return (result);
01127 }


Member Data Documentation

ValueBuilder* Symbol::builder
 

Definition at line 117 of file cmt_symbol.h.

Referenced by build_macro_value(), clean_macro_value(), create(), and resolve_macro_value().

cmt_string Symbol::name
 

Definition at line 119 of file cmt_symbol.h.

Referenced by action(), all_set(), ActionBuilder::build(), ScriptBuilder::build(), MacroBuilder::build(), PathBuilder::build(), SetBuilder::build(), PathBuilder::clean(), create(), Constituent::parse_all(), print(), print_clean(), Cmt::print_macros(), Cmt::print_symbol_names(), SymbolValueList::show(), show_macro(), Symbol(), and value_is_reflexive().

ScopeType Symbol::scope
 

Definition at line 120 of file cmt_symbol.h.

Referenced by create().

int Symbol::selected_value
 

Definition at line 125 of file cmt_symbol.h.

Referenced by create().

SymbolType Symbol::type
 

Definition at line 121 of file cmt_symbol.h.

Referenced by all_print(), all_print_clean(), all_set(), create(), Cmt::do_show_action(), Cmt::do_show_macro(), Constituent::parse_all(), print(), print_clean(), Cmt::print_macros(), Cmt::print_symbol_names(), and resolve_value_for_macros().

SymbolValueList::SymbolValueListVector Symbol::value_lists
 

Definition at line 123 of file cmt_symbol.h.

Referenced by add_value_to_list(), ActionBuilder::build(), ScriptBuilder::build(), MacroBuilder::build(), PathBuilder::build(), SetBuilder::build(), check_tag_used(), PathBuilder::clean(), create(), Cmt::do_show_action(), Cmt::do_show_macro(), is_selected(), Constituent::parse_all(), and Cmt::print_macros().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:26:03 2005 for CMT by doxygen 1.3.5