+2005-06-10 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/ly-module.cc (ly_make_anonymous_module): call make-module
+ directly. This fixes a massive memory leak, provided you use CVS
+ GUILE.
+
2005-06-10 Erik Sandberg <ersa9195@student.uu.se>
* ly/property-init.ly: Added tieDashed.
class Lily_lexer : public Includable_lexer
{
DECLARE_SMOBS (Lily_lexer,);
-public:
- SCM scopes_;
private:
int lookup_keyword (String);
char escaped_char (char) const;
Keyword_table *keytable_;
-
+ SCM scopes_;
+ SCM start_module_;
public:
String main_input_name_;
void *lexval;
Input here_input () const;
void add_scope (SCM);
+ void set_current_scope ();
SCM remove_scope ();
void start_main_input ();
scopes_ = SCM_EOL;
error_level_ = 0;
is_main_input_ = false;
-
+ start_module_ = SCM_EOL;
smobify_self ();
add_scope (ly_make_anonymous_module (false));
chordmodifier_tab_ = src.chordmodifier_tab_;
pitchname_tab_stack_ = src.pitchname_tab_stack_;
sources_ = src.sources_;
-
+ start_module_ = SCM_EOL;
+
error_level_ = src.error_level_;
is_main_input_ = src.is_main_input_;
Lily_lexer::add_scope (SCM module)
{
ly_reexport_module (scm_current_module ());
+ if (!scm_is_pair (scopes_))
+ start_module_ = scm_current_module ();
+
scm_set_current_module (module);
for (SCM s = scopes_; scm_is_pair (s); s = scm_cdr (s))
{
scopes_ = scm_cons (module, scopes_);
}
+
SCM
Lily_lexer::remove_scope ()
{
SCM sc = scm_car (scopes_);
scopes_ = scm_cdr (scopes_);
- scm_set_current_module (scm_car (scopes_));
-
+ set_current_scope ();
return sc;
}
+void
+Lily_lexer::set_current_scope ()
+{
+ if (scm_is_pair (scopes_))
+ scm_set_current_module (scm_car (scopes_));
+ else
+ scm_set_current_module (start_module_);
+}
+
int
Lily_lexer::lookup_keyword (String s)
{
try_load_text_metrics (out_name);
}
+ SCM oldmod = scm_current_module ();
+
lexer_ = new Lily_lexer (sources_);
scm_gc_unprotect_object (lexer_->self_scm ());
// TODO: use $parser
error_level_ = error_level_ | lexer_->error_level_;
lexer_ = 0;
+
+ scm_set_current_module (oldmod);
}
void
scm_gc_unprotect_object (lexer_->self_scm ());
SCM oldmod = scm_current_module ();
- scm_set_current_module (scm_car (lexer_->scopes_));
-
// TODO: use $parser
lexer_->set_identifier (ly_symbol2scm ("parser"),
self_scm ());
-
+
lexer_->main_input_name_ = "<string>";
lexer_->is_main_input_ = true;
#define FUNC_NAME __FUNCTION__
-static int module_count;
-
-void
-ly_init_anonymous_module (void *data)
-{
- (void) data;
-}
-
SCM
ly_make_anonymous_module (bool safe)
{
SCM mod = SCM_EOL;
if (!safe)
{
- String s = "*anonymous-ly-" + to_string (module_count++) + "*";
- mod = scm_c_define_module (s.to_str0 (), ly_init_anonymous_module, 0);
+ SCM maker = ly_lily_module_constant ("make-module");
+ SCM scm_module = ly_lily_module_constant ("the-scm-module");
+
+ mod = scm_call_0 (maker);
+ ly_use_module (mod, scm_module);
ly_use_module (mod, global_lily_module);
}
else
#include "ly-smobs.icc"
+#include "program-option.hh"
+
+#include "string-convert.hh"
+
Output_def::Output_def ()
{
scope_ = SCM_EOL;
(lambda (a b)
(< (object-address (car a))
(object-address (car b))))))
-
+
(out-file-name (string-append
"gcstat-" (number->string gc-protect-stat-count)
".scm"))
" ")
"\n")))
protects))
- outfile)))
+ outfile)
+
+ (if (defined? 'gc-live-object-stats)
+ (let*
+ ((dummy (gc))
+ (dummy2 (gc))
+ (stats (gc-live-object-stats))
+ )
+
+ (for-each
+ (lambda (x)
+ (format outfile "~a: ~a\n" (car x) (cdr x)))
+ (sort (gc-live-object-stats)
+ (lambda (x y)
+ (string<? (car x) (car y)))))
+ ))
+
+ ))
(define-public (tweak-grob-property grob sym val)
(set! (ly:grob-property grob sym) val))