Skip to content

Commit

Permalink
rename type->info to type->nspc
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 31, 2024
1 parent ae645e2 commit 35c027b
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ static t_CKBOOL CK_DLL_CALL ck_get_mvar(Chuck_DL_Api::Object o, const char * nam
Chuck_Object* obj = (Chuck_Object*)o;
Chuck_Type* type = obj->type_ref;
// check type
if (type->info == NULL)
if (type->nspc == NULL)
{
// put error here
EM_error2(0, "get mvar: ck_get_mvar: object has no type info");
Expand All @@ -1848,7 +1848,7 @@ static t_CKBOOL CK_DLL_CALL ck_get_mvar(Chuck_DL_Api::Object o, const char * nam

vector<Chuck_Value*> vars;
Chuck_Value* var = NULL;
type->info->get_values(vars);
type->nspc->get_values(vars);
// iterate over retrieved functions
for (vector<Chuck_Value*>::iterator v = vars.begin(); v != vars.end(); v++)
{
Expand Down
20 changes: 10 additions & 10 deletions src/core/chuck_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4669,7 +4669,7 @@ t_CKBOOL emit_engine_emit_exp_dot_member( Chuck_Emitter * emit,
t_base = base_static ? member->t_base->actual_type : member->t_base;

// make sure that the base type is object
assert( t_base->info != NULL );
assert( t_base->nspc != NULL );

// if base is static?
if( !base_static )
Expand Down Expand Up @@ -4889,9 +4889,9 @@ t_CKBOOL emit_engine_pre_constructor( Chuck_Emitter * emit, Chuck_Type * type, a
if( type->has_pre_ctor )
{
// make sure
assert( type->info->pre_ctor != NULL );
assert( type->nspc->pre_ctor != NULL );
// append instruction
emit->append( new Chuck_Instr_Pre_Constructor( type->info->pre_ctor,
emit->append( new Chuck_Instr_Pre_Constructor( type->nspc->pre_ctor,
emit->code->frame->curr_offset ) );
}

Expand Down Expand Up @@ -5704,7 +5704,7 @@ t_CKBOOL emit_engine_emit_class_def( Chuck_Emitter * emit, a_Class_Def class_def
a_Class_Body body = class_def->body;

// make sure the code is empty
if( type->info->pre_ctor != NULL && type->info->pre_ctor->instr != NULL )
if( type->nspc->pre_ctor != NULL && type->nspc->pre_ctor->instr != NULL )
{
EM_error2( class_def->where,
"(emit): class '%s' already emitted...",
Expand Down Expand Up @@ -5787,13 +5787,13 @@ t_CKBOOL emit_engine_emit_class_def( Chuck_Emitter * emit, a_Class_Def class_def
// use CK_SAFE_REF_ASSIGN to add_ref RHS then releae LHS | 1.5.1.5
// maintain refcount integrity whether type->info->pre_ctor==NULL or not
// ----------------------
CK_SAFE_REF_ASSIGN( type->info->pre_ctor,
emit_to_code( emit->code, type->info->pre_ctor, emit->dump ) );
CK_SAFE_REF_ASSIGN( type->nspc->pre_ctor,
emit_to_code( emit->code, type->nspc->pre_ctor, emit->dump ) );

// allocate static
type->info->class_data = new t_CKBYTE[type->info->class_data_size];
type->nspc->class_data = new t_CKBYTE[type->nspc->class_data_size];
// verify
if( !type->info->class_data )
if( !type->nspc->class_data )
{
// we have a problem
CK_FPRINTF_STDERR(
Expand All @@ -5804,15 +5804,15 @@ t_CKBOOL emit_engine_emit_class_def( Chuck_Emitter * emit, a_Class_Def class_def
else
{
// zero it out
memset( type->info->class_data, 0, type->info->class_data_size );
memset( type->nspc->class_data, 0, type->nspc->class_data_size );
}
}

// check again
if( !ret )
{
// release | 1.5.1.5 (ge) changed from DELETE to RELEASE
CK_SAFE_RELEASE( type->info->pre_ctor );
CK_SAFE_RELEASE( type->nspc->pre_ctor );
}

// unset the class
Expand Down
12 changes: 6 additions & 6 deletions src/core/chuck_instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4171,7 +4171,7 @@ void call_all_parent_pre_constructors( Chuck_VM * vm, Chuck_VM_Shred * shred,
// next, call my pre-ctor
if( type->has_pre_ctor )
{
call_pre_constructor( vm, shred, type->info->pre_ctor, stack_offset );
call_pre_constructor( vm, shred, type->nspc->pre_ctor, stack_offset );
}
// next, call my default ctor | 1.5.2.2 (ge)
if( type->ctor_default && type->ctor_default->code )
Expand Down Expand Up @@ -4375,7 +4375,7 @@ t_CKBOOL initialize_object( Chuck_Object * object, Chuck_Type * type, Chuck_VM_S

// sanity
assert( type != NULL );
assert( type->info != NULL );
assert( type->nspc != NULL );

// REFACTOR-2017: added | 1.5.1.5 (ge & andrew) moved here from instantiate_...
object->setOriginVM( vm );
Expand All @@ -4386,7 +4386,7 @@ t_CKBOOL initialize_object( Chuck_Object * object, Chuck_Type * type, Chuck_VM_S
object->vtable = new Chuck_VTable;
if( !object->vtable ) goto out_of_memory;
// copy the object's virtual table
object->vtable->funcs = type->info->obj_v_table.funcs;
object->vtable->funcs = type->nspc->obj_v_table.funcs;
// set the type reference
object->type_ref = type;
// reference count
Expand Down Expand Up @@ -4508,7 +4508,7 @@ Chuck_Object * instantiate_and_initialize_object( Chuck_Type * type, Chuck_VM_Sh

// sanity
assert( type != NULL );
assert( type->info != NULL );
assert( type->nspc != NULL );

// allocate the VM object
if( !type->ugen_info )
Expand Down Expand Up @@ -7649,9 +7649,9 @@ void Chuck_Instr_Dot_Static_Data::execute( Chuck_VM * vm, Chuck_VM_Shred * shred
// get the object pointer
Chuck_Type * t_class = (Chuck_Type *)(*sp);
// make sure
assert( (m_offset + m_size) <= t_class->info->class_data_size );
assert( (m_offset + m_size) <= t_class->nspc->class_data_size );
// calculate the data pointer
data = (t_CKUINT)(t_class->info->class_data + m_offset);
data = (t_CKUINT)(t_class->nspc->class_data + m_offset);

// emit addr or value
if( m_emit_addr )
Expand Down
8 changes: 4 additions & 4 deletions src/core/chuck_oo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ Chuck_Object::~Chuck_Object()
// SPENCER TODO: HACK! is there a better way to call the dtor?
// has_pre-dtor: related to info->pre_dtor, but different since info is shared with arrays
// of this type (via new_array_type()), but this flag pertains to this type only
if( type->info && type->has_pre_dtor ) // 1.5.0.0 (ge) added type->info check
if( type->nspc && type->has_pre_dtor ) // 1.5.0.0 (ge) added type->info check
{
// make sure
assert( type->info->pre_dtor );
assert( type->nspc->pre_dtor );
// check origin of dtor
if( type->info->pre_dtor->native_func ) // c++-defined deconstructor
if( type->nspc->pre_dtor->native_func ) // c++-defined deconstructor
{
// REFACTOR-2017: do we know which VM to pass in? (diff main/sub instance?)
// pass in type-associated vm and current shred | 1.5.1.8
((f_dtor)(type->info->pre_dtor->native_func))( this, vm, shred, Chuck_DL_Api::instance() );
((f_dtor)(type->nspc->pre_dtor->native_func))( this, vm, shred, Chuck_DL_Api::instance() );
}
else // chuck-defined deconstructor
{
Expand Down
24 changes: 12 additions & 12 deletions src/core/chuck_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,34 +276,34 @@ t_CKBOOL type_engine_scan0_class_def( Chuck_Env * env, a_Class_Def class_def )
the_class->array_depth = 0;
the_class->size = sizeof(void *);
the_class->obj_size = 0; // TODO:
the_class->info = env->context->new_Chuck_Namespace();
CK_SAFE_ADD_REF( the_class->info );
the_class->info->name = the_class->base_name;
the_class->nspc = env->context->new_Chuck_Namespace();
CK_SAFE_ADD_REF( the_class->nspc );
the_class->nspc->name = the_class->base_name;
// public? | 1.5.4.0 (ge) added
the_class->is_public = (class_def->decl == ae_key_public);
// if public class, then set parent to context
// ... allowing the class to address current context
// TODO: add ref to the parent?
if( the_class->is_public )
{ the_class->info->parent = env->context->nspc; }
else { the_class->info->parent = env->curr; }
{ the_class->nspc->parent = env->context->nspc; }
else { the_class->nspc->parent = env->curr; }
the_class->func = 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;
// add code
the_class->info->pre_ctor = new Chuck_VM_Code;
CK_SAFE_ADD_REF( the_class->info->pre_ctor );
the_class->nspc->pre_ctor = new Chuck_VM_Code;
CK_SAFE_ADD_REF( the_class->nspc->pre_ctor );
// name | 1.5.2.0 (ge) added
the_class->info->pre_ctor->name = string("class ") + the_class->base_name;
the_class->nspc->pre_ctor->name = string("class ") + the_class->base_name;
// add to env
env->curr->type.add( the_class->base_name, the_class ); // URGENT: make this global
// incomplete
the_class->is_complete = FALSE;

// set the new type as current
env->nspc_stack.push_back( env->curr );
env->curr = the_class->info;
env->curr = the_class->nspc;
// push the class def
env->class_stack.push_back( env->class_def );
env->class_def = the_class;
Expand Down Expand Up @@ -1443,7 +1443,7 @@ t_CKBOOL type_engine_scan1_class_def( Chuck_Env * env, a_Class_Def class_def )

// set the new type as current
env->nspc_stack.push_back( env->curr );
env->curr = the_class->info;
env->curr = the_class->nspc;
// push the class def
env->class_stack.push_back( env->class_def );
env->class_def = the_class;
Expand Down Expand Up @@ -2858,7 +2858,7 @@ t_CKBOOL type_engine_scan2_class_def( Chuck_Env * env, a_Class_Def class_def )

// set the new type as current
env->nspc_stack.push_back( env->curr );
env->curr = the_class->info;
env->curr = the_class->nspc;
// push the class def
env->class_stack.push_back( env->class_def );
env->class_def = the_class;
Expand Down Expand Up @@ -2938,7 +2938,7 @@ t_CKBOOL type_engine_scan2_class_def( Chuck_Env * env, a_Class_Def class_def )
// check for fun
assert( env->context != NULL );
assert( class_def->type != NULL );
assert( class_def->type->info != NULL );
assert( class_def->type->nspc != NULL );

// retrieve the new type (created in scan_class_def)
the_class = class_def->type;
Expand Down
Loading

0 comments on commit 35c027b

Please sign in to comment.