1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="none" email=""/>
// <version>$Revision: 4482 $</version>
// </file>
using ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.NRefactory.Parser
{
internal class ModifierList
{
Modifiers cur;
Location location = new Location(-1, -1);
public Modifiers Modifier {
get {
return cur;
}
set {
cur = value;
}
}
public Location GetDeclarationLocation(Location keywordLocation)
{
if(location.IsEmpty) {
return keywordLocation;
}
return location;
}
// public Location Location {
// get {
// return location;
// }
// set {
// location = value;
// }
// }
public bool isNone { get { return cur == Modifiers.None; } }
public bool Contains(Modifiers m)
{
return ((cur & m) != 0);
}
public void Add(Modifiers m, Location tokenLocation)
{
if(location.IsEmpty) {
location = tokenLocation;
}
if (m == Modifiers.Internal && (cur & Modifiers.Protected) != 0) {
cur = Modifiers.ProtectedAndInternal;
return;
}
if ((cur & m) == 0) {
cur |= m;
} else {
// parser.Error("modifier " + m + " already defined");
}
}
// public void Add(Modifiers m)
// {
// Add(m.cur, m.Location);
// }
public void Check(Modifiers allowed)
{
Modifiers wrong = cur & ~allowed;
if (wrong != Modifiers.None) {
// parser.Error("modifier(s) " + wrong + " not allowed here");
}
}
}
}
|