Inheritance: ITypeMapper
Esempio n. 1
0
 public DelegateGen Delegate(System.Type returnType, string name)
 {
     return(Delegate(TypeMapper.MapType(returnType), name));
 }
Esempio n. 2
0
 public PropertyGen PropertyImplementation(System.Type interfaceType, System.Type type, string name)
 {
     return(PropertyImplementation(TypeMapper.MapType(interfaceType), TypeMapper.MapType(type), name));
 }
Esempio n. 3
0
 public TypeGen Class(string name)
 {
     return(Class(name, TypeMapper.MapType(typeof(object)), Type.EmptyTypes));
 }
Esempio n. 4
0
 public TypeGen Class(string name, System.Type baseType, params Type[] interfaces)
 {
     return(Class(name, TypeMapper.MapType(baseType), interfaces));
 }
Esempio n. 5
0
 public MethodGen Operator(Operator op, System.Type returnType, System.Type operandType)
 {
     return(Operator(op, TypeMapper.MapType(returnType), TypeMapper.MapType(operandType)));
 }
Esempio n. 6
0
 public MethodGen Operator(Operator op, System.Type returnType, System.Type leftType, System.Type rightType)
 {
     return(Operator(op, TypeMapper.MapType(returnType), TypeMapper.MapType(leftType), TypeMapper.MapType(rightType)));
 }
Esempio n. 7
0
 public T Parameter(System.Type type, string name)
 {
     return(Parameter(TypeMapper.MapType(type), name));
 }
Esempio n. 8
0
 public MethodGen ExplicitConversionTo(System.Type toType)
 {
     return(ExplicitConversionTo(TypeMapper.MapType(toType)));
 }
Esempio n. 9
0
 public void Invoke(System.Type target, string method)
 {
     Invoke(TypeMapper.MapType(target), method);
 }
Esempio n. 10
0
 public void Invoke(System.Type target, string method, params Operand[] args)
 {
     Invoke(TypeMapper.MapType(target), method, args);
 }
Esempio n. 11
0
        public MethodGen AddMethod(string parameterName)
        {
            if (_adder == null)
            {
                LockSignature();
                _adder = new MethodGen(_owner, "add_" + Name, _attrs | MethodAttributes.SpecialName, TypeMapper.MapType(typeof(void)), 0);
                _adder.ImplementedInterface = ImplementedInterface;
                _adder.Parameter(_type, parameterName);
                _eb.SetAddOnMethod(_adder.GetMethodBuilder());
            }

            return(_adder);
        }
Esempio n. 12
0
 public AttributeGen <EventGen> BeginAttribute(System.Type attributeType, params object[] args)
 {
     return(BeginAttribute(TypeMapper.MapType(attributeType), args));
 }
Esempio n. 13
0
 public AttributeGen <EventGen> BeginAttribute(System.Type attributeType)
 {
     return(BeginAttribute(TypeMapper.MapType(attributeType)));
 }
Esempio n. 14
0
 public EventGen Attribute(System.Type attributeType)
 {
     return(Attribute(TypeMapper.MapType(attributeType)));
 }
Esempio n. 15
0
        public void Complete()
        {
            if (_type != null)
            {
                return;
            }

            if (_owner != null && TypeBuilder.IsValueType)
            {
                if (_fields.Count == 0 && _properties.Count == 0)
                {
                    // otherwise  "Value class has neither fields nor size parameter."
                    Private.ReadOnly.Field(_typeMapper.MapType(typeof(int)), "_____");
                }
            }

            foreach (TypeGen nested in _nestedTypes)
            {
                nested.Complete();
            }

            if (_owner != null)
            {
                // ensure creation of default constructor
                EnsureDefaultConstructor();
            }

            FlushDefinitionQueue();
            FlushCompletionQueue();

            // implement all interfaces
            foreach (InterfaceImplEntry iie in _implementations)
            {
                if (!iie.IsBound)
                {
                    throw new NotImplementedException(string.Format(null, Properties.Messages.ErrInterfaceNotImplemented,
                                                                    iie.InterfaceType, iie.InterfaceMethod.Member));
                }

                TypeBuilder.DefineMethodOverride(iie.BoundMethod.GetMethodBuilder(), (MethodInfo)iie.InterfaceMethod.Member);
            }

            // set indexer name
            if (_indexerName != null)
            {
                CustomAttributeBuilder cab = new CustomAttributeBuilder(
                    TypeMapper.MapType(typeof(DefaultMemberAttribute)).GetConstructor(new Type[] { TypeMapper.MapType(typeof(string)) }),
                    new object[] { _indexerName });
                TypeBuilder.SetCustomAttribute(cab);
            }

            AttributeGen.ApplyList(ref _customAttributes, TypeBuilder.SetCustomAttribute);

            _type = TypeBuilder.CreateType();

            _typeMapper.TypeInfo.UnregisterProvider(TypeBuilder);
        }
Esempio n. 16
0
 public MethodGen ExplicitConversionFrom(System.Type fromType, string parameterName)
 {
     return(ExplicitConversionFrom(TypeMapper.MapType(fromType), parameterName));
 }
Esempio n. 17
0
 public FieldGen Field(System.Type type, string name)
 {
     return(Field(TypeMapper.MapType(type), name));
 }
Esempio n. 18
0
 public MethodGen ExplicitConversionTo(System.Type toType, string parameterName)
 {
     return(ExplicitConversionTo(TypeMapper.MapType(toType), parameterName));
 }
Esempio n. 19
0
 public FieldGen Field(System.Type type, string name, Operand initialValue)
 {
     return(Field(TypeMapper.MapType(type), name, initialValue));
 }
