Beispiel #1
0
        public Type BuildRuntimeProxy(CilProgram program)
        {
            var parentClass = this;

            while (!program.IsExternalType(parentClass.ExtendsName))
            {
                parentClass = parentClass.Extends;
            }

            var extClass = ReflectionHelper.GetExternalType(parentClass.ExtendsName);

            if (!extClass.IsAbstract)
            {
                return(extClass);
            }

            var extProxy = RuntimeTypeBuilder.RegisterProxy(parentClass.ExtendsName);

            return(extProxy);
        }
Beispiel #2
0
        public Type BuildRuntimeType(CilProgram program, CilManagedMemory managedMemory)
        {
            var type = RuntimeTypeBuilder.RegisterType(this, program, managedMemory);

            return(type);
        }
Beispiel #3
0
        public CilType GetCilType(CilProgram _program)
        {
            if (Type != null)
            {
                return(Type);
            }

            if (!_program.IsExternalType(this) && ClassName != null)
            {
                if (_program.IsValueType(ClassName))
                {
                    return(new CilTypeValueType(ClassName));
                }

                return(new CilTypeClass(ClassName));
            }

            if (_program.IsExternalType(this) && ClassName != null)
            {
                var type = ReflectionHelper.GetExternalType(ClassName);

                if (type == typeof(char))
                {
                    return(new CilTypeChar());
                }
                if (type == typeof(string))
                {
                    return(new CilTypeString());
                }
                if (type == typeof(int))
                {
                    return(new CilTypeInt32());
                }
                if (type == typeof(sbyte))
                {
                    return(new CilTypeInt8());
                }
                if (type == typeof(ushort))
                {
                    return(new CilTypeUInt16());
                }
                if (type == typeof(ulong))
                {
                    return(new CilTypeUInt64());
                }
                if (type == typeof(uint))
                {
                    return(new CilTypeUInt32());
                }
                if (type == typeof(short))
                {
                    return(new CilTypeInt16());
                }
                if (type == typeof(long))
                {
                    return(new CilTypeInt64());
                }
                if (type == typeof(float))
                {
                    return(new CilTypeFloat32());
                }
                if (type == typeof(double))
                {
                    return(new CilTypeFloat64());
                }
                if (type == typeof(byte))
                {
                    return(new CilTypeUInt8());
                }
                if (type == typeof(object))
                {
                    return(new CilTypeObject());
                }
                else if (type.IsValueType)
                {
                    return(new CilTypeValueType(ClassName));
                }
                else
                {
                    return(new CilTypeClass(ClassName));
                }
            }

            throw new NotImplementedException();
        }