A group of CLR methods that are treated as a single Ruby method.
Inheritance: RubyMethodGroupBase
コード例 #1
1
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : base(info.MethodBases, flags, module) {
     _isStatic = info._isStatic;
     _hasVirtuals = info._hasVirtuals;
     _staticDispatchMethods = info._staticDispatchMethods;
     // Note: overloadOwners and maxCachedOverloadLevel are cleared whenever the group is copied.
 }
コード例 #2
0
        private RubyMethodGroupInfo /*!*/ MakeAllMethodsGroup(RubyClass /*!*/ cls)
        {
            var overloads      = new MethodBase[_allMethods.Count];
            var overloadOwners = new RubyMethodGroupInfo[overloads.Length];
            int i = 0;

            foreach (var entry in _allMethods.Values)
            {
                overloads[i]      = entry.Overload;
                overloadOwners[i] = entry.Owner;
                i++;
            }

            var result = new RubyMethodGroupInfo(overloads, cls, overloadOwners, cls.IsSingletonClass);

            // update ownership of overloads owned by the new group:
            foreach (var entry in _allMethods.Values)
            {
                if (entry.Owner != null)
                {
                    entry.Owner.CachedInGroup(result);
                }
                else
                {
                    entry.Owner = result;
                }
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Creates a CLR method group.
        /// </summary>
        internal RubyMethodGroupInfo(MethodBase/*!*/[]/*!*/ methods, RubyModule/*!*/ declaringModule,
            RubyMethodGroupInfo/*!*/[] overloadOwners, bool isStatic)
            : base(methods, RubyMemberFlags.Public, declaringModule) {
            Debug.Assert(overloadOwners == null || methods.Length == overloadOwners.Length);

            _isStatic = isStatic;
            _overloadOwners = overloadOwners;
        }
コード例 #4
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : base(info.MethodBases, flags, module) {
     _isStatic = info._isStatic;
     _hasVirtuals = info._hasVirtuals;
     _staticDispatchMethods = info._staticDispatchMethods;
     // Note: overloadOwners and maxCachedOverloadLevel are cleared whenever the group is copied
     // The resulting group captures an immutable set of underlying CLR members.
 }
コード例 #5
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo /*!*/ info, RubyMemberFlags flags, RubyModule /*!*/ module)
     : base(flags, module)
 {
     _methodBases  = info._methodBases;
     _overloads    = info._overloads;
     _isRubyMethod = info._isRubyMethod;
     _isClrStatic  = info._isClrStatic;
 }
コード例 #6
0
        // Called on this group whenever other group includes some overloads from this group.
        // Updates maxCachedOverloadLevel - the max. class hierarchy level which caches an overload owned by this group.
        internal void CachedInGroup(RubyMethodGroupInfo/*!*/ group) {
            Context.RequiresClassHierarchyLock();

            int groupLevel = ((RubyClass)group.DeclaringModule).Level;
            if (_maxCachedOverloadLevel < groupLevel) {
                _maxCachedOverloadLevel = groupLevel;
            }
        }
コード例 #7
0
        internal override void BuildCallNoFlow(MetaObjectBuilder /*!*/ metaBuilder, CallArguments /*!*/ args, string /*!*/ name)
        {
            var actualArgs = RubyMethodGroupInfo.MakeActualArgs(metaBuilder, args, true, false, false, false);

            metaBuilder.Result = Methods.SetInstanceVariable.OpCall(
                AstFactory.Box(actualArgs[0]),
                AstFactory.Box(actualArgs[1]),
                args.ScopeExpression,
                AstUtils.Constant(InstanceVariableName)
                );
        }
コード例 #8
0
ファイル: RubyOverloadGroupInfo.cs プロジェクト: ltwlf/IronSP
        // Called on this group whenever other group includes some overloads from this group.
        // Updates maxCachedOverloadLevel - the max. class hierarchy level which caches an overload owned by this group.
        internal void CachedInGroup(RubyMethodGroupInfo /*!*/ group)
        {
            Context.RequiresClassHierarchyLock();

            int groupLevel = ((RubyClass)group.DeclaringModule).Level;

            if (_maxCachedOverloadLevel < groupLevel)
            {
                _maxCachedOverloadLevel = groupLevel;
            }
        }
コード例 #9
0
ファイル: RubyClass.cs プロジェクト: kashano/main
        // thread safe: doesn't need any lock since it only accesses immutable state
        public bool TryGetClrConstructor(out RubyMemberInfo method) {
            OverloadInfo[] ctors;
            if (TypeTracker != null && (ctors = GetConstructors(TypeTracker.Type).ToArray()).Length > 0) {
                method = new RubyMethodGroupInfo(ctors, this, true);
                return true;
            }

            method = null;
            return false;
        }
コード例 #10
0
ファイル: RubyClass.cs プロジェクト: techarch/ironruby
        // thread safe: doesn't need any lock since it only accesses immutable state
        public bool TryGetClrConstructor(out RubyMemberInfo method) {
            ConstructorInfo[] ctors;
            if (TypeTracker != null && !TypeTracker.Type.IsInterface && (ctors = TypeTracker.Type.GetConstructors()) != null && ctors.Length > 0) {
                method = new RubyMethodGroupInfo(ctors, this, true);
                return true;
            }

            method = null;
            return false;
        }
コード例 #11
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : base(flags, module) {
     _methodBases = info._methodBases;
     _overloads = info._overloads;
     _isRubyMethod = info._isRubyMethod;
     _isClrStatic = info._isClrStatic;
 }
コード例 #12
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, MethodBase/*!*/[] methods)
     : base(methods, info.Flags, info.DeclaringModule) {
     _isStatic = info._isStatic;
     // Note: overloadOwners and maxCachedOverloadLevel are cleared whenever the group is copied.
 }