Esempio n. 20
0
 public MethodGen Operator(Operator op, System.Type returnType, Type operandType, string operandName)
 {
     return(Operator(op, TypeMapper.MapType(returnType), operandType, operandName));
 }
Esempio n. 21
0
 public PropertyGen Property(System.Type type, string name)
 {
     return(Property(TypeMapper.MapType(type), name));
 }
Esempio n. 22
0
 public MethodGen Operator(Operator op, System.Type returnType, System.Type leftType, string leftName, System.Type rightType, string rightName)
 {
     return(Operator(op, TypeMapper.MapType(returnType), TypeMapper.MapType(leftType), leftName, TypeMapper.MapType(rightType), rightName));
 }
Esempio n. 23
0
 public PropertyGen Indexer(System.Type type, string name)
 {
     return(Indexer(TypeMapper.MapType(type), name));
 }
Esempio n. 24
0
 public TypeGen Class(string name, System.Type baseType)
 {
     return(Class(name, TypeMapper.MapType(baseType)));
 }
Esempio n. 25
0
 public EventGen CustomEvent(System.Type handlerType, string name)
 {
     return(CustomEvent(TypeMapper.MapType(handlerType), name));
 }
Esempio n. 26
0
        public TypeGen Struct(string name, params Type[] interfaces)
        {
            if (TypeBuilder.IsInterface)
            {
                throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoNested);
            }

            if (_typeVis == 0)
            {
                _typeVis |= TypeAttributes.NestedPrivate;
            }

            TypeGen tg = new TypeGen(this, name, (_typeVis | _typeVirt | _typeFlags | TypeAttributes.Sealed | TypeAttributes.SequentialLayout) ^ TypeAttributes.BeforeFieldInit, TypeMapper.MapType(typeof(ValueType)), interfaces, _typeMapper);

            ResetAttrs();
            return(tg);
        }
Esempio n. 27
0
 public MethodGen Method(System.Type returnType, string name)
 {
     return(Method(TypeMapper.MapType(returnType), name));
 }
Esempio n. 28
0
 public MethodGen MethodImplementation(Type interfaceType, System.Type returnType, string name)
 {
     return(MethodImplementation(interfaceType, TypeMapper.MapType(returnType), name));
 }
Esempio n. 29
0
 public MethodGen ExplicitConversionFrom(System.Type fromType)
 {
     return(ExplicitConversionFrom(TypeMapper.MapType(fromType)));
 }
Esempio n. 30
0
 public EventGen EventImplementation(System.Type interfaceType, System.Type eventHandlerType, string name)
 {
     return(EventImplementation(TypeMapper.MapType(interfaceType), TypeMapper.MapType(eventHandlerType), name));
 }
Esempio n. 31
0
        void Initialize(Universe universe, string assemblyName, AssemblyBuilderAccess access, CompilerOptions options, ITypeMapper typeMapper = null)
        {
            if (universe == null) throw new ArgumentNullException(nameof(universe));
            if (options == null) throw new ArgumentNullException(nameof(options));
            _compilerOptions = options;
            if (typeMapper == null)
#if FEAT_IKVM
                typeMapper = new TypeMapper(universe);
#else
                typeMapper = new TypeMapper();
#endif
            ExpressionFactory = new ExpressionFactory(typeMapper);
            StaticFactory = new StaticFactory(typeMapper);

#if SILVERLIGHT
            bool save = false;
#else
            bool save = (access & AssemblyBuilderAccess.Save) != 0;
#endif
            string path = options.OutputPath;
            if (path == null && save) throw new ArgumentNullException("options.OutputPath");

            Universe = universe;

            TypeMapper = typeMapper;
            _access = access;

            if (Helpers.IsNullOrEmpty(assemblyName))
            {
                if (save) throw new ArgumentNullException(nameof(assemblyName));
                assemblyName = Guid.NewGuid().ToString();
            }
            
            string moduleName = path == null ? assemblyName : assemblyName + Path.GetExtension(path);

            _fileName = path;

            AssemblyName an = new AssemblyName();
            an.Name = assemblyName;

            AssemblyBuilder =
#if !SILVERLIGHT
                path != null ? Universe.DefineDynamicAssembly(an, access, Path.GetDirectoryName(path)) :
#endif
                    Universe.DefineDynamicAssembly(an, access);
#if FEAT_IKVM
            if (!Helpers.IsNullOrEmpty(options.KeyFile))
            {
               AssemblyBuilder.__SetAssemblyKeyPair(new StrongNameKeyPair(File.OpenRead(options.KeyFile)));
            }
            else if (!Helpers.IsNullOrEmpty(options.KeyContainer))
            {
                AssemblyBuilder.__SetAssemblyKeyPair(new StrongNameKeyPair(options.KeyContainer));
            }
            else if (!Helpers.IsNullOrEmpty(options.PublicKey))
            {
                AssemblyBuilder.__SetAssemblyPublicKey(FromHex(options.PublicKey));
            }
            if (!Helpers.IsNullOrEmpty(options.ImageRuntimeVersion) && options.MetaDataVersion != 0)
            {
                AssemblyBuilder.__SetImageRuntimeVersion(options.ImageRuntimeVersion, options.MetaDataVersion);
            }
            ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, path, options.SymbolInfo);
#else
            if (save)
            {
#if !SILVERLIGHT
                ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, Path.GetFileName(path));
#else
                throw new NotSupportedException("Can't save on this platform");
#endif
            }
            else
                ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName);
#endif
        }