internal bool IsAccessibleFrom(ScriptObject scope){ //Never call this if the member is public
while (scope != null && !(scope is ClassScope))
scope = scope.GetParent();
ClassScope thisScope = (ClassScope)this.cons.enclosing_scope;
if (this.IsPrivate)
if (scope == null)
return false;
else
return scope == thisScope || ((ClassScope)scope).IsNestedIn(thisScope, false);
else if (this.IsFamily)
if (scope == null)
return false;
else
return ((ClassScope)scope).IsSameOrDerivedFrom(thisScope) || ((ClassScope)scope).IsNestedIn(thisScope, false);
else { // if (this.IsAssembly || this.isFamilyOrAssembly)
if (this.IsFamilyOrAssembly && scope != null &&
(((ClassScope)scope).IsSameOrDerivedFrom(thisScope) || ((ClassScope)scope).IsNestedIn(thisScope, false)))
return true;
else if (scope == null) //Code is not in a class and hence it is in the default package
return thisScope.GetPackage() == null; //null indicates default package
else
return thisScope.GetPackage() == ((ClassScope)scope).GetPackage();
}
}