struct pvm_object pvm_create_class_object(struct pvm_object name, struct pvm_object iface, int da_size) { struct pvm_object _data = pvm_object_create_fixed( pvm_get_class_class() ); struct data_area_4_class * da = (struct data_area_4_class *)_data.data->da; da->object_data_area_size = da_size; da->object_flags = 0; da->object_default_interface = iface; da->sys_table_id = -1; da->class_name = name; da->class_parent = pvm_get_null_class(); return _data; }
int pvm_ip_to_linenum(pvm_object_t tclass, int method_ordinal, int ip) { if(!pvm_object_class_exactly_is( tclass, pvm_get_class_class() )) { printf("pvm_ip_to_linenum: not a class\n"); return -1; } struct data_area_4_class *cda= pvm_object_da( tclass, class ); pvm_object_t ip2line_maps = cda->ip2line_maps; //cda->method_names = method_names; pvm_object_t map = pvm_get_ofield( ip2line_maps, method_ordinal ); struct data_area_4_binary * bin = pvm_object_da( map, binary ); int nrecords = (map.data->_da_size)/sizeof(struct vm_code_linenum); struct vm_code_linenum *sp = (void *)bin->data; int i; for( i = 0; i < nrecords; i++) { // TODO bin search, array must be sorted if( sp[i].ip >= ip ) { if( i == 0 ) return -1; return sp[i-1].line; } } return -1; }