lilypond-1.1.44
[lilypond.git] / lily / scope.cc
blob2f8c56a3ed70a733c710f39f69d2349d4791d823
1 /*
2 scope.cc -- implement Scope
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "scope.hh"
11 #include "dictionary-iter.hh"
12 #include "debug.hh"
13 #include "identifier.hh"
15 void
16 Scope::print () const
18 bool init_b = false; // ugh
19 for (Scope_iter ai (*this); ai.ok(); ai++)
21 if (ai.val()->init_b_ == init_b)
23 DOUT << ai.key() << "=";
24 ai.val()->print ();
29 Scope::~Scope ()
31 for (Scope_iter ai (*this); ai.ok(); ai++)
33 DOUT << "deleting: " << ai.key() << '\n';
34 delete ai.val ();
38 Scope::Scope (Scope const&s)
39 : Hash_table<Protected_scm,Identifier*> (s)
41 for (Scope_iter ai (s); ai.ok(); ai++)
43 (*this)[ai.scm_key ()] = ai.val ()->clone ();
47 unsigned int scm_hash (Protected_scm s)
49 return scm_ihashv (s, ~1u);
52 Scope::Scope ()
54 hash_func_ = scm_hash;
57 bool
58 Scope::elem_b (String s) const
60 return elem_b (ly_symbol (s.ch_C()));
64 Identifier *&
65 Scope::elem (String s)
67 return elem (ly_symbol (s.ch_C()));
71 Scope_iter::Scope_iter (Scope const &s)
72 : Hash_table_iter<Protected_scm,Identifier*>(s)
76 String
77 Scope_iter::key () const
79 SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
80 return symbol_to_string (s);
83 bool
84 Scope::elem_b (SCM s) const
86 return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
89 Identifier* &
90 Scope::elem (SCM s)
92 return Hash_table<Protected_scm,Identifier*> ::elem (s);
95 SCM
96 Scope_iter::scm_key () const
98 return Hash_table_iter<Protected_scm,Identifier*>::key ();