// 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. }
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); }
/// <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; }
// 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. }
// 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; }
// 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; } }
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) ); }
// 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; } }
// 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; }
// 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; }
// 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; }
// 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. }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module) : this(info, flags, module, info._methodBases) { }
// 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. }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo /*!*/ info, RubyMemberFlags flags, RubyModule /*!*/ module) : base(info.MethodBases, flags, module) { _isStatic = info._isStatic; }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo /*!*/ info, OverloadInfo /*!*/[] methods) : base(methods, info.Flags, info.DeclaringModule) { _isStatic = info._isStatic; }
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; }
// 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; }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module) : base(info.MethodBases, flags, module) { _isStatic = info._isStatic; _hasVirtuals = info._hasVirtuals; _staticDispatchMethods = info._staticDispatchMethods; }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module) : base(info.MethodBases, flags, module) { _isStatic = info._isStatic; }
// copy ctor private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, OverloadInfo/*!*/[] methods) : base(methods, info.Flags, info.DeclaringModule) { _isStatic = info._isStatic; }