]> git.donarmstrong.com Git - lilypond.git/commitdiff
use SCM module in stead of
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 15 Sep 2002 23:35:55 +0000 (23:35 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 15 Sep 2002 23:35:55 +0000 (23:35 +0000)
Scheme_hash_table. Changes throughout.

(warning: doesn't run!)

21 files changed:
ChangeLog
configure.in
lily/grob-scheme.cc
lily/include/input-file-results.hh
lily/include/lily-guile.hh
lily/include/music-output-def.hh
lily/include/music-output.hh
lily/include/my-lily-lexer.hh
lily/include/paper-def.hh
lily/include/paper-outputter.hh
lily/include/score.hh
lily/input-file-results.cc
lily/lily-guile.cc
lily/midi-def.cc
lily/music-output-def.cc
lily/my-lily-lexer.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/paper-score.cc
lily/parser.yy
lily/score.cc

index c9f34af08ca122d588c065bf9d4d405f79044685..6f963bc6854c719679f8e6add4a69fa6bf5dc95c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-09-16  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/my-lily-lexer.cc: use SCM module in stead of
+       Scheme_hash_table. Changes throughout.  
+
 2002-09-15  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * VERSION (MY_PATCH_LEVEL): make 1.7.0
index 8162b5b0d46061490118bca362783dc42691f3aa..10300587a156338723c27e5d3ca6e1c96978f8a8 100644 (file)
@@ -29,7 +29,7 @@ STEPMAKE_GETTEXT
 STEPMAKE_MSGFMT(REQUIRED)
 STEPMAKE_TEXMF
 STEPMAKE_TEXMF_DIRS
-STEPMAKE_GUILE_DEVEL(REQUIRED, 1.4)
+STEPMAKE_GUILE_DEVEL(REQUIRED, 1.6)
 STEPMAKE_KPATHSEA
 STEPMAKE_MAKEINFO(REQUIRED)
 STEPMAKE_PYTHON_DEVEL(REQUIRED)
index 0e42044ba7d5f4599a4a38af48d056ce2e7eb4db..2cd6bb32d50503c168f96f067c5daf33762ec8d9 100644 (file)
@@ -64,6 +64,10 @@ left, and @code{1} for right.
   return sl->get_bound (to_dir (dir))->self_scm ();
 }
 
+/*
+  TODO: make difference between scaled and unscalead variable in
+  calling (i.e different funcs.)
+ */
 LY_DEFINE(ly_get_paper_var,"ly-get-paper-variable", 2, 0, 0,
   (SCM grob, SCM sym),
   "Get a variable from the \\paper block.")
@@ -72,7 +76,7 @@ LY_DEFINE(ly_get_paper_var,"ly-get-paper-variable", 2, 0, 0,
   SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
   SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");  
 
-  return sc->get_paper () ->get_scmvar_scm (sym);
+  return sc->get_paper () ->lookup_variable (sym);
 }
 
 
index 8b6e31582c734b64486e9bf07376b80b9ec1da30..1cd5c825ed52086cdf2a7005bc78fa50171cf3ae 100644 (file)
@@ -13,7 +13,7 @@
 #include "lily-proto.hh"
 #include "source.hh"
 #include "parray.hh"
-#include "scm-hash.hh"
+#include "protected-scm.hh"
 
 class Input_file_results
 {
@@ -22,8 +22,7 @@ public:
   Array<String> inclusion_names_;
   Array<String> target_strings_;
   Link_array<Score> scores_;
-  /* Global? prefix is bit confusing */
-  Scheme_hash_table * header_;
+  Protected_scm header_;
 
   void do_deps ();
   void do_scores ();
index e447afb5b1b356f5e638055db73a2fbabf2f0e70..056ca65d6eadc7a075fc9456f3736eeadfddccf2 100644 (file)
@@ -225,6 +225,12 @@ SCM index_set_cell (SCM cell, Direction d, SCM val);
 SCM ly_snoc (SCM s, SCM list);
 SCM ly_split_list (SCM s, SCM list);
 SCM ly_unique (SCM list);
+
+
+SCM ly_make_anonymous_module ();
+void ly_copy_module_variable (SCM dest, SCM src);
+SCM ly_module_to_alist (SCM mod);
+
 /*
   snarfing.
  */
index 0b554ffdec6e599da2585d98d97ec91ffb9649c0..b01a7e8a3f6313f2e088f72cd8e025152ba13e1f 100644 (file)
@@ -23,9 +23,8 @@ class Music_output_def
 {
 public:
   Scheme_hash_table * translator_tab_;
-  Scheme_hash_table * variable_tab_;  
-
 
+  SCM scope_;
   SCM scaled_fonts_;
   SCM style_sheet_;
   
@@ -39,8 +38,13 @@ public:
   void assign_translator (SCM transdef);
   SCM find_translator (SCM name) const;
   String outname_string () ;
+  SCM get_scmvar (String id)const;
+  SCM lookup_variable  (SCM sym) const;
+  void set_variable  (SCM, SCM sym);
   
   DECLARE_SMOBS (Music_output_def,);
+
+  
 };
 
 DECLARE_UNSMOB(Music_output_def,music_output_def);
index d8efb9314a0b1a758430e6134795ac10ba1174fe..4d2d41f5ce5155e58a118dc0197e240dd6923b21 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "string.hh"
 #include "lily-proto.hh"
+#include "protected-scm.hh"
 
 /**
   Output something that was defined in a lilypond file. 
@@ -19,7 +20,7 @@
 class Music_output 
 {
 public:
-  Scheme_hash_table * header_;
+  Protected_scm header_;
   String default_out_string_;
   String origin_string_;
   int errorlevel_;
index 8bdcd6ee47fbd39a36092d9945acd8fd08f67ba1..06449288ed14a011ce7747375f7d8fb68357fe84 100644 (file)
@@ -28,10 +28,10 @@ void set_lexer ();
 /// lexer for Lilypond
 class My_lily_lexer : public Includable_lexer 
 {
+  Protected_scm scopes_;
 public:
   String main_input_string_;
   void * lexval;
-  Scheme_hash_table * toplevel_variable_tab_;
   bool main_input_b_;
 
   /*
@@ -39,8 +39,6 @@ public:
    */
   Protected_scm chordmodifier_tab_;
   Protected_scm pitchname_tab_;
-  
-  Link_array<Scheme_hash_table> scopes_;
   Keyword_table * keytable_;
   int errorlevel_;
 
@@ -50,6 +48,9 @@ public:
 
   Input here_input () const;
 
+  void add_scope (SCM);
+  SCM remove_scope ();
+  
   void start_main_input ();
 
   SCM lookup_identifier (String s);
index b434c92759346c5c8768e568ad1fb97525c683ea..3acf25a85f2eb712cb53feb1a4d3582b507e69b7 100644 (file)
@@ -60,8 +60,6 @@ public:
    */
   Real get_realvar (SCM symbol) const;
   Real get_var (String id) const;
-  SCM get_scmvar (String id)const;
-  SCM get_scmvar_scm  (SCM sym) const;
   void reinit ();
   Paper_def ();
   Paper_def (Paper_def const&);
index 56defcc3b211408c523780f6d487880ed8eb1cd2..c36b38a53d5b3f118add57108b035fd92ef47a42 100644 (file)
@@ -43,7 +43,7 @@ public:
   void output_int_def (String k, int v);
   void output_Real_def (String k, Real v);
   void output_String_def (String k, String v);
-  void output_scope (Scheme_hash_table*, String prefix);
+  void output_scope (SCM, String prefix);
   void output_version ();
   void output_font_def (int i, String str);
   void output_font_switch (int i);
@@ -53,7 +53,7 @@ public:
   void output_scheme (SCM scm);
 
   void write_header_field_to_file (String filename, SCM, SCM);
-  void write_header_fields_to_file (Scheme_hash_table *);
+  void write_header_fields_to_file (SCM);
 };
 
 #endif // PAPER_OUTPUTTER_HH
index 2af42321e5a2f574748c8b93a570e4729041d2c7..414f4d5ef9c159c7546a70f4fbcb65f3e7aea0af 100644 (file)
@@ -22,7 +22,7 @@ public:
   /// paper_, staves_ and commands_ form the problem definition.
   Link_array<Music_output_def> defs_;
   SCM music_;
-  Scheme_hash_table * header_;
+  SCM header_;
   Input_file_results* input_file_;
   
   int errorlevel_;
index beb789209beae09a1912d47a4220730b87844f62..7ceb7b2cfc2ad30660caa75df1fe928dc673858d 100644 (file)
@@ -118,8 +118,8 @@ Input_file_results::do_deps ()
 void
 Input_file_results::do_scores ()
 {
-  if (!header_)
-    header_ = new Scheme_hash_table;
+  if (header_ == SCM_EOL)
+    header_ = ly_make_anonymous_module ();
 
   for (int i=0; i < scores_.size (); i++)
     {
@@ -147,7 +147,7 @@ Input_file_results::~Input_file_results ()
   
   inclusion_names_.clear ();
   if (header_)
-    scm_gc_unprotect_object (header_ ->self_scm ());
+    header_ = SCM_EOL;
 
   global_input_file =0;
 }
@@ -157,7 +157,7 @@ Input_file_results* global_input_file;
 
 Input_file_results::Input_file_results (String init_string, String file_string)
 {
-  header_ = 0;
+  header_ = SCM_EOL;
   global_input_file = this;
   ly_set_point_and_click_x (SCM_BOOL_F);
   
index 7a08f7d3f30227842b6c5068a2782368c70f2dee..680696c938142b0f4f507c590f3949a410b5a589 100644 (file)
@@ -198,7 +198,9 @@ void
 ly_init_guile ()
 {
   SCM last_mod = scm_current_module ();
-  scm_set_current_module (scm_c_resolve_module ("guile"));
+  scm_set_current_module (scm_c_resolve_module ("lily"));
+
+  scm_c_use_module ("guile");
   
   for (int i=scm_init_funcs_->size () ; i--;)
     (scm_init_funcs_->elem (i)) ();
@@ -703,3 +705,47 @@ robust_list_ref(int i, SCM l)
 
   return gh_car(l);
 }
+
+static int module_count;
+
+SCM
+ly_make_anonymous_module ()
+{
+  String s = "*anonymous-ly-" + to_string (module_count++) +  "*";
+  SCM mod = scm_c_resolve_module (s.to_str0());
+
+  scm_module_define (mod, ly_symbol2scm ("symbols-defined-here"), SCM_EOL);
+  return mod;
+}
+
+void
+ly_copy_module_variable (SCM dest, SCM src)
+{
+  SCM defd = ly_symbol2scm ("symbols-defined-here");
+  SCM dvar = scm_module_lookup (src, ly_symbol2scm ("symbols-defined-here"));
+  SCM lst =  scm_variable_ref (dvar);
+  for (SCM s =lst; gh_pair_p (s); s  = gh_cdr (s))
+    {
+      SCM var  = scm_module_lookup (src, gh_car (s));
+      scm_module_define (dest, gh_car (s),
+                        scm_variable_ref (var));
+    }
+
+  scm_module_define (dest, defd, lst);
+}
+
+SCM
+ly_module_to_alist (SCM mod)
+{
+  SCM defd = ly_symbol2scm ("symbols-defined-here");
+  SCM dvar = scm_module_lookup (mod, defd);
+  SCM lst = scm_variable_ref (dvar);
+
+  SCM alist =  SCM_EOL;
+  for (SCM s =lst; gh_pair_p (s); s  = gh_cdr (s))
+    {
+      SCM var  = scm_module_lookup (mod, gh_car (s));
+      alist= scm_cons (scm_cons (gh_car(s), scm_variable_ref (var)), alist);
+    }
+  return alist;
+}
index 2684973f564623e88e50ca2137d7eb7905d2fff8..853d56adafc0493e5f295bad4fc0e11c7f278fad 100644 (file)
@@ -23,7 +23,7 @@ int
 Midi_def::get_tempo (Moment one_beat_mom)
 {
   SCM wis  = ly_symbol2scm ("whole-in-seconds");
-  Moment *w = unsmob_moment (variable_tab_->get (wis));
+  Moment *w = unsmob_moment (lookup_variable (wis));
 
   Moment wholes_per_min = Moment (60);
   if (!w)
@@ -46,7 +46,7 @@ Midi_def::set_tempo (Moment one_beat_mom, int beats_per_minute_i)
   Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
 
   Moment m = Moment (1)/Moment (beats_per_second * one_beat_mom);
-  variable_tab_->set (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
+  set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
 }
 
 
index 4381e4f2ba4f9c93435345f8429a376a1c954796..401bcb08103da491252b856299ba7d943e58306d 100644 (file)
@@ -29,13 +29,14 @@ Music_output_def::Music_output_def ()
 {
   style_sheet_ = SCM_EOL;
   scaled_fonts_ = SCM_EOL;
-
-  variable_tab_ = new Scheme_hash_table;
+  
   translator_tab_ = new Scheme_hash_table;
-
+  scope_ = SCM_EOL;
+  
   smobify_self ();
-  scm_gc_unprotect_object (variable_tab_->self_scm ());
-  scm_gc_unprotect_object (translator_tab_->self_scm ());  
+  scm_gc_unprotect_object (translator_tab_->self_scm ());
+
+  scope_ =   ly_make_anonymous_module();
 }
 
 Music_output_def::~Music_output_def ()
@@ -44,18 +45,21 @@ Music_output_def::~Music_output_def ()
 
 Music_output_def::Music_output_def (Music_output_def const &s)
 {
-  variable_tab_ = new Scheme_hash_table (*s.variable_tab_);
+  scope_ = SCM_EOL;
   translator_tab_ = new Scheme_hash_table (*s.translator_tab_);
 
   style_sheet_ = SCM_EOL;
   scaled_fonts_ = SCM_EOL;
 
   smobify_self ();
-  scm_gc_unprotect_object (variable_tab_->self_scm ());
   scm_gc_unprotect_object (translator_tab_->self_scm ());  
   
   style_sheet_ = scm_list_copy (s.style_sheet_);
   scaled_fonts_ = scm_list_copy (s.scaled_fonts_);  
+
+  scope_= ly_make_anonymous_module ();
+  ly_copy_module_variable (scope_, s.scope_);
+
 }
 
 
@@ -69,7 +73,7 @@ Music_output_def::mark_smob (SCM m)
   Music_output_def * mo = (Music_output_def*) SCM_CELL_WORD_1 (m);
   scm_gc_mark (mo->style_sheet_);
   scm_gc_mark (mo->translator_tab_->self_scm ());
-  scm_gc_mark (mo->variable_tab_->self_scm ());
+  scm_gc_mark (mo->scope_);
 
   return mo->scaled_fonts_;
 }
@@ -149,3 +153,29 @@ Music_output_def::outname_string ()
     }
   return out;
 }
+
+
+
+SCM
+Music_output_def::get_scmvar (String s) const
+{
+  return lookup_variable (ly_symbol2scm (s.to_str0 ()));
+}
+
+
+void
+Music_output_def::set_variable (SCM sym, SCM val)
+{
+  scm_module_define (scope_, sym, val);
+  
+  SCM var = scm_module_lookup (scope_, ly_symbol2scm ("symbols-defined-here"));
+  scm_variable_set_x (var, gh_cons (sym,  scm_variable_ref (var)));
+}
+
+SCM
+Music_output_def::lookup_variable (SCM sym) const
+{
+  SCM var = scm_module_lookup (scope_, sym);
+
+  return scm_variable_ref (var);
+}
index 48005225d18c895bc4f3bf781d24df77ab1a55cb..ebe0302cf8739cd43c434b28d7ded26e67657244 100644 (file)
@@ -94,16 +94,35 @@ static Keyword_ent the_key_tab[]={
   {0,0}
 };
 
+
 My_lily_lexer::My_lily_lexer ()
 {
   keytable_ = new Keyword_table (the_key_tab);
-  toplevel_variable_tab_ = new Scheme_hash_table ;
-  scopes_.push (toplevel_variable_tab_);
+  scopes_ = SCM_EOL;
   
-  errorlevel_ = 0;
+  add_scope(ly_make_anonymous_module());
+
   main_input_b_ = false;
 }
 
+void
+My_lily_lexer::add_scope (SCM module)
+{
+  scm_set_current_module (module);
+  scopes_ = scm_cons (module, scopes_);
+}
+
+SCM
+My_lily_lexer::remove_scope ()
+{
+  SCM sc = gh_car (scopes_);
+  scopes_ = gh_cdr (scopes_);
+  scm_set_current_module (gh_car (scopes_));
+
+  return sc;
+}
+
+
 int
 My_lily_lexer::lookup_keyword (String s)
 {
@@ -113,14 +132,13 @@ My_lily_lexer::lookup_keyword (String s)
 SCM
 My_lily_lexer::lookup_identifier (String s)
 {
-  SCM sym = ly_symbol2scm (s.to_str0 ());
-  
-  for (int i = scopes_.size (); i--;)
-    {
-      SCM val = SCM_UNSPECIFIED;
-      if (scopes_[i]->try_retrieve (sym, &val))
-       return val;
-    }
+  SCM sym = ly_symbol2scm (s.to_str0());
+  for (SCM s = scopes_; gh_pair_p (s); s = gh_cdr (s))
+  {
+    SCM var = scm_module_lookup (gh_car (s), sym);
+    return scm_variable_ref (var);
+  }
+
   return SCM_UNSPECIFIED;
 }
 
@@ -143,14 +161,18 @@ My_lily_lexer::set_identifier (SCM name, SCM s)
       warning (_f ("Identifier name is a keyword: `%s'", str));
       free  (str);
     }
-  
-  scopes_.top ()->set (scm_string_to_symbol (name), s);
+
+  SCM sym = scm_string_to_symbol (name);
+  SCM mod = gh_car (scopes_);
+  SCM var = scm_module_lookup (mod, ly_symbol2scm ("symbols-defined-here"));
+
+  scm_variable_set_x (var, gh_cons (sym,  scm_variable_ref (var)));
+  scm_module_define (mod, sym, s);
 }
 
 My_lily_lexer::~My_lily_lexer ()
 {
   delete keytable_;
-  scm_gc_unprotect_object (toplevel_variable_tab_->self_scm ());
 }
 
 
