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

Symbol Class Reference

#include <cmt_symbol.h>

Collaboration diagram for Symbol:

[legend]
List of all members.

Public Types

typedef cmt_vector< Symbol >? SymbolVector
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

Symbol *? create (const cmt_string &name, CommandType command, Use *use=0)
Symbol *? find (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 ()
SymbolVector &? symbols ()
SymbolMap &? symbol_map ()
Symbol &? symbol (int index)
void? clear_all ()
void? expand (cmt_string &text)
bool? check_tag_used (Tag *tag)

Public Attributes

ValueBuilder *? builder
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          
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     //     $()
01179     //     ${}
01180     //     %%
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 1378 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().

01379 {
01380   static SymbolVector& Symbols = symbols ();
01381 
01382   int number;
01383 
01384   if (Symbols.size () == 0) return;
01385 
01386   for (number = 0; number < Symbol::symbol_number (); number++)
01387     {
01388       Symbol& symbol = Symbol::symbol (number);
01389 
01390       if ((symbol.type == SymbolSet) ||
01391           (symbol.type == SymbolAlias) ||
01392           (symbol.type == SymbolSetupScript))
01393         {
01394           if (symbol.print (mode))
01395             {
01396               if (mode == Bat)
01397                 {
01398                   cout << endl;
01399                 }
01400               else
01401                 {
01402                   //cout << "; ";
01403                   cout << endl;
01404                 }
01405             }
01406         }
01407     }
01408 
01409   for (number = 0; number < Symbol::symbol_number (); number++)
01410     {
01411       Symbol& symbol = Symbol::symbol (number);
01412 
01413       if ((symbol.type != SymbolPath)) continue;
01414 
01415       if (symbol.print (mode))
01416         {
01417           if (mode == Bat)
01418             {
01419               cout << endl;
01420             }
01421           else
01422             {
01423               //cout << "; ";
01424               cout << endl;
01425             }
01426         }
01427     }
01428 }

void Symbol::all_print_clean (? PrintMode? mode ?)? [static]
?

Definition at line 1431 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().

01432 {
01433   static SymbolVector& Symbols = symbols ();
01434 
01435   int number;
01436 
01437   if (Symbols.size () == 0) return;
01438 
01439   for (number = Symbols.size () - 1; number >= 0; number--)
01440     {
01441       Symbol& symbol = Symbols[number];
01442 
01443       if ((symbol.type == SymbolSet) ||
01444           (symbol.type == SymbolAlias) ||
01445           (symbol.type == SymbolCleanupScript))
01446         {
01447           if (symbol.print_clean (mode))
01448             {
01449               cout << endl;
01450             }
01451         }
01452     }
01453 
01454   for (number = Symbols.size () - 1; number >= 0; number--)
01455     {
01456       Symbol& symbol = Symbols[number];
01457 
01458       if ((symbol.type != SymbolPath)) continue;
01459 
01460       if (symbol.print_clean (mode))
01461         {
01462           cout << endl;
01463         }
01464     }
01465 }

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, Use::current(), Use::discarded, expand(), Cmt::get_all_sets_done(), CmtSystem::get_cmt_config(), Cmt::get_debug(), Use::get_full_path(), Use::get_ordered_uses(), Use::get_package_name(), Use::get_strategy(), name, Use::prefix, CmtSystem::putenv(), cmt_string::replace_all(), Cmt::set_all_sets_done(), cmt_vector< T >::size(), symbol(), symbol_number(), SymbolPath, symbols(), SymbolSet, SymbolVector, type, and Use::UsePtrVector.

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   Use::UsePtrVector& Uses = Use::get_ordered_uses ();
01250 
01251   static CmtSystem::cmt_string_vector envs;
01252 
01253   envs.clear ();
01254 
01255   int number;
01256 
01257   if (Symbols.size () == 0) 
01258     {
01259         //running = false;
01260       return;
01261     }
01262 
01263   cmt_string value;
01264 
01265   for (number = 0; number < Symbol::symbol_number (); number++)
01266     {
01267       Symbol& symbol = Symbol::symbol (number);
01268 
01269       if (symbol.type != SymbolSet) continue;
01270 
01271       value = symbol.build_macro_value ();
01272       if (value != "")
01273         {
01274           cmt_string& temp = envs.add ();
01275 
01276           temp = symbol.name;
01277           temp += '=';
01278           temp += value;
01279         }
01280     }
01281 
01282   cmt_string cmtconfig = CmtSystem::get_cmt_config ();
01283 
01284   if (Uses.size () > 0)
01285     {
01286       int number;
01287 
01288       for (number = 0; number < Uses.size (); number++)
01289         {
01290           Use& use = *(Uses[number]);
01291 
01292           if (use.discarded) continue;
01293 
01294           if (use.get_package_name () == "cmt_standalone") continue;
01295 
01296           if (use.get_strategy ("SetupConfig"))
01297             {
01298               cmt_string& temp = envs.add ();
01299 
01300               temp = use.prefix;
01301               temp += "CONFIG=";
01302               temp += cmtconfig;
01303             }
01304 
01305           if (use.get_strategy ("SetupRoot"))
01306             {
01307               cmt_string& temp = envs.add ();
01308 
01309               temp = use.prefix;
01310               temp += "ROOT=";
01311               temp += use.get_full_path ();
01312             }
01313         }
01314     }
01315 
01316   {
01317     Use& use = Use::current ();
01318 
01319     if (use.get_package_name () != "cmt_standalone")
01320       {
01321         if (use.get_strategy ("SetupConfig"))
01322           {
01323             cmt_string& temp = envs.add ();
01324             
01325             temp = use.prefix;
01326             temp += "CONFIG=";
01327             temp += cmtconfig;
01328           }
01329         
01330         if (use.get_strategy ("SetupRoot"))
01331           {
01332             cmt_string& temp = envs.add ();
01333             
01334             temp = use.prefix;
01335             temp += "ROOT=";
01336             temp += use.get_full_path ();
01337           }
01338       }
01339   }
01340 
01341   for (number = 0; number < Symbol::symbol_number (); number++)
01342     {
01343       Symbol& symbol = Symbol::symbol (number);
01344 
01345       if ((symbol.type != SymbolPath)) continue;
01346 
01347       value = symbol.build_macro_value ();
01348       if (value != "")
01349         {
01350           cmt_string& temp = envs.add ();
01351 
01352           temp = symbol.name;
01353           temp += '=';
01354           temp += value;
01355         }
01356     }
01357 
01358   for (number = 0; number < envs.size (); number++)
01359     {
01360       cmt_string& env = envs[number];
01361       Symbol::expand (env);
01362 
01363 #ifdef WIN32
01364       env.replace_all ("/", "\\");
01365 #endif
01366 
01367       if (Cmt::get_debug ())
01368         {
01369           cout << "Symbol::all_set> " << env << endl;
01370         }
01371       CmtSystem::putenv (env);
01372     }
01373 
01374     //running = false;
01375 }

