for(i=0; i<size; i++)
attributes[i] = null_instance;
+ Instance_incr_ref(null_instance);
return attributes;
`}
var id = mproperty.intro_mclassdef.mclass.vtable.id
- # TODO : ugly hack
- recv.attributes[mproperty] = value
-
# Replace the old value of mproperty in recv
write_attribute_ph(recv.internal_attributes, recv.vtable.internal_vtable,
recv.vtable.mask, id, mproperty.offset, value)
int absolute_offset = *(pointer + 1);
((Instance *)instance)[absolute_offset + offset] = value;
+ Instance_incr_ref(value);
`}
end
# and informations to perform subtyping tests
class VTable
# The mask to perform perfect hashing
- var mask: Int
+ var mask: Int is noinit
# Unique identifier given by perfect hashing
- var id: Int
+ var id: Int is noinit
# Pointer to the c-allocated area, represents the virtual table
- var internal_vtable: Pointer
+ var internal_vtable: Pointer is noinit
# The short classname of this class
- var classname: String
-
- init do end
+ var classname: String is noinit
end
redef class Instance
total_size += 2;
}
- // Add the size of the perfect hashtable
- total_size += mask+1;
+ // Add the size of the perfect hashtable (mask +1)
+ // Add one because we start to fill the vtable at position 1 (0 is the init position)
+ total_size += mask+2;
long unsigned int* vtable = malloc(sizeof(long unsigned int)*total_size);
// Initialisation to the first position of the virtual table (ie : Object)
return vtable;
`}
-end
\ No newline at end of file
+end