Inheritance: MemberSpec, IInterfaceMemberSpec
コード例 #1
0
        public void Emit(OpCode opcode, FieldSpec field)
        {
            if (IsAnonymousStoreyMutateRequired)
            {
                field = field.Mutate(CurrentAnonymousMethod.Storey.Mutator);
            }

            ig.Emit(opcode, field.GetMetaInfo());

            if (TrackStackTypes)
            {
                switch (opcode.StackBehaviourPush)
                {
                case StackBehaviour.Push0:
                    // nothing
                    break;

                case StackBehaviour.Push1:
                    SetStackType(field.MemberType);
                    break;

                case StackBehaviour.Pushi:
                    SetStackType(ReferenceContainer.MakeType(Module, field.MemberType));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
コード例 #2
0
        static public void Reset()
        {
//		object_type = null;

            // TODO: I am really bored by all this static stuff
            system_type_get_type_from_handle         =
                bool_movenext_void                   =
                    void_dispose_void                =
                        void_monitor_enter_object    =
                            void_monitor_exit_object =
                                void_initializearray_array_fieldhandle                                =
                                    int_interlocked_compare_exchange                                  =
                                        gen_interlocked_compare_exchange                              =
                                            methodbase_get_type_from_handle                           =
                                                methodbase_get_type_from_handle_generic               =
                                                    fieldinfo_get_field_from_handle                   =
                                                        fieldinfo_get_field_from_handle_generic       =
                                                            activator_create_instance                 =
                                                                delegate_combine_delegate_delegate    =
                                                                    delegate_remove_delegate_delegate = null;

            int_get_offset_to_string_data =
                ienumerator_getcurrent    = null;

            void_decimal_ctor_five_args        =
                void_decimal_ctor_int_arg      =
                    void_decimal_ctor_long_arg = null;

            string_empty = null;

            typed_reference_type             = arg_iterator_type = mbr_type =
                generic_ilist_type           = generic_icollection_type = generic_ienumerator_type =
                    generic_ienumerable_type = generic_nullable_type = expression_type = null;
        }
コード例 #3
0
ファイル: field.cs プロジェクト: Arsslensoft/VSharp
        public override bool Define()
        {
            if (!base.Define())
            {
                return(false);
            }
            // SYNC_MOD_CTRL
            if ((ModFlags & Modifiers.SYNC) == Modifiers.SYNC)
            {
                Report.Error(3661, Location, "A sync modifier cannot be used in field declaration. ");
            }

            MetaType[] required_modifier = null;
            if ((ModFlags & Modifiers.VOLATILE) != 0)
            {
                var mod = Module.PredefinedTypes.IsVolatile.Resolve();
                if (mod != null)
                {
                    required_modifier = new MetaType[] { mod.GetMetaInfo() }
                }
                ;
            }

            FieldBuilder = Parent.TypeBuilder.DefineField(
                Name, member_type.GetMetaInfo(), required_modifier, null, ModifiersExtensions.FieldAttr(ModFlags));

            spec = new FieldSpec(Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

            //
            // Don't cache inaccessible fields except for struct where we
            // need them for definitive assignment checks
            //
            if ((ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct)
            {
                Parent.MemberCache.AddMember(spec);
            }

            if (initializer != null)
            {
                Parent.RegisterFieldForInitialization(this, new FieldInitializer(this, initializer, TypeExpression.Location));
            }

            if (declarators != null)
            {
                foreach (var d in declarators)
                {
                    var f = new Field(Parent, d.GetFieldTypeExpression(this), ModFlags, new MemberName(d.Name.Value, d.Name.Location), OptAttributes);
                    if (d.Initializer != null)
                    {
                        f.initializer = d.Initializer;
                    }

                    f.Define();
                    Parent.PartialContainer.Members.Add(f);
                }
            }

            return(true);
        }
コード例 #4
0
        public FixedFieldSpec(TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers)
            : base(declaringType, definition, element.MemberType, info, modifiers)
        {
            this.element = element;

            // It's never CLS-Compliant
            state &= ~StateFlags.CLSCompliant_Undetected;
        }
コード例 #5
0
ファイル: field.cs プロジェクト: raj581/Marvin
        public override bool Define()
        {
            if (!base.Define())
            {
                return(false);
            }



            MetaType[] required_modifier = null;
            if ((ModFlags & Modifiers.VOLATILE) != 0)
            {
                var mod = Module.PredefinedTypes.IsVolatile.Resolve();
                if (mod != null)
                {
                    required_modifier = new MetaType[] { mod.GetMetaInfo() }
                }
                ;
            }

            FieldBuilder = Parent.TypeBuilder.DefineField(
                Name, member_type.GetMetaInfo(), required_modifier, null, ModifiersExtensions.FieldAttr(ModFlags));

            spec = new FieldSpec(Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

            //
            // Don't cache inaccessible fields except for struct where we
            // need them for definitive assignment checks
            //
            if ((ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct)
            {
                Parent.MemberCache.AddMember(spec);
            }

            if (initializer != null)
            {
                ((TypeContainer)Parent).RegisterFieldForInitialization(this,
                                                                       new FieldInitializer(spec, initializer, this));
            }

            if (declarators != null)
            {
                var t     = new TypeExpression(MemberType, TypeExpression.Location);
                int index = Parent.PartialContainer.Fields.IndexOf(this);
                foreach (var d in declarators)
                {
                    var f = new Field(Parent, t, ModFlags, new MemberName(d.Name.Value, d.Name.Location), OptAttributes);
                    if (d.Initializer != null)
                    {
                        f.initializer = d.Initializer;
                    }

                    Parent.PartialContainer.Fields.Insert(++index, f);
                }
            }

            return(true);
        }
コード例 #6
0
        public void Emit(OpCode opcode, FieldSpec field)
        {
            if (IsAnonymousStoreyMutateRequired)
            {
                field = field.Mutate(CurrentAnonymousMethod.Storey.Mutator);
            }

            ig.Emit(opcode, field.GetMetaInfo());
        }
コード例 #7
0
 public FieldInitializer(FieldSpec spec, Expression expression, IMemberContext mc)
     : base(new FieldExpr(spec, expression.Location), expression, expression.Location)
 {
     this.mc = mc;
     if (!spec.IsStatic)
     {
         ((FieldExpr)target).InstanceExpression = new CompilerGeneratedThis(mc.CurrentType, expression.Location);
     }
 }
コード例 #8
0
        public override bool Define()
        {
            if (!base.Define())
            {
                return(false);
            }

            MetaType[] required_modifier = null;
            if ((ModFlags & Modifiers.VOLATILE) != 0)
            {
                var mod = Module.PredefinedTypes.IsVolatile.Resolve();
                if (mod != null)
                {
                    required_modifier = new MetaType[] { mod.GetMetaInfo() }
                }
                ;
            }

            FieldBuilder = Parent.TypeBuilder.DefineField(
                Name, member_type.GetMetaInfo(), required_modifier, null, ModifiersExtensions.FieldAttr(ModFlags));

            spec = new FieldSpec(Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

            // Don't cache inaccessible fields
            if ((ModFlags & Modifiers.BACKING_FIELD) == 0)
            {
                Parent.MemberCache.AddMember(spec);
            }

            if (initializer != null)
            {
                ((TypeContainer)Parent).RegisterFieldForInitialization(this,
                                                                       new FieldInitializer(spec, initializer, this));
            }

            if (declarators != null)
            {
                var t     = new TypeExpression(MemberType, TypeExpression.Location);
                int index = Parent.PartialContainer.Fields.IndexOf(this);
                foreach (var d in declarators)
                {
                    var f = new Field(Parent, t, ModFlags, new MemberName(d.Name.Value, d.Name.Location), OptAttributes);
                    if (d.Initializer != null)
                    {
                        f.initializer = d.Initializer;
                    }

                    Parent.PartialContainer.Fields.Insert(++index, f);
                }
            }

/*
 *                      if ((ModFlags & (Modifiers.STATIC | Modifiers.READONLY | Modifiers.COMPILER_GENERATED)) == Modifiers.STATIC)
 *                              Console.WriteLine ("{0}: {1}", Location.ToString (), GetSignatureForError ());
 */
            return(true);
        }
コード例 #9
0
        public override bool Define()
        {
            if (!base.Define())
            {
                return(false);
            }

            if (!BuiltinTypeSpec.IsPrimitiveType(MemberType))
            {
                Report.Error(1663, Location,
                             "`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
                             GetSignatureForError());
            }
            else if (declarators != null)
            {
                var t     = new TypeExpression(MemberType, TypeExpression.Location);
                int index = Parent.PartialContainer.Fields.IndexOf(this);
                foreach (var d in declarators)
                {
                    var f = new FixedField(Parent, t, ModFlags, new MemberName(d.Name.Value, d.Name.Location), OptAttributes);
                    f.initializer = d.Initializer;
                    ((ConstInitializer)f.initializer).Name = d.Name.Value;
                    Parent.PartialContainer.Fields.Insert(++index, f);
                }
            }

            // Create nested fixed buffer container
            string name = String.Format("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);

            fixed_buffer_type = Parent.TypeBuilder.DefineNestedType(name,
                                                                    TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit,
                                                                    Compiler.BuiltinTypes.ValueType.GetMetaInfo());

            var ffield = fixed_buffer_type.DefineField(FixedElementName, MemberType.GetMetaInfo(), FieldAttributes.Public);

            FieldBuilder = Parent.TypeBuilder.DefineField(Name, fixed_buffer_type, ModifiersExtensions.FieldAttr(ModFlags));

            var element_spec = new FieldSpec(null, this, MemberType, ffield, ModFlags);

            spec = new FixedFieldSpec(Parent.Definition, this, FieldBuilder, element_spec, ModFlags);

            Parent.MemberCache.AddMember(spec);
            return(true);
        }
コード例 #10
0
ファイル: field.cs プロジェクト: speier/shake
        public override bool Define()
        {
            if (!base.Define ())
                return false;

            try {
                Type[] required_modifier = null;
                if ((ModFlags & Modifiers.VOLATILE) != 0) {
                    if (TypeManager.isvolatile_type == null)
                        TypeManager.isvolatile_type = TypeManager.CoreLookupType (Compiler,
                            "System.Runtime.CompilerServices", "IsVolatile", MemberKind.Class, true);

                    if (TypeManager.isvolatile_type != null)
                        required_modifier = new Type[] { TypeManager.isvolatile_type.GetMetaInfo () };
                }

                FieldBuilder = Parent.TypeBuilder.DefineField (
                    Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));

                spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

                // Don't cache inaccessible fields
                if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
                    Parent.MemberCache.AddMember (spec);
                }
            }
            catch (ArgumentException) {
                Report.RuntimeMissingSupport (Location, "`void' or `void*' field type");
                return false;
            }

            if (initializer != null) {
                ((TypeContainer) Parent).RegisterFieldForInitialization (this,
                    new FieldInitializer (this, initializer, this));
            }

            return true;
        }
コード例 #11
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(this, new MemberName("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
                    size_type.CreateContainer();
                    size_type.DefineContainer();

                    size_types.Add(data.Length, size_type);

                    // It has to work even if StructLayoutAttribute does not exist
                    size_type.TypeBuilder.__SetLayout(1, data.Length);
                }

                FieldSpec fs;
                var       data_hash = GenerateDataFieldName(data);

                if (!data_hashes.TryGetValue(data_hash, out fs))
                {
                    var             name     = "$field-" + data_hash;
                    const Modifiers fmod     = Modifiers.STATIC | Modifiers.INTERNAL | Modifiers.READONLY;
                    var             fbuilder = TypeBuilder.DefineField(name, size_type.CurrentType.GetMetaInfo(), ModifiersExtensions.FieldAttr(fmod) | FieldAttributes.HasFieldRVA);
                    fbuilder.__SetDataAndRVA(data);

                    fs = new FieldSpec(CurrentType, null, size_type.CurrentType, fbuilder, fmod);
                    data_hashes.Add(data_hash, fs);
                }

                return(fs);
            }
コード例 #12
0
ファイル: field.cs プロジェクト: agallero/mono
		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			MetaType[] required_modifier = null;
			if ((ModFlags & Modifiers.VOLATILE) != 0) {
				var mod = Module.PredefinedTypes.IsVolatile.Resolve ();
				if (mod != null)
					required_modifier = new MetaType[] { mod.GetMetaInfo () };
			}

			FieldBuilder = Parent.TypeBuilder.DefineField (
				Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));

			spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

			//
			// Don't cache inaccessible fields except for struct where we
			// need them for definitive assignment checks
			//
			if ((ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct) {
				Parent.MemberCache.AddMember (spec);
			}

			if (initializer != null) {
				((TypeContainer) Parent).RegisterFieldForInitialization (this,
					new FieldInitializer (spec, initializer, this));
			}

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					if (d.Initializer != null)
						f.initializer = d.Initializer;

					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}

			return true;
		}
コード例 #13
0
ファイル: codegen.cs プロジェクト: ccflo/mono
		public void Emit (OpCode opcode, FieldSpec field)
		{
			if (IsAnonymousStoreyMutateRequired)
				field = field.Mutate (CurrentAnonymousMethod.Storey.Mutator);

			ig.Emit (opcode, field.GetMetaInfo ());

			if (TrackStackTypes) {
				switch (opcode.StackBehaviourPush) {
				case StackBehaviour.Push0:
					// nothing
					break;
				case StackBehaviour.Push1:
					SetStackType (field.MemberType);
					break;
				case StackBehaviour.Pushi:
					SetStackType (ReferenceContainer.MakeType (Module, field.MemberType));
					break;
				default:
					throw new NotImplementedException ();
				}
			}
		}
コード例 #14
0
ファイル: field.cs プロジェクト: agallero/mono
		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			if (!BuiltinTypeSpec.IsPrimitiveType (MemberType)) {
				Report.Error (1663, Location,
					"`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
					GetSignatureForError ());
			} else if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					f.initializer = d.Initializer;
					((ConstInitializer) f.initializer).Name = d.Name.Value;
					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}
			
			// Create nested fixed buffer container
			string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
			fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name,
				TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit,
				Compiler.BuiltinTypes.ValueType.GetMetaInfo ());

			var ffield = fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public);
			
			FieldBuilder = Parent.TypeBuilder.DefineField (Name, fixed_buffer_type, ModifiersExtensions.FieldAttr (ModFlags));

			var element_spec = new FieldSpec (null, this, MemberType, ffield, ModFlags);
			spec = new FixedFieldSpec (Parent.Definition, this, FieldBuilder, element_spec, ModFlags);

			Parent.MemberCache.AddMember (spec);
			return true;
		}
コード例 #15
0
ファイル: field.cs プロジェクト: agallero/mono
		public FixedFieldSpec (TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers)
			: base (declaringType, definition, element.MemberType, info, modifiers)
		{
			this.element = element;

			// It's never CLS-Compliant
			state &= ~StateFlags.CLSCompliant_Undetected;
		}
コード例 #16
0
ファイル: assign.cs プロジェクト: pgoron/monodevelop
		public FieldInitializer (FieldSpec spec, Expression expression, IMemberContext mc)
			: base (new FieldExpr (spec, expression.Location), expression, expression.Location)
		{
			this.mc = mc;
			if (!spec.IsStatic)
				((FieldExpr)target).InstanceExpression = CompilerGeneratedThis.Instance;
		}
コード例 #17
0
ファイル: codegen.cs プロジェクト: blinds52/mono
		public void Emit (OpCode opcode, FieldSpec field)
		{
			if (IsAnonymousStoreyMutateRequired)
				field = field.Mutate (CurrentAnonymousMethod.Storey.Mutator);

			ig.Emit (opcode, field.GetMetaInfo ());
		}
コード例 #18
0
ファイル: typemanager.cs プロジェクト: silk/monodevelop
	static public void Reset ()
	{
//		object_type = null;
	
		assembly_internals_vis_attrs = new Dictionary<Assembly, bool> ();
		
		// TODO: I am really bored by all this static stuff
		system_type_get_type_from_handle =
		bool_movenext_void =
		void_dispose_void =
		void_monitor_enter_object =
		void_monitor_exit_object =
		void_initializearray_array_fieldhandle =
		int_interlocked_compare_exchange =
		methodbase_get_type_from_handle =
		methodbase_get_type_from_handle_generic =
		fieldinfo_get_field_from_handle =
		fieldinfo_get_field_from_handle_generic =
		activator_create_instance =
		delegate_combine_delegate_delegate =
		delegate_remove_delegate_delegate = null;

		int_get_offset_to_string_data =
		ienumerator_getcurrent = null;

		void_decimal_ctor_five_args =
		void_decimal_ctor_int_arg =
		void_decimal_ctor_long_arg = null;

		string_empty = null;

		call_site_type =
		generic_call_site_type =
		binder_flags = null;

		binder_type = null;

		typed_reference_type = arg_iterator_type = mbr_type =
		runtime_helpers_type = iasyncresult_type = asynccallback_type =
		runtime_argument_handle_type = void_ptr_type = isvolatile_type =
		generic_ilist_type = generic_icollection_type = generic_ienumerator_type =
		generic_ienumerable_type = generic_nullable_type = expression_type =
		parameter_expression_type = fieldinfo_type = methodinfo_type = ctorinfo_type = null;

		expression_type_expr = null;
	}
コード例 #19
0
ファイル: typemanager.cs プロジェクト: telurmasin/mono
	static public void Reset ()
	{
//		object_type = null;
	
		// TODO: I am really bored by all this static stuff
		system_type_get_type_from_handle =
		bool_movenext_void =
		void_dispose_void =
		void_monitor_enter_object =
		void_monitor_exit_object =
		void_initializearray_array_fieldhandle =
		int_interlocked_compare_exchange =
		gen_interlocked_compare_exchange =
		methodbase_get_type_from_handle =
		methodbase_get_type_from_handle_generic =
		fieldinfo_get_field_from_handle =
		fieldinfo_get_field_from_handle_generic =
		activator_create_instance =
		delegate_combine_delegate_delegate =
		delegate_remove_delegate_delegate = null;

		int_get_offset_to_string_data =
		ienumerator_getcurrent = null;

		void_decimal_ctor_five_args =
		void_decimal_ctor_int_arg =
		void_decimal_ctor_long_arg = null;

		string_empty = null;

		typed_reference_type = arg_iterator_type = mbr_type =
		generic_ilist_type = generic_icollection_type = generic_ienumerator_type =
		generic_ienumerable_type = generic_nullable_type = expression_type = null;
	}
コード例 #20
0
ファイル: generic.cs プロジェクト: ikvm/mono
		public FieldInfo Mutate (FieldSpec fs)
		{
			// TODO:
			return fs.GetMetaInfo ();
		}
コード例 #21
0
ファイル: field.cs プロジェクト: speier/shake
        public override bool Define()
        {
            if (!base.Define ())
                return false;

            if (!TypeManager.IsPrimitiveType (MemberType)) {
                Report.Error (1663, Location,
                    "`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
                    GetSignatureForError ());
            }

            // Create nested fixed buffer container
            string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
            fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name, Parent.Module.DefaultCharSetType |
                TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, TypeManager.value_type.GetMetaInfo ());

            fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public);
            RootContext.RegisterCompilerGeneratedType (fixed_buffer_type);

            FieldBuilder = Parent.TypeBuilder.DefineField (Name, fixed_buffer_type, ModifiersExtensions.FieldAttr (ModFlags));
            var element_spec = new FieldSpec (null, this, MemberType, FieldBuilder, ModFlags);
            spec = new FixedFieldSpec (Parent.Definition, this, FieldBuilder, element_spec, ModFlags);

            Parent.MemberCache.AddMember (spec);
            return true;
        }
