/runtime/typeinfo/ti_tuple.d

http://github.com/wilkie/djehuty · D · 60 lines · 43 code · 11 blank · 6 comment · 8 complexity · 34baf6b0e0e4acc36eb10ac70b86f8ca MD5 · raw file

  1. /*
  2. * ti_tuple.d
  3. *
  4. * This module implements the TypeInfo for tuple types.
  5. *
  6. */
  7. module runtime.typeinfo.ti_tuple;
  8. class TypeInfo_Tuple : TypeInfo {
  9. TypeInfo[] elements;
  10. char[] toString() {
  11. char[] s;
  12. s = "(";
  13. foreach (i, element; elements) {
  14. if (i)
  15. s ~= ',';
  16. s ~= element.toString();
  17. }
  18. s ~= ")";
  19. return s;
  20. }
  21. int opEquals(Object o) {
  22. if (this is o)
  23. return 1;
  24. auto t = cast(TypeInfo_Tuple)o;
  25. if (t && elements.length == t.elements.length) {
  26. for (size_t i = 0; i < elements.length; i++) {
  27. if (elements[i] != t.elements[i])
  28. return 0;
  29. }
  30. return 1;
  31. }
  32. return 0;
  33. }
  34. hash_t getHash(void *p) {
  35. assert(0);
  36. }
  37. int equals(void *p1, void *p2) {
  38. assert(0);
  39. }
  40. int compare(void *p1, void *p2) {
  41. assert(0);
  42. }
  43. size_t tsize() {
  44. assert(0);
  45. }
  46. void swap(void *p1, void *p2) {
  47. assert(0);
  48. }
  49. }