internal void InitializeMembersFrom(RubyModule/*!*/ module) { ContractUtils.RequiresNotNull(module, "module"); #if !SILVERLIGHT // missing Clone on Delegate if (module.DeclaresGlobalConstants || module._clrConstants != null && _constants == null) { #endif EnsureInitialized(); module.EnsureInitialized(); #if !SILVERLIGHT } else { _state = module._state; _initializer = (module._initializer != null) ? (Action<RubyModule>)module._initializer.Clone() : null; } #endif if (module.DeclaresGlobalConstants) { Debug.Assert(module._constants == null && module._clrConstants == null); Debug.Assert(_constants != null); _constants.Clear(); foreach (KeyValuePair<SymbolId, object> constant in _context.TopGlobalScope.Items) { _constants.Add(SymbolTable.IdToString(constant.Key), constant.Value); } } else { _constants = (module._constants != null) ? new Dictionary<string, object>(module._constants) : null; // copy namespace members: if (module._clrConstants != null) { Debug.Assert(_constants != null); foreach (KeyValuePair<SymbolId, object> constant in module._clrConstants.SymbolAttributes) { _constants.Add(SymbolTable.IdToString(constant.Key), constant.Value); } } } _methods = (module._methods != null) ? new Dictionary<string, RubyMemberInfo>(module._methods) : null; _classVariables = (module._classVariables != null) ? new Dictionary<string, object>(module._classVariables) : null; _mixins = ArrayUtils.Copy(module._mixins); // dependentModules - skip // tracker - skip, .NET members not copied Updated("InitializeFrom"); }
internal void AddFullVersionTest(RubyModule/*!*/ module, RubyContext/*!*/ context, Expression/*!*/ contextExpression) { Assert.NotNull(module, context, contextExpression); module.EnsureInitialized(); // Initialization changes the version number, so ensure that the module is initialized // check for runtime (note that the module's runtime could be different from the call-site runtime): AddRestriction(Ast.Equal(contextExpression, Ast.Constant(context))); // check for version: AddCondition(Ast.Equal(Ast.Property(Ast.Constant(module), RubyModule.VersionProperty), Ast.Constant(module.Version))); }