Skip to content

Commit

Permalink
more stringent Type cleanup; re-order base type deletion sequence; #2…
Browse files Browse the repository at this point in the history
…024-func-call-update
  • Loading branch information
gewang committed Nov 27, 2024
1 parent 71c9839 commit 1d2b0b6
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/core/chuck_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4931,10 +4931,10 @@ t_CKBOOL emit_engine_emit_exp_if( Chuck_Emitter * emit, a_Exp_If exp_if )
t_CKBOOL emit_engine_pre_constructor( Chuck_Emitter * emit, Chuck_Type * type, a_Ctor_Call ctor_info )
{
// parent first pre constructor
if( type->parent != NULL )
if( type->parent_type != NULL )
{
// first emit parent pre and base constructor
emit_engine_pre_constructor( emit, type->parent, NULL );
emit_engine_pre_constructor( emit, type->parent_type, NULL );
}

// pre constructor
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4191,9 +4191,9 @@ void call_all_parent_pre_constructors( Chuck_VM * vm, Chuck_VM_Shred * shred,
Chuck_Type * type, t_CKUINT stack_offset )
{
// first, call parent ctor
if( type->parent != NULL )
if( type->parent_type != NULL )
{
call_all_parent_pre_constructors( vm, shred, type->parent, stack_offset );
call_all_parent_pre_constructors( vm, shred, type->parent_type, stack_offset );
}
// next, call my pre-ctor
if( type->has_pre_ctor )
Expand Down
2 changes: 1 addition & 1 deletion src/core/chuck_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3836,7 +3836,7 @@ CK_DLL_MFUN( type_parent )
// get self as type
Chuck_Type * type = (Chuck_Type *)SELF;
// get parent type
RETURN->v_object = type->parent;
RETURN->v_object = type->parent_type;
}

CK_DLL_MFUN( type_children )
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_oo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Chuck_Object::~Chuck_Object()
}

// go up the inheritance
type = type->parent;
type = type->parent_type;
}

// release class-scope member vars | 1.5.2.0 (ge) added
Expand All @@ -346,7 +346,7 @@ Chuck_Object::~Chuck_Object()
}

// go up to parent type
type = type->parent;
type = type->parent_type;
}

// release origin shred
Expand Down
15 changes: 8 additions & 7 deletions src/core/chuck_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,6 @@ t_CKBOOL type_engine_scan0_class_def( Chuck_Env * env, a_Class_Def class_def )
{ the_class->nspc->parent = env->context->nspc; }
else { the_class->nspc->parent = env->curr; }

// 1.5.4.3 (ge) commented out...type2func_bridge already init to NULL
// #2024-func-call-update
// the_class->type2func_bridge = NULL;

// 1.5.0.5 (ge) commented out; the AST is cleaned up after every compilation;
// would need to make deep copy if want to keep around
// the_class->def = class_def;
Expand Down Expand Up @@ -2958,7 +2954,7 @@ t_CKBOOL type_engine_scan2_class_def( Chuck_Env * env, a_Class_Def class_def )
the_class = class_def->type;

// set fields not set in scan
the_class->parent = t_parent; CK_SAFE_ADD_REF(t_parent);
the_class->parent_type = t_parent; CK_SAFE_ADD_REF(t_parent);
// inherit ugen_info data from parent PLD
the_class->ugen_info = t_parent->ugen_info; CK_SAFE_ADD_REF(t_parent->ugen_info);

Expand Down Expand Up @@ -3088,9 +3084,14 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f )
type = env->context->new_Chuck_Type( env );
type->xid = te_function;
type->base_name = "[function]";
type->parent = env->ckt_function; // TODO: reference count the parent
type->size = sizeof(void *);
type->type2func_bridge = func; // TODO: consider ref count

// 1.5.4.3 (ge) add ref; was: type->parent_type = env->ckt_function;
// part of #2024-func-call-update
CK_SAFE_REF_ASSIGN(type->parent_type,env->ckt_function);
// 1.5.4.3 (ge) add ref; was: type->func_bridge = func;
// part of #2024-func-call-update
CK_SAFE_REF_ASSIGN(type->func_bridge, func);

// make new value, with potential overloaded name
value = env->context->new_Chuck_Value( type, func_name );
Expand Down
Loading

0 comments on commit 1d2b0b6

Please sign in to comment.