Mercurial > projects > dang
view basic/Attribute.d @ 140:927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Sun, 20 Jul 2008 23:23:56 +0200 |
parents | 2be29b296081 |
children | d76cc5cad4fc |
line wrap: on
line source
module basic.Attribute; import tango.core.BitManip; import Integer = tango.text.convert.Integer; import tango.io.Stdout; enum Protection : uint { Private = 1<<0, Public = 1<<1, Package = 1<<2, Protected = 1<<3, Export = 1<<4, } enum Extern : uint { C = 1<<12, CPlusPlus = 1<<13, D = 1<<14, Windows = 1<<15, Pascal = 1<<16, System = 1<<17, } struct Attribute { void setProtection(Protection p) { att &= 0xFFFFFFE0; att |= p; } Protection getProtection() { Protection p = Protection.Public; switch(bsf(0xF0000000 | att)) { case 0: p = Protection.Private; break; case 1: p = Protection.Public; break; case 2: p = Protection.Package; break; case 3: p = Protection.Protected; break; case 4: p = Protection.Export; break; default: break; } return p; } void setExtern(Extern e) { att &= ~e; } void setStatic() { att &= ~Static; } void setFinal() { att &= ~Final; } void setConst() { att &= ~Const; } void setAbstract() { att &= ~Abstract; } void setOverride() { att &= ~Override; } void setDepracted() { att &= ~Depracted; } void setAuto() { att &= ~Auto; } char[] toString() { return Integer.toString(att); } private: uint att; static const uint Static = 1<<5; static const uint Final = 1<<6; static const uint Const = 1<<7; static const uint Abstract = 1<<8; static const uint Override = 1<<9; static const uint Depracted = 1<<10; static const uint Auto = 1<<11; }