struct pvm_object pvm_create_interface_object( int n_methods, struct pvm_object parent_class ) { struct pvm_object ret = create_interface_worker( n_methods ); struct pvm_object * data_area = (struct pvm_object *)ret.data->da; if(pvm_is_null( parent_class )) pvm_exec_panic( "create interface: parent is null" ); struct pvm_object_storage *base_i = ((struct data_area_4_class*)parent_class.data->da)->object_default_interface.data; int base_icount = da_po_limit(base_i); if(base_icount > n_methods) { // root classes have N_SYS_METHODS slots in interface, don't cry about that if( n_methods > N_SYS_METHODS ) printf( " create interface: child has less methods (%d) than parent (%d)\n", n_methods, base_icount ); base_icount = n_methods; } int i = 0; // copy methods from parent for( ; i < base_icount; i++ ) { pvm_object_t baseMethod = (da_po_ptr(base_i->da))[i]; ref_inc_o(baseMethod); data_area[i] = baseMethod; } // fill others with nulls for( ; i < n_methods; i++ ) data_area[i] = pvm_get_null_object(); // null return ret; }
void pvm_internal_init_call_frame(struct pvm_object_storage * os) { //struct data_area_4_call_frame *da = pvm_data_area( os, call_frame ); struct data_area_4_call_frame *da = (struct data_area_4_call_frame *)&(os->da); da->IP_max = 0; da->IP = 0; da->code = 0; da->this_object = pvm_get_null_object(); da->prev = pvm_get_null_object(); da->istack = pvm_create_istack_object(); da->ostack = pvm_create_ostack_object(); da->estack = pvm_create_estack_object(); }
pvm_object_t pvm_get_field_name( pvm_object_t tclass, int ordinal ) { struct data_area_4_class *cda= pvm_object_da( tclass, class ); pvm_object_t fnames = cda->field_names; if( pvm_is_null(fnames)) return pvm_get_null_object(); pvm_object_t name = pvm_get_ofield( fnames, ordinal ); return name; }
pvm_object_t pvm_get_method_name( pvm_object_t tclass, int method_ordinal ) { struct data_area_4_class *cda= pvm_object_da( tclass, class ); pvm_object_t mnames = cda->method_names; if( pvm_is_null(mnames)) return pvm_get_null_object(); pvm_object_t name = pvm_get_ofield( mnames, method_ordinal ); return name; }
void pvm_internal_init_page(struct pvm_object_storage * os) { assert( ((os->_da_size) % sizeof(struct pvm_object)) == 0); // Natural num of int n_slots = (os->_da_size) / sizeof(struct pvm_object); struct pvm_object * data_area = (struct pvm_object *)&(os->da); int i; for( i = 0; i < n_slots; i++ ) data_area[i] = pvm_get_null_object(); }
void pvm_internal_init_class(struct pvm_object_storage * os) { struct data_area_4_class * da = (struct data_area_4_class *)os->da; da->object_data_area_size = 0; da->object_flags = 0; da->object_default_interface = pvm_get_null_class(); da->sys_table_id = -1; da->class_name = pvm_get_null_object(); da->class_parent = pvm_get_null_class(); }
struct pvm_object pvm_create_page_object( int n_slots, struct pvm_object *init, int init_slots ) { int das = n_slots*sizeof(struct pvm_object); struct pvm_object _data = pvm_object_create_dynamic( pvm_get_page_class(), das ); struct pvm_object * data_area = (struct pvm_object *)&(_data.data->da); // NB! Bug! Here is the way to set object pointers to some garbage value //if( init_value ) memcpy( data_area, init_value, das ); //else memset( data_area, 0, das ); assert(init_slots < n_slots); int i; for( i = 0; i < init_slots; i++ ) data_area[i] = *init++; for( ; i < n_slots; i++ ) data_area[i] = pvm_get_null_object(); return _data; }