]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scope.cc
release: 1.5.4
[lilypond.git] / lily / scope.cc
index 39e91b3065d23539eb61b6daa40a5623ba3156a5..f578433a800d1e39ec5d8e71a96e6adfde95a3b3 100644 (file)
@@ -3,97 +3,61 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "scope.hh"
-#include "dictionary-iter.hh"
-#include "debug.hh"
-#include "identifier.hh"
+#include "string.hh"
+#include "scm-hash.hh"
 
-void
-Scope::print () const
-{
-  bool init_b = false;         // ugh
-  for (Scope_iter ai (*this);  ai.ok(); ai++)
-    {
-      if (ai.val()->init_b_ == init_b)
-       {
-         DOUT << ai.key() << "=";
-         ai.val()->print ();
-       }
-    }
-}
-
-Scope::~Scope ()
+Scope::Scope (Scheme_hash_table * st)
 {
-  for (Scope_iter       ai (*this); ai.ok(); ai++)
-    {
-      DOUT << "deleting: " << ai.key() << '\n';
-      delete ai.val ();
-    }
+  assert (st);
+  id_dict_ =st;
 }
 
-Scope::Scope (Scope const&s)
-  : Hash_table<Protected_scm,Identifier*> (s)
+bool
+Scope::elem_b (String s) const
 {
-  for (Scope_iter ai (s); ai.ok(); ai++)
-    {
-      (*this)[ai.scm_key ()] = ai.val ()->clone ();
-    }
+  return id_dict_->elem_b (ly_symbol2scm (s.ch_C ()));
 }
 
-unsigned int scm_hash (Protected_scm s)
+bool
+Scope::elem_b (SCM s) const
 {
-  return scm_ihashv (s, ~1u);
+  return id_dict_->elem_b (s);
 }
 
-Scope::Scope ()
-{
-  hash_func_ = scm_hash;
-}
 
-bool
-Scope::elem_b (String s) const
+SCM
+Scope::scm_elem (SCM s)const
 {
-  return elem_b (ly_symbol (s.ch_C()));
+  return id_dict_->get (s);
 }
 
-
-Identifier *&
-Scope::elem (String s) 
+SCM
+Scope::scm_elem (String s) const
 {
 return elem (ly_symbol (s.ch_C()));
return scm_elem (ly_symbol2scm (s.ch_C ()));
 }
 
 
-Scope_iter::Scope_iter (Scope const &s)
-  : Hash_table_iter<Protected_scm,Identifier*>(s)
+void
+Scope::set (String s, SCM id)
 {
+  return id_dict_->set (ly_symbol2scm (s.ch_C ()), id);
 }
 
-String
-Scope_iter::key () const
+SCM
+Scope::to_alist () const
 {
-  SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
-  return symbol_to_string (s);
+  return id_dict_->to_alist ();
 }
 
 bool
-Scope::elem_b (SCM s) const
+Scope::try_retrieve (SCM k , SCM *v)const
 {
-  return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
+  return id_dict_->try_retrieve (k, v);
 }
 
-Identifier* &
-Scope::elem (SCM s)
-{
-  return Hash_table<Protected_scm,Identifier*> ::elem (s);
-}
-
-SCM
-Scope_iter::scm_key () const
-{
-  return Hash_table_iter<Protected_scm,Identifier*>::key ();
-}