private void BindName()
{
int lexLevel = 0;
int evalLexLevel = 0;
ScriptObject scope = Globals.ScopeStack.Peek();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
bool staticClassFound = false; // is there a static class on the scope chain
bool enclosingClassForStaticClassFound = false; // has the class enclosing a static nested class been found
while (scope != null)
{
MemberInfo[] members = null;
WithObject withScope = scope as WithObject;
if (withScope != null && enclosingClassForStaticClassFound)
{
members = withScope.GetMember(this.name, flags, false);
}
else
{
members = scope.GetMember(this.name, flags);
}
this.members = members;
if (members.Length > 0)
{
break;
}
if (scope is WithObject)
{
this.isFullyResolved = this.isFullyResolved && ((WithObject)scope).isKnownAtCompileTime;
lexLevel++;
}
else if (scope is ActivationObject)
{
this.isFullyResolved = this.isFullyResolved && ((ActivationObject)scope).isKnownAtCompileTime;
if (scope is BlockScope || (scope is FunctionScope && ((FunctionScope)scope).mustSaveStackLocals))
{
lexLevel++;
}
if (scope is ClassScope)
{
if (staticClassFound)
{
enclosingClassForStaticClassFound = true;
}
if (((ClassScope)scope).owner.isStatic)
{
flags &= ~BindingFlags.Instance;
staticClassFound = true;
}
}
}
else if (scope is StackFrame)
{
lexLevel++;
}
evalLexLevel++;
scope = scope.GetParent();
}
if (this.members.Length > 0)
{
this.lexLevel = lexLevel;
this.evalLexLevel = evalLexLevel;
}
}