当前位置: 首页>>代码示例>>C#>>正文


C# Calls.RubyMemberInfo类代码示例

本文整理汇总了C#中IronRuby.Runtime.Calls.RubyMemberInfo的典型用法代码示例。如果您正苦于以下问题:C# RubyMemberInfo类的具体用法?C# RubyMemberInfo怎么用?C# RubyMemberInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RubyMemberInfo类属于IronRuby.Runtime.Calls命名空间,在下文中一共展示了RubyMemberInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnboundMethod

        internal UnboundMethod(RubyModule/*!*/ targetConstraint, string/*!*/ name, RubyMemberInfo/*!*/ info) {
            Assert.NotNull(targetConstraint, name, info);

            _name = name;
            _info = info;
            _targetConstraint = targetConstraint;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:7,代码来源:UnboundMethod.cs

示例2: MethodResolutionResult

 public MethodResolutionResult(RubyMemberInfo/*!*/ info, RubyModule/*!*/ owner, bool visible)
 {
     Assert.NotNull(info, owner);
     _info = info;
     _owner = owner;
     _visible = visible;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:MethodResolutionResult.cs

示例3: SelectOverload

 internal static RubyMemberInfo/*!*/ SelectOverload(RubyContext/*!*/ context, RubyMemberInfo/*!*/ info, string/*!*/ name, object[]/*!*/ typeArgs) {
     RubyMemberInfo result = info.TrySelectOverload(Protocols.ToTypes(context, typeArgs));
     if (result == null) {
         throw RubyExceptions.CreateArgumentError("no overload of `{0}' matches given parameter types", name);
     }
     return result;
 }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:7,代码来源:MethodOps.cs

示例4: BindGenericParameters

 internal static RubyMemberInfo/*!*/ BindGenericParameters(RubyContext/*!*/ context, RubyMemberInfo/*!*/ info, string/*!*/ name, object[]/*!*/ typeArgs) {
     RubyMemberInfo result = info.TryBindGenericParameters(Protocols.ToTypes(context, typeArgs));
     if (result == null) {
         throw RubyExceptions.CreateArgumentError("wrong number of generic arguments for `{0}'", name);
     }
     return result;
 }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:7,代码来源:MethodOps.cs

示例5: RubyMethod

 public RubyMethod(object target, RubyMemberInfo/*!*/ info, string/*!*/ name) {
     ContractUtils.RequiresNotNull(info, "info");
     ContractUtils.RequiresNotNull(name, "name");
                 
     _target = target;
     _info = info;
     _name = name;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:RubyMethod.cs

示例6: TryGetClrProperty

        // TODO: Indexers can be overloaded:
        //private bool TryGetClrProperty(Type/*!*/ type, BindingFlags bindingFlags, string/*!*/ name, bool isWrite, out RubyMemberInfo method) {
        //    Assert.NotNull(type, name);

        //    PropertyInfo propertyInfo = type.GetProperty(name, bindingFlags);
        //    if (propertyInfo != null) {
        //        MethodInfo accessor = isWrite ? propertyInfo.GetSetMethod(false) : propertyInfo.GetGetMethod(false);
        //        if (accessor != null) {
        //            // TODO: define RubyPropertyInfo class
        //            method = new RubyMethodGroupInfo(new MethodBase[] { accessor }, this, _isSingletonClass);
        //            return true;
        //        }
        //    }

        //    method = null;
        //    return false;
        //}

        private bool TryGetClrProperty(Type/*!*/ type, BindingFlags bindingFlags, bool inherited, bool isWrite, 
            string/*!*/ name, string/*!*/ clrName, string altClrName, out RubyMemberInfo method) {

            return TryGetClrMethod(type, bindingFlags, inherited, true, name, isWrite ? "set_" : "get_", clrName, altClrName, out method);
        }
开发者ID:kashano,项目名称:main,代码行数:23,代码来源:RubyClass.cs

示例7: Resolve

        internal static MethodResolutionResult Resolve(MetaObjectBuilder/*!*/ metaBuilder, string/*!*/ methodName, CallArguments/*!*/ args,
            out RubyMemberInfo methodMissing) {

            MethodResolutionResult method;
            var targetClass = args.TargetClass;
            var visibilityContext = GetVisibilityContext(args.Signature, args.Scope);
            using (targetClass.Context.ClassHierarchyLocker()) {
                metaBuilder.AddTargetTypeTest(args.Target, targetClass, args.TargetExpression, args.MetaContext, 
                    new[] { methodName, Symbols.MethodMissing }
                );

                if (args.Signature.IsSuperCall) {
                    Debug.Assert(!args.Signature.IsVirtualCall && args.Signature.HasImplicitSelf);
                    method = targetClass.ResolveSuperMethodNoLock(methodName, targetClass).InvalidateSitesOnOverride();
                } else {
                    var options = args.Signature.IsVirtualCall ? MethodLookup.Virtual : MethodLookup.Default;
                    method = targetClass.ResolveMethodForSiteNoLock(methodName, visibilityContext, options);
                }

                if (!method.Found) {
                    methodMissing = targetClass.ResolveMethodMissingForSite(methodName, method.IncompatibleVisibility);
                } else {
                    methodMissing = null;
                }
            }

            // Whenever the current self's class changes we need to invalidate the rule, if a protected method is being called.
            if (method.Info != null && method.Info.IsProtected && visibilityContext.Class != null) {
                // We don't need to compare versions, just the class objects (super-class relationship cannot be changed).
                // Since we don't want to hold on a class object (to make it collectible) we compare references to the version handlers.
                metaBuilder.AddCondition(Ast.Equal(
                    Methods.GetSelfClassVersionHandle.OpCall(AstUtils.Convert(args.MetaScope.Expression, typeof(RubyScope))),
                    Ast.Constant(visibilityContext.Class.Version)
                ));
            }

            return method;
        }
开发者ID:madpilot,项目名称:ironruby,代码行数:38,代码来源:RubyCallAction.cs

示例8: TryGetClrMember

        private bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool tryUnmangle, BindingFlags basicBindingFlags, out RubyMemberInfo method) {
            basicBindingFlags |= BindingFlags.Public | BindingFlags.NonPublic;

            // We look only for members directly declared on the type and handle method overloads inheritance manually.  
            BindingFlags bindingFlags = basicBindingFlags | ((_isSingletonClass) ? BindingFlags.Static : BindingFlags.Instance);

            // instance methods on Object are also available in static context:
            if (type == typeof(Object)) {
                bindingFlags |= BindingFlags.Instance;
            }

            string operatorName;
            if (tryUnmangle && !_isSingletonClass && (operatorName = RubyUtils.MapOperator(name)) != null) {
                // instance invocation of an operator:
                if (TryGetClrMethod(type, basicBindingFlags | BindingFlags.Static, true, name, null, operatorName, null, out method)) {
                    return true;
                }
            } else if (tryUnmangle && (name == "[]" || name == "[]=")) {
                if (type.IsArray && !_isSingletonClass) {
                    bool isSetter = name.Length == 3;
                    TryGetClrMethod(type, bindingFlags, false, name, null, isSetter ? "Set" : "Get", null, out method);
                    Debug.Assert(method != null);
                    return true;
                } else {
                    object[] attrs = type.GetCustomAttributes(typeof(DefaultMemberAttribute), false);
                    if (attrs.Length == 1) {
                        // default indexer accessor:
                        bool isSetter = name.Length == 3;
                        if (TryGetClrProperty(type, bindingFlags, isSetter, name, ((DefaultMemberAttribute)attrs[0]).MemberName, null, out method)) {
                            return true;
                        }
                    }
                }
            } else if (name.LastCharacter() == '=') {
                string propertyName = name.Substring(0, name.Length - 1);
                string altName = tryUnmangle ? RubyUtils.TryUnmangleName(propertyName) : null;
                
                // property setter:
                if (TryGetClrProperty(type, bindingFlags, true, name, propertyName, altName, out method)) return true;

                // writeable field:
                if (TryGetClrField(type, bindingFlags, true, propertyName, altName, out method)) return true;
            } else {
                string altName = tryUnmangle ? RubyUtils.TryUnmangleName(name) : null;

                // method:
                if (TryGetClrMethod(type, bindingFlags, false, name, null, name, altName, out method)) return true;
                
                // getter:
                if (TryGetClrProperty(type, bindingFlags, false, name, name, altName, out method)) return true;

                // event:
                if (TryGetClrEvent(type, bindingFlags, name, altName, out method)) return true;

                // field:
                if (TryGetClrField(type, bindingFlags, false, name, altName, out method)) return true;
            }

            method = null;
            return false;
        }
开发者ID:techarch,项目名称:ironruby,代码行数:61,代码来源:RubyClass.cs

示例9: TryGetClrMember

        protected override bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool mapNames, bool unmangleNames, out RubyMemberInfo method) {
            Context.RequiresClassHierarchyLock();

            if (IsFailureCached(type, name, _isSingletonClass, _extensionVersion)) {
                method = null;
                return false;
            }

            if (TryGetClrMember(type, name, mapNames, unmangleNames, false, out method)) {
                return true;
            }

            CacheFailure(type, name, _isSingletonClass, _extensionVersion);
            method = null;
            return false;
        }
开发者ID:kashano,项目名称:main,代码行数:16,代码来源:RubyClass.cs

示例10: TryGetClrMethod

        /// <summary>
        /// There are basically 4 cases:
        /// 1) CLR method of the given name is not defined in the specified type.
        ///    Do nothing, the method will be found as we traverse the hierarhy towards the Kernel module.
        /// 2) Otherwise
        ///    1) There is no RubyMemberInfo of given <c>name</c> present in the (type..Kernel] ancestors.
        ///       We need to search all types in (type..Object] for CLR method overloads.
        ///    2) There is a RubyMemberInfo in a class, say C, in (type..Kernel]. 
        ///       We need to get CLR methods from (type..C) in addition to the members in the type.
        ///        1) C.HidesInheritedOverloads == true
        ///           All overloads of the method we look for are in [type..C).
        ///        2) C.HidesInheritedOverloads == false
        ///           All overloads of the method we look for are in [type..C) and in the RubyMemberInfo.
        /// </summary>
        /// <remarks>
        /// Doesn't include explicitly implemented interface methods. Including them would allow to call them directly (obj.foo) 
        /// if the overload resolution succeeds. However, the interface methods are probably implemented explicitly for a reason:
        /// 1) There is a conflict in signatures -> the overload resolution would probably fail.
        /// 2) The class was designed with an intention to not expose the implementations directly.
        /// </remarks>
        private bool TryGetClrMethod(Type/*!*/ type, BindingFlags bindingFlags, bool inherited, bool specialNameOnly, 
            string/*!*/ name, string clrNamePrefix, string/*!*/ clrName, string altClrName, out RubyMemberInfo method) {
            Context.RequiresClassHierarchyLock();

            // declared only:
            List<OverloadInfo> initialMembers = new List<OverloadInfo>(GetClrMethods(type, bindingFlags, inherited, clrNamePrefix, clrName, altClrName, specialNameOnly));
            if (initialMembers.Count == 0) {
                // case [1]
                //
                // Note: This failure might be cached (see CacheFailure) based on the type and name, 
                // therefore it must not depend on any other mutable state:
                method = null;
                return false;
            }

            // If all CLR inherited members are to be returned we are done.
            // (creates a detached info; used by Kernel#clr_member)
            if (inherited) {
                method = MakeGroup(initialMembers, initialMembers.Count, specialNameOnly, true);
                return true;
            }

            // inherited overloads:
            List<RubyClass> ancestors = new List<RubyClass>();
            RubyMemberInfo inheritedRubyMember = null;
            bool skipHidden = false;

            ForEachAncestor((module) => {
                if (module != this) {
                    if (module.TryGetDefinedMethod(name, ref skipHidden, out inheritedRubyMember) && !inheritedRubyMember.IsSuperForwarder) {
                        return true;
                    }

                    // Skip classes that have no tracker, e.g. Fixnum(tracker) <: Integer(null) <: Numeric(null) <: Object(tracker).
                    // Skip CLR modules, their methods are not callable => do not include them into a method group.
                    // Skip all classes once hidden sentinel is encountered (no CLR overloads are visible since then).
                    if (!skipHidden && module.TypeTracker != null && module.IsClass) {
                        ancestors.Add((RubyClass)module);
                    }
                }

                // continue:
                return false;
            });

            // (method clr name, parameter types) => (overload, owner)
            Dictionary<Key<string, ValueArray<Type>>, ClrOverloadInfo> allMethods = null;

            if (inheritedRubyMember != null) {
                // case [2.2.2]: add CLR methods from the Ruby member:
                var inheritedGroup = inheritedRubyMember as RubyOverloadGroupInfo;

                if (inheritedGroup != null) {
                    AddMethodsOverwriteExisting(ref allMethods, inheritedGroup.MethodBases, inheritedGroup.OverloadOwners, specialNameOnly);
                } else if (inheritedRubyMember.IsRemovable) {
                    // The groups created below won't contain overloads defined above (if there are any).
                    // If this method is removed we need to invalidate them.
                    inheritedRubyMember.InvalidateGroupsOnRemoval = true;
                }
            }

            // populate classes in (type..Kernel] or (type..C) with method groups:
            for (int i = ancestors.Count - 1; i >= 0; i--) {
                var declared = ancestors[i].GetClrMethods(ancestors[i].TypeTracker.Type, bindingFlags, false, clrNamePrefix, clrName, altClrName, specialNameOnly);
                if (AddMethodsOverwriteExisting(ref allMethods, declared, null, specialNameOnly)) {
                    // There is no cached method that needs to be invalidated.
                    //
                    // Proof:
                    // Suppose the group being created here overridden an existing method that is cached in a dynamic site invoked on some target class.
                    // Then either the target class is above all ancestors[i] or below some. If it is above then the new group doesn't 
                    // invalidate validity of the site. If it is below then the method resolution for the cached method would create
                    // and store to method tables all method groups in between the target class and the owner of the cached method, including the 
                    // one that contain overloads of ancestors[i]. But no module below inheritedRubyMember contains a method group of the name 
                    // being currently resolved.
                    ancestors[i].AddMethodNoCacheInvalidation(name, ancestors[i].MakeGroup(allMethods.Values));
                }
            }

            if (allMethods != null) {
                // add members declared in self:
//.........这里部分代码省略.........
开发者ID:kashano,项目名称:main,代码行数:101,代码来源:RubyClass.cs

示例11: PrepareMethodUpdate

 internal override void PrepareMethodUpdate(string/*!*/ methodName, RubyMemberInfo/*!*/ method) {
     PrepareMethodUpdate(methodName, method, 0);
 }
开发者ID:kashano,项目名称:main,代码行数:3,代码来源:RubyClass.cs

示例12: TryGetClrEvent

        private bool TryGetClrEvent(Type/*!*/ type, BindingFlags bindingFlags, bool inherited, string/*!*/ name, out RubyMemberInfo method) {
            Assert.NotNull(type, name);

            EventInfo eventInfo;
            if (inherited) {
                eventInfo = type.GetInheritedEvents(name).WithBindingFlags(bindingFlags).FirstOrDefault();
            } else {
                eventInfo = type.GetDeclaredEvent(name).WithBindingFlags(bindingFlags);
            }
            
            if (eventInfo != null) {
                // creates detached info if only declared members are requested (used by Kernel#clr_member):
                method = new RubyEventInfo((EventTracker)MemberTracker.FromMemberInfo(eventInfo), RubyMemberFlags.Public, this, isDetached: inherited);
                return true;
            }

            method = null;
            return false;
        }
开发者ID:kashano,项目名称:main,代码行数:19,代码来源:RubyClass.cs

示例13: TryGetClrField

        private bool TryGetClrField(Type/*!*/ type, BindingFlags bindingFlags, bool inherited, bool isWrite, string/*!*/ name, out RubyMemberInfo method) {
            FieldInfo fieldInfo;
            if (inherited) {
                fieldInfo = type.GetInheritedFields(name).WithBindingFlags(bindingFlags).FirstOrDefault();
            } else {
                fieldInfo = type.GetDeclaredField(name).WithBindingFlags(bindingFlags);
            }
            
            if (fieldInfo != null && IsVisible(fieldInfo) && (!isWrite || IsWriteable(fieldInfo))) {
                // creates detached info if only declared members are requested (used by Kernel#clr_member):
                method = new RubyFieldInfo(fieldInfo, RubyMemberFlags.Public, this, isWrite, isDetached: inherited);
                return true;
            }

            method = null;
            return false;
        }
开发者ID:kashano,项目名称:main,代码行数:17,代码来源:RubyClass.cs

示例14: Curried

 internal Curried(object target, RubyMemberInfo/*!*/ info, string/*!*/ methodNameArg)
     : base(target, info, "method_missing") {
     _methodNameArg = methodNameArg;
 }
开发者ID:Jirapong,项目名称:main,代码行数:4,代码来源:RubyMethod.cs

示例15: BindToKernelMethodMissing

        private static MethodMissingBinding BindToKernelMethodMissing(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ methodName,
            RubyMemberInfo methodMissing, RubyMethodVisibility incompatibleVisibility, bool isSuperCall) {

            // TODO: better specialization of method_missing methods
            if (methodMissing == null ||
                methodMissing.DeclaringModule == methodMissing.Context.KernelModule && methodMissing is RubyLibraryMethodInfo) {

                if (isSuperCall) {
                    metaBuilder.SetError(Methods.MakeMissingSuperException.OpCall(AstUtils.Constant(methodName)));
                } else if (incompatibleVisibility == RubyMethodVisibility.Private) {
                    metaBuilder.SetError(Methods.MakePrivateMethodCalledError.OpCall(
                        AstUtils.Convert(args.MetaContext.Expression, typeof(RubyContext)), args.TargetExpression, AstUtils.Constant(methodName))
                    );
                } else if (incompatibleVisibility == RubyMethodVisibility.Protected) {
                    metaBuilder.SetError(Methods.MakeProtectedMethodCalledError.OpCall(
                        AstUtils.Convert(args.MetaContext.Expression, typeof(RubyContext)), args.TargetExpression, AstUtils.Constant(methodName))
                    );
                } else {
                    return MethodMissingBinding.Fallback;
                }

                return MethodMissingBinding.Error;
            }

            return MethodMissingBinding.Custom;
        }
开发者ID:madpilot,项目名称:ironruby,代码行数:26,代码来源:RubyCallAction.cs


注:本文中的IronRuby.Runtime.Calls.RubyMemberInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。