コード例 #22
0
ファイル: async.cs プロジェクト: mono-soc-2011/mono
        //
        // Fabricates stack forwarder based on stack types which copies all
        // parameters to type fields
        //
        public MethodSpec GetStackForwarder(TypeSpec[] types, out FieldSpec[] fields)
        {
            if (stack_forwarders == null)
            {
                stack_forwarders = new Dictionary <TypeSpec[], Tuple <MethodSpec, FieldSpec[]> > (TypeSpecComparer.Default);
            }
            else
            {
                //
                // Does same forwarder method with same types already exist
                //
                Tuple <MethodSpec, FieldSpec[]> method;
                if (stack_forwarders.TryGetValue(types, out method))
                {
                    fields = method.Item2;
                    return(method.Item1);
                }
            }

            Parameter[] p      = new Parameter[types.Length + 1];
            TypeSpec[]  ptypes = new TypeSpec[p.Length];
            fields = new FieldSpec[types.Length];

            for (int i = 0; i < types.Length; ++i)
            {
                var t = types[i];

                TypeSpec parameter_type = t;
                if (parameter_type == InternalType.CurrentTypeOnStack)
                {
                    parameter_type = CurrentType;
                }

                p[i]      = new Parameter(new TypeExpression(parameter_type, Location), null, 0, null, Location);
                ptypes[i] = parameter_type;

                if (t == InternalType.CurrentTypeOnStack)
                {
                    // Null means the type is `this' we can optimize by ignoring
                    continue;
                }

                var reference = t as ReferenceContainer;
                if (reference != null)
                {
                    t = reference.Element;
                }

                fields[i] = CreateStackValueField(t);
            }

            var this_parameter = new Parameter(new TypeExpression(CurrentType, Location), null, 0, null, Location);

            p[types.Length]      = this_parameter;
            ptypes[types.Length] = CurrentType;

            var parameters = ParametersCompiled.CreateFullyResolved(p, ptypes);

            var m = new Method(this, null, new TypeExpression(Compiler.BuiltinTypes.Void, Location),
                               Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
                               new MemberName("<>s__" + stack_forwarders.Count.ToString("X")), parameters, null);

            m.Block = new ToplevelBlock(Compiler, parameters, Location);
            m.Block.AddScopeStatement(new ParametersLoadStatement(fields, ptypes));

            m.Define();
            Methods.Add(m);

            stack_forwarders.Add(types, Tuple.Create(m.Spec, fields));

            return(m.Spec);
        }