cmt_string Symbol::build_macro_value (? bool? display_it = false ?)? const
?

Definition at line 1651 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().

01652 {
01653   cmt_string temp;
01654 
01655   if (display_it)
01656     {
01657       temp = builder->build_and_display (*this);
01658     }
01659   else
01660     {
01661       temp = builder->build (*this);
01662     }
01663 
01664   return (temp);
01665 }

bool Symbol::check_tag_used (? Tag *? tag ?)? [static]
?

Definition at line 2918 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().

02919 {
02920   if (tag == 0) return (false);
02921 
02922   static SymbolVector& Symbols = symbols ();
02923 
02924   if (Symbols.size () == 0) 
02925     {
02926       return (false);
02927     }
02928 
02929   for (int number = 0; number < Symbol::symbol_number (); number++)
02930     {
02931       Symbol& symbol = Symbol::symbol (number);
02932 
02933       for (int i = 0; i < symbol.value_lists.size (); i++)
02934         {
02935           const SymbolValueList& value_list = symbol.value_lists[i];
02936 
02937           for (int j = 0; j < value_list.values.size (); j++)
02938             {
02939               const SymbolValue& value = value_list.values[j];
02940               Tag* t = value.tag;
02941 
02942               if (t != 0)
02943                 {
02944                   if (t->use_operand (tag)) return (true);
02945                 }
02946             }
02947         }
02948     }
02949 
02950   return (false);
02951 }

cmt_string Symbol::clean_macro_value (? ?)? const
?

