diff --git a/src/core/chuck_type.cpp b/src/core/chuck_type.cpp index ec9724969..1b57be8e4 100644 --- a/src/core/chuck_type.cpp +++ b/src/core/chuck_type.cpp @@ -558,6 +558,9 @@ t_CKBOOL type_engine_init( Chuck_Carrier * carrier ) EM_log( CK_LOG_HERALD, "adding base classes..." ); EM_pushlog(); + //------------------------- + // disable array type cache until ckt_array is initialized | 1.5.3.5 (ge) added + env->arrayTypeCache()->enable( FALSE ); // special: Object and Type, whose initializations mutually depend init_class_object( env, env->ckt_object ); // special: @array and Type, whose initializations mutually depend @@ -567,6 +570,9 @@ t_CKBOOL type_engine_init( Chuck_Carrier * carrier ) // initialize of Object's and @array's Type objects are deferred until after init_class_type() type_engine_init_special( env, env->ckt_object ); type_engine_init_special( env, env->ckt_array ); + // enable array type cache now that ckt_array is initialized | 1.5.3.5 (ge) added + env->arrayTypeCache()->enable( TRUE ); + //------------------------- // initialize the remaining internal classes init_class_string( env, env->ckt_string ); @@ -7990,19 +7996,23 @@ Chuck_Type * Chuck_ArrayTypeCache::getOrCreate( Chuck_Env * env, Chuck_Type * base_type /* , Chuck_Namespace * owner_nspc */ ) { + // if cache not enabled + if( !m_enabled ) + { + // create and return + return create_new_array_type( env, array_parent, depth, base_type ); + } + // return value Chuck_Type * type = NULL; - // look for key std::map::iterator it = cache.find(Chuck_ArrayTypeKey(array_parent,depth,base_type)); + // if found - if( false ) // disabled for now, iuntil - // if( it != cache.end() ) - // if( cache.count( Chuck_ArrayTypeKey(array_parent, depth, base_type) ) ) + if( it != cache.end() ) { // get the value from cache type = it->second; - // type = cache[Chuck_ArrayTypeKey(array_parent, depth, base_type)]; } else // not found { diff --git a/src/core/chuck_type.h b/src/core/chuck_type.h index 0a94aa415..e5192b051 100644 --- a/src/core/chuck_type.h +++ b/src/core/chuck_type.h @@ -685,10 +685,16 @@ struct Chuck_ArrayTypeKeyCmp struct Chuck_ArrayTypeCache { public: + // constructor + Chuck_ArrayTypeCache() : m_enabled(FALSE) { } // destructor virtual ~Chuck_ArrayTypeCache() { clear(); } // clear it void clear(); + // enable or disable + void enable( t_CKBOOL yesOrNo ) { m_enabled = yesOrNo; } + // get whether enabled + t_CKBOOL isEnabled() const { return m_enabled; } // lookup an array type; if not already cached, create and insert Chuck_Type * getOrCreate( Chuck_Env * env, Chuck_Type * array_parent, @@ -698,6 +704,8 @@ struct Chuck_ArrayTypeCache protected: // the cache std::map cache; + // is the cache currently enabled? + t_CKBOOL m_enabled; }; @@ -746,6 +754,8 @@ struct Chuck_Env : public Chuck_VM_Object Chuck_Compiler * compiler() const { return m_carrier ? m_carrier->compiler : NULL; } public: + // array type cache + Chuck_ArrayTypeCache * arrayTypeCache() { return &array_types; } // retrieve array type based on parameters | 1.5.3.5 (ge, nick, andrew) added Chuck_Type * get_array_type( Chuck_Type * array_parent, t_CKUINT depth, Chuck_Type * base_type /*,