1 /* src/vm/jit/verify/typeinfo.c - type system used by the type checker
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Edwin Steiner
29 $Id: typeinfo.c 2182 2005-04-01 20:56:33Z edwin $
36 #include "mm/memory.h"
37 #include "toolbox/logging.h"
39 #include "vm/loader.h"
40 #include "vm/tables.h"
41 #include "vm/jit/jit.h"
42 #include "vm/jit/verify/typeinfo.h"
43 #include "vm/descriptor.h"
44 #include "vm/resolve.h"
47 /* check if a linked class is an array class. Only use for linked classes! */
48 #define CLASSINFO_IS_ARRAY(clsinfo) ((clsinfo)->vftbl->arraydesc != NULL)
50 #define CLASSINFO_IMPLEMENTS_INTERFACE(cls,index) \
51 ( ((index) < (cls)->vftbl->interfacetablelength) \
52 && (VFTBLINTERFACETABLE((cls)->vftbl,(index)) != NULL) )
54 /******************************************************************************/
56 /******************************************************************************/
59 #define TYPEINFO_ASSERT(cond) assert(cond)
61 #define TYPEINFO_ASSERT(cond)
64 /**********************************************************************/
65 /* TYPEVECTOR FUNCTIONS */
66 /**********************************************************************/
69 typevectorset_copy(typevector *src,int k,int size)
71 typevector *dst = DNEW_TYPEVECTOR(size);
73 memcpy(dst,src,TYPEVECTOR_SIZE(size));
76 dst->alt = typevectorset_copy(src->alt,k+1,size);
81 typevectorset_checktype(typevector *vec,int index,int type)
84 if (vec->td[index].type != type)
86 } while ((vec = vec->alt) != NULL);
91 typevectorset_checkreference(typevector *vec,int index)
94 if (!TYPEDESC_IS_REFERENCE(vec->td[index]))
96 } while ((vec = vec->alt) != NULL);
101 typevectorset_checkretaddr(typevector *vec,int index)
104 if (!TYPEDESC_IS_RETURNADDRESS(vec->td[index]))
106 } while ((vec = vec->alt) != NULL);
111 typevectorset_copymergedtype(typevector *vec,int index,typeinfo *dst)
116 td = vec->td + index;
118 TYPEINFO_COPY(td->info,*dst);
123 primitive = TYPEINFO_IS_PRIMITIVE(*dst) ? 1 : 0;
125 while ((vec = vec->alt) != NULL) {
126 td = vec->td + index;
127 if (type != td->type)
130 if (type == TYPE_ADDRESS) {
131 if ((TYPEINFO_IS_PRIMITIVE(td->info) ? 1 : 0) != primitive)
133 typeinfo_merge(dst,&(td->info));
141 typevectorset_mergedtype(typevector *vec,int index,typeinfo *temp,typeinfo **result)
145 return typevectorset_copymergedtype(vec,index,temp);
148 *result = &(vec->td[index].info);
149 return vec->td[index].type;
153 typevectorset_mergedtypeinfo(typevector *vec,int index,typeinfo *temp)
156 int type = typevectorset_mergedtype(vec,index,temp,&result);
157 return (type == TYPE_ADDRESS) ? result : NULL;
161 typevectorset_store(typevector *vec,int index,int type,typeinfo *info)
164 vec->td[index].type = type;
166 TYPEINFO_COPY(*info,vec->td[index].info);
167 if (index > 0 && IS_2_WORD_TYPE(vec->td[index-1].type))
168 vec->td[index-1].type = TYPE_VOID;
169 } while ((vec = vec->alt) != NULL);
173 typevectorset_store_retaddr(typevector *vec,int index,typeinfo *info)
175 typeinfo_retaddr_set *adr;
177 adr = (typeinfo_retaddr_set*) TYPEINFO_RETURNADDRESS(*info);
179 vec->td[index].type = TYPE_ADDRESS;
180 TYPEINFO_INIT_RETURNADDRESS(vec->td[index].info,adr->addr);
181 if (index > 0 && IS_2_WORD_TYPE(vec->td[index-1].type))
182 vec->td[index-1].type = TYPE_VOID;
184 } while ((vec = vec->alt) != NULL);
188 typevectorset_store_twoword(typevector *vec,int index,int type)
191 vec->td[index].type = type;
192 vec->td[index+1].type = TYPE_VOID;
193 if (index > 0 && IS_2_WORD_TYPE(vec->td[index-1].type))
194 vec->td[index-1].type = TYPE_VOID;
195 } while ((vec = vec->alt) != NULL);
199 typevectorset_init_object(typevector *set,void *ins,
200 classref_or_classinfo initclass,
205 for (;set; set=set->alt) {
206 for (i=0; i<size; ++i) {
207 if (set->td[i].type == TYPE_ADR
208 && TYPEINFO_IS_NEWOBJECT(set->td[i].info)
209 && TYPEINFO_NEWOBJECT_INSTRUCTION(set->td[i].info) == ins)
211 TYPEINFO_INIT_CLASSREF_OR_CLASSINFO(set->td[i].info,initclass);
218 typevector_merge(typevector *dst,typevector *y,int size)
220 bool changed = false;
222 typedescriptor *a = dst->td;
223 typedescriptor *b = y->td;
225 if (a->type != TYPE_VOID && a->type != b->type) {
229 else if (a->type == TYPE_ADDRESS) {
230 if (TYPEINFO_IS_PRIMITIVE(a->info)) {
231 /* 'a' is a returnAddress */
232 if (!TYPEINFO_IS_PRIMITIVE(b->info)
233 || (TYPEINFO_RETURNADDRESS(a->info)
234 != TYPEINFO_RETURNADDRESS(b->info)))
241 /* 'a' is a reference */
242 if (TYPEINFO_IS_PRIMITIVE(b->info)) {
247 changed |= typeinfo_merge(&(a->info),&(b->info));
258 typevector_separable_from(typevector *a,typevector *b,int size)
260 typedescriptor *tda = a->td;
261 typedescriptor *tdb = b->td;
262 for (;size--; tda++,tdb++) {
263 if (TYPEDESC_IS_RETURNADDRESS(*tda)
264 && TYPEDESC_IS_RETURNADDRESS(*tdb)
265 && TYPEINFO_RETURNADDRESS(tda->info)
266 != TYPEINFO_RETURNADDRESS(tdb->info))
273 typevectorset_add(typevector *dst,typevector *v,int size)
277 dst->alt = DNEW_TYPEVECTOR(size);
278 memcpy(dst->alt,v,TYPEVECTOR_SIZE(size));
279 dst->alt->alt = NULL;
280 dst->alt->k = dst->k + 1;
284 typevectorset_select(typevector **set,int retindex,void *retaddr)
286 typevector *selected;
288 if (!*set) return NULL;
290 if (TYPEINFO_RETURNADDRESS((*set)->td[retindex].info) == retaddr) {
292 *set = selected->alt;
293 selected->alt = typevectorset_select(set,retindex,retaddr);
296 selected = typevectorset_select(&((*set)->alt),retindex,retaddr);
302 typevectorset_separable_with(typevector *set,typevector *add,int size)
309 for (i=0; i<size; ++i) {
310 if (!TYPEDESC_IS_RETURNADDRESS(add->td[i]))
312 addr = TYPEINFO_RETURNADDRESS(add->td[i].info);
317 if (!TYPEDESC_IS_RETURNADDRESS(v->td[i]))
319 if (TYPEINFO_RETURNADDRESS(v->td[i].info) != addr)
322 if (!v && separable) return true;
331 typevectorset_collapse(typevector *dst,int size)
333 bool changed = false;
336 typevector_merge(dst,dst->alt,size);
337 dst->alt = dst->alt->alt;
343 /**********************************************************************/
344 /* READ-ONLY FUNCTIONS */
345 /* The following functions don't change typeinfo data. */
346 /**********************************************************************/
349 typeinfo_is_array(typeinfo *info)
351 TYPEINFO_ASSERT(info);
352 return TYPEINFO_IS_ARRAY(*info);
356 typeinfo_is_primitive_array(typeinfo *info,int arraytype)
358 TYPEINFO_ASSERT(info);
359 return TYPEINFO_IS_PRIMITIVE_ARRAY(*info,arraytype);
363 typeinfo_is_array_of_refs(typeinfo *info)
365 TYPEINFO_ASSERT(info);
366 return TYPEINFO_IS_ARRAY_OF_REFS(*info);
370 interface_extends_interface(classinfo *cls,classinfo *interf)
374 TYPEINFO_ASSERT(cls);
375 TYPEINFO_ASSERT(interf);
376 TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
377 TYPEINFO_ASSERT((cls->flags & ACC_INTERFACE) != 0);
379 /* first check direct superinterfaces */
380 for (i=0; i<cls->interfacescount; ++i) {
381 if (cls->interfaces[i] == interf)
385 /* check indirect superinterfaces */
386 for (i=0; i<cls->interfacescount; ++i) {
387 if (interface_extends_interface(cls->interfaces[i],interf))
395 classinfo_implements_interface(classinfo *cls,classinfo *interf)
397 TYPEINFO_ASSERT(cls);
398 TYPEINFO_ASSERT(interf);
399 TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
402 if (!load_class_bootstrap(cls)) /* XXX */
406 if (!link_class(cls)) /* XXX */
409 if (cls->flags & ACC_INTERFACE) {
410 /* cls is an interface */
414 /* check superinterfaces */
415 return interface_extends_interface(cls,interf);
418 return CLASSINFO_IMPLEMENTS_INTERFACE(cls,interf->index);
422 mergedlist_implements_interface(typeinfo_mergedlist *merged,
426 classref_or_classinfo *mlist;
428 TYPEINFO_ASSERT(interf);
429 TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
431 /* Check if there is an non-empty mergedlist. */
435 /* If all classinfos in the (non-empty) merged array implement the
436 * interface return true, otherwise false.
438 mlist = merged->list;
441 if (IS_CLASSREF(*mlist)) {
444 if (!classinfo_implements_interface((mlist++)->cls,interf))
451 merged_implements_interface(classinfo *typeclass,typeinfo_mergedlist *merged,
454 /* primitive types don't support interfaces. */
458 /* the null type can be cast to any interface type. */
459 if (typeclass == pseudo_class_Null)
462 /* check if typeclass implements the interface. */
463 if (classinfo_implements_interface(typeclass,interf))
466 /* check the mergedlist */
467 return (merged && mergedlist_implements_interface(merged,interf));
471 typeinfo_is_assignable(typeinfo *value,typeinfo *dest)
473 TYPEINFO_ASSERT(value);
474 TYPEINFO_ASSERT(dest);
475 TYPEINFO_ASSERT(dest->merged == NULL);
477 return typeinfo_is_assignable_to_class(value,dest->typeclass);
481 typeinfo_is_assignable_to_class(typeinfo *value,classref_or_classinfo dest)
483 classref_or_classinfo c;
487 TYPEINFO_ASSERT(value);
489 c = value->typeclass;
491 /* assignments of primitive values are not checked here. */
492 if (!c.any && !dest.any)
495 /* primitive and reference types are not assignment compatible. */
496 if (!c.any || !dest.any)
499 /* the null type can be assigned to any type */
500 if (TYPEINFO_IS_NULLTYPE(*value))
503 /* uninitialized objects are not assignable */
504 if (TYPEINFO_IS_NEWOBJECT(*value))
507 if (IS_CLASSREF(c)) {
508 /* The value type is an unresolved class reference. */
509 classname = c.ref->name;
512 classname = c.cls->name;
515 if (IS_CLASSREF(dest)) {
516 /* the destination type is an unresolved class reference */
517 /* In this case we cannot tell a lot about assignability. */
519 /* the common case of value and dest type having the same classname */
520 if (dest.ref->name == classname && !value->merged)
523 /* we cannot tell if value is assignable to dest, so we */
524 /* leave it up to the resolving code to check this */
528 /* { we know that dest is a loaded class } */
530 if (IS_CLASSREF(c)) {
531 /* the value type is an unresolved class reference */
533 /* the common case of value and dest type having the same classname */
534 if (dest.cls->name == classname)
537 /* we cannot tell if value is assignable to dest, so we */
538 /* leave it up to the resolving code to check this */
542 /* { we know that both c and dest are loaded classes } */
547 load_class_bootstrap(cls); /* XXX */
548 if (!dest.cls->loaded)
549 load_class_bootstrap(dest.cls); /* XXX */
551 TYPEINFO_ASSERT(cls->loaded);
552 TYPEINFO_ASSERT(dest.cls->loaded);
554 /* maybe we need to link the classes */
556 link_class(cls); /* XXX */
557 if (!dest.cls->linked)
558 link_class(dest.cls); /* XXX */
560 /* { we know that both c and dest are linked classes } */
561 TYPEINFO_ASSERT(cls->linked);
562 TYPEINFO_ASSERT(dest.cls->linked);
564 if (dest.cls->flags & ACC_INTERFACE) {
565 /* We are assigning to an interface type. */
566 return merged_implements_interface(cls,value->merged,dest.cls);
569 if (CLASSINFO_IS_ARRAY(dest.cls)) {
570 arraydescriptor *arraydesc = dest.cls->vftbl->arraydesc;
571 int dimension = arraydesc->dimension;
572 classinfo *elementclass = (arraydesc->elementvftbl)
573 ? arraydesc->elementvftbl->class : NULL;
575 /* We are assigning to an array type. */
576 if (!TYPEINFO_IS_ARRAY(*value))
579 /* {Both value and dest.cls are array types.} */
581 /* value must have at least the dimension of dest.cls. */
582 if (value->dimension < dimension)
585 if (value->dimension > dimension) {
586 /* value has higher dimension so we need to check
587 * if its component array can be assigned to the
588 * element type of dest.cls */
590 if (!elementclass) return false;
592 if (elementclass->flags & ACC_INTERFACE) {
593 /* We are assigning to an interface type. */
594 return classinfo_implements_interface(pseudo_class_Arraystub,
598 /* We are assigning to a class type. */
599 return class_issubclass(pseudo_class_Arraystub,elementclass);
602 /* {value and dest.cls have the same dimension} */
604 if (value->elementtype != arraydesc->elementtype)
607 if (value->elementclass.any) {
608 /* We are assigning an array of objects so we have to
609 * check if the elements are assignable.
612 if (elementclass->flags & ACC_INTERFACE) {
613 /* We are assigning to an interface type. */
615 return merged_implements_interface(value->elementclass.cls,
620 /* We are assigning to a class type. */
621 return class_issubclass(value->elementclass.cls,elementclass);
627 /* {dest.cls is not an array} */
628 /* {dest.cls is a loaded class} */
630 /* If there are any unresolved references in the merged list, we cannot */
631 /* tell if the assignment will be ok. */
632 /* This can only happen when cls is java.lang.Object */
633 if (cls == class_java_lang_Object && value->merged) {
634 classref_or_classinfo *mlist = value->merged->list;
635 int i = value->merged->count;
637 if (IS_CLASSREF(*mlist++))
641 /* We are assigning to a class type */
642 if (cls->flags & ACC_INTERFACE)
643 cls = class_java_lang_Object;
645 return class_issubclass(cls,dest.cls);
648 /**********************************************************************/
649 /* INITIALIZATION FUNCTIONS */
650 /* The following functions fill in uninitialized typeinfo structures. */
651 /**********************************************************************/
654 typeinfo_init_class(typeinfo *info,classref_or_classinfo c)
660 TYPEINFO_ASSERT(c.any);
661 TYPEINFO_ASSERT(info);
663 /* if necessary, try to resolve lazily */
664 if (!resolve_classref_or_classinfo(NULL /* XXX should now method */,
665 c,resolveLazy,true,&cls))
667 panic("XXX could not resolve class reference"); /* XXX */
672 TYPEINFO_INIT_CLASSINFO(*info,cls);
676 /* {the type could no be resolved lazily} */
678 info->typeclass.ref = c.ref;
679 info->elementclass.any = NULL;
683 /* handle array type references */
684 utf_ptr = c.ref->name->text;
685 len = c.ref->name->blength;
686 if (*utf_ptr == '[') {
687 /* count dimensions */
688 while (*utf_ptr == '[') {
693 if (*utf_ptr == 'L') {
696 info->elementtype = ARRAYTYPE_OBJECT;
697 info->elementclass.ref = class_get_classref(c.ref->referer,utf_new(utf_ptr,len));
700 /* an array with primitive element type */
701 /* should have been resolved above */
702 TYPEINFO_ASSERT(false);
709 typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo *info)
711 TYPEINFO_ASSERT(desc);
713 #ifdef TYPEINFO_VERBOSE
714 fprintf(stderr,"typeinfo_init_from_typedesc(");
715 descriptor_debug_print_typedesc(stderr,desc);
716 fprintf(stderr,")\n");
723 if (desc->type == TYPE_ADR) {
724 TYPEINFO_ASSERT(desc->classref);
725 TYPEINFO_INIT_CLASSREF(*info,desc->classref);
728 TYPEINFO_INIT_PRIMITIVE(*info);
734 typeinfo_init_from_methoddesc(methoddesc *desc,u1 *typebuf,typeinfo *infobuf,
735 int buflen,bool twoword,
736 u1 *returntype,typeinfo *returntypeinfo)
741 TYPEINFO_ASSERT(desc);
742 TYPEINFO_ASSERT(typebuf);
743 TYPEINFO_ASSERT(infobuf);
745 #ifdef TYPEINFO_VERBOSE
746 fprintf(stderr,"typeinfo_init_from_methoddesc(");
747 descriptor_debug_print_methoddesc(stderr,desc);
748 fprintf(stderr,")\n");
751 /* check arguments */
752 for (i=0; i<desc->paramcount; ++i) {
754 panic("Buffer too small for method arguments."); /* XXX */
756 typeinfo_init_from_typedesc(desc->paramtypes + i,typebuf++,infobuf++);
758 if (twoword && (typebuf[-1] == TYPE_LONG || typebuf[-1] == TYPE_DOUBLE)) {
760 panic("Buffer too small for method arguments."); /* XXX */
761 *typebuf++ = TYPE_VOID;
762 TYPEINFO_INIT_PRIMITIVE(*infobuf);
767 /* check returntype */
769 typeinfo_init_from_typedesc(&(desc->returntype),returntype,returntypeinfo);
774 typedescriptor_init_from_typedesc(typedescriptor *td,
777 td->type = desc->type;
778 if (td->type == TYPE_ADR) {
779 TYPEINFO_INIT_CLASSREF(td->info,desc->classref);
782 TYPEINFO_INIT_PRIMITIVE(td->info);
787 typedescriptors_init_from_methoddesc(typedescriptor *td,
789 int buflen,bool twoword,
790 typedescriptor *returntype)
795 /* check arguments */
796 for (i=0; i<desc->paramcount; ++i) {
798 panic("Buffer too small for method arguments."); /* XXX */
800 typedescriptor_init_from_typedesc(td,desc->paramtypes + i);
803 if (twoword && (td[-1].type == TYPE_LONG || td[-1].type == TYPE_DOUBLE)) {
805 panic("Buffer too small for method arguments."); /* XXX */
806 td->type = TYPE_VOID;
807 TYPEINFO_INIT_PRIMITIVE(td->info);
812 /* check returntype */
814 typedescriptor_init_from_typedesc(returntype,&(desc->returntype));
821 typeinfo_init_component(typeinfo *srcarray,typeinfo *dst)
823 if (TYPEINFO_IS_NULLTYPE(*srcarray)) {
824 TYPEINFO_INIT_NULLTYPE(*dst);
828 if (!TYPEINFO_IS_ARRAY(*srcarray))
829 panic("Trying to access component of non-array"); /* XXX throw exception */
831 if (IS_CLASSREF(srcarray->typeclass)) {
832 constant_classref *comp;
833 comp = class_get_classref_component_of(srcarray->typeclass.ref);
836 TYPEINFO_INIT_CLASSREF(*dst,comp);
838 TYPEINFO_INIT_PRIMITIVE(*dst);
843 TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl);
844 TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl->arraydesc);
846 comp = srcarray->typeclass.cls->vftbl->arraydesc->componentvftbl;
848 TYPEINFO_INIT_CLASSINFO(*dst,comp->class);
850 TYPEINFO_INIT_PRIMITIVE(*dst);
853 dst->merged = srcarray->merged; /* XXX should we do a deep copy? */
857 typeinfo_clone(typeinfo *src,typeinfo *dest)
860 classref_or_classinfo *srclist,*destlist;
868 count = src->merged->count;
869 TYPEINFO_ALLOCMERGED(dest->merged,count);
870 dest->merged->count = count;
872 srclist = src->merged->list;
873 destlist = dest->merged->list;
875 *destlist++ = *srclist++;
879 /**********************************************************************/
880 /* MISCELLANEOUS FUNCTIONS */
881 /**********************************************************************/
884 typeinfo_free(typeinfo *info)
886 TYPEINFO_FREEMERGED_IF_ANY(info->merged);
890 /**********************************************************************/
891 /* MERGING FUNCTIONS */
892 /* The following functions are used to merge the types represented by */
893 /* two typeinfo structures into one typeinfo structure. */
894 /**********************************************************************/
898 typeinfo_merge_error(char *str,typeinfo *x,typeinfo *y) {
899 #ifdef TYPEINFO_VERBOSE
900 fprintf(stderr,"Error in typeinfo_merge: %s\n",str);
901 fprintf(stderr,"Typeinfo x:\n");
902 typeinfo_print(stderr,x,1);
903 fprintf(stderr,"Typeinfo y:\n");
904 typeinfo_print(stderr,y,1);
906 panic(str); /* XXX throw an exception */
909 /* Condition: clsx != clsy. */
910 /* Returns: true if dest was changed (currently always true). */
913 typeinfo_merge_two(typeinfo *dest,classref_or_classinfo clsx,classref_or_classinfo clsy)
915 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
916 TYPEINFO_ALLOCMERGED(dest->merged,2);
917 dest->merged->count = 2;
919 TYPEINFO_ASSERT(clsx.any != clsy.any);
921 if (clsx.any < clsy.any) {
922 dest->merged->list[0] = clsx;
923 dest->merged->list[1] = clsy;
926 dest->merged->list[0] = clsy;
927 dest->merged->list[1] = clsx;
933 /* Returns: true if dest was changed. */
936 typeinfo_merge_add(typeinfo *dest,typeinfo_mergedlist *m,classref_or_classinfo cls)
939 typeinfo_mergedlist *newmerged;
940 classref_or_classinfo *mlist,*newlist;
945 /* Check if cls is already in the mergedlist m. */
947 if ((mlist++)->any == cls.any) { /* XXX check equal classrefs? */
948 /* cls is in the list, so m is the resulting mergedlist */
949 if (dest->merged == m)
952 /* We have to copy the mergedlist */
953 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
955 TYPEINFO_ALLOCMERGED(dest->merged,count);
956 dest->merged->count = count;
957 newlist = dest->merged->list;
960 *newlist++ = *mlist++;
966 /* Add cls to the mergedlist. */
968 TYPEINFO_ALLOCMERGED(newmerged,count+1);
969 newmerged->count = count+1;
970 newlist = newmerged->list;
973 if (mlist->any > cls.any)
975 *newlist++ = *mlist++;
980 *newlist++ = *mlist++;
983 /* Put the new mergedlist into dest. */
984 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
985 dest->merged = newmerged;
990 /* Returns: true if dest was changed. */
993 typeinfo_merge_mergedlists(typeinfo *dest,typeinfo_mergedlist *x,
994 typeinfo_mergedlist *y)
998 typeinfo_mergedlist *temp,*result;
999 classref_or_classinfo *clsx,*clsy,*newlist;
1001 /* count the elements that will be in the resulting list */
1002 /* (Both lists are sorted, equal elements are counted only once.) */
1007 while (countx && county) {
1008 if (clsx->any == clsy->any) {
1014 else if (clsx->any < clsy->any) {
1024 count += countx + county;
1026 /* {The new mergedlist will have count entries.} */
1028 if ((x->count != count) && (y->count == count)) {
1029 temp = x; x = y; y = temp;
1031 /* {If one of x,y is already the result it is x.} */
1032 if (x->count == count) {
1033 /* x->merged is equal to the result */
1034 if (x == dest->merged)
1037 if (!dest->merged || dest->merged->count != count) {
1038 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
1039 TYPEINFO_ALLOCMERGED(dest->merged,count);
1040 dest->merged->count = count;
1043 newlist = dest->merged->list;
1046 *newlist++ = *clsx++;
1051 /* {We have to merge two lists.} */
1053 /* allocate the result list */
1054 TYPEINFO_ALLOCMERGED(result,count);
1055 result->count = count;
1056 newlist = result->list;
1058 /* merge the sorted lists */
1063 while (countx && county) {
1064 if (clsx->any == clsy->any) {
1065 *newlist++ = *clsx++;
1070 else if (clsx->any < clsy->any) {
1071 *newlist++ = *clsx++;
1075 *newlist++ = *clsy++;
1080 *newlist++ = *clsx++;
1082 *newlist++ = *clsy++;
1084 /* replace the list in dest with the result list */
1085 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
1086 dest->merged = result;
1093 typeinfo_merge_nonarrays(typeinfo *dest,
1094 classref_or_classinfo *result,
1095 classref_or_classinfo x,classref_or_classinfo y,
1096 typeinfo_mergedlist *mergedx,
1097 typeinfo_mergedlist *mergedy)
1099 classref_or_classinfo t;
1100 classinfo *tcls,*common;
1101 typeinfo_mergedlist *tmerged;
1106 TYPEINFO_ASSERT(dest && result && x.any && y.any);
1107 TYPEINFO_ASSERT(x.cls != pseudo_class_Null);
1108 TYPEINFO_ASSERT(y.cls != pseudo_class_Null);
1109 TYPEINFO_ASSERT(x.cls != pseudo_class_New);
1110 TYPEINFO_ASSERT(y.cls != pseudo_class_New);
1115 if (!load_class_bootstrap(clsx))
1119 if (!link_class(clsx))
1124 if (!load_class_bootstrap(clsy))
1128 if (!link_class(clsy))
1132 /*--------------------------------------------------*/
1134 /*--------------------------------------------------*/
1136 /* Common case 1: x and y are the same class or class reference */
1137 /* (This case is very simple unless *both* x and y really represent
1138 * merges of subclasses of clsx==clsy.)
1140 if ( (x.any == y.any) && (!mergedx || !mergedy) ) {
1142 /* DEBUG */ /* log_text("return simple x"); */
1143 changed = (dest->merged != NULL);
1144 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
1145 dest->merged = NULL;
1147 /* DEBUG */ /* log_text("returning"); */
1151 xname = (IS_CLASSREF(x)) ? x.ref->name : x.cls->name;
1152 yname = (IS_CLASSREF(y)) ? y.ref->name : y.cls->name;
1154 /* Common case 2: xname == yname, at least one unresolved */
1155 if ((IS_CLASSREF(x) || IS_CLASSREF(y)) && (xname == yname))
1157 /* use the loaded one if any */
1158 if (!IS_CLASSREF(y))
1160 goto return_simple_x;
1163 /*--------------------------------------------------*/
1164 /* non-trivial cases */
1165 /*--------------------------------------------------*/
1167 #ifdef TYPEINFO_VERBOSE
1170 fprintf(stderr,"merge_nonarrays:\n");
1171 TYPEINFO_INIT_CLASSREF_OR_CLASSINFO(dbgx,x);
1172 dbgx.merged = mergedx;
1173 TYPEINFO_INIT_CLASSREF_OR_CLASSINFO(dbgy,y);
1174 dbgy.merged = mergedy;
1175 typeinfo_print(stderr,&dbgx,4);
1176 fprintf(stderr," with:\n");
1177 typeinfo_print(stderr,&dbgy,4);
1181 /* If y is unresolved or an interface, swap x and y. */
1182 if (IS_CLASSREF(y) || (!IS_CLASSREF(x) && y.cls->flags & ACC_INTERFACE))
1184 t = x; x = y; y = t;
1185 tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
1188 /* {We know: If only one of x,y is unresolved it is x,} */
1189 /* { If both x,y are resolved and only one of x,y is an interface it is x.} */
1191 if (IS_CLASSREF(x)) {
1192 /* {We know: x and y have different class names} */
1194 /* Check if we are merging an unresolved type with java.lang.Object */
1195 if (y.cls == class_java_lang_Object && !mergedy) {
1197 goto return_simple_x;
1200 common = class_java_lang_Object;
1201 goto merge_with_simple_x;
1204 /* {We know: both x and y are resolved} */
1205 /* {We know: If only one of x,y is an interface it is x.} */
1207 /* Handle merging of interfaces: */
1208 if (x.cls->flags & ACC_INTERFACE) {
1209 /* {x.cls is an interface and mergedx == NULL.} */
1211 if (y.cls->flags & ACC_INTERFACE) {
1212 /* We are merging two interfaces. */
1213 /* {mergedy == NULL} */
1215 /* {We know that x.cls!=y.cls (see common case at beginning.)} */
1216 result->cls = class_java_lang_Object;
1217 return typeinfo_merge_two(dest,x,y);
1220 /* {We know: x is an interface, y is a class.} */
1222 /* Check if we are merging an interface with java.lang.Object */
1223 if (y.cls == class_java_lang_Object && !mergedy) {
1225 goto return_simple_x;
1229 /* If the type y implements x then the result of the merge
1230 * is x regardless of mergedy.
1233 if (CLASSINFO_IMPLEMENTS_INTERFACE(y.cls,x.cls->index)
1234 || mergedlist_implements_interface(mergedy,x.cls))
1236 /* y implements x, so the result of the merge is x. */
1237 goto return_simple_x;
1240 /* {We know: x is an interface, the type y a class or a merge
1241 * of subclasses and does not implement x.} */
1243 /* There may still be superinterfaces of x which are implemented
1244 * by y, too, so we have to add x.cls to the mergedlist.
1247 /* if x has no superinterfaces we could return a simple java.lang.Object */
1249 common = class_java_lang_Object;
1250 goto merge_with_simple_x;
1253 /* {We know: x and y are classes (not interfaces).} */
1255 /* If *x is deeper in the inheritance hierarchy swap x and y. */
1256 if (x.cls->index > y.cls->index) {
1257 t = x; x = y; y = t;
1258 tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
1261 /* {We know: y is at least as deep in the hierarchy as x.} */
1263 /* Find nearest common anchestor for the classes. */
1266 while (tcls->index > common->index)
1268 while (common != tcls) {
1269 common = common->super;
1273 /* {common == nearest common anchestor of x and y.} */
1275 /* If x.cls==common and x is a whole class (not a merge of subclasses)
1276 * then the result of the merge is x.
1278 if (x.cls == common && !mergedx) {
1279 goto return_simple_x;
1283 result->cls = common;
1285 return typeinfo_merge_mergedlists(dest,mergedx,mergedy);
1287 return typeinfo_merge_add(dest,mergedx,y);
1290 merge_with_simple_x:
1291 result->cls = common;
1293 return typeinfo_merge_add(dest,mergedy,x);
1295 return typeinfo_merge_two(dest,x,y);
1298 /* Condition: *dest must be a valid initialized typeinfo. */
1299 /* Condition: dest != y. */
1300 /* Returns: true if dest was changed. */
1302 typeinfo_merge(typeinfo *dest,typeinfo* y)
1306 classref_or_classinfo common;
1307 classref_or_classinfo elementclass;
1312 /*--------------------------------------------------*/
1314 /*--------------------------------------------------*/
1316 /* Merging something with itself is a nop */
1320 /* Merging two returnAddress types is ok. */
1321 /* Merging two different returnAddresses never happens, as the verifier */
1322 /* keeps them separate in order to check all the possible return paths */
1323 /* from JSR subroutines. */
1324 if (!dest->typeclass.any && !y->typeclass.any) {
1325 TYPEINFO_ASSERT(TYPEINFO_RETURNADDRESS(*dest) == TYPEINFO_RETURNADDRESS(*y));
1329 /* Primitive types cannot be merged with reference types */
1330 /* XXX only check this in debug mode? */
1331 if (!dest->typeclass.any || !y->typeclass.any)
1332 typeinfo_merge_error("Trying to merge primitive types.",dest,y);
1334 /* handle uninitialized object types */
1335 if (TYPEINFO_IS_NEWOBJECT(*dest) || TYPEINFO_IS_NEWOBJECT(*y)) {
1336 if (!TYPEINFO_IS_NEWOBJECT(*dest) || !TYPEINFO_IS_NEWOBJECT(*y))
1337 typeinfo_merge_error("Trying to merge uninitialized object type.",dest,y);
1338 if (TYPEINFO_NEWOBJECT_INSTRUCTION(*dest)
1339 != TYPEINFO_NEWOBJECT_INSTRUCTION(*y))
1340 typeinfo_merge_error("Trying to merge different uninitialized objects.",dest,y);
1344 /*--------------------------------------------------*/
1346 /*--------------------------------------------------*/
1348 /* Common case: dest and y are the same class or class reference */
1349 /* (This case is very simple unless *both* dest and y really represent
1350 * merges of subclasses of class dest==class y.)
1352 if ((dest->typeclass.any == y->typeclass.any) && (!dest->merged || !y->merged)) {
1354 changed = (dest->merged != NULL);
1355 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
1356 dest->merged = NULL;
1360 /* Handle null types: */
1361 if (TYPEINFO_IS_NULLTYPE(*y)) {
1364 if (TYPEINFO_IS_NULLTYPE(*dest)) {
1365 TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
1366 TYPEINFO_CLONE(*y,*dest);
1370 /* Common case: two types with the same name, at least one unresolved */
1371 if (IS_CLASSREF(dest->typeclass)) {
1372 if (IS_CLASSREF(y->typeclass)) {
1373 if (dest->typeclass.ref->name == y->typeclass.ref->name)
1377 /* XXX should we take y instead of dest here? */
1378 if (dest->typeclass.ref->name == y->typeclass.cls->name)
1383 if (IS_CLASSREF(y->typeclass)
1384 && (dest->typeclass.cls->name == y->typeclass.ref->name))
1390 /*--------------------------------------------------*/
1391 /* non-trivial cases */
1392 /*--------------------------------------------------*/
1394 #ifdef TYPEINFO_VERBOSE
1395 fprintf(stderr,"merge:\n");
1396 typeinfo_print(stderr,dest,4);
1397 typeinfo_print(stderr,y,4);
1400 /* This function uses x internally, so x and y can be swapped
1401 * without changing dest. */
1405 /* Handle merging of arrays: */
1406 if (TYPEINFO_IS_ARRAY(*x) && TYPEINFO_IS_ARRAY(*y)) {
1408 /* Make x the one with lesser dimension */
1409 if (x->dimension > y->dimension) {
1410 tmp = x; x = y; y = tmp;
1413 /* If one array (y) has higher dimension than the other,
1414 * interpret it as an array (same dim. as x) of Arraystubs. */
1415 if (x->dimension < y->dimension) {
1416 dimension = x->dimension;
1417 elementtype = ARRAYTYPE_OBJECT;
1418 elementclass.cls = pseudo_class_Arraystub;
1421 dimension = y->dimension;
1422 elementtype = y->elementtype;
1423 elementclass = y->elementclass;
1426 /* {The arrays are of the same dimension.} */
1428 if (x->elementtype != elementtype) {
1429 /* Different element types are merged, so the resulting array
1430 * type has one accessible dimension less. */
1431 if (--dimension == 0) {
1432 common.cls = pseudo_class_Arraystub;
1434 elementclass.any = NULL;
1437 common.cls = class_multiarray_of(dimension,pseudo_class_Arraystub);
1438 elementtype = ARRAYTYPE_OBJECT;
1439 elementclass.cls = pseudo_class_Arraystub;
1443 /* {The arrays have the same dimension and elementtype.} */
1445 if (elementtype == ARRAYTYPE_OBJECT) {
1446 /* The elements are references, so their respective
1447 * types must be merged.
1449 changed |= typeinfo_merge_nonarrays(dest,
1453 x->merged,y->merged);
1455 /* DEBUG */ /* log_text("finding resulting array class: "); */
1456 if (IS_CLASSREF(elementclass))
1457 common.ref = class_get_classref_multiarray_of(dimension,elementclass.ref);
1459 common.cls = class_multiarray_of(dimension,elementclass.cls);
1460 /* DEBUG */ /* utf_display(common->name); printf("\n"); */
1463 common.any = y->typeclass.any;
1468 /* {We know that at least one of x or y is no array, so the
1469 * result cannot be an array.} */
1471 changed |= typeinfo_merge_nonarrays(dest,
1473 x->typeclass,y->typeclass,
1474 x->merged,y->merged);
1478 elementclass.any = NULL;
1481 /* Put the new values into dest if neccessary. */
1483 if (dest->typeclass.any != common.any) {
1484 dest->typeclass.any = common.any;
1487 if (dest->dimension != dimension) {
1488 dest->dimension = dimension;
1491 if (dest->elementtype != elementtype) {
1492 dest->elementtype = elementtype;
1495 if (dest->elementclass.any != elementclass.any) {
1496 dest->elementclass.any = elementclass.any;
1504 /**********************************************************************/
1505 /* DEBUGGING HELPERS */
1506 /**********************************************************************/
1508 #ifdef TYPEINFO_DEBUG
1512 typeinfo_test_compare(classref_or_classinfo *a,classref_or_classinfo *b)
1514 if (a->any == b->any) return 0;
1515 if (a->any < b->any) return -1;
1520 typeinfo_test_parse(typeinfo *info,char *str)
1527 utf *desc = utf_new_char(str);
1529 num = typeinfo_count_method_args(desc,false);
1531 typebuf = DMNEW(u1,num);
1532 infobuf = DMNEW(typeinfo,num);
1534 typeinfo_init_from_method_args(desc,typebuf,infobuf,num,false,
1537 TYPEINFO_ALLOCMERGED(info->merged,num);
1538 info->merged->count = num;
1540 for (i=0; i<num; ++i) {
1541 if (typebuf[i] != TYPE_ADDRESS)
1542 panic("non-reference type in mergedlist");
1543 info->merged->list[i].any = infobuf[i].typeclass.any;
1545 qsort(info->merged->list,num,sizeof(classref_or_classinfo),
1546 (int(*)(const void *,const void *))&typeinfo_test_compare);
1549 typeinfo_init_from_method_args(desc,NULL,NULL,0,false,
1555 #define TYPEINFO_TEST_BUFLEN 4000
1558 typeinfo_equal(typeinfo *x,typeinfo *y)
1562 if (x->typeclass.any != y->typeclass.any) return false;
1563 if (x->dimension != y->dimension) return false;
1565 if (x->elementclass.any != y->elementclass.any) return false;
1566 if (x->elementtype != y->elementtype) return false;
1569 if (TYPEINFO_IS_NEWOBJECT(*x))
1570 if (TYPEINFO_NEWOBJECT_INSTRUCTION(*x)
1571 != TYPEINFO_NEWOBJECT_INSTRUCTION(*y))
1574 if (x->merged || y->merged) {
1575 if (!(x->merged && y->merged)) return false;
1576 if (x->merged->count != y->merged->count) return false;
1577 for (i=0; i<x->merged->count; ++i)
1578 if (x->merged->list[i].any != y->merged->list[i].any)
1585 typeinfo_testmerge(typeinfo *a,typeinfo *b,typeinfo *result,int *failed)
1588 bool changed,changed_should_be;
1590 TYPEINFO_CLONE(*a,dest);
1593 typeinfo_print_short(stdout,&dest);
1595 typeinfo_print_short(stdout,b);
1598 changed = (typeinfo_merge(&dest,b)) ? 1 : 0;
1599 changed_should_be = (!typeinfo_equal(&dest,a)) ? 1 : 0;
1601 printf(" %s\n",(changed) ? "changed" : "=");
1603 if (typeinfo_equal(&dest,result)) {
1605 typeinfo_print_short(stdout,&dest);
1607 if (changed != changed_should_be) {
1608 printf("WRONG RETURN VALUE!\n");
1614 typeinfo_print_short(stdout,&dest);
1616 printf("SHOULD BE ");
1617 typeinfo_print_short(stdout,result);
1625 typeinfo_inc_dimension(typeinfo *info)
1627 if (info->dimension++ == 0) {
1628 info->elementtype = ARRAYTYPE_OBJECT;
1629 info->elementclass = info->typeclass;
1631 info->typeclass = class_array_of(info->typeclass);
1635 #define TYPEINFO_TEST_MAXDIM 10
1638 typeinfo_testrun(char *filename)
1640 char buf[TYPEINFO_TEST_BUFLEN];
1641 char bufa[TYPEINFO_TEST_BUFLEN];
1642 char bufb[TYPEINFO_TEST_BUFLEN];
1643 char bufc[TYPEINFO_TEST_BUFLEN];
1647 FILE *file = fopen(filename,"rt");
1651 panic("could not open typeinfo test file");
1653 while (fgets(buf,TYPEINFO_TEST_BUFLEN,file)) {
1654 if (buf[0] == '#' || !strlen(buf))
1657 res = sscanf(buf,"%s\t%s\t%s\n",bufa,bufb,bufc);
1658 if (res != 3 || !strlen(bufa) || !strlen(bufb) || !strlen(bufc))
1659 panic("Invalid line in typeinfo test file (none of empty, comment or test)");
1661 typeinfo_test_parse(&a,bufa);
1662 typeinfo_test_parse(&b,bufb);
1663 typeinfo_test_parse(&c,bufc);
1668 typeinfo_testmerge(&a,&b,&c,&failed); /* check result */
1669 typeinfo_testmerge(&b,&a,&c,&failed); /* check commutativity */
1671 if (TYPEINFO_IS_NULLTYPE(a)) break;
1672 if (TYPEINFO_IS_NULLTYPE(b)) break;
1673 if (TYPEINFO_IS_NULLTYPE(c)) break;
1675 maxdim = a.dimension;
1676 if (b.dimension > maxdim) maxdim = b.dimension;
1677 if (c.dimension > maxdim) maxdim = c.dimension;
1680 if (maxdim < TYPEINFO_TEST_MAXDIM) {
1681 typeinfo_inc_dimension(&a);
1682 typeinfo_inc_dimension(&b);
1683 typeinfo_inc_dimension(&c);
1685 } while (maxdim < TYPEINFO_TEST_MAXDIM);
1692 fprintf(stderr,"Failed typeinfo_merge tests: %d\n",failed);
1693 panic("Failed test");
1700 log_text("Running typeinfo test file...");
1701 typeinfo_testrun("typeinfo.tst");
1702 log_text("Finished typeinfo test file.");
1707 typeinfo_init_from_fielddescriptor(typeinfo *info,char *desc)
1709 typeinfo_init_from_descriptor(info,desc,desc+strlen(desc));
1713 #define TYPEINFO_MAXINDENT 80
1716 typeinfo_print_class(FILE *file,classref_or_classinfo c)
1718 /*fprintf(file,"<class %p>",c.any);*/
1721 fprintf(file,"<null>");
1724 if (IS_CLASSREF(c)) {
1725 fprintf(file,"<ref>");
1726 utf_fprint(file,c.ref->name);
1729 utf_fprint(file,c.cls->name);
1735 typeinfo_print(FILE *file,typeinfo *info,int indent)
1738 char ind[TYPEINFO_MAXINDENT + 1];
1742 if (indent > TYPEINFO_MAXINDENT) indent = TYPEINFO_MAXINDENT;
1744 for (i=0; i<indent; ++i)
1748 if (TYPEINFO_IS_PRIMITIVE(*info)) {
1749 bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
1751 fprintf(file,"%sreturnAddress (L%03d)\n",ind,bptr->debug_nr);
1753 fprintf(file,"%sprimitive\n",ind);
1757 if (TYPEINFO_IS_NULLTYPE(*info)) {
1758 fprintf(file,"%snull\n",ind);
1762 if (TYPEINFO_IS_NEWOBJECT(*info)) {
1763 ins = (instruction *)TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
1765 fprintf(file,"%sNEW(%p):",ind,(void*)ins);
1766 typeinfo_print_class(file,CLASSREF_OR_CLASSINFO(ins[-1].val.a));
1770 fprintf(file,"%sNEW(this)",ind);
1775 fprintf(file,"%sClass: ",ind);
1776 typeinfo_print_class(file,info->typeclass);
1779 if (TYPEINFO_IS_ARRAY(*info)) {
1780 fprintf(file,"%sDimension: %d",ind,(int)info->dimension);
1781 fprintf(file,"\n%sElements: ",ind);
1782 switch (info->elementtype) {
1783 case ARRAYTYPE_INT : fprintf(file,"int\n"); break;
1784 case ARRAYTYPE_LONG : fprintf(file,"long\n"); break;
1785 case ARRAYTYPE_FLOAT : fprintf(file,"float\n"); break;
1786 case ARRAYTYPE_DOUBLE : fprintf(file,"double\n"); break;
1787 case ARRAYTYPE_BYTE : fprintf(file,"byte\n"); break;
1788 case ARRAYTYPE_CHAR : fprintf(file,"char\n"); break;
1789 case ARRAYTYPE_SHORT : fprintf(file,"short\n"); break;
1790 case ARRAYTYPE_BOOLEAN : fprintf(file,"boolean\n"); break;
1792 case ARRAYTYPE_OBJECT:
1793 typeinfo_print_class(file,info->elementclass);
1798 fprintf(file,"INVALID ARRAYTYPE!\n");
1803 fprintf(file,"%sMerged: ",ind);
1804 for (i=0; i<info->merged->count; ++i) {
1805 if (i) fprintf(file,", ");
1806 typeinfo_print_class(file,info->merged->list[i]);
1813 typeinfo_print_short(FILE *file,typeinfo *info)
1819 /*fprintf(file,"<typeinfo %p>",info);*/
1822 fprintf(file,"(typeinfo*)NULL");
1826 if (TYPEINFO_IS_PRIMITIVE(*info)) {
1827 bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
1829 fprintf(file,"ret(L%03d)",bptr->debug_nr);
1831 fprintf(file,"primitive");
1835 if (TYPEINFO_IS_NULLTYPE(*info)) {
1836 fprintf(file,"null");
1840 if (TYPEINFO_IS_NEWOBJECT(*info)) {
1841 ins = (instruction *)TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
1843 /*fprintf(file,"<ins %p>",ins);*/
1844 fprintf(file,"NEW(%p):",(void*)ins);
1845 typeinfo_print_class(file,CLASSREF_OR_CLASSINFO(ins[-1].val.a));
1848 fprintf(file,"NEW(this)");
1852 typeinfo_print_class(file,info->typeclass);
1856 for (i=0; i<info->merged->count; ++i) {
1857 if (i) fprintf(file,",");
1858 typeinfo_print_class(file,info->merged->list[i]);
1865 typeinfo_print_type(FILE *file,int type,typeinfo *info)
1868 case TYPE_VOID: fprintf(file,"V"); break;
1869 case TYPE_INT: fprintf(file,"I"); break;
1870 case TYPE_FLOAT: fprintf(file,"F"); break;
1871 case TYPE_DOUBLE: fprintf(file,"D"); break;
1872 case TYPE_LONG: fprintf(file,"J"); break;
1874 typeinfo_print_short(file,info);
1883 typeinfo_print_stacktype(FILE *file,int type,typeinfo *info)
1885 TYPEINFO_ASSERT(file);
1886 TYPEINFO_ASSERT(type != TYPE_ADDRESS || info != NULL);
1887 if (type == TYPE_ADDRESS && TYPEINFO_IS_PRIMITIVE(*info)) {
1888 typeinfo_retaddr_set *set = (typeinfo_retaddr_set*)
1889 TYPEINFO_RETURNADDRESS(*info);
1890 fprintf(file,"ret(L%03d",((basicblock*)(set->addr))->debug_nr);
1893 fprintf(file,"|L%03d",((basicblock*)(set->addr))->debug_nr);
1899 typeinfo_print_type(file,type,info);
1903 typedescriptor_print(FILE *file,typedescriptor *td)
1905 typeinfo_print_type(file,td->type,&(td->info));
1909 typevector_print(FILE *file,typevector *vec,int size)
1913 fprintf(file,"[%d]",vec->k);
1914 for (i=0; i<size; ++i) {
1915 fprintf(file," %d=",i);
1916 typedescriptor_print(file,vec->td + i);
1921 typevectorset_print(FILE *file,typevector *set,int size)
1926 fprintf(file,"[%d",set->k);
1929 fprintf(file,"|%d",vec->k);
1934 for (i=0; i<size; ++i) {
1935 fprintf(file," %d=",i);
1936 typedescriptor_print(file,set->td + i);
1940 typedescriptor_print(file,vec->td + i);
1946 #endif /* TYPEINFO_DEBUG */
1950 * These are local overrides for various environment variables in Emacs.
1951 * Please do not remove this and leave it at the end of the file, where
1952 * Emacs will automagically detect them.
1953 * ---------------------------------------------------------------------
1956 * indent-tabs-mode: t