Exemplo n.º 1
0
        private void ImplementInterface(ClsTypeEmitter/*!*/ emitter, Type/*!*/ interfaceType, Dictionary<Type/*!*/, bool>/*!*/ doneTypes) {
            if (doneTypes.ContainsKey(interfaceType)) {
                return;
            }
            doneTypes.Add(interfaceType, true);
            emitter.OverrideMethods(interfaceType);

            foreach (Type t in interfaceType.GetInterfaces()) {
                ImplementInterface(emitter, t, doneTypes);
            }
        }
Exemplo n.º 2
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            // TODO: Exclude interfaces already implemented in base class feature sets
            // TODO: Exclude IDynamicObject, IRubyObject, etc. or handle specially
            Dictionary <Type, bool> doneTypes = new Dictionary <Type, bool>();

            foreach (Type interfaceType in _interfaces)
            {
                _tb.AddInterfaceImplementation(interfaceType);
                ImplementInterface(emitter, interfaceType, doneTypes);
            }
        }
Exemplo n.º 3
0
        private void ImplementInterface(ClsTypeEmitter /*!*/ emitter, Type /*!*/ interfaceType, Dictionary <Type /*!*/, bool> /*!*/ doneTypes)
        {
            if (doneTypes.ContainsKey(interfaceType))
            {
                return;
            }
            doneTypes.Add(interfaceType, true);
            emitter.OverrideMethods(interfaceType);

            foreach (Type t in interfaceType.GetInterfaces())
            {
                ImplementInterface(emitter, t, doneTypes);
            }
        }
