Index: lily/context.cc |
diff --git a/lily/context.cc b/lily/context.cc |
index 9f6ec8ebdb8184b78a859916e3d46b5ad747dc7d..20529d9911e9bfca74ca0028dbef680befc9afd0 100644 |
--- a/lily/context.cc |
+++ b/lily/context.cc |
@@ -111,8 +111,11 @@ Context::create_unique_context (SCM name, const string &id, SCM operations) |
Don't create multiple score contexts. |
*/ |
Global_context *gthis = dynamic_cast<Global_context *> (this); |
- if (gthis && gthis->get_score_context ()) |
- return gthis->get_score_context ()->create_unique_context (name, id, operations); |
+ if (gthis) |
+ { |
+ if (Context *score = gthis->get_score_context ()) |
lemzwerg
2020/01/03 16:18:09
Not sure whether compilers warn about the `if (...
dak
2020/01/03 21:21:32
They don't. lily/parser.yy is full of it (and a n
|
+ return score->create_unique_context (name, id, operations); |
+ } |
vector<Context_def *> path = path_to_acceptable_context (name); |
if (!path.empty ()) |
@@ -138,11 +141,8 @@ Context::find_create_context (SCM n, const string &id, |
Global_context *gthis = dynamic_cast<Global_context *> (this); |
if (gthis) |
{ |
- if (gthis->get_score_context ()) |
- { |
- return gthis->get_score_context ()-> |
- find_create_context (n, id, operations); |
- } |
+ if (Context *score = gthis->get_score_context ()) |
+ return score->find_create_context (n, id, operations); |
} |
// Searching below in recursive calls can find contexts beyond those that are |
@@ -193,10 +193,7 @@ Context::make_revert_finalization (SCM sym) |
void |
Context::add_global_finalization (SCM x) |
{ |
- if (Global_context *g = get_global_context ()) |
- g->add_finalization (x); |
- else |
- programming_error ("no global context"); |
+ find_global_context (this)->add_finalization (x); |
} |
void |
@@ -714,15 +711,6 @@ Context::diagnostic_id (SCM name, const string& id) |
return result; |
} |
-Context * |
-Context::get_score_context () const |
-{ |
- if (daddy_context_) |
- return daddy_context_->get_score_context (); |
- else |
- return 0; |
-} |
- |
Output_def * |
Context::get_output_def () const |
{ |
@@ -799,19 +787,6 @@ Context::mark_smob () const |
const char * const Context::type_p_name_ = "ly:context?"; |
-Global_context * |
-Context::get_global_context () const |
-{ |
- if (dynamic_cast<Global_context *> ((Context *) this)) |
- return dynamic_cast<Global_context *> ((Context *) this); |
- |
- if (daddy_context_) |
- return daddy_context_->get_global_context (); |
- |
- programming_error ("no Global context"); |
- return 0; |
-} |
- |
Context * |
Context::get_parent_context () const |
{ |