2 scope.cc -- implement Scope
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "dictionary-iter.hh"
13 #include "identifier.hh"
14 #include "dictionary.hh"
15 #include "protected-scm.hh"
21 bool init_b = false; // ugh
22 for (Scope_iter ai (*this); ai.ok(); ai++)
24 if (ai.val()->init_b_ == init_b)
26 DEBUG_OUT << ai.key() << "=";
35 for (Scope_iter ai (*this); ai.ok(); ai++)
37 DEBUG_OUT << "deleting: " << ai.key() << '\n';
43 Scope::Scope (Scope const&s)
45 id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
46 for (Scope_iter ai (s); ai.ok(); ai++)
48 id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
52 unsigned int ly_pscm_hash (Protected_scm s)
54 return ly_scm_hash (s);
60 id_dict_ = new Hash_table<Protected_scm,Identifier*>;
61 id_dict_->hash_func_ = ly_pscm_hash;
65 Scope::elem_b (String s) const
67 return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
72 Scope::elem (String s)
74 return id_dict_->elem (ly_symbol2scm (s.ch_C()));
78 Scope_iter::Scope_iter (Scope const &s)
80 iter_ = new Hash_table_iter<Protected_scm,Identifier*>(*s.id_dict_);
84 Scope_iter::key () const
87 return ly_symbol2string (s);
91 Scope::elem_b (SCM s) const
93 return id_dict_->elem_b (s);
99 return id_dict_->elem (s);
103 Scope_iter::scm_key () const
105 return iter_->key ();
109 Scope_iter::ok () const
115 Scope_iter::operator ++(int)
121 Scope_iter::val ()const
123 return iter_->val ();