Inheritance: ScriptObject
コード例 #1
0
 internal TypeReflector this[Type type]
 {
     get
     {
         int index = type.GetHashCode() % this.table.Length;
         for (TypeReflector reflector = this.table[index]; reflector != null; reflector = reflector.next)
         {
             if (reflector.type == type)
             {
                 return(reflector);
             }
         }
         return(null);
     }
     set
     {
         if (++this.count >= this.threshold)
         {
             this.Rehash();
         }
         int index = (int)(value.hashCode % this.table.Length);
         value.next        = this.table[index];
         this.table[index] = value;
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        private MemberInfo[] GetNewMemberArray(String name, int index)
        {
            MemberInfo[] result = null;
            Object       ob     = this.memberLookupTable[index];

            // ob could be null if another thread got in here before us
            if (ob == null)
            {
                return(this.memberInfos[index]);
            }
            MemberInfo member = ob as MemberInfo;

            if (member != null)
            {
                result = new MemberInfo[] { member }
            }
            ;
            else
            {
                result = ((MemberInfoList)ob).ToArray();
            }
            this.memberInfos[index]       = result;
            this.memberLookupTable[index] = null;
            TypeReflector.WrapMembers(result);
            return(result);
        }
コード例 #4
0
ファイル: jsobject.cs プロジェクト: ydunk/masters
 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;
 }
コード例 #5
0
 internal TypeReflector this[Type type] {
     get{
         uint          hashCode = (uint)type.GetHashCode();
         int           index    = (int)(hashCode % (uint)this.table.Length);
         TypeReflector tr       = this.table[index];
         while (tr != null)
         {
             if (tr.type == type)
             {
                 return(tr);
             }
             tr = tr.next;
         }
         return(null);
     }
     set{
         Debug.Assert(this[type] == null);
         if (++this.count >= this.threshold)
         {
             this.Rehash();
         }
         int index = (int)(value.hashCode % (uint)this.table.Length);
         value.next        = this.table[index];
         this.table[index] = value;
     }
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
ファイル: typereflector.cs プロジェクト: ydunk/masters
        internal TypeReflector(Type type)
            : base(null)
        {
            this.defaultMembers = null;
            SimpleHashtable staticMembers = new SimpleHashtable(256);

            foreach (MemberInfo member in type.GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy))
            {
                String name = member.Name;
                Object ob   = staticMembers[name];
                if (ob == null)
                {
                    staticMembers[name] = member; //Avoid allocating an array until needed
                }
                else if (ob is MemberInfo)
                {
                    MemberInfoList mems = new MemberInfoList(); //Allocate a flexarray of MemberInfo, and turn it into a fixed array when GetMember is called for this name
                    mems.Add((MemberInfo)ob);
                    mems.Add(member);
                    staticMembers[name] = mems;
                }
                else
                {
                    ((MemberInfoList)ob).Add(member);
                }
            }
            this.staticMembers = staticMembers;
            SimpleHashtable instanceMembers = new SimpleHashtable(256);

            foreach (MemberInfo member in type.GetMembers(BindingFlags.Public | BindingFlags.Instance))
            {
                String name = member.Name;
                Object ob   = instanceMembers[name];
                if (ob == null)
                {
                    instanceMembers[name] = member; //Avoid allocating an array until needed
                }
                else if (ob is MemberInfo)
                {
                    MemberInfoList mems = new MemberInfoList();
                    mems.Add((MemberInfo)ob);
                    mems.Add(member);
                    instanceMembers[name] = mems;
                }
                else
                {
                    ((MemberInfoList)ob).Add(member);
                }
            }
            this.instanceMembers    = instanceMembers;
            this.memberInfos        = new MemberInfo[staticMembers.count + instanceMembers.count][];
            this.count              = 0;
            this.type               = type;
            this.implementsIReflect = null;
            this.hashCode           = (uint)type.GetHashCode();
            this.next               = null;
        }
コード例 #9
0
 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()));
     }
 }
コード例 #10
0
 internal MemberInfo[] GetDefaultMembers()
 {
     MemberInfo[] result = this.defaultMembers;
     if (result == null)
     {
         result = JSBinder.GetDefaultMembers(this.type);
         if (result == null)
         {
             result = new MemberInfo[0];
         }
         TypeReflector.WrapMembers(this.defaultMembers = result);
     }
     return(result);
 }
