Skip to content

Commit

Permalink
remove extra user namespace stack push
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 10, 2024
1 parent 9891fe9 commit 0aa8ec1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
16 changes: 6 additions & 10 deletions src/core/chuck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,7 @@ void Chuck_Env::reset()
// TODO: release stack items?
nspc_stack.clear();
// push global namespace
nspc_stack.push_back( this->global() );
// push user namespace
if( user_nspc != NULL ) nspc_stack.push_back( this->user_nspc );
nspc_stack.push_back( global_nspc );
// TODO: release stack items?
class_stack.clear(); class_stack.push_back( NULL );
// should be at top level
Expand All @@ -331,8 +329,8 @@ void Chuck_Env::reset()
// release curr? class_def? func?
// 1.5.0.1 (ge) don't think these need ref counts; they are used as temporary variables

// assign
curr = (user_nspc != NULL) ? this->user() : this->global();
// current namesapce
curr = (user_nspc != NULL) ? user_nspc : global_nspc;
// clear
class_def = NULL; func = NULL;

Expand All @@ -353,11 +351,9 @@ void Chuck_Env::reset()
void Chuck_Env::load_user_namespace()
{
// user namespace
user_nspc = new Chuck_Namespace;
user_nspc->name = "[user]";
user_nspc->parent = global_nspc;
CK_SAFE_ADD_REF(global_nspc);
CK_SAFE_ADD_REF(user_nspc);
user_nspc = new Chuck_Namespace; CK_SAFE_ADD_REF(user_nspc);
user_nspc->name = "@[user]";
user_nspc->parent = global_nspc; CK_SAFE_ADD_REF(global_nspc);
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,10 @@ struct Chuck_Env : public Chuck_VM_Object
Chuck_Carrier * m_carrier;

protected:
// global namespace
Chuck_Namespace * global_nspc;
// global context
Chuck_Context global_context;
// global namespace
Chuck_Namespace * global_nspc;
// user-global namespace
Chuck_Namespace * user_nspc;
// cache of various array types, which are created as needed by the type system
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ t_CKBOOL Chuck_VM::shutdown()
// log
EM_log( CK_LOG_SYSTEM, "freeing special ugens..." );
// explcitly calling a destructor, accounting for internal ref counts | 1.5.2.0
stereo_dtor( m_dac, this, NULL, Chuck_DL_Api::instance() );
stereo_dtor( m_adc, this, NULL, Chuck_DL_Api::instance() );
if( m_dac ) stereo_dtor( m_dac, this, NULL, Chuck_DL_Api::instance() );
if( m_adc ) stereo_dtor( m_adc, this, NULL, Chuck_DL_Api::instance() );
// special case: if mono, must zero out multi-chan[0] (see Chuck_VM::initialize_synthesis())
if( m_num_dac_channels == 1 ) // 1.5.2.0 (ge) added
{
Expand Down

0 comments on commit 0aa8ec1

Please sign in to comment.