]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/global-translator.cc
release: 1.3.87
[lilypond.git] / lily / global-translator.cc
index aa7178f0796d50ff6fae54f2c3c49686e86571f2..1713ce373637844343ec828a977c3c9b08e7d7b1 100644 (file)
@@ -3,23 +3,28 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "global-translator.hh"
-#include "music-iterator.hh"
 #include "debug.hh"
+#include "music.hh"
+#include "request.hh"
+#include "music-list.hh"
+#include "music-iterator.hh"
+#include "global-translator.hh"
 
-Global_translator::Global_translator()
+Global_translator::Global_translator ()
 {
-  last_mom_ = 0;
 }
 
 void
 Global_translator::add_moment_to_process (Moment m)
 {
-  if (m  > last_mom_)
+  if (m  > final_mom_)
     return;
+
+  if (m < now_mom_ )
+    programming_error ("Trying to freeze in time.");
   
   for (int i=0; i <  extra_mom_pq_.size(); i++)
     if (extra_mom_pq_[i] == m)
@@ -27,13 +32,12 @@ Global_translator::add_moment_to_process (Moment m)
   extra_mom_pq_.insert (m);
 }
 
-void
-Global_translator::modify_next (Moment &w)
+Moment
+Global_translator::sneaky_insert_extra_moment (Moment w)
 {
-  while (extra_mom_pq_.size() && 
-        extra_mom_pq_.front() <= w)
-       
-    w =extra_mom_pq_.get();
+  while (extra_mom_pq_.size() && extra_mom_pq_.front() <= w)
+    w = extra_mom_pq_.get();
+  return w;
 }
 
 int
@@ -45,6 +49,7 @@ Global_translator::moments_left_i() const
 void
 Global_translator::prepare (Moment m)
 {
+  prev_mom_  = now_mom_;
   now_mom_ = m;
 }
 
@@ -78,25 +83,22 @@ Global_translator::finish ()
 void
 Global_translator::run_iterator_on_me (Music_iterator * iter)
 {
-  while (iter->ok() || moments_left_i ())
+
+  while (iter->ok () || moments_left_i ())
     {
       Moment w;
       w.set_infinite (1);
-      if (iter->ok())
+      if (iter->ok ())
        {
-         w = iter->next_moment();
-         DOUT << "proccing: " << w << '\n';
-         if (!monitor->silent_b ("walking"))
-           iter->print();
-       }
+         w = iter->pending_moment();
       
-      modify_next (w);
+         DEBUG_OUT << "proccing: " << w << '\n';
+       }
+
+      w = sneaky_insert_extra_moment (w);
       prepare (w);
+      iter->process (w);
       
-      if (!monitor->silent_b ("walking"))
-       print();
-
-      iter->process_and_next (w);
-      process();
+      process ();
     }
 }