Ejemplo n.º 1
0
/**
 * Create a new VMClass with a specific number of fields
 */
pVMClass VMClass_new_num_fields(intptr_t number_of_fields) {
    // calculate Class size without fields
    size_t class_stub_size = sizeof(VMClass) - 
                             sizeof(pVMObject) * 
                            (SIZE_DIFF_VMOBJECT(VMClass) - 1);
    pVMClass result = 
        (pVMClass)gc_allocate_object(class_stub_size +
                              sizeof(pVMObject) * number_of_fields);

    if(result) {
        result->_vtable = VMClass_vtable();
        gc_start_uninterruptable_allocation();
        INIT(result, number_of_fields);
        gc_end_uninterruptable_allocation();
    }
    
    return result;
}
Ejemplo n.º 2
0
/**
 *
 * Return the offset of the indexable Fields from "normal" fields
 *
 */
size_t _VMMethod__get_offset(void* _self) {
    return (size_t)SIZE_DIFF_VMOBJECT(VMMethod);
}
Ejemplo n.º 3
0
/**
 *
 * Return the offset of the indexable Fields from "normal" fields
 *
 */
size_t _VMArray__get_offset(void* _self) {
    return (size_t)SIZE_DIFF_VMOBJECT(VMArray);
}
Ejemplo n.º 4
0
/**
 * Create a new VMClass
 */
pVMClass VMClass_new(void) {
    return VMClass_new_num_fields(SIZE_DIFF_VMOBJECT(VMClass) - 1);
}