PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 8module runtime.typeinfo.ti_tuple;
 9
10class TypeInfo_Tuple : TypeInfo {
11	TypeInfo[] elements;
12
13	char[] toString() {
14		char[] s;
15		s = "(";
16		foreach (i, element; elements) {
17			if (i)
18				s ~= ',';
19			s ~= element.toString();
20		}
21		s ~= ")";
22		return s;
23	}
24
25	int opEquals(Object o) {
26		if (this is o)
27			return 1;
28
29		auto t = cast(TypeInfo_Tuple)o;
30		if (t && elements.length == t.elements.length) {
31			for (size_t i = 0; i < elements.length; i++) {
32				if (elements[i] != t.elements[i])
33					return 0;
34			}
35			return 1;
36		}
37		return 0;
38	}
39
40	hash_t getHash(void *p) {
41		assert(0);
42	}
43
44	int equals(void *p1, void *p2) {
45		assert(0);
46	}
47
48	int compare(void *p1, void *p2) {
49		assert(0);
50	}
51
52	size_t tsize() {
53		assert(0);
54	}
55
56	void swap(void *p1, void *p2) {
57		assert(0);
58	}
59}
60