26
|
1 module sema.DType;
|
|
2
|
|
3 import tango.text.Util : jhash;
|
|
4
|
|
5 import sema.SymbolTable;
|
|
6
|
|
7 class DType
|
|
8 {
|
|
9 Identifier id;
|
|
10 Scope sc;
|
|
11 DType actual;
|
|
12
|
|
13 this(Identifier id, Scope sc, DType actual = null)
|
|
14 {
|
|
15 this.id = id;
|
|
16 this.sc = sc;
|
|
17 if (actual is null)
|
|
18 this.actual = this;
|
|
19 _name = id.get;
|
|
20 }
|
|
21
|
|
22 int opEquals(Object o)
|
|
23 {
|
|
24 if (auto t = cast(DType)o)
|
|
25 return this.actual is t.actual;
|
|
26 return 0;
|
|
27 }
|
|
28
|
|
29 int opCmp(Object o)
|
|
30 {
|
|
31 if (auto t = cast(DType)o)
|
|
32 return cast(void*)this.actual - cast(void*)t.actual;
|
|
33 return 0;
|
|
34 }
|
|
35
|
|
36 hash_t toHash()
|
|
37 {
|
|
38 return cast(hash_t)(cast(void*)this);
|
|
39 }
|
|
40
|
|
41 char[] name() { return _name; }
|
|
42
|
|
43 private:
|
|
44 char[] _name;
|
|
45 }
|
|
46
|
|
47 class DStruct : DType
|
|
48 {
|
|
49 this(Identifier id, Scope sc, DType actual = null)
|
|
50 {
|
|
51 super(id, sc, actual);
|
|
52 }
|
|
53 DType[] members;
|
|
54 }
|
|
55
|
|
56 class DFunction : DType
|
|
57 {
|
|
58 this(Identifier id, Scope sc, DType actual = null)
|
|
59 {
|
|
60 super(id, sc, actual);
|
|
61 }
|
|
62 DType[] params;
|
|
63 DType return_type;
|
|
64 }
|
|
65
|