Definition at line 1668 of file cmt_symbol.cxx.

References builder, and ValueBuilder::clean().

Referenced by print_clean().

01669 {
01670   cmt_string temp;
01671 
01672   temp = builder->clean (*this);
01673 
01674   return (temp);
01675 }

void Symbol::clear_all (? ?)? [static]
?

Definition at line 1802 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().

01803 {
01804   static SymbolVector& Symbols = symbols ();
01805   static SymbolMap& SymbolMap = symbol_map ();
01806 
01807   SymbolMap.clear ();
01808   Symbols.clear ();
01809 }

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 1812 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(), Include::parse(), Constituent::parse(), CmtGenerator::prepare_use_context(), Use::set(), CmtGenerator::set_full_name(), and show_macro().

01813 {
01814   static cmt_regexp reg ("[$%`]");
01815 
01816   if (!reg.match (text)) return;
01817 
01818   resolve_value (text);
01819 }

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 1559 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().

01560 {
01561   int result = 0;
01562   cmt_string temp;
01563 
01564   temp = build_macro_value ();
01565 
01566   bool empty = (temp.size () == 0) ? true : false;
01567 
01568   switch (type)
01569     {
01570       case SymbolSet :
01571       case SymbolPath :
01572         switch (mode)
01573           {
01574             case Csh :
01575               if (empty) cout << "unsetenv " << name;
01576               else cout << "setenv " << name << " \"" << temp << "\"";
01577 
01578               result = 1;
01579               break;
01580             case Sh :
01581               if (empty) cout << "unset " << name;
01582               else cout << name << "=\"" << temp << "\"; export " << name;
01583 
01584               result = 1;
01585               break;
01586             case Bat :
01587               temp.replace_all ("/", "\\");
01588               cout << "set " << name << "=" << temp;
01589               result = 1;
01590               break;
01591           }
01592         break;
01593       case SymbolAlias :
01594         switch (mode)
01595           {
01596             case Csh :
01597               cout << "alias " << name <<
01598                   " \"" << temp << "\"";
01599               result = 1;
01600               break;
01601             case Sh :
01602               cout << "alias " << name <<
01603                   "=\"" << temp << "\"";
01604               result = 1;
01605               break;
01606             case Bat :
01607               cout << "set " << name <<
01608                   "=" << temp;
01609               result = 1;
01610               break;
01611           }
01612         break;
01613       default :
01614         break;
01615     }
01616 
01617   if (temp != "")
01618     {
01619       switch (type)
01620         {
01621           case SymbolSetupScript :
01622             switch (mode)
01623               {
01624                 case Csh :
01625                   cout << "if ( -f " << name << ".csh ) then" << endl;
01626                   cout << "  source " << name << ".csh" << endl;
01627                   cout << "endif" << endl;
01628                   result = 1;
01629                   break;
01630                 case Sh :
01631                   cout << "if test -f " << name << ".sh; then" << endl;
01632                   cout << "  . " << name << ".sh" << endl;
01633                   cout << "fi" << endl;
01634                   result = 1;
01635                   break;
01636                 case Bat :
01637                   cout << "call " << name;
01638                   result = 1;
01639                   break;
01640               }
01641             break;
01642           default:
01643             break;
01644         }
01645     }
01646 
01647   return (result);
01648 }

int Symbol::print_clean (? PrintMode? mode ?)?
?

Definition at line 1468 of file cmt_symbol.cxx.

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

Referenced by all_print_clean().