index f6bf6ec19bd404f485e5b6200aed8ed5981942b8..8cc0f7ada5fac3037bf06a4b695fee227eba73a3 100644 (file)
@@ -47,44 +47,14 @@ Paper_def::get_var (String s) const
   return get_realvar (ly_symbol2scm (s.to_str0 ()));
 }
 
-SCM
-Paper_def::get_scmvar (String s) const
-{
-  return variable_tab_->get (ly_symbol2scm (s.to_str0 ()));
-}
-
-
-SCM
-Paper_def::get_scmvar_scm (SCM sym) const
-{
-  return  gh_double2scm (get_realvar (sym));
-}
-
 Real
 Paper_def::get_realvar (SCM s) const
 {
-  SCM val ;
-  if (!variable_tab_->try_retrieve (s, &val))
-    {
-      programming_error ("unknown paper variable: " +  ly_symbol2string (s));
-      return 0.0;
-    }
-
-  Real sc = 1.0;
-  SCM ssc;
-  if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
-    {
-      sc = gh_scm2double (ssc);
-    }
-  if (gh_number_p (val))
-    {
-      return gh_scm2double (val) / sc;
-    }
-  else
-    {
-      programming_error ("not a real variable");
-      return 0.0;
-    }
+  SCM val = lookup_variable (s);
+  SCM scale = lookup_variable (ly_symbol2scm ("outputscale"));
+  
+  Real sc = gh_scm2double (scale);
+  return gh_scm2double (val) / sc;
 }
 
 /*
@@ -158,11 +128,8 @@ Paper_def::find_font (SCM fn, Real m)
     }
   else
     {
-      SCM ssc;
-      if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
-       {
-         m /= gh_scm2double (ssc);
-       }
+      SCM var =  scm_module_lookup (scope_, ly_symbol2scm ("outputscale"));
+      m /= gh_scm2double (scm_variable_ref (var));
 
       f = all_fonts_global->find_font (ly_scm2string (fn));
       SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
index 2177afffcd08813f0be0441a2d65cbc61930475c..796f94079c2db0f6193f6c069ba5facd98fdd8ab 100644 (file)
@@ -92,9 +92,9 @@ Paper_outputter::output_scheme (SCM scm)
 }
 
 void
-Paper_outputter::output_scope (Scheme_hash_table *scope, String prefix)
+Paper_outputter::output_scope (SCM mod, String prefix)
 {
-  SCM al = scope->to_alist ();
+  SCM al = ly_module_to_alist (mod);
   for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s))
     {
       SCM k = ly_caar (s);
@@ -170,11 +170,12 @@ Paper_outputter::write_header_field_to_file (String filename, SCM key, SCM value
 }
 
 void
-Paper_outputter::write_header_fields_to_file (Scheme_hash_table * header)
+Paper_outputter::write_header_fields_to_file (SCM mod)
 {
+  
   if (dump_header_fieldnames_global.size ())
     {
-      SCM fields = header->to_alist ();
+      SCM fields = ly_module_to_alist (mod);
       for (int i = 0; i < dump_header_fieldnames_global.size (); i++)
        {
          String key = dump_header_fieldnames_global[i];
index 295ba1626521d45937bbe192d7fcf4daba905d52..077e5c2f0de818d133d9dc7930c6bdbf369a9f0e 100644 (file)
@@ -38,6 +38,7 @@ Paper_score::typeset_line (System *l)
     {
       system_ = l;             // ugh.
     }
+
   main_smob_ = gh_cons (l->self_scm (), main_smob_);
   l->pscore_ = this;
 
@@ -115,8 +116,7 @@ Paper_score::process ()
   outputter_->output_comment (_ ("Outputting Score, defined at: "));
   outputter_->output_comment (origin_string_);
 
-  if (paper_->variable_tab_)
-    outputter_->output_scope (paper_->variable_tab_, "lilypondpaper");
+  outputter_->output_scope (paper_->scope_, "lilypondpaper");
 
   SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
   outputter_->output_scheme (scm);
index 99ff6633534efbb7039a2bc11f6ff13e91075011..2754f6dd79ba0fc0a4d4cb98776d5ac6e1b79845 100644 (file)
@@ -274,7 +274,7 @@ yylex (YYSTYPE *s,  void * v)
 %token <scm>   REAL
 
 %type <outputdef> output_def
-%type <scmhash>        lilypond_header lilypond_header_body
+%type <scm>    lilypond_header lilypond_header_body
 %type <request>        open_request_parens close_request_parens open_request close_request
 %type <request> request_with_dir request_that_take_dir verbose_request
 %type <i>      sub_quotes sup_quotes
@@ -350,8 +350,6 @@ toplevel_expression:
                THIS->lexer_->chordmodifier_tab_  = $1;
        }
        | lilypond_header {
-               if (THIS->input_file_->header_)
-                       scm_gc_unprotect_object (THIS->input_file_->header_->self_scm ());
                THIS->input_file_->header_ = $1;
        }
        | score_block {
@@ -401,18 +399,17 @@ notenames_body:
 
 lilypond_header_body:
        {
-               $$ = new Scheme_hash_table;
-               THIS->lexer_-> scopes_.push ($$);
+               $$ = ly_make_anonymous_module (); 
+               THIS->lexer_->add_scope ($$);
        }
        | lilypond_header_body assignment  { 
-
+               
        }
        ;
 
 lilypond_header:
        HEADER '{' lilypond_header_body '}'     {
-               $$ = $3;
-               THIS->lexer_->scopes_.pop ();
+               $$ = THIS->lexer_-> remove_scope();
        }
        ;
 
@@ -588,7 +585,6 @@ score_body:
                $$->set_spot (THIS->here_input ());
        }
        | score_body lilypond_header    {
-               scm_gc_unprotect_object ($2->self_scm ()); 
                $$->header_ = $2;
        }
        | score_body output_def {
@@ -606,23 +602,23 @@ score_body:
 output_def:
        music_output_def_body '}' {
                $$ = $1;
-               THIS-> lexer_-> scopes_.pop ();
+               THIS-> lexer_-> remove_scope ();
        }
        ;
 
 music_output_def_body:
        MIDI '{'    {
-          Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
+               Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
 
-               
-        Midi_def* p =0;
-       if (id)
-               p = dynamic_cast<Midi_def*> (id->clone ());
-       else
-               p = new Midi_def;
 
-        $$ = p;
-        THIS->lexer_->scopes_.push (p->variable_tab_);
+               Midi_def* p =0;
+               if (id)
+                       p = dynamic_cast<Midi_def*> (id->clone ());
+               else
+                       p = new Midi_def;
+
+               $$ = p;
+               THIS->lexer_->add_scope (p->scope_);
        }
        | PAPER '{'     {
                Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
@@ -631,20 +627,20 @@ music_output_def_body:
                        p = dynamic_cast<Paper_def*> (id->clone ());
                else
                        p = new Paper_def;
-               THIS-> lexer_-> scopes_.push (p->variable_tab_);
+               THIS-> lexer_->add_scope (p->scope_);
                $$ = p;
        }
        | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER         {
                Music_output_def *p = unsmob_music_output_def ($3);
                p = p->clone ();
-               THIS->lexer_->scopes_.push (p->variable_tab_);
+               THIS->lexer_->add_scope (p->scope_);
                $$ = p;
        }
        | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER  {
                Music_output_def *p = unsmob_music_output_def ($3);
                p = p->clone ();
 
-               THIS->lexer_->scopes_.push (p->variable_tab_);
+               THIS->lexer_->add_scope (p->scope_);
                $$ = p;
        }
        | music_output_def_body assignment  {
@@ -1959,7 +1955,7 @@ simple_element:
                $$ = velt;
        }
        | MULTI_MEASURE_REST optional_notemode_duration         {
-               Input i = THIS->pop_spot ();
+               THIS->pop_spot ();
 
                Skip_req * sk = new Skip_req;
                sk->set_mus_property ("duration", $2);
index ceb327d9ec228e7506adf664793ad5f566604a14..650d7da8ea4097e6f246a531c02bd7ae1709d6c2 100644 (file)
@@ -30,7 +30,7 @@ Score::Score ()
   : Input ()
 {
   input_file_ = 0;
-  header_ = 0;
+  header_ = SCM_EOL;
   music_ = SCM_EOL;
   errorlevel_ = 0;
 
@@ -57,12 +57,8 @@ Score::Score (Score const &s)
   for (int i=0; i < s.defs_.size (); i++)
     defs_.push (s.defs_[i]->clone ());
   errorlevel_ = s.errorlevel_;
-  if (s.header_)
-    {
-      header_ = (s.header_) ? new Scheme_hash_table (*s.header_): 0;
-
-      scm_gc_unprotect_object (header_->self_scm ());
-    }
+  header_ = ly_make_anonymous_module ();
+  ly_copy_module_variable (header_, s.header_);
 }
 
 Score::~Score ()
@@ -124,7 +120,7 @@ Score::run_translator (Music_output_def *odef)
     progress_indication (_f ("elapsed time: %.2f seconds",  timer.read ()));
 
   if (!header_)
-    header_ = new Scheme_hash_table; // ugh
+    header_ = ly_make_anonymous_module(); // ug.h
 
   output->header_ = header_;
   output->origin_string_ =  location_string ();
@@ -165,8 +161,8 @@ SCM
 Score::mark_smob (SCM s)
 {
   Score * sc = (Score*) SCM_CELL_WORD_1 (s);
-  if (sc->header_)
-    scm_gc_mark (sc->header_->self_scm ());
+
+  scm_gc_mark (sc->header_);
   for (int i = sc->defs_.size (); i--;)
     scm_gc_mark (sc->defs_[i]->self_scm ());