コード例 #13
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : this(info, flags, module, info._methodBases) {
 }
コード例 #14
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, MethodBase/*!*/[] methods)
     : base(methods, info.Flags, info.DeclaringModule) {
     _isStatic = info._isStatic;
     // Note: overloadOwners and maxCachedOverloadLevel are cleared whenever the group is copied.
     // The resulting group captures an immutable set of underlying CLR members.
 }
コード例 #15
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo /*!*/ info, RubyMemberFlags flags, RubyModule /*!*/ module)
     : base(info.MethodBases, flags, module)
 {
     _isStatic = info._isStatic;
 }
コード例 #16
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo /*!*/ info, OverloadInfo /*!*/[] methods)
     : base(methods, info.Flags, info.DeclaringModule)
 {
     _isStatic = info._isStatic;
 }
コード例 #17
0
        private RubyMethodGroupInfo/*!*/ MakeAllMethodsGroup(RubyClass/*!*/ cls) {
            var overloads = new MethodBase[_allMethods.Count];
            var overloadOwners = new RubyMethodGroupInfo[overloads.Length];
            int i = 0;
            foreach (var entry in _allMethods.Values) {
                overloads[i] = entry.Overload;
                overloadOwners[i] = entry.Owner;
                i++;
            }

            var result = new RubyMethodGroupInfo(overloads, cls, overloadOwners, cls.IsSingletonClass);

            // update ownership of overloads owned by the new group:
            foreach (var entry in _allMethods.Values) {
                if (entry.Owner != null) {
                    entry.Owner.CachedInGroup(result);
                } else {
                    entry.Owner = result;
                }
            }

            return result;
        }
コード例 #18
0
        // Returns the number of methods newly added to the dictionary.
        private bool AddMethodsOverwriteExisting(
            MemberInfo/*!*/[]/*!*/ newOverloads, RubyMethodGroupInfo/*!*/[] overloadOwners) {

            bool anyChange = false;
            for (int i = 0; i < newOverloads.Length; i++) {
                var method = (MethodBase)newOverloads[i];
                if (IsVisible(method)) {
                    var paramTypes = new ValueArray<Type>(ReflectionUtils.GetParameterTypes(method.GetParameters()));
                    if (_allMethods == null) {
                        _allMethods = new Dictionary<ValueArray<Type>, ClrOverloadInfo>();
                    }

                    _allMethods[paramTypes] = new ClrOverloadInfo {
                        Overload = method,
                        Owner = (overloadOwners != null) ? overloadOwners[i] : null
                    };

                    anyChange = true;
                }
            }
            return anyChange;
        }
コード例 #19
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : base(info.MethodBases, flags, module) {
     _isStatic = info._isStatic;
     _hasVirtuals = info._hasVirtuals;
     _staticDispatchMethods = info._staticDispatchMethods;
 }
コード例 #20
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
     : base(info.MethodBases, flags, module) {
     _isStatic = info._isStatic;
 }
コード例 #21
0
 // copy ctor
 private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, OverloadInfo/*!*/[] methods)
     : base(methods, info.Flags, info.DeclaringModule) {
     _isStatic = info._isStatic;
 }