RuntimeMissingSupport() public méthode

public RuntimeMissingSupport ( Mono.CSharp.Location loc, string feature ) : void
loc Mono.CSharp.Location
feature string
Résultat void
Exemple #1
0
            public FieldSpec DefineInitializedData(byte[] data, Location loc)
            {
                Struct size_type;

                if (!size_types.TryGetValue(data.Length, out size_type))
                {
                    //
                    // Build common type for this data length. We cannot use
                    // DefineInitializedData because it creates public type,
                    // and its name is not unique among modules
                    //
                    size_type = new Struct(null, this, new MemberName("$ArrayType=" + data.Length, Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
                    size_type.CreateType();
                    size_type.DefineType();

                    size_types.Add(data.Length, size_type);

                    var pa = Module.PredefinedAttributes.StructLayout;
                    if (pa.Constructor != null || pa.ResolveConstructor(Location, TypeManager.short_type))
                    {
                        var argsEncoded = new AttributeEncoder();
                        argsEncoded.Encode((short)LayoutKind.Explicit);

                        var field_size = pa.GetField("Size", TypeManager.int32_type, Location);
                        var pack       = pa.GetField("Pack", TypeManager.int32_type, Location);
                        if (field_size != null)
                        {
                            argsEncoded.EncodeNamedArguments(
                                new[] { field_size, pack },
                                new[] { new IntConstant((int)data.Length, Location), new IntConstant(1, Location) }
                                );
                        }

                        pa.EmitAttribute(size_type.TypeBuilder, argsEncoded);
                    }
                }

                var name = "$field-" + fields.ToString("X");

                ++fields;
                const Modifiers fmod     = Modifiers.STATIC | Modifiers.INTERNAL;
                var             fbuilder = TypeBuilder.DefineField(name, size_type.CurrentType.GetMetaInfo(), ModifiersExtensions.FieldAttr(fmod) | FieldAttributes.HasFieldRVA);

#if STATIC
                fbuilder.__SetDataAndRVA(data);
#else
                if (set_data == null)
                {
                    set_data = typeof(FieldBuilder).GetMethod("SetRVAData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                }

                try {
                    set_data.Invoke(fbuilder, new object[] { data });
                } catch {
                    Report.RuntimeMissingSupport(loc, "SetRVAData");
                }
#endif

                return(new FieldSpec(CurrentType, null, size_type.CurrentType, fbuilder, fmod));
            }
 public ReturnParameter(MethodBuilder mb, Location location) :
     base(null)
 {
     try {
         builder = mb.DefineParameter(0, ParameterAttributes.None, "");
     }
     catch (ArgumentOutOfRangeException) {
         Report.RuntimeMissingSupport(location, "custom attributes on the return type");
     }
 }
Exemple #3
0
        public Module AddModule(string module)
        {
            MethodInfo m = AddModule_Method;

            if (m == null)
            {
                Report.RuntimeMissingSupport(Location.Null, "/addmodule");
                Environment.Exit(1);
            }

            try {
                return((Module)m.Invoke(Builder, new object [] { module }));
            } catch (TargetInvocationException ex) {
                throw ex.InnerException;
            }
        }
Exemple #4
0
 protected virtual void SaveModule(PortableExecutableKinds pekind, ImageFileMachine machine)
 {
     Report.RuntimeMissingSupport(Location.Null, "-target:module");
 }
Exemple #5
0
		static public void Save (string name, bool saveDebugInfo, Report Report)
		{
			PortableExecutableKinds pekind;
			ImageFileMachine machine;

			switch (RootContext.Platform) {
			case Platform.X86:
				pekind = PortableExecutableKinds.Required32Bit;
				machine = ImageFileMachine.I386;
				break;
			case Platform.X64:
				pekind = PortableExecutableKinds.PE32Plus;
				machine = ImageFileMachine.AMD64;
				break;
			case Platform.IA64:
				pekind = PortableExecutableKinds.PE32Plus;
				machine = ImageFileMachine.IA64;
				break;
			case Platform.AnyCPU:
			default:
				pekind = PortableExecutableKinds.ILOnly;
				machine = ImageFileMachine.I386;
				break;
			}
			try {
				Assembly.Builder.Save (Basename (name), pekind, machine);
			}
			catch (COMException) {
				if ((RootContext.StrongNameKeyFile == null) || (!RootContext.StrongNameDelaySign))
					throw;

				// FIXME: it seems Microsoft AssemblyBuilder doesn't like to delay sign assemblies 
				Report.Error (1548, "Couldn't delay-sign the assembly with the '" +
					RootContext.StrongNameKeyFile +
					"', Use MCS with the Mono runtime or CSC to compile this assembly.");
			}
			catch (System.IO.IOException io) {
				Report.Error (16, "Could not write to file `"+name+"', cause: " + io.Message);
				return;
			}
			catch (System.UnauthorizedAccessException ua) {
				Report.Error (16, "Could not write to file `"+name+"', cause: " + ua.Message);
				return;
			}
			catch (System.NotImplementedException nie) {
				Report.RuntimeMissingSupport (Location.Null, nie.Message);
				return;
			}

			//
			// Write debuger symbol file
			//
			if (saveDebugInfo)
				SymbolWriter.WriteSymbolFile ();
			}
Exemple #6
0
        public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
        {
            if (a.IsValidSecurityAttribute())
            {
                if (declarative_security == null)
                {
                    declarative_security = new ListDictionary();
                }

                a.ExtractSecurityPermissionSet(declarative_security);
                return;
            }

            if (a.Type == pa.AssemblyCulture)
            {
                string value = a.GetString();
                if (value == null || value.Length == 0)
                {
                    return;
                }

                if (RootContext.Target == Target.Exe)
                {
                    a.Error_AttributeEmitError("The executables cannot be satelite assemblies, remove the attribute or keep it empty");
                    return;
                }
            }

            if (a.Type == pa.AssemblyVersion)
            {
                string value = a.GetString();
                if (value == null || value.Length == 0)
                {
                    return;
                }

                value = value.Replace('*', '0');

                if (!IsValidAssemblyVersion(value))
                {
                    a.Error_AttributeEmitError(string.Format("Specified version `{0}' is not valid", value));
                    return;
                }
            }

            if (a.Type == pa.InternalsVisibleTo && !CheckInternalsVisibleAttribute(a))
            {
                return;
            }

            if (a.Type == pa.TypeForwarder)
            {
                Type t = a.GetArgumentType();
                if (t == null || TypeManager.HasElementType(t))
                {
                    Report.Error(735, a.Location, "Invalid type specified as an argument for TypeForwardedTo attribute");
                    return;
                }

                t = TypeManager.DropGenericTypeArguments(t);
                if (emitted_forwarders == null)
                {
                    emitted_forwarders = new ListDictionary();
                }
                else if (emitted_forwarders.Contains(t))
                {
                    Report.SymbolRelatedToPreviousError(((Attribute)emitted_forwarders[t]).Location, null);
                    Report.Error(739, a.Location, "A duplicate type forward of type `{0}'",
                                 TypeManager.CSharpName(t));
                    return;
                }

                emitted_forwarders.Add(t, a);

                if (TypeManager.LookupDeclSpace(t) != null)
                {
                    Report.SymbolRelatedToPreviousError(t);
                    Report.Error(729, a.Location, "Cannot forward type `{0}' because it is defined in this assembly",
                                 TypeManager.CSharpName(t));
                    return;
                }

                if (t.DeclaringType != null)
                {
                    Report.Error(730, a.Location, "Cannot forward type `{0}' because it is a nested type",
                                 TypeManager.CSharpName(t));
                    return;
                }

                if (add_type_forwarder == null)
                {
                    add_type_forwarder = typeof(AssemblyBuilder).GetMethod("AddTypeForwarder",
                                                                           BindingFlags.NonPublic | BindingFlags.Instance);

                    if (add_type_forwarder == null)
                    {
                        Report.RuntimeMissingSupport(a.Location, "TypeForwardedTo attribute");
                        return;
                    }
                }

                add_type_forwarder.Invoke(Builder, new object[] { t });
                return;
            }

            if (a.Type == pa.Extension)
            {
                a.Error_MisusedExtensionAttribute();
                return;
            }

            Builder.SetCustomAttribute(cb);
        }
Exemple #7
0
        static public void Save(string name, bool saveDebugInfo, Report Report)
        {
#if GMCS_SOURCE
            PortableExecutableKinds pekind;
            ImageFileMachine        machine;

            switch (RootContext.Platform)
            {
            case Platform.X86:
                pekind  = PortableExecutableKinds.Required32Bit;
                machine = ImageFileMachine.I386;
                break;

            case Platform.X64:
                pekind  = PortableExecutableKinds.PE32Plus;
                machine = ImageFileMachine.AMD64;
                break;

            case Platform.IA64:
                pekind  = PortableExecutableKinds.PE32Plus;
                machine = ImageFileMachine.IA64;
                break;

            case Platform.AnyCPU:
            default:
                pekind  = PortableExecutableKinds.ILOnly;
                machine = ImageFileMachine.I386;
                break;
            }
#endif
            try {
#if GMCS_SOURCE
                Assembly.Builder.Save(Basename(name), pekind, machine);
#else
                Assembly.Builder.Save(Basename(name));
#endif
            }
            catch (COMException) {
                if ((RootContext.StrongNameKeyFile == null) || (!RootContext.StrongNameDelaySign))
                {
                    throw;
                }

                // FIXME: it seems Microsoft AssemblyBuilder doesn't like to delay sign assemblies
                Report.Error(1548, "Couldn't delay-sign the assembly with the '" +
                             RootContext.StrongNameKeyFile +
                             "', Use MCS with the Mono runtime or CSC to compile this assembly.");
            }
            catch (System.IO.IOException io) {
                Report.Error(16, "Could not write to file `" + name + "', cause: " + io.Message);
                return;
            }
            catch (System.UnauthorizedAccessException ua) {
                Report.Error(16, "Could not write to file `" + name + "', cause: " + ua.Message);
                return;
            }
            catch (System.NotImplementedException nie) {
                Report.RuntimeMissingSupport(Location.Null, nie.Message);
                return;
            }

            //
            // Write debuger symbol file
            //
            if (saveDebugInfo)
            {
                SymbolWriter.WriteSymbolFile();
            }
        }