internal JSObject(ScriptObject parent, bool checkSubType) : base(parent) { this.memberCache = null; this.isASubClass = false; this.subClassIR = null; if (checkSubType) { Type subType = this.GetType(); Debug.Assert(subType != typeof(BuiltinFunction)); if (subType != Typeob.JSObject) { this.isASubClass = true; this.subClassIR = TypeReflector.GetTypeReflectorFor(subType); } } else { Debug.Assert(this.GetType() == Typeob.JSObject); } this.noExpando = this.isASubClass; this.name_table = null; this.field_table = null; this.outer_class_instance = null; }
internal GlobalScope(GlobalScope parent, VsaEngine engine, bool isComponentScope) : base(parent) { this.componentScopes = null; this.recursive = false; this.isComponentScope = isComponentScope; if (parent == null) { this.globalObject = engine.Globals.globalObject; this.globalObjectTR = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(this.globalObject.GetType())); this.fast = !(this.globalObject is LenientGlobalObject); } else { this.globalObject = null; this.globalObjectTR = null; this.fast = parent.fast; if (isComponentScope) { ((GlobalScope)this.parent).AddComponentScope(this); } } this.engine = engine; this.isKnownAtCompileTime = this.fast; this.evilScript = true; //True by default. Set it false when a single script block is being compiled. this.thisObject = this; this.typeReflector = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(this.GetType())); if (isComponentScope) { engine.Scopes.Add(this); } }
internal GlobalScope(GlobalScope parent, VsaEngine engine, bool isComponentScope) : base(parent) { this.componentScopes = null; this.recursive = false; this.isComponentScope = isComponentScope; if (parent == null) { this.globalObject = engine.Globals.globalObject; this.globalObjectTR = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(this.globalObject.GetType())); base.fast = !(this.globalObject is LenientGlobalObject); } else { this.globalObject = null; this.globalObjectTR = null; base.fast = parent.fast; if (isComponentScope) { ((GlobalScope)base.parent).AddComponentScope(this); } } base.engine = engine; base.isKnownAtCompileTime = base.fast; this.evilScript = true; this.thisObject = this; this.typeReflector = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(base.GetType())); if (isComponentScope) { engine.Scopes.Add(this); } }
internal void SetFast() { this.fast = true; this.isKnownAtCompileTime = true; if (this.globalObject != null) { this.globalObject = GlobalObject.commonInstance; this.globalObjectTR = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(this.globalObject.GetType())); } }
internal JSObject(ScriptObject parent, Type subType) : base(parent) { this.memberCache = null; this.isASubClass = false; this.subClassIR = null; subType = Globals.TypeRefs.ToReferenceContext(subType); if (subType != Typeob.JSObject) { this.isASubClass = true; this.subClassIR = TypeReflector.GetTypeReflectorFor(subType); } this.noExpando = this.isASubClass; this.name_table = null; this.field_table = null; }
internal JSObject(ScriptObject parent, Type subType) : base(parent) { this.memberCache = null; this.isASubClass = false; this.subClassIR = null; Debug.Assert(subType == this.GetType() || this.GetType() == typeof(BuiltinFunction)); if (subType != Typeob.JSObject) { this.isASubClass = true; this.subClassIR = TypeReflector.GetTypeReflectorFor(subType); } this.noExpando = this.isASubClass; this.name_table = null; this.field_table = null; }
internal JSObject(ScriptObject parent, bool checkSubType) : base(parent) { this.memberCache = null; this.isASubClass = false; this.subClassIR = null; if (checkSubType) { Type type = Globals.TypeRefs.ToReferenceContext(base.GetType()); if (type != Typeob.JSObject) { this.isASubClass = true; this.subClassIR = TypeReflector.GetTypeReflectorFor(type); } } this.noExpando = this.isASubClass; this.name_table = null; this.field_table = null; this.outer_class_instance = null; }
private MemberInfo[] GetLocalMember(String name, BindingFlags bindingAttr, bool wrapMembers) { MemberInfo[] result = null; FieldInfo field = this.name_table == null ? null : (FieldInfo)this.name_table[name]; if (field == null && this.isASubClass) { if (this.memberCache != null) { result = (MemberInfo[])this.memberCache[name]; if (result != null) { return(result); } } bindingAttr &= ~BindingFlags.NonPublic; //Never expose non public fields of old style objects result = this.subClassIR.GetMember(name, bindingAttr); if (result.Length == 0) { result = this.subClassIR.GetMember(name, (bindingAttr & ~BindingFlags.Instance) | BindingFlags.Static); } int n = result.Length; if (n > 0) { //Suppress any members that are declared in JSObject or earlier. But keep the ones in Object. int hiddenMembers = 0; foreach (MemberInfo mem in result) { Type mtype = mem.DeclaringType; if (mtype == Typeob.JSObject || mtype == Typeob.ScriptObject || mtype == Typeob.ArrayWrapper) { hiddenMembers++; } } if (hiddenMembers > 0 && !(n == 1 && this is ObjectPrototype && name == "ToString")) { MemberInfo[] newResult = new MemberInfo[n - hiddenMembers]; int j = 0; foreach (MemberInfo mem in result) { Type mtype = mem.DeclaringType; if (mtype != Typeob.JSObject && mtype != Typeob.ScriptObject && mtype != Typeob.ArrayWrapper) { newResult[j++] = mem; } } result = newResult; } } if ((result == null || result.Length == 0) && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0) { BindingFlags flags = (bindingAttr & BindingFlags.IgnoreCase) | BindingFlags.Public | BindingFlags.Instance; if (this is StringObject) { result = TypeReflector.GetTypeReflectorFor(Typeob.String).GetMember(name, flags); } else if (this is NumberObject) { result = TypeReflector.GetTypeReflectorFor(((NumberObject)this).baseType).GetMember(name, flags); } else if (this is BooleanObject) { result = TypeReflector.GetTypeReflectorFor(Typeob.Boolean).GetMember(name, flags); } else if (this is StringConstructor) { result = TypeReflector.GetTypeReflectorFor(Typeob.String).GetMember(name, (flags | BindingFlags.Static) & ~BindingFlags.Instance); } else if (this is BooleanConstructor) { result = TypeReflector.GetTypeReflectorFor(Typeob.Boolean).GetMember(name, (flags | BindingFlags.Static) & ~BindingFlags.Instance); } else if (this is ArrayWrapper) { result = TypeReflector.GetTypeReflectorFor(Typeob.Array).GetMember(name, flags); } } if (result != null && result.Length > 0) { if (wrapMembers) { result = ScriptObject.WrapMembers(result, this); } if (this.memberCache == null) { this.memberCache = new SimpleHashtable(32); } this.memberCache[name] = result; return(result); } } if ((bindingAttr & BindingFlags.IgnoreCase) != 0 && (result == null || result.Length == 0)) { result = null; IDictionaryEnumerator e = this.name_table.GetEnumerator(); while (e.MoveNext()) { if (String.Compare(e.Key.ToString(), name, true, CultureInfo.InvariantCulture) == 0) { field = (FieldInfo)e.Value; break; } } } if (field != null) { return new MemberInfo[] { field } } ; if (result == null) { result = new MemberInfo[0]; } return(result); }
private MemberInfo[] GetLocalMember(string name, BindingFlags bindingAttr, bool wrapMembers) { MemberInfo[] members = null; FieldInfo info = (this.name_table == null) ? null : ((FieldInfo)this.name_table[name]); if ((info == null) && this.isASubClass) { if (this.memberCache != null) { members = (MemberInfo[])this.memberCache[name]; if (members != null) { return(members); } } bindingAttr &= ~BindingFlags.NonPublic; members = this.subClassIR.GetMember(name, bindingAttr); if (members.Length == 0) { members = this.subClassIR.GetMember(name, (bindingAttr & ~BindingFlags.Instance) | BindingFlags.Static); } int length = members.Length; if (length > 0) { int num2 = 0; foreach (MemberInfo info2 in members) { if (IsHiddenMember(info2)) { num2++; } } if ((num2 > 0) && (((length != 1) || !(this is ObjectPrototype)) || (name != "ToString"))) { MemberInfo[] infoArray2 = new MemberInfo[length - num2]; int num3 = 0; foreach (MemberInfo info3 in members) { if (!IsHiddenMember(info3)) { infoArray2[num3++] = info3; } } members = infoArray2; } } if (((members == null) || (members.Length == 0)) && (((bindingAttr & BindingFlags.Public) != BindingFlags.Default) && ((bindingAttr & BindingFlags.Instance) != BindingFlags.Default))) { BindingFlags flags = ((bindingAttr & BindingFlags.IgnoreCase) | BindingFlags.Public) | BindingFlags.Instance; if (this is StringObject) { members = TypeReflector.GetTypeReflectorFor(Typeob.String).GetMember(name, flags); } else if (this is NumberObject) { members = TypeReflector.GetTypeReflectorFor(((NumberObject)this).baseType).GetMember(name, flags); } else if (this is BooleanObject) { members = TypeReflector.GetTypeReflectorFor(Typeob.Boolean).GetMember(name, flags); } else if (this is StringConstructor) { members = TypeReflector.GetTypeReflectorFor(Typeob.String).GetMember(name, (flags | BindingFlags.Static) & ~BindingFlags.Instance); } else if (this is BooleanConstructor) { members = TypeReflector.GetTypeReflectorFor(Typeob.Boolean).GetMember(name, (flags | BindingFlags.Static) & ~BindingFlags.Instance); } else if (this is ArrayWrapper) { members = TypeReflector.GetTypeReflectorFor(Typeob.Array).GetMember(name, flags); } } if ((members != null) && (members.Length > 0)) { if (wrapMembers) { members = ScriptObject.WrapMembers(members, this); } if (this.memberCache == null) { this.memberCache = new SimpleHashtable(0x20); } this.memberCache[name] = members; return(members); } } if (((bindingAttr & BindingFlags.IgnoreCase) != BindingFlags.Default) && ((members == null) || (members.Length == 0))) { members = null; IDictionaryEnumerator enumerator = this.name_table.GetEnumerator(); while (enumerator.MoveNext()) { if (string.Compare(enumerator.Key.ToString(), name, StringComparison.OrdinalIgnoreCase) == 0) { info = (FieldInfo)enumerator.Value; break; } } } if (info != null) { return(new MemberInfo[] { info }); } if (members == null) { members = new MemberInfo[0]; } return(members); }