public enum Modifier {none=0, _new=1, _public=2, _protected=4, _internal=8, _private=16, constants=31, _unsafe=32,
structsInterfacesEnumsDelegates=63, _static=64,
_readonly=128, _volatile=256, fields=511, _virtual=512,
_sealed=1024, _override=2048, _abstract=4096, classes=5183, _extern=8192, destructors=8224, constructors=8254,
staticConstructors=8288, operatiors=8290, propertysEventsMethods=15999, indexers=15935, all=16383};
public class Modifiers {
public Modifier cur;
public Modifiers() {
cur=Modifier.none;
}
public bool AddModifier(Modifier modifier) {
bool result=((cur&modifier)==0);
if (result) {
cur |= modifier;
}
else {
Error("You have defined the modifier twice: " + modifier.ToString().Substring(1));
}
return result;
}
public void CheckModifiers (Modifier allowed) {
string errorString="";
Modifier temp = cur & (allowed ^ Modifier.all);
for (Modifier m=Modifier._new; m<=Modifier.all; m=(Modifier)((int )m<<1)) {
if ((temp&m)!=0) {
errorString = errorString + (temp&m).ToString().Substring(1) + " ,";
}
}
if (!errorString.Equals("")) {
errorString = errorString.Substring(0, errorString.Length-1);
Error("These modifieres are not allowed here: " + errorString);
}
}
}
|