コード例 #11
0
 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;
 }
コード例 #12
0
ファイル: jsobject.cs プロジェクト: ydunk/masters
 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;
 }
コード例 #13
0
        private void Rehash()
        {
            TypeReflector[] oldTable    = this.table;
            int             threshold   = this.threshold = oldTable.Length + 1;
            int             newCapacity = threshold * 2 - 1;

            TypeReflector[] newTable = this.table = new TypeReflector[newCapacity];
            for (int i = threshold - 1; i-- > 0;)
            {
                for (TypeReflector old = oldTable[i]; old != null;)
                {
                    TypeReflector tr    = old; old = old.next;
                    int           index = (int)(tr.hashCode % (uint)newCapacity);
                    tr.next         = newTable[index];
                    newTable[index] = tr;
                }
            }
        }
コード例 #14
0
ファイル: typereflector.cs プロジェクト: ydunk/masters
        private MemberInfo[] GetNewMemberArray(String name, Object ob, SimpleHashtable lookupTable)
        {
            MemberInfo[] result = null;
            MemberInfo   member = ob as MemberInfo;

            if (member != null)
            {
                result = new MemberInfo[] { member }
            }
            ;
            else
            {
                result = ((MemberInfoList)ob).ToArray();
            }
            lookupTable[name] = this.count;
            this.memberInfos[this.count++] = result;
            TypeReflector.WrapMembers(result);
            return(result);
        }
コード例 #15
0
 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;
 }
コード例 #16
0
        internal static TypeReflector GetTypeReflectorFor(Type type)
        {
            TypeReflector result = TypeReflector.Table[type];

            if (result != null)
            {
                return(result);
            }
            result = new TypeReflector(type);
            lock (TypeReflector.Table){
                TypeReflector r = TypeReflector.Table[type];
                if (r != null)
                {
                    return(r);
                }
                TypeReflector.Table[type] = result;
            }
            return(result);
        }
コード例 #17
0
        internal static TypeReflector GetTypeReflectorFor(Type type)
        {
            TypeReflector reflector = Table[type];

            if (reflector == null)
            {
                reflector = new TypeReflector(type);
                lock (Table)
                {
                    TypeReflector reflector2 = Table[type];
                    if (reflector2 != null)
                    {
                        return(reflector2);
                    }
                    Table[type] = reflector;
                }
            }
            return(reflector);
        }
コード例 #18
0
ファイル: typereflector.cs プロジェクト: ArildF/masters
 internal TypeReflector(Type type)
   : base(null){
   this.defaultMembers = null;
   SimpleHashtable staticMembers = new SimpleHashtable(256);
   foreach (MemberInfo member in type.GetMembers(BindingFlags.Public|BindingFlags.Static|BindingFlags.FlattenHierarchy)){
     String name = member.Name;
     Object ob = staticMembers[name];
     if (ob == null)
       staticMembers[name] = member; //Avoid allocating an array until needed
     else if (ob is MemberInfo){
       MemberInfoList mems = new MemberInfoList(); //Allocate a flexarray of MemberInfo, and turn it into a fixed array when GetMember is called for this name
       mems.Add((MemberInfo)ob);
       mems.Add(member);
       staticMembers[name] = mems;
     }else
       ((MemberInfoList)ob).Add(member);
   }
   this.staticMembers = staticMembers;
   SimpleHashtable instanceMembers = new SimpleHashtable(256);
   foreach (MemberInfo member in type.GetMembers(BindingFlags.Public|BindingFlags.Instance)){
     String name = member.Name;
     Object ob = instanceMembers[name];
     if (ob == null)
       instanceMembers[name] = member; //Avoid allocating an array until needed
     else if (ob is MemberInfo){
       MemberInfoList mems = new MemberInfoList();
       mems.Add((MemberInfo)ob);
       mems.Add(member);
       instanceMembers[name] = mems;
     }else
       ((MemberInfoList)ob).Add(member);
   }
   this.instanceMembers = instanceMembers;
   this.memberInfos = new MemberInfo[staticMembers.count+instanceMembers.count][];
   this.count = 0;
   this.type = type;
   this.implementsIReflect = null;
   this.hashCode = (uint)type.GetHashCode();
   this.next = null;
 }
