comparison tango/lib/compiler/llvmdc/genobj.d @ 272:94ef6d63f7bb trunk

[svn r293] Fixed: object.TypeInfo_Struct implementation was incorrect.
author lindquist
date Wed, 18 Jun 2008 22:27:02 +0200
parents 1e6e2b5d5bfe
children 665b81613475
comparison
equal deleted inserted replaced
271:1e6e2b5d5bfe 272:94ef6d63f7bb
759 { 759 {
760 debug(PRINTF) printf("getHash() using default hash\n"); 760 debug(PRINTF) printf("getHash() using default hash\n");
761 // A sorry hash algorithm. 761 // A sorry hash algorithm.
762 // Should use the one for strings. 762 // Should use the one for strings.
763 // BUG: relies on the GC not moving objects 763 // BUG: relies on the GC not moving objects
764 for (size_t i = 0; i < init.length; i++) 764 for (size_t i = 0; i < m_init.length; i++)
765 { h = h * 9 + *cast(ubyte*)p; 765 { h = h * 9 + *cast(ubyte*)p;
766 p++; 766 p++;
767 } 767 }
768 } 768 }
769 return h; 769 return h;
770 } 770 }
771 771
772 int equals(void *p2, void *p1) 772 int equals(void *p1, void *p2)
773 { int c; 773 { int c;
774 774
775 if (p1 == p2) 775 if (p1 == p2)
776 c = 1; 776 c = 1;
777 else if (!p1 || !p2) 777 else if (!p1 || !p2)
778 c = 0; 778 c = 0;
779 else if (xopEquals) 779 else if (xopEquals)
780 c = (*xopEquals)(p1, p2); 780 c = (*xopEquals)(p1, p2);
781 else 781 else
782 // BUG: relies on the GC not moving objects 782 // BUG: relies on the GC not moving objects
783 c = (memcmp(p1, p2, init.length) == 0); 783 c = (memcmp(p1, p2, m_init.length) == 0);
784 return c; 784 return c;
785 } 785 }
786 786
787 int compare(void *p2, void *p1) 787 int compare(void *p1, void *p2)
788 { 788 {
789 int c = 0; 789 int c = 0;
790 790
791 // Regard null references as always being "less than" 791 // Regard null references as always being "less than"
792 if (p1 != p2) 792 if (p1 != p2)
796 c = 1; 796 c = 1;
797 else if (xopCmp) 797 else if (xopCmp)
798 c = (*xopCmp)(p1, p2); 798 c = (*xopCmp)(p1, p2);
799 else 799 else
800 // BUG: relies on the GC not moving objects 800 // BUG: relies on the GC not moving objects
801 c = memcmp(p1, p2, init.length); 801 c = memcmp(p1, p2, m_init.length);
802 } 802 }
803 else 803 else
804 c = -1; 804 c = -1;
805 } 805 }
806 return c; 806 return c;
807 } 807 }
808 808
809 size_t tsize() 809 size_t tsize()
810 { 810 {
811 return init.length; 811 return m_init.length;
812 } 812 }
813 813
814 void[] init() { return m_init; } 814 void[] init() { return m_init; }
815 815
816 uint flags() { return m_flags; } 816 uint flags() { return m_flags; }
817 817
818 char[] name; 818 char[] name;
819 void[] m_init; // initializer; init.ptr == null if 0 initialize 819 void[] m_init; // initializer; never null
820 820
821 hash_t function(void*) xtoHash; 821 hash_t function(void*) xtoHash;
822 int function(void*,void*) xopEquals; 822 int function(void*,void*) xopEquals;
823 int function(void*,void*) xopCmp; 823 int function(void*,void*) xopCmp;
824 char[] function(void*) xtoString; 824 char[] function(void*) xtoString;