Skip to content

Commit

Permalink
re-factor delegate constructors; handle global dependency for public …
Browse files Browse the repository at this point in the history
…classes
  • Loading branch information
gewang committed Jul 31, 2023
1 parent 87a18bf commit dadf357
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/core/chuck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3736,8 +3736,8 @@ t_CKBOOL type_engine_check_exp_decl_part1( Chuck_Env * env, a_Exp_Decl decl )
value->is_global = decl->is_global;

// dependency tracking: remember the code position of the DECL | 1.5.0.8
// do only if file-top-level or class-top-level
if( value->is_member || value->is_context_global )
// do only if file-top-level or class-top-level, but not global
if( (value->is_member || value->is_context_global) && !value->is_global )
value->depend_init_where = var_decl->where;

// remember the value
Expand Down Expand Up @@ -7696,6 +7696,22 @@ Chuck_Value_Dependency::Chuck_Value_Dependency( Chuck_Value * argValue, t_CKUINT



//-----------------------------------------------------------------------------
// name: Chuck_Value_Dependency()
// desc: copy constructor; DANGER: needed to properly ref-count
//-----------------------------------------------------------------------------
Chuck_Value_Dependency::Chuck_Value_Dependency( const Chuck_Value_Dependency & rhs )
: value(NULL)
{
CK_SAFE_REF_ASSIGN( value, rhs.value );
use_where = rhs.use_where;
// for convenience
where = value ? value->depend_init_where : 0;
}




//-----------------------------------------------------------------------------
// name: ~Chuck_Value_Dependency()
// desc: destructor
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 @@ -606,8 +606,8 @@ struct Chuck_Value_Dependency
Chuck_Value_Dependency() : value(NULL), where(0), use_where(0) { }
// constructor
Chuck_Value_Dependency( Chuck_Value * argValue, t_CKUINT argUseWhere = 0 );
// copy constructor | DANGER: needed to properly ref-count
Chuck_Value_Dependency( const Chuck_Value_Dependency & rhs ) : Chuck_Value_Dependency( rhs.value, rhs.use_where ) { }
// copy constructor | NOTE: needed to properly ref-count
Chuck_Value_Dependency( const Chuck_Value_Dependency & rhs );
// destructor
virtual ~Chuck_Value_Dependency();
};
Expand Down

0 comments on commit dadf357

Please sign in to comment.