コード例 #19
0
        private void Rehash()
        {
            TypeReflector[] table = this.table;
            int             num   = this.threshold = table.Length + 1;
            int             num2  = (num * 2) - 1;

            TypeReflector[] reflectorArray2 = this.table = new TypeReflector[num2];
            int             index           = num - 1;

            while (index-- > 0)
            {
                TypeReflector next = table[index];
                while (next != null)
                {
                    TypeReflector reflector2 = next;
                    next = next.next;
                    int num4 = (int)(reflector2.hashCode % num2);
                    reflector2.next       = reflectorArray2[num4];
                    reflectorArray2[num4] = reflector2;
                }
            }
        }
コード例 #20
0
ファイル: globalscope.cs プロジェクト: ArildF/masters
 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(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(this.GetType());
   if (isComponentScope)
     engine.Scopes.Add(this);
 }
コード例 #21
0
        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);
        }
コード例 #22
0
ファイル: globalscope.cs プロジェクト: ArildF/masters
 internal void SetFast(){
   this.fast = true;
   this.isKnownAtCompileTime = true;
   if (this.globalObject != null){
     this.globalObject = GlobalObject.commonInstance;
     this.globalObjectTR = TypeReflector.GetTypeReflectorFor(this.globalObject.GetType());
   }
 }
コード例 #23
0
 internal static TypeReflector GetTypeReflectorFor(Type type)
 {
     TypeReflector reflector = Table[type];
     if (reflector == null)
     {
         reflector = new TypeReflector(type);
         lock (Table)
         {
             TypeReflector reflector2 = Table[type];
             if (reflector2 != null)
             {
                 return reflector2;
             }
             Table[type] = reflector;
         }
     }
     return reflector;
 }
コード例 #24
0
 internal TypeReflector(Type type) : base(null)
 {
     this.defaultMembers = null;
     ArrayList list = new ArrayList(0x200);
     int num = 0;
     SimpleHashtable hashtable = new SimpleHashtable(0x100);
     foreach (MemberInfo info in type.GetMembers(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static))
     {
         string name = info.Name;
         object obj2 = hashtable[name];
         if (obj2 == null)
         {
             hashtable[name] = num++;
             list.Add(info);
         }
         else
         {
             int num2 = (int) obj2;
             obj2 = list[num2];
             MemberInfo elem = obj2 as MemberInfo;
             if (elem != null)
             {
                 MemberInfoList list2 = new MemberInfoList();
                 list2.Add(elem);
                 list2.Add(info);
                 list[num2] = list2;
             }
             else
             {
                 ((MemberInfoList) obj2).Add(info);
             }
         }
     }
     this.staticMembers = hashtable;
     SimpleHashtable hashtable2 = new SimpleHashtable(0x100);
     foreach (MemberInfo info3 in type.GetMembers(BindingFlags.Public | BindingFlags.Instance))
     {
         string str2 = info3.Name;
         object obj3 = hashtable2[str2];
         if (obj3 == null)
         {
             hashtable2[str2] = num++;
             list.Add(info3);
         }
         else
         {
             int num3 = (int) obj3;
             obj3 = list[num3];
             MemberInfo info4 = obj3 as MemberInfo;
             if (info4 != null)
             {
                 MemberInfoList list3 = new MemberInfoList();
                 list3.Add(info4);
                 list3.Add(info3);
                 list[num3] = list3;
             }
             else
             {
                 ((MemberInfoList) obj3).Add(info3);
             }
         }
     }
     this.instanceMembers = hashtable2;
     this.memberLookupTable = list;
     this.memberInfos = new MemberInfo[num][];
     this.type = type;
     this.implementsIReflect = null;
     this.is__ComObject = null;
     this.hashCode = (uint) type.GetHashCode();
     this.next = null;
 }
コード例 #25
0
 internal static TypeReflector GetTypeReflectorFor(Type type){
   TypeReflector result = TypeReflector.Table[type];
   if (result != null) return result;
   result = new TypeReflector(type);
   lock(TypeReflector.Table){
     TypeReflector r = TypeReflector.Table[type];
     if (r != null) return r;
     TypeReflector.Table[type] = result;
   }
   return result;
 }
コード例 #26
0
ファイル: jsobject.cs プロジェクト: ydunk/masters
        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);
        }
コード例 #27
0
 internal void SetFast()
 {
     base.fast = true;
     base.isKnownAtCompileTime = true;
     if (this.globalObject != null)
     {
         this.globalObject = GlobalObject.commonInstance;
         this.globalObjectTR = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(this.globalObject.GetType()));
     }
 }