01469 {
01470   int result = 0;
01471   static cmt_string temp;
01472 
01473   if (name == "CMTCONFIG") return (0);
01474 
01475   switch (type)
01476     {
01477     case SymbolSet :
01478       switch (mode)
01479         {
01480         case Csh :
01481           cout << "unsetenv " << name;
01482           result = 1;
01483           break;
01484         case Sh :
01485           cout << "unset " << name;
01486           result = 1;
01487           break;
01488         case Bat :
01489           cout << "set " << name << "=";
01490           result = 1;
01491           break;
01492         }
01493       break;
01494     case SymbolAlias :
01495       switch (mode)
01496         {
01497           case Csh :
01498             cout << "unalias " << name;
01499             result = 1;
01500             break;
01501           case Sh :
01502             cout << "unset " << name;
01503             result = 1;
01504             break;
01505         }
01506       break;
01507     case SymbolPath :
01508       temp = clean_macro_value ();
01509       switch (mode)
01510         {
01511         case Csh :
01512           if (temp == "")
01513             {
01514               cout << "unsetenv " << name;
01515             }
01516           else
01517             {
01518               cout << "setenv " << name << " " << temp;
01519             }
01520           result = 1;
01521           break;
01522         case Sh :
01523           cout << name << "=" << temp << "; export " << name;
01524           result = 1;
01525           break;
01526         case Bat :
01527           cout << "set " << name << "=" << temp;
01528           result = 1;
01529           break;
01530         }
01531       break;
01532     case SymbolCleanupScript :
01533       switch (mode)
01534         {
01535         case Csh :
01536           cout << "if ( -f " << name << ".csh ) then" << endl;
01537           cout << "  source " << name << ".csh" << endl;
01538           cout << "endif" << endl;
01539           result = 1;
01540           break;
01541         case Sh :
01542           cout << "if test -f " << name << ".sh; then" << endl;
01543           cout << "  . " << name << ".sh" << endl;
01544           cout << "fi" << endl;
01545           result = 1;
01546           break;
01547         case Bat :
01548           cout << "call " << name;
01549           result = 1;
01550           break;
01551         }
01552       break;
01553     }
01554 
01555   return (result);
01556 }

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 1701 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().

01702 {
01703   cmt_string temp = builder->build (*this, tag_name);
01704 
01705   resolve_value (temp);
01706 
01707   return (temp);
01708 }

void Symbol::show_macro (? PrintMode? mode ?)?
?

Definition at line 1711 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().

01712 {
01713   if (Cmt::get_debug ())
01714     {
01715       cout << "Symbol::show_macro> " << name << endl;
01716     }
01717 
01718   ActionType action = Cmt::get_action ();
01719 
01720   cmt_string value = build_macro_value (true);
01721 
01722   if ((!Cmt::get_quiet ()) &&
01723       (action != action_build_tag_makefile) &&
01724       (action != action_show_macros) &&
01725       (action != action_show_actions) &&
01726       (action != action_show_sets))
01727     {
01728       cout << "#" << endl;
01729       cout << "# Selection : " << endl;
01730     }
01731 
01732   if (value.size () > 0)
01733     {
01734       if ((action == action_show_macro) ||
01735           (action == action_show_macros) ||
01736           (action == action_show_sets) ||
01737           (action == action_show_set) ||
01738           (action == action_show_actions) ||
01739           (action == action_show_action) ||
01740           (action == action_build_tag_makefile) ||
01741           (action == action_load) ||
01742           (!Cmt::get_quiet ()))
01743         {
01744           if (mode == Make)
01745             {
01746               cout << name << "=";
01747             }
01748           else
01749             {
01750               cout << name << "='";
01751             }
01752         }
01753 
01754       if ((action == action_show_macro_value) ||
01755           (action == action_show_set_value) ||
01756           (action == action_show_action_value))
01757         {
01758           expand (value);
01759         }
01760       else if (action == action_build_tag_makefile)
01761         {
01762             /* 
01763                Unfortunately, the %xxx% pattern has to be kept on Unix. Therefore
01764                we cannot force all patterns to become $(xxx)
01765 
01766                This was useful on Windows so as to only keep $(xxx)
01767              */
01768 #ifdef WIN32
01769           suppress_OS_delimiters (value);
01770 #endif
01771         }
01772 
01773       cout << value;
01774 
01775       if ((action == action_show_macro) ||
01776           (action == action_show_macros) ||
01777           (action == action_show_sets) ||
01778           (action == action_show_set) ||
01779           (action == action_show_actions) ||
01780           (action == action_show_action) ||
01781           (action == action_build_tag_makefile) ||
01782           (action == action_load) ||
01783           (!Cmt::get_quiet ()))
01784         {
01785           if (mode != Make)
01786             {
01787               cout << "'";
01788             }
01789 #ifdef WIN32
01790           else
01791             {
01792               cout << " ";
01793             }
01794 #endif
01795         }
01796 
01797       cout << endl;
01798     }
01799 }

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 Sep 5 16:31:47 2005 for CMT by 1.3.5