From 0aa8ec1dbc58041f1f9f9f982b2e65b546e6d414 Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Sun, 10 Nov 2024 00:45:58 -0800 Subject: [PATCH] remove extra user namespace stack push --- src/core/chuck_type.cpp | 16 ++++++---------- src/core/chuck_type.h | 4 ++-- src/core/chuck_vm.cpp | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/core/chuck_type.cpp b/src/core/chuck_type.cpp index cb0c8c165..f53c78521 100644 --- a/src/core/chuck_type.cpp +++ b/src/core/chuck_type.cpp @@ -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 @@ -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; @@ -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); } diff --git a/src/core/chuck_type.h b/src/core/chuck_type.h index 702289de1..954d12288 100644 --- a/src/core/chuck_type.h +++ b/src/core/chuck_type.h @@ -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 diff --git a/src/core/chuck_vm.cpp b/src/core/chuck_vm.cpp index 9a8096784..9b716b57e 100644 --- a/src/core/chuck_vm.cpp +++ b/src/core/chuck_vm.cpp @@ -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 {