public DelegateGen Delegate(System.Type returnType, string name) { return(Delegate(TypeMapper.MapType(returnType), name)); }
public PropertyGen PropertyImplementation(System.Type interfaceType, System.Type type, string name) { return(PropertyImplementation(TypeMapper.MapType(interfaceType), TypeMapper.MapType(type), name)); }
public TypeGen Class(string name) { return(Class(name, TypeMapper.MapType(typeof(object)), Type.EmptyTypes)); }
public TypeGen Class(string name, System.Type baseType, params Type[] interfaces) { return(Class(name, TypeMapper.MapType(baseType), interfaces)); }
public MethodGen Operator(Operator op, System.Type returnType, System.Type operandType) { return(Operator(op, TypeMapper.MapType(returnType), TypeMapper.MapType(operandType))); }
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))); }
public T Parameter(System.Type type, string name) { return(Parameter(TypeMapper.MapType(type), name)); }
public MethodGen ExplicitConversionTo(System.Type toType) { return(ExplicitConversionTo(TypeMapper.MapType(toType))); }
public void Invoke(System.Type target, string method) { Invoke(TypeMapper.MapType(target), method); }
public void Invoke(System.Type target, string method, params Operand[] args) { Invoke(TypeMapper.MapType(target), method, args); }
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); }
public AttributeGen <EventGen> BeginAttribute(System.Type attributeType, params object[] args) { return(BeginAttribute(TypeMapper.MapType(attributeType), args)); }
public AttributeGen <EventGen> BeginAttribute(System.Type attributeType) { return(BeginAttribute(TypeMapper.MapType(attributeType))); }
public EventGen Attribute(System.Type attributeType) { return(Attribute(TypeMapper.MapType(attributeType))); }
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); }
public MethodGen ExplicitConversionFrom(System.Type fromType, string parameterName) { return(ExplicitConversionFrom(TypeMapper.MapType(fromType), parameterName)); }
public FieldGen Field(System.Type type, string name) { return(Field(TypeMapper.MapType(type), name)); }
public MethodGen ExplicitConversionTo(System.Type toType, string parameterName) { return(ExplicitConversionTo(TypeMapper.MapType(toType), parameterName)); }
public FieldGen Field(System.Type type, string name, Operand initialValue) { return(Field(TypeMapper.MapType(type), name, initialValue)); }
public MethodGen Operator(Operator op, System.Type returnType, Type operandType, string operandName) { return(Operator(op, TypeMapper.MapType(returnType), operandType, operandName)); }
public PropertyGen Property(System.Type type, string name) { return(Property(TypeMapper.MapType(type), name)); }
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)); }
public PropertyGen Indexer(System.Type type, string name) { return(Indexer(TypeMapper.MapType(type), name)); }
public TypeGen Class(string name, System.Type baseType) { return(Class(name, TypeMapper.MapType(baseType))); }
public EventGen CustomEvent(System.Type handlerType, string name) { return(CustomEvent(TypeMapper.MapType(handlerType), name)); }
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); }
public MethodGen Method(System.Type returnType, string name) { return(Method(TypeMapper.MapType(returnType), name)); }
public MethodGen MethodImplementation(Type interfaceType, System.Type returnType, string name) { return(MethodImplementation(interfaceType, TypeMapper.MapType(returnType), name)); }
public MethodGen ExplicitConversionFrom(System.Type fromType) { return(ExplicitConversionFrom(TypeMapper.MapType(fromType))); }
public EventGen EventImplementation(System.Type interfaceType, System.Type eventHandlerType, string name) { return(EventImplementation(TypeMapper.MapType(interfaceType), TypeMapper.MapType(eventHandlerType), name)); }
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 }