コード例 #28
0
 internal TypeReflector(Type type)
   : base(null){
   this.defaultMembers = null;
   ArrayList memberLookupTable = new ArrayList(512);
   int count = 0;
   SimpleHashtable staticMembers = new SimpleHashtable(256);
   foreach (MemberInfo member in type.GetMembers(BindingFlags.Public|BindingFlags.Static|BindingFlags.FlattenHierarchy)){
     String name = member.Name;
     Object ob = staticMembers[name];
     if (ob == null){
       staticMembers[name] = count++; //Avoid allocating an array until needed
       memberLookupTable.Add(member);
     }else{
       int index = (int)ob;
       ob = memberLookupTable[index];
       MemberInfo firstMember = ob as MemberInfo;
       if (firstMember != null){
         MemberInfoList mems = new MemberInfoList(); //Allocate a flexarray of MemberInfo, and turn it into a fixed array when GetMember is called for this name
         mems.Add(firstMember);
         mems.Add(member);
         memberLookupTable[index] = mems;
       }else
         ((MemberInfoList)ob).Add(member);
     }
   }
   this.staticMembers = staticMembers;
   SimpleHashtable instanceMembers = new SimpleHashtable(256);
   foreach (MemberInfo member in type.GetMembers(BindingFlags.Public|BindingFlags.Instance)){
     String name = member.Name;
     Object ob = instanceMembers[name];
     if (ob == null){
       instanceMembers[name] = count++; //Avoid allocating an array until needed
       memberLookupTable.Add(member);
     }else{
       int index = (int)ob;
       ob = memberLookupTable[index];
       MemberInfo firstMember = ob as MemberInfo;
       if (firstMember != null){
         MemberInfoList mems = new MemberInfoList();
         mems.Add(firstMember);
         mems.Add(member);
         memberLookupTable[index] = mems;
       }else
         ((MemberInfoList)ob).Add(member);
     }
   }
   this.instanceMembers = instanceMembers;
   this.memberLookupTable = memberLookupTable;
   this.memberInfos = new MemberInfo[count][];
   this.type = type;
   this.implementsIReflect = null;
   this.hashCode = (uint)type.GetHashCode();
   this.next = null;
 }
コード例 #29
0
        internal TypeReflector(Type type) : base(null)
        {
            this.defaultMembers = null;
            ArrayList       list      = new ArrayList(0x200);
            int             num       = 0;
            SimpleHashtable hashtable = new SimpleHashtable(0x100);

            foreach (MemberInfo info in type.GetMembers(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static))
            {
                string name = info.Name;
                object obj2 = hashtable[name];
                if (obj2 == null)
                {
                    hashtable[name] = num++;
                    list.Add(info);
                }
                else
                {
                    int num2 = (int)obj2;
                    obj2 = list[num2];
                    MemberInfo elem = obj2 as MemberInfo;
                    if (elem != null)
                    {
                        MemberInfoList list2 = new MemberInfoList();
                        list2.Add(elem);
                        list2.Add(info);
                        list[num2] = list2;
                    }
                    else
                    {
                        ((MemberInfoList)obj2).Add(info);
                    }
                }
            }
            this.staticMembers = hashtable;
            SimpleHashtable hashtable2 = new SimpleHashtable(0x100);

            foreach (MemberInfo info3 in type.GetMembers(BindingFlags.Public | BindingFlags.Instance))
            {
                string str2 = info3.Name;
                object obj3 = hashtable2[str2];
                if (obj3 == null)
                {
                    hashtable2[str2] = num++;
                    list.Add(info3);
                }
                else
                {
                    int num3 = (int)obj3;
                    obj3 = list[num3];
                    MemberInfo info4 = obj3 as MemberInfo;
                    if (info4 != null)
                    {
                        MemberInfoList list3 = new MemberInfoList();
                        list3.Add(info4);
                        list3.Add(info3);
                        list[num3] = list3;
                    }
                    else
                    {
                        ((MemberInfoList)obj3).Add(info3);
                    }
                }
            }
            this.instanceMembers   = hashtable2;
            this.memberLookupTable = list;
            this.memberInfos       = new MemberInfo[num][];
            this.type = type;
            this.implementsIReflect = null;
            this.is__ComObject      = null;
            this.hashCode           = (uint)type.GetHashCode();
            this.next = null;
        }