(TYPE_PRECISION (long_double_type_node) / BITS_PER_UNIT));
this->realalignsize = TYPE_ALIGN_UNIT (long_double_type_node);
- /* Size of run-time TypeInfo object. */
- this->classinfosize = 19 * this->ptrsize;
-
/* Much of the dmd front-end uses ints for sizes and offsets, and cannot
handle any larger data type without some pervasive rework. */
this->maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node));
extern tree start_function (FuncDeclaration *);
extern void finish_function (tree);
extern void mark_needed (tree);
-extern unsigned base_vtable_offset (ClassDeclaration *, BaseClass *);
extern tree get_vtable_decl (ClassDeclaration *);
extern tree build_new_class_expr (ClassReferenceExp *);
extern tree aggregate_initializer_decl (AggregateDeclaration *);
extern bool have_typeinfo_p (ClassDeclaration *);
extern tree layout_typeinfo (TypeInfoDeclaration *);
extern tree layout_classinfo (ClassDeclaration *);
+extern unsigned base_vtable_offset (ClassDeclaration *, BaseClass *);
extern tree get_typeinfo_decl (TypeInfoDeclaration *);
extern tree get_classinfo_decl (ClassDeclaration *);
extern tree build_typeinfo (const Loc &, Type *);
}
}
-/* Get the offset to the BC's vtbl[] initializer from the start of CD.
- Returns "~0u" if the base class is not found in any vtable interfaces. */
-
-unsigned
-base_vtable_offset (ClassDeclaration *cd, BaseClass *bc)
-{
- unsigned csymoffset = target.classinfosize;
- unsigned interfacesize = int_size_in_bytes (vtbl_interface_type_node);
- csymoffset += cd->vtblInterfaces->length * interfacesize;
-
- for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
- {
- BaseClass *b = (*cd->vtblInterfaces)[i];
- if (b == bc)
- return csymoffset;
- csymoffset += b->sym->vtbl.length * target.ptrsize;
- }
-
- /* Check all overriding interface vtbl[]s. */
- for (ClassDeclaration *cd2 = cd->baseClass; cd2; cd2 = cd2->baseClass)
- {
- for (size_t k = 0; k < cd2->vtblInterfaces->length; k++)
- {
- BaseClass *bs = (*cd2->vtblInterfaces)[k];
- if (bs->fillVtbl (cd, NULL, 0))
- {
- if (bc == bs)
- return csymoffset;
- csymoffset += bs->sym->vtbl.length * target.ptrsize;
- }
- }
- }
-
- return ~0u;
-}
-
/* Get the VAR_DECL of the vtable symbol for DECL. If this does not yet exist,
create it. The vtable is accessible via ClassInfo, but since it is needed
frequently (like for rtti comparisons), make it directly accessible. */
tree type = TREE_TYPE (TREE_TYPE (ptr));
/* size_t bitsize = sizeof(*ptr) * BITS_PER_UNIT; */
- tree bitsize = fold_convert (type, TYPE_SIZE (type));
+ tree bitsize = fold_convert (type, TYPE_SIZE (TREE_TYPE (ptr)));
/* ptr[bitnum / bitsize] */
ptr = build_array_index (ptr, fold_build2 (TRUNC_DIV_EXPR, type,
/* mask = 1 << (bitnum % bitsize); */
bitnum = fold_build2 (TRUNC_MOD_EXPR, type, bitnum, bitsize);
- bitnum = fold_build2 (LSHIFT_EXPR, type, size_one_node, bitnum);
+ bitnum = fold_build2 (LSHIFT_EXPR, type, build_one_cst (type), bitnum);
/* cond = ptr[bitnum / size] & mask; */
tree cond = fold_build2 (BIT_AND_EXPR, type, ptr, bitnum);
/* cond ? -1 : 0; */
cond = build_condition (TREE_TYPE (callexp), d_truthvalue_conversion (cond),
- integer_minus_one_node, integer_zero_node);
+ build_minus_one_cst (TREE_TYPE (callexp)),
+ build_zero_cst (TREE_TYPE (callexp)));
/* Update the bit as needed, only testing the bit for bt(). */
tree_code code;
return v.result ();
}
+/* Get the offset to the BC's vtbl[] initializer from the start of CD.
+ Returns "~0u" if the base class is not found in any vtable interfaces. */
+
+unsigned
+base_vtable_offset (ClassDeclaration *cd, BaseClass *bc)
+{
+ unsigned csymoffset = int_size_in_bytes (tinfo_types[TK_CLASSINFO_TYPE]);
+ unsigned interfacesize = int_size_in_bytes (vtbl_interface_type_node);
+ csymoffset += cd->vtblInterfaces->length * interfacesize;
+
+ for (size_t i = 0; i < cd->vtblInterfaces->length; i++)
+ {
+ BaseClass *b = (*cd->vtblInterfaces)[i];
+ if (b == bc)
+ return csymoffset;
+ csymoffset += b->sym->vtbl.length * target.ptrsize;
+ }
+
+ /* Check all overriding interface vtbl[]s. */
+ for (ClassDeclaration *cd2 = cd->baseClass; cd2; cd2 = cd2->baseClass)
+ {
+ for (size_t k = 0; k < cd2->vtblInterfaces->length; k++)
+ {
+ BaseClass *bs = (*cd2->vtblInterfaces)[k];
+ if (bs->fillVtbl (cd, NULL, 0))
+ {
+ if (bc == bs)
+ return csymoffset;
+ csymoffset += bs->sym->vtbl.length * target.ptrsize;
+ }
+ }
+ }
+
+ return ~0u;
+}
+
/* Layout fields that immediately come after the classinfo type for DECL if
there's any interfaces or interface vtables to be added.
This must be mirrored with base_vtable_offset(). */