public abstract GetMember ( String name, BindingFlags bindingAttr ) : System.Reflection.MemberInfo[] | ||
name | String | |
bindingAttr | BindingFlags | |
return | System.Reflection.MemberInfo[] |
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; while (scope != null) { MemberInfo[] members = this.members = scope.GetMember(this.name, flags); 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 && ((ClassScope)scope).owner.isStatic) { flags &= ~BindingFlags.Instance; } } else if (scope is StackFrame) { lexLevel++; } evalLexLevel++; scope = scope.GetParent(); } if (this.members.Length > 0) { this.lexLevel = lexLevel; this.evalLexLevel = evalLexLevel; } }
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; } }
public override MemberInfo[] GetMember(string name, BindingFlags bindingAttr) { FieldInfo info = (FieldInfo)base.name_table[name]; if (info != null) { return(new MemberInfo[] { info }); } bool flag = false; ScriptObject parent = base.parent; while (parent is FunctionScope) { FunctionScope scope = (FunctionScope)parent; flag = scope.isMethod && !scope.isStatic; JSLocalField field = (JSLocalField)scope.name_table[name]; if (field == null) { parent = parent.GetParent(); } else { if (field.IsLiteral && !(field.value is FunctionObject)) { return(new MemberInfo[] { field }); } JSLocalField field2 = new JSLocalField(field.Name, this, base.field_table.Count, Microsoft.JScript.Missing.Value) { outerField = field, debugOn = field.debugOn }; if ((!field2.debugOn && this.owner.funcContext.document.debugOn) && scope.owner.funcContext.document.debugOn) { field2.debugOn = Array.IndexOf <string>(scope.owner.formal_parameters, field.Name) >= 0; } field2.isDefined = field.isDefined; field2.debuggerName = "outer." + field2.Name; if (field.IsLiteral) { field2.attributeFlags |= FieldAttributes.Literal; field2.value = field.value; } this.AddOuterScopeField(name, field2); if (this.ProvidesOuterScopeLocals[parent] == null) { this.ProvidesOuterScopeLocals[parent] = parent; } ((FunctionScope)parent).mustSaveStackLocals = true; return(new MemberInfo[] { field2 }); } } if ((parent is ClassScope) && flag) { MemberInfo[] member = parent.GetMember(name, bindingAttr & ~BindingFlags.DeclaredOnly); int length = member.Length; bool flag2 = false; for (int i = 0; i < length; i++) { MethodInfo info3; PropertyInfo info4; MemberInfo info2 = member[i]; MemberTypes memberType = info2.MemberType; if (memberType != MemberTypes.Field) { if (memberType == MemberTypes.Method) { goto Label_029E; } if (memberType == MemberTypes.Property) { goto Label_02C7; } } else { info = (FieldInfo)info2; if (info.IsLiteral) { JSMemberField field3 = info as JSMemberField; if (((field3 != null) && (field3.value is ClassScope)) && !((ClassScope)field3.value).owner.IsStatic) { flag2 = true; } } if (!info.IsStatic && !info.IsLiteral) { member[i] = new JSClosureField(info); flag2 = true; } } continue; Label_029E: info3 = (MethodInfo)info2; if (!info3.IsStatic) { member[i] = new JSClosureMethod(info3); flag2 = true; } continue; Label_02C7: info4 = (PropertyInfo)info2; MethodInfo getMethod = JSProperty.GetGetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); MethodInfo setMethod = JSProperty.GetSetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); bool flag3 = false; if ((getMethod != null) && !getMethod.IsStatic) { flag3 = true; getMethod = new JSClosureMethod(getMethod); } if ((setMethod != null) && !setMethod.IsStatic) { flag3 = true; setMethod = new JSClosureMethod(setMethod); } if (flag3) { member[i] = new JSClosureProperty(info4, getMethod, setMethod); flag2 = true; } } if (flag2) { this.GiveOuterFunctionsTheBadNews(); } if (length > 0) { return(member); } } if ((bindingAttr & BindingFlags.DeclaredOnly) != BindingFlags.Default) { return(new MemberInfo[0]); } return(parent.GetMember(name, bindingAttr)); }
public override MemberInfo[] GetMember(String name, BindingFlags bindingAttr) { FieldInfo field = (FieldInfo)(this.name_table[name]); if (field != null) { return new MemberInfo[] { field } } ; bool nestedInInstanceMethod = false; ScriptObject parent = this.parent; //Treat locals of outer functions as if they were locals of this function while (parent is FunctionScope) { FunctionScope fscope = (FunctionScope)parent; nestedInInstanceMethod = fscope.isMethod && !fscope.isStatic; JSLocalField lfield = (JSLocalField)fscope.name_table[name]; if (lfield == null) { parent = parent.GetParent(); continue; } if (lfield.IsLiteral && !(lfield.value is FunctionObject)) { return new MemberInfo[] { lfield } } ; JSLocalField f = new JSLocalField(lfield.Name, this, this.field_table.Count, Missing.Value); f.outerField = lfield; f.debugOn = lfield.debugOn; if (!f.debugOn && this.owner.funcContext.document.debugOn && fscope.owner.funcContext.document.debugOn) { //Check to see it is off because outer field is a parameter f.debugOn = Array.IndexOf(fscope.owner.formal_parameters, lfield.Name) >= 0; } f.isDefined = lfield.isDefined; f.debuggerName = "outer" + "." + f.Name; if (lfield.IsLiteral) { f.attributeFlags |= FieldAttributes.Literal; f.value = lfield.value; } this.AddOuterScopeField(name, f); if (this.ProvidesOuterScopeLocals[parent] == null) { this.ProvidesOuterScopeLocals[parent] = parent; } ((FunctionScope)parent).mustSaveStackLocals = true; return(new MemberInfo[] { f }); } if (parent is ClassScope && nestedInInstanceMethod) { //return class members as if they were local to the function. It is more convenient to wrap up instance members //at this stage than it is to figure out later that a special case is involved. MemberInfo[] members = parent.GetMember(name, bindingAttr & ~BindingFlags.DeclaredOnly); int n = members.Length; bool giveBadNews = false; for (int i = 0; i < n; i++) { MemberInfo member = members[i]; switch (member.MemberType) { case MemberTypes.Field: field = (FieldInfo)member; if (field.IsLiteral) { JSMemberField mfield = field as JSMemberField; if (mfield != null && mfield.value is ClassScope && !((ClassScope)mfield.value).owner.IsStatic) { giveBadNews = true; } } if (!field.IsStatic && !field.IsLiteral) { members[i] = new JSClosureField(field); giveBadNews = true; } break; case MemberTypes.Method: MethodInfo meth = (MethodInfo)member; if (!meth.IsStatic) { members[i] = new JSClosureMethod(meth); giveBadNews = true; } break; case MemberTypes.Property: PropertyInfo prop = (PropertyInfo)member; MethodInfo getMeth = JSProperty.GetGetMethod(prop, (bindingAttr & BindingFlags.NonPublic) != 0); MethodInfo setMeth = JSProperty.GetSetMethod(prop, (bindingAttr & BindingFlags.NonPublic) != 0); bool nonStatic = false; if (getMeth != null && !getMeth.IsStatic) { nonStatic = true; getMeth = new JSClosureMethod(getMeth); } if (setMeth != null && !setMeth.IsStatic) { nonStatic = true; setMeth = new JSClosureMethod(setMeth); } if (nonStatic) { members[i] = new JSClosureProperty(prop, getMeth, setMeth); giveBadNews = true; } break; } } if (giveBadNews) { this.GiveOuterFunctionsTheBadNews(); //They have to create explicit stack frames } if (n > 0) { return(members); } } if ((bindingAttr & BindingFlags.DeclaredOnly) != 0) { return(new MemberInfo[0]); } return(parent.GetMember(name, bindingAttr)); }
private void BindName() { int num = 0; int num2 = 0; ScriptObject parent = base.Globals.ScopeStack.Peek(); BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; bool flag = false; bool flag2 = false; while (parent != null) { MemberInfo[] member = null; WithObject obj3 = parent as WithObject; if ((obj3 != null) && flag2) { member = obj3.GetMember(base.name, bindingAttr, false); } else { member = parent.GetMember(base.name, bindingAttr); } base.members = member; if (member.Length > 0) { break; } if (parent is WithObject) { base.isFullyResolved = base.isFullyResolved && ((WithObject)parent).isKnownAtCompileTime; num++; } else if (parent is ActivationObject) { base.isFullyResolved = base.isFullyResolved && ((ActivationObject)parent).isKnownAtCompileTime; if ((parent is BlockScope) || ((parent is FunctionScope) && ((FunctionScope)parent).mustSaveStackLocals)) { num++; } if (parent is ClassScope) { if (flag) { flag2 = true; } if (((ClassScope)parent).owner.isStatic) { bindingAttr &= ~BindingFlags.Instance; flag = true; } } } else if (parent is StackFrame) { num++; } num2++; parent = parent.GetParent(); } if (base.members.Length > 0) { this.lexLevel = num; this.evalLexLevel = num2; } }