コード例 #23
0
ファイル: field.cs プロジェクト: ngraziano/mono
		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			MetaType[] required_modifier = null;
			if ((ModFlags & Modifiers.VOLATILE) != 0) {
				var mod = Module.PredefinedTypes.IsVolatile.Resolve ();
				if (mod != null)
					required_modifier = new MetaType[] { mod.GetMetaInfo () };
			}

			FieldBuilder = Parent.TypeBuilder.DefineField (
				Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));

			spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

			// Don't cache inaccessible fields
			if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
				Parent.MemberCache.AddMember (spec);
			}

			if (initializer != null) {
				((TypeContainer) Parent).RegisterFieldForInitialization (this,
					new FieldInitializer (spec, initializer, this));
			}

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					if (d.Initializer != null)
						f.initializer = d.Initializer;

					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}

/*
			if ((ModFlags & (Modifiers.STATIC | Modifiers.READONLY | Modifiers.COMPILER_GENERATED)) == Modifiers.STATIC)
				Console.WriteLine ("{0}: {1}", Location.ToString (), GetSignatureForError ());
*/
			return true;
		}
コード例 #24
0
ファイル: module.cs プロジェクト: chriswebb/mono
			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 (this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
					size_type.CreateContainer ();
					size_type.DefineContainer ();

					size_types.Add (data.Length, size_type);

					// It has to work even if StructLayoutAttribute does not exist
					size_type.TypeBuilder.__SetLayout (1, data.Length);
				}

				FieldSpec fs;
				var data_hash = GenerateDataFieldName (data);
				if (!data_hashes.TryGetValue (data_hash, out fs)) {
					var name = "$field-" + data_hash;
					const Modifiers fmod = Modifiers.STATIC | Modifiers.INTERNAL | Modifiers.READONLY;
					var fbuilder = TypeBuilder.DefineField (name, size_type.CurrentType.GetMetaInfo (), ModifiersExtensions.FieldAttr (fmod) | FieldAttributes.HasFieldRVA);
					fbuilder.__SetDataAndRVA (data);

					fs = new FieldSpec (CurrentType, null, size_type.CurrentType, fbuilder, fmod);
					data_hashes.Add (data_hash, fs);
				}

				return fs;
			}
コード例 #25
0
ファイル: ecore.cs プロジェクト: speier/shake
        public FieldExpr(FieldSpec spec, Location loc)
        {
            this.spec = spec;
            this.loc = loc;

            type = spec.MemberType;
        }
コード例 #26
0
ファイル: field.cs プロジェクト: alisci01/mono
		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			Type[] required_modifier = null;
			if ((ModFlags & Modifiers.VOLATILE) != 0) {
				if (TypeManager.isvolatile_type == null)
					TypeManager.isvolatile_type = TypeManager.CoreLookupType (Compiler,
						"System.Runtime.CompilerServices", "IsVolatile", MemberKind.Class, true);

				if (TypeManager.isvolatile_type != null)
					required_modifier = new Type[] { TypeManager.isvolatile_type.GetMetaInfo () };
			}

			FieldBuilder = Parent.TypeBuilder.DefineField (
				Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));

			spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

			// Don't cache inaccessible fields
			if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
				Parent.MemberCache.AddMember (spec);
			}

			if (initializer != null) {
				((TypeContainer) Parent).RegisterFieldForInitialization (this,
					new FieldInitializer (spec, initializer, this));
			}

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					if (d.Initializer != null)
						f.initializer = d.Initializer;

					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}

			return true;
		}