]> git.donarmstrong.com Git - lilypond.git/blob - lily/scope.cc
release: 1.3.0
[lilypond.git] / lily / scope.cc
1 /*   
2   scope.cc --  implement Scope
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "scope.hh"
11 #include "dictionary-iter.hh"
12 #include "debug.hh"
13 #include "identifier.hh"
14
15 void
16 Scope::print () const
17 {
18   bool init_b = false;          // ugh
19   for (Scope_iter ai (*this);  ai.ok(); ai++)
20     {
21       if (ai.val()->init_b_ == init_b)
22         {
23           DEBUG_OUT << ai.key() << "=";
24           ai.val()->print ();
25         }
26     }
27 }
28
29 Scope::~Scope ()
30 {
31   for (Scope_iter ai (*this); ai.ok(); ai++)
32     {
33       DEBUG_OUT << "deleting: " << ai.key() << '\n';
34       delete ai.val ();
35     }
36 }
37
38 Scope::Scope (Scope const&s)
39   : Hash_table<Protected_scm,Identifier*> (s)
40 {
41   for (Scope_iter ai (s); ai.ok(); ai++)
42     {
43       (*this)[ai.scm_key ()] = ai.val ()->clone ();
44     }
45 }
46
47 unsigned int ly_pscm_hash (Protected_scm s)
48 {
49   return ly_scm_hash (s);
50 }
51
52
53 Scope::Scope ()
54 {
55   hash_func_ = ly_pscm_hash;
56 }
57
58 bool
59 Scope::elem_b (String s) const
60 {
61   return elem_b (ly_symbol (s.ch_C()));
62 }
63
64
65 Identifier *&
66 Scope::elem (String s) 
67 {
68   return elem (ly_symbol (s.ch_C()));
69 }
70
71
72 Scope_iter::Scope_iter (Scope const &s)
73   : Hash_table_iter<Protected_scm,Identifier*>(s)
74 {
75 }
76
77 String
78 Scope_iter::key () const
79 {
80   SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
81   return symbol_to_string (s);
82 }
83
84 bool
85 Scope::elem_b (SCM s) const
86 {
87   return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
88 }
89
90 Identifier* &
91 Scope::elem (SCM s)
92 {
93   return Hash_table<Protected_scm,Identifier*> ::elem (s);
94 }
95
96 SCM
97 Scope_iter::scm_key () const
98 {
99   return Hash_table_iter<Protected_scm,Identifier*>::key ();
100 }