Exemplo n.º 4
0
        public void Implement(ClsTypeEmitter/*!*/ emitter) {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

            if (!IsDerivedRubyType) {
                DefineRubyObjectImplementation();
                DefineSerializer();
                DefineDynamicObjectImplementation();

#if !SILVERLIGHT // ICustomTypeDescriptor
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Exemplo n.º 5
0
        public void Implement(ClsTypeEmitter/*!*/ emitter) {
            DefineConstructors();
            DefineRubyObjectImplementation();
            DefineSerializer();

            RubyTypeEmitter re = (emitter as RubyTypeEmitter);
            Assert.NotNull(re);
            re.ImmediateClassField = _immediateClassField;

            DefineDynamicObjectImplementation();

#if !SILVERLIGHT // ICustomTypeDescriptor
            DefineCustomTypeDescriptor();
#endif

        }
Exemplo n.º 6
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

            if (!IsDerivedRubyType)
            {
                DefineRubyObjectImplementation();
                DefineSerializer();
                DefineDynamicObjectImplementation();

#if !SILVERLIGHT // ICustomTypeDescriptor
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Exemplo n.º 7
0
        public void Implement(ClsTypeEmitter/*!*/ emitter) {
            // TODO: Exclude interfaces already implemented in base class feature sets
            // TODO: Exclude IDynamicMetaObjectProvider, IRubyObject, etc. or handle specially
            Dictionary<Type, bool> doneTypes = new Dictionary<Type, bool>();
            foreach (Type interfaceType in _interfaces) {
                if (interfaceType != typeof(IRubyType) && 
                    interfaceType != typeof(IRubyObject) && 
#if !SILVERLIGHT
                    interfaceType != typeof(ICustomTypeDescriptor) &&
                    interfaceType != typeof(ISerializable) &&
#endif
                    interfaceType != typeof(IRubyDynamicMetaObjectProvider)) {
                    _tb.AddInterfaceImplementation(interfaceType);
                    ImplementInterface(emitter, interfaceType, doneTypes);
                }
            }
        }
Exemplo n.º 8
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

            if (!IsDerivedRubyType)
            {
                DefineRubyObjectImplementation();
                DefineSerializer();
                DefineDynamicObjectImplementation();

#if FEATURE_CUSTOM_TYPE_DESCRIPTOR
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Exemplo n.º 9
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            // TODO: Exclude interfaces already implemented in base class feature sets
            // TODO: Exclude IDynamicMetaObjectProvider, IRubyObject, etc. or handle specially
            Dictionary <Type, bool> doneTypes = new Dictionary <Type, bool>();

            foreach (Type interfaceType in _interfaces)
            {
                if (interfaceType != typeof(IRubyType) &&
                    interfaceType != typeof(IRubyObject) &&
#if !SILVERLIGHT
                    interfaceType != typeof(ICustomTypeDescriptor) &&
                    interfaceType != typeof(ISerializable) &&
#endif
                    interfaceType != typeof(IRubyDynamicMetaObjectProvider))
                {
                    _tb.AddInterfaceImplementation(interfaceType);
                    ImplementInterface(emitter, interfaceType, doneTypes);
                }
            }
        }
Exemplo n.º 10
0
        public void Implement(ClsTypeEmitter/*!*/ emitter) {
            DefineConstructors();
            DefineRubyObjectImplementation();
            DefineSerializer();

            RubyTypeEmitter re = (emitter as RubyTypeEmitter);
            Assert.NotNull(re);
            re.ClassField = _classField;

            DefineDynamicObjectImplementation();

#if !SILVERLIGHT // ICustomTypeDescriptor
            DefineCustomTypeDescriptor();
#endif

            // we need to get the right execution context
#if OBSOLETE
            // TODO: remove the need for these methods to be special cased
            EmitOverrideEquals(typeGen);
            EmitOverrideGetHashCode(typeGen);
#endif
        }
Exemplo n.º 11
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            DefineConstructors();
            DefineRubyObjectImplementation();
            DefineSerializer();

            RubyTypeEmitter re = (emitter as RubyTypeEmitter);

            Assert.NotNull(re);
            re.ClassField = _classField;

            DefineDynamicObjectImplementation();

#if !SILVERLIGHT // ICustomTypeDescriptor
            DefineCustomTypeDescriptor();
#endif

            // we need to get the right execution context
#if OBSOLETE
            // TODO: remove the need for these methods to be special cased
            EmitOverrideEquals(typeGen);
            EmitOverrideGetHashCode(typeGen);
#endif
        }
Exemplo n.º 12
0
 public void Implement(ClsTypeEmitter/*!*/ emitter) {
     // TODO: Exclude interfaces already implemented in base class feature sets
     // TODO: Exclude IDynamicMetaObjectProvider, IRubyObject, etc. or handle specially
     Dictionary<Type, bool> doneTypes = new Dictionary<Type, bool>();
     foreach (Type interfaceType in _interfaces) {
         _tb.AddInterfaceImplementation(interfaceType);
         ImplementInterface(emitter, interfaceType, doneTypes);
     }
 }
Exemplo n.º 13
0
        private void BuildConstructors(IList <ConstructorBuilderInfo> /*!*/ ctors)
        {
            foreach (var ctor in ctors)
            {
                // ctor(... RubyClass! class ..., <visible params>) : base(<hidden params>, <visible params>) { _class = class; }
                // ctor(... RubyClass! class ..., <visible params>) : base(... RubyOps.GetContextFromClass(class) ..., <visible params>) { _class = class; }
                // ctor(RubyClass! class) : base(RubyOps.GetDefaultExceptionMessage(class)) { _class = class; }
                ConstructorBuilder cb = _tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctor.ParameterTypes);
                ILGen il = new ILGen(cb.GetILGenerator());

                int paramIndex = 0;
                int argIndex   = 0;

                // We need to initialize before calling base ctor since the ctor can call virtual methods.
                // _immediateClass = immediateClass:
                if (!IsDerivedRubyType)
                {
                    il.EmitLoadArg(0);
                    il.EmitLoadArg(1 + ctor.ClassParamIndex);
                    il.EmitFieldSet(ImmediateClassField);
                }

                // base ctor call:
                il.EmitLoadArg(0);

                ConstructorInfo msgCtor;
                if (ctor.ParameterTypes.Length == 1 && ctor.Adjustment == SignatureAdjustment.InsertClass &&
                    _tb.IsSubclassOf(typeof(Exception)) && IsAvailable(msgCtor = _tb.BaseType.GetConstructor(_exceptionMessageSignature)))
                {
                    // a parameterless exception constructor should use Ruby default message:
                    il.EmitLoadArg(1);
                    il.EmitCall(Methods.GetDefaultExceptionMessage);
                    il.Emit(OpCodes.Call, msgCtor);
                }
                else
                {
                    if (ctor.Adjustment == SignatureAdjustment.InsertClass)
                    {
                        paramIndex++;
                    }

                    while (paramIndex < ctor.ParameterTypes.Length)
                    {
                        if (ctor.Adjustment == SignatureAdjustment.ConvertClassToContext && argIndex == ctor.ContextArgIndex)
                        {
                            il.EmitLoadArg(1 + ctor.ClassParamIndex);
                            il.EmitCall(Methods.GetContextFromModule);
                        }
                        else
                        {
                            ClsTypeEmitter.DefineParameterCopy(cb, paramIndex, ctor.BaseParameters[argIndex]);
                            il.EmitLoadArg(1 + paramIndex);
                        }
                        argIndex++;
                        paramIndex++;
                    }
                    il.Emit(OpCodes.Call, ctor.BaseCtor);
                }

                il.Emit(OpCodes.Ret);
            }
        }
Exemplo n.º 14
0
        public void Implement(ClsTypeEmitter/*!*/ emitter)
        {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

            if (!IsDerivedRubyType) {
                DefineRubyObjectImplementation();
                DefineSerializer();
                DefineDynamicObjectImplementation();

            #if FEATURE_CUSTOM_TYPE_DESCRIPTOR
                DefineCustomTypeDescriptor();
            #endif
                DefineRubyTypeImplementation();
            }
        }