*/
#include "scope.hh"
-#include "dictionary-iter.hh"
-#include "debug.hh"
#include "identifier.hh"
-#include "dictionary.hh"
-#include "protected-scm.hh"
+#include "scm-hash.hh"
-void
-Scope::print () const
-{
-#ifndef NPRINT
- bool init_b = false; // ugh
- for (Scope_iter ai (*this); ai.ok(); ai++)
- {
- if (ai.val()->init_b_ == init_b)
- {
- DEBUG_OUT << ai.key() << "=";
- ai.val()->print ();
- }
- }
-#endif
-}
Scope::~Scope ()
{
- for (Scope_iter ai (*this); ai.ok(); ai++)
- {
- DEBUG_OUT << "deleting: " << ai.key() << '\n';
- delete ai.val ();
- }
- delete id_dict_;
+ scm_unprotect_object (id_dict_->self_scm ());
}
Scope::Scope (Scope const&s)
{
- id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
- for (Scope_iter ai (s); ai.ok(); ai++)
- {
- id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
- }
+ id_dict_ =new Scheme_hash_table (*s.id_dict_);
}
-unsigned int ly_pscm_hash (Protected_scm s)
-{
- return ly_scm_hash (s);
-}
-
-
Scope::Scope ()
{
- id_dict_ = new Hash_table<Protected_scm,Identifier*>;
- id_dict_->hash_func_ = ly_pscm_hash;
+ id_dict_ = new Scheme_hash_table;
}
bool
}
-Identifier *&
-Scope::elem (String s)
+bool
+Scope::elem_b (SCM s) const
{
- return id_dict_->elem (ly_symbol2scm (s.ch_C()));
+ return id_dict_->elem_b (s);
}
-
-
-Scope_iter::Scope_iter (Scope const &s)
+Identifier*
+Scope::elem (SCM s)const
{
- iter_ = new Hash_table_iter<Protected_scm,Identifier*>(*s.id_dict_);
+ return unsmob_identifier (id_dict_->get (s));
}
-String
-Scope_iter::key () const
+SCM
+Scope::scm_elem (SCM s)const
{
- SCM s= iter_->key ();
- return ly_symbol2string (s);
+ return id_dict_->get (s);
}
-bool
-Scope::elem_b (SCM s) const
+SCM
+Scope::scm_elem (String s) const
{
- return id_dict_->elem_b (s);
+ return scm_elem (ly_symbol2scm (s.ch_C()));
}
-Identifier* &
-Scope::elem (SCM s)
+Identifier*
+Scope::elem (String s)const
{
- return id_dict_->elem (s);
+ return elem (ly_symbol2scm (s.ch_C()));
}
-SCM
-Scope_iter::scm_key () const
+void
+Scope::set (String s, SCM id)
{
- return iter_->key ();
+ return id_dict_->set (ly_symbol2scm (s.ch_C()), id);
}
-bool
-Scope_iter::ok () const
+void
+Scope::set (String s, Identifier * id)
{
- return iter_->ok();
+ return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
}
-void
-Scope_iter::operator ++(int)
+SCM
+Scope::to_alist () const
{
- (*iter_) ++;
+ return id_dict_->to_alist ();
}
-Identifier*
-Scope_iter::val ()const
+bool
+Scope::try_retrieve (SCM k , SCM *v)const
{
- return iter_->val ();
+ return id_dict_->try_retrieve (k, v);
}
+