Mercurial > projects > dang
view sema/DType.d @ 26:b4dc2b2c0e38 new_gen
Added a DType class
author | Anders Halager <halager@gmail.com> |
---|---|
date | Sat, 19 Apr 2008 22:19:14 +0200 |
parents | |
children | 9031487e97d7 |
line wrap: on
line source
module sema.DType; import tango.text.Util : jhash; import sema.SymbolTable; class DType { Identifier id; Scope sc; DType actual; this(Identifier id, Scope sc, DType actual = null) { this.id = id; this.sc = sc; if (actual is null) this.actual = this; _name = id.get; } int opEquals(Object o) { if (auto t = cast(DType)o) return this.actual is t.actual; return 0; } int opCmp(Object o) { if (auto t = cast(DType)o) return cast(void*)this.actual - cast(void*)t.actual; return 0; } hash_t toHash() { return cast(hash_t)(cast(void*)this); } char[] name() { return _name; } private: char[] _name; } class DStruct : DType { this(Identifier id, Scope sc, DType actual = null) { super(id, sc, actual); } DType[] members; } class DFunction : DType { this(Identifier id, Scope sc, DType actual = null) { super(id, sc, actual); } DType[] params; DType return_type; }