public override void Emit() { if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder); } else if (!(Parent is CompilerGeneratedClass) && member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder, member_type, Location); } if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(FieldBuilder); } if (OptAttributes != null) { OptAttributes.Emit(); } if (((status & Status.HAS_OFFSET) == 0) && (ModFlags & (Modifiers.STATIC | Modifiers.BACKING_FIELD)) == 0 && Parent.PartialContainer.HasExplicitLayout) { Report.Error(625, Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute", GetSignatureForError()); } base.Emit(); }
public override void Emit() { if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder); } else if (!Parent.IsCompilerGenerated && member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder, member_type, Location); } if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(FieldBuilder); } if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { Module.PredefinedAttributes.DebuggerBrowsable.EmitAttribute(FieldBuilder, System.Diagnostics.DebuggerBrowsableState.Never); } if (OptAttributes != null) { OptAttributes.Emit(); } if (((status & Status.HAS_OFFSET) == 0) && (ModFlags & (Modifiers.STATIC | Modifiers.BACKING_FIELD)) == 0 && Parent.PartialContainer.HasExplicitLayout) { Report.Error(625, Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute", GetSignatureForError()); } ConstraintChecker.Check(this, member_type, type_expr.Location); base.Emit(); }
public virtual void Emit(TypeContainer tc) { if (OptAttributes == null) { return; } OptAttributes.Emit(); }
public override void Emit() { if (OptAttributes != null) { OptAttributes.Emit(); } if (Compiler.Settings.Unsafe) { var pa = PredefinedAttributes.UnverifiableCode; if (pa.IsDefined) { pa.EmitAttribute(builder); } } foreach (var tc in types) { tc.DefineConstants(); } foreach (TypeContainer tc in types) { tc.EmitType(); } if (Compiler.Report.Errors > 0) { return; } foreach (TypeContainer tc in types) { tc.VerifyMembers(); } if (anonymous_types != null) { foreach (var atypes in anonymous_types) { foreach (var at in atypes.Value) { at.EmitType(); } } } if (compiler_generated != null) { foreach (var c in compiler_generated) { c.EmitType(); } } }
public virtual void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index) { if (mb == null) { builder = cb.DefineParameter(index, Attributes, Name); } else { builder = mb.DefineParameter(index, Attributes, Name); } if (OptAttributes != null) { OptAttributes.Emit(); } }
public override void Emit() { Parameters.ApplyAttributes(InvokeBuilder); if (BeginInvokeBuilder != null) { Parameters p = (Parameters)TypeManager.GetParameterData(BeginInvokeBuilder); p.ApplyAttributes(BeginInvokeBuilder); } if (OptAttributes != null) { OptAttributes.Emit(); } base.Emit(); }
public override void Emit() { if (OptAttributes != null) { OptAttributes.Emit(); } if (RootContext.Unsafe) { var pa = PredefinedAttributes.UnverifiableCode; if (pa.IsDefined) { pa.EmitAttribute(builder); } } foreach (var tc in types) { tc.DefineConstants(); } HackCorlib(); foreach (TypeContainer tc in types) { tc.EmitType(); } if (Compiler.Report.Errors > 0) { return; } foreach (TypeContainer tc in types) { tc.VerifyMembers(); } if (compiler_generated != null) { foreach (var c in compiler_generated) { c.EmitType(); } } }
public override void Emit() { if (OptAttributes != null) { OptAttributes.Emit(); } if (is_unsafe) { Type t = TypeManager.CoreLookupType(context, "System.Security", "UnverifiableCodeAttribute", Kind.Class, true); if (t != null) { ConstructorInfo unverifiable_code_ctor = TypeManager.GetPredefinedConstructor(t, Location.Null, Type.EmptyTypes); if (unverifiable_code_ctor != null) { Builder.SetCustomAttribute(new CustomAttributeBuilder(unverifiable_code_ctor, new object [0])); } } } }
public override void EmitType() { if (ReturnType.Type != null) { if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location); Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder); } else if (ReturnType.Type.HasDynamicElement) { return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location); Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder, ReturnType.Type, Location); } ConstraintChecker.Check(this, ReturnType.Type, ReturnType.Location); } Constructor.ParameterInfo.ApplyAttributes(this, Constructor.ConstructorBuilder); Constructor.ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime); parameters.CheckConstraints(this); parameters.ApplyAttributes(this, InvokeBuilder.MethodBuilder); InvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime); if (BeginInvokeBuilder != null) { BeginInvokeBuilder.ParameterInfo.ApplyAttributes(this, BeginInvokeBuilder.MethodBuilder); EndInvokeBuilder.ParameterInfo.ApplyAttributes(this, EndInvokeBuilder.MethodBuilder); BeginInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime); EndInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime); } if (OptAttributes != null) { OptAttributes.Emit(); } base.Emit(); }
public virtual void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index) { if (mb == null) { builder = cb.DefineParameter(index, Attributes, Name); } else { builder = mb.DefineParameter(index, Attributes, Name); } if (OptAttributes != null) { OptAttributes.Emit(); } if (HasDefaultValue) { // // Emit constant values for true constants only, the other // constant-like expressions will rely on default value expression // Constant c = default_expr as Constant; if (c != null) { if (default_expr.Type == TypeManager.decimal_type) { builder.SetCustomAttribute(Const.CreateDecimalConstantAttribute(c)); } else { builder.SetConstant(c.GetValue()); } } } if (TypeManager.IsDynamicType(parameter_type)) { PredefinedAttributes.Get.Dynamic.EmitAttribute(builder, Location); } }
public override void EmitContainer() { if (OptAttributes != null) { OptAttributes.Emit(); } if (Compiler.Settings.Unsafe && !assembly.IsSatelliteAssembly) { var pa = PredefinedAttributes.UnverifiableCode; if (pa.IsDefined) { pa.EmitAttribute(builder); } } foreach (var tc in containers) { tc.PrepareEmit(); } base.EmitContainer(); if (Compiler.Report.Errors == 0 && !Compiler.Settings.WriteMetadataOnly) { VerifyMembers(); } if (anonymous_types != null) { foreach (var atypes in anonymous_types) { foreach (var at in atypes.Value) { at.EmitContainer(); } } } }
public override void Emit() { if (TypeManager.IsDynamicType(ret_type)) { return_attributes = new ReturnParameter(InvokeBuilder, Location); return_attributes.EmitPredefined(PredefinedAttributes.Get.Dynamic, Location); } Parameters.ApplyAttributes(InvokeBuilder); if (BeginInvokeBuilder != null) { ParametersCompiled p = (ParametersCompiled)TypeManager.GetParameterData(BeginInvokeBuilder); p.ApplyAttributes(BeginInvokeBuilder); } if (OptAttributes != null) { OptAttributes.Emit(); } base.Emit(); }
public virtual void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa) { if (builder != null) { throw new InternalErrorException("builder already exists"); } var pattrs = ParametersCompiled.GetParameterAttribute(modFlags); if (HasOptionalExpression) { pattrs |= ParameterAttributes.Optional; } if (mb == null) { builder = cb.DefineParameter(index, pattrs, Name); } else { builder = mb.DefineParameter(index, pattrs, Name); } if (OptAttributes != null) { OptAttributes.Emit(); } if (HasDefaultValue) { // // Emit constant values for true constants only, the other // constant-like expressions will rely on default value expression // var def_value = DefaultValue; Constant c = def_value != null ? def_value.Child as Constant : default_expr as Constant; if (c != null) { if (c.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { pa.DecimalConstant.EmitAttribute(builder, (decimal)c.GetValue(), c.Location); } else { builder.SetConstant(c.GetValue()); } } else if (default_expr.Type.IsStruct) { // // Handles special case where default expression is used with value-type // // void Foo (S s = default (S)) {} // builder.SetConstant(null); } } if (parameter_type != null) { if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { pa.Dynamic.EmitAttribute(builder); } else if (parameter_type.HasDynamicElement) { pa.Dynamic.EmitAttribute(builder, parameter_type, Location); } } }