Ejemplo n.º 1
0
        private static Type CreateType(TypeDescription/*!*/ typeInfo) {
            Type baseType = typeInfo.BaseType;
            if (baseType.IsSealed) {
                throw new NotSupportedException("Can't inherit from a sealed type.");
            }

            string typeName = GetName(baseType);
            TypeBuilder tb = Snippets.Shared.DefinePublicType(typeName, baseType);
            Utils.Log(typeName, "TYPE_BUILDER");

            IFeatureBuilder[] features = new IFeatureBuilder[typeInfo.Features.Count];
            RubyTypeEmitter emitter = new RubyTypeEmitter(tb);

            for (int i = 0; i < typeInfo.Features.Count; i++) {
                features[i] = typeInfo.Features[i].MakeBuilder(tb);
            }

            foreach (IFeatureBuilder feature in features) {
                feature.Implement(emitter);
            }

            if (!typeInfo.NoOverrides) {
                emitter.OverrideMethods(baseType);
            }

            Type result = emitter.FinishType();
            lock (_typeFeatures) {
                _typeFeatures.Add(result, typeInfo.Features);
            }
            return result;
        }
Ejemplo n.º 2
0
        public void Implement(ClsTypeEmitter/*!*/ emitter) {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

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

#if !SILVERLIGHT // ICustomTypeDescriptor
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Ejemplo n.º 3
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

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

#if !SILVERLIGHT // ICustomTypeDescriptor
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Ejemplo n.º 4
0
        public void Implement(ClsTypeEmitter /*!*/ emitter)
        {
            _emitter = (RubyTypeEmitter)emitter;
            DefineConstructors();

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

#if FEATURE_CUSTOM_TYPE_DESCRIPTOR
                DefineCustomTypeDescriptor();
#endif
                DefineRubyTypeImplementation();
            }
        }
Ejemplo n.º 5
0
        private static Type CreateType(TypeDescription /*!*/ typeInfo)
        {
            Type baseType = typeInfo.BaseType;

            if (baseType.IsSealed())
            {
                throw new NotSupportedException(
                          String.Format(CultureInfo.InvariantCulture, "Can't inherit from a sealed type {0}.",
                                        RubyContext.GetQualifiedNameNoLock(baseType, null, false))
                          );
            }

#if FEATURE_REFEMIT
            string      typeName = GetName(baseType);
            TypeBuilder tb       = Snippets.Shared.DefinePublicType(typeName, baseType);
            Utils.Log(typeName, "TYPE_BUILDER");

            IFeatureBuilder[] features = new IFeatureBuilder[typeInfo.Features.Count];
            RubyTypeEmitter   emitter  = new RubyTypeEmitter(tb);

            for (int i = 0; i < typeInfo.Features.Count; i++)
            {
                features[i] = typeInfo.Features[i].MakeBuilder(tb);
            }

            foreach (IFeatureBuilder feature in features)
            {
                feature.Implement(emitter);
            }

            if (!typeInfo.NoOverrides)
            {
                emitter.OverrideMethods(baseType);
            }

            Type result = emitter.FinishType();
            lock (_typeFeatures) {
                _typeFeatures.Add(result, typeInfo.Features);
            }
            return(result);
#else
            throw new NotSupportedException("Creating new CLR types is not supported on this platform.");
#endif
        }
Ejemplo n.º 6
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
        }
Ejemplo n.º 7
0
        private static Type CreateType(TypeDescription/*!*/ typeInfo)
        {
            Type baseType = typeInfo.BaseType;
            if (baseType.IsSealed()) {
                throw new NotSupportedException(
                    String.Format(CultureInfo.InvariantCulture, "Can't inherit from a sealed type {0}.",
                    RubyContext.GetQualifiedNameNoLock(baseType, null, false))
                );
            }

            #if FEATURE_REFEMIT
            string typeName = GetName(baseType);
            TypeBuilder tb = Snippets.Shared.DefinePublicType(typeName, baseType);
            Utils.Log(typeName, "TYPE_BUILDER");

            IFeatureBuilder[] features = new IFeatureBuilder[typeInfo.Features.Count];
            RubyTypeEmitter emitter = new RubyTypeEmitter(tb);

            for (int i = 0; i < typeInfo.Features.Count; i++) {
                features[i] = typeInfo.Features[i].MakeBuilder(tb);
            }

            foreach (IFeatureBuilder feature in features) {
                feature.Implement(emitter);
            }

            if (!typeInfo.NoOverrides) {
                emitter.OverrideMethods(baseType);
            }

            Type result = emitter.FinishType();
            lock (_typeFeatures) {
                _typeFeatures.Add(result, typeInfo.Features);
            }
            return result;
            #else
            throw new NotSupportedException("Creating new CLR types is not supported on this platform.");
            #endif
        }
Ejemplo 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();
            }
        }