X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=typeinfo.c;h=258ca1cd58f02370cb4bb5a4ba9e66f31dd99bbb;hb=fa3aaa46100a241924617c5f18d0e1ed9d344079;hp=1c7f3328d4166547419d08e15b1dc285fb053d58;hpb=60f1b98f1d72071b811de8a34e796f038c0b7b98;p=cacao.git diff --git a/typeinfo.c b/typeinfo.c index 1c7f3328d..258ca1cd5 100644 --- a/typeinfo.c +++ b/typeinfo.c @@ -26,7 +26,7 @@ Authors: Edwin Steiner - $Id: typeinfo.c 922 2004-02-24 13:26:24Z edwin $ + $Id: typeinfo.c 1296 2004-07-10 17:02:15Z stefan $ */ @@ -36,7 +36,7 @@ #include "typeinfo.h" #include "tables.h" #include "loader.h" -#include "toolbox/loging.h" +#include "toolbox/logging.h" #include "toolbox/memory.h" #include "jit/jit.h" /* XXX move typeinfo.* into jit/ */ @@ -370,6 +370,14 @@ static bool classinfo_implements_interface(classinfo *cls,classinfo *interf) { + if (!cls->loaded) + if (!class_load(cls)) + return false; + + if (!cls->linked) + if (!class_link(cls)) + return false; + if (cls->flags & ACC_INTERFACE) { /* cls is an interface */ if (cls == interf) @@ -451,6 +459,13 @@ typeinfo_is_assignable_to_classinfo(typeinfo *value,classinfo *dest) if (!cls || !dest) return false; + /* maybe we need to load and link the class */ + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + #ifdef TYPEINFO_DEBUG if (!dest->linked) panic("Internal error: typeinfo_is_assignable_to_classinfo: unlinked class."); @@ -553,12 +568,19 @@ typeinfo_init_from_descriptor(typeinfo *info,char *utf_ptr,char *end_ptr) | CLASSLOAD_NOVOID | CLASSLOAD_CHECKEND); - if (cls) + if (cls) { + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + /* a class, interface or array descriptor */ TYPEINFO_INIT_CLASSINFO(*info,cls); - else + } else { /* a primitive type */ TYPEINFO_INIT_PRIMITIVE(*info); + } } int @@ -610,9 +632,16 @@ typeinfo_init_from_method_args(utf *desc,u1 *typebuf,typeinfo *infobuf, | CLASSLOAD_NULLPRIMITIVE | CLASSLOAD_NOVOID); - if (cls) - TYPEINFO_INIT_CLASSINFO(*infobuf,cls); - else { + if (cls) { + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + + TYPEINFO_INIT_CLASSINFO(*infobuf, cls); + + } else { TYPEINFO_INIT_PRIMITIVE(*infobuf); } infobuf++; @@ -633,11 +662,20 @@ typeinfo_init_from_method_args(utf *desc,u1 *typebuf,typeinfo *infobuf, CLASSLOAD_NULLPRIMITIVE | CLASSLOAD_NEW | CLASSLOAD_CHECKEND); + if (returntypeinfo) { - if (cls) - TYPEINFO_INIT_CLASSINFO(*returntypeinfo,cls); - else + if (cls) { + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + + TYPEINFO_INIT_CLASSINFO(*returntypeinfo, cls); + + } else { TYPEINFO_INIT_PRIMITIVE(*returntypeinfo); + } } } } @@ -666,9 +704,16 @@ typedescriptors_init_from_method_args(typedescriptor *td, | CLASSLOAD_NULLPRIMITIVE | CLASSLOAD_NOVOID); - if (cls) - TYPEINFO_INIT_CLASSINFO(td->info,cls); - else { + if (cls) { + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + + TYPEINFO_INIT_CLASSINFO(td->info, cls); + + } else { TYPEINFO_INIT_PRIMITIVE(td->info); } td++; @@ -689,10 +734,18 @@ typedescriptors_init_from_method_args(typedescriptor *td, CLASSLOAD_NULLPRIMITIVE | CLASSLOAD_NEW | CLASSLOAD_CHECKEND); - if (cls) + if (cls) { + if (!cls->loaded) + class_load(cls); + + if (!cls->linked) + class_link(cls); + TYPEINFO_INIT_CLASSINFO(returntype->info,cls); - else + + } else { TYPEINFO_INIT_PRIMITIVE(returntype->info); + } } return args; } @@ -700,7 +753,7 @@ typedescriptors_init_from_method_args(typedescriptor *td, void typeinfo_init_component(typeinfo *srcarray,typeinfo *dst) { - vftbl *comp = NULL; + vftbl_t *comp = NULL; if (TYPEINFO_IS_NULLTYPE(*srcarray)) { TYPEINFO_INIT_NULLTYPE(*dst); @@ -986,6 +1039,24 @@ typeinfo_merge_nonarrays(typeinfo *dest, #endif */ + /* check clsx */ + if (!clsx->loaded) + if (!class_load(clsx)) + return false; + + if (!clsx->linked) + if (!class_link(clsx)) + return false; + + /* check clsy */ + if (!clsy->loaded) + if (!class_load(clsy)) + return false; + + if (!clsy->linked) + if (!class_link(clsy)) + return false; + /* Common case: clsx == clsy */ /* (This case is very simple unless *both* x and y really represent * merges of subclasses of clsx==clsy.)