예제 #1
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 7001:
                fLichSX frm = new fLichSX();
                frm.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm);

            case 7002:
                fNhapTP frm1 = new fNhapTP();
                frm1.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm1);

            case 7003:
                fTaoPhieuXuatLSX frm2 = new fTaoPhieuXuatLSX();
                frm2.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm2);
            }
            return(f);
        }
예제 #2
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 5001:
                Coster cost = new Coster();
                return(cost.Co);

            case 5002:
                UpdateddFilter f1 = new UpdateddFilter();
                return(f1);

                //f.ShowDialog();
                break;

            case 5003:
                CopyCondition fa = new CopyCondition();
                return(fa);

                //fa.ShowDialog();
                break;

            case 5004:
                CoPhanBoCP cocp = new CoPhanBoCP();
                return(cocp);

                break;
            }
            return(f);
        }
예제 #3
0
        public static TypeInfo GetTypeInfo(TypeSpec type, IMemberContext context)
        {
            if (!type.IsStruct)
            {
                return(simple_type);
            }

            TypeInfo info;

            if (type_hash.TryGetValue(type, out info))
            {
                return(info);
            }

            var struct_info = StructInfo.GetStructInfo(type, context);

            if (struct_info != null)
            {
                info = new TypeInfo(struct_info, 0);
            }
            else
            {
                info = simple_type;
            }

            type_hash.Add(type, info);
            return(info);
        }
예제 #4
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 7001:
                Filter frm = new Filter();
                return(frm);

                //frm.Text = si.MenuName;
                //frm.ShowDialog();
                break;

            case 7002:
                fKyHoaDon frm1 = new fKyHoaDon();
                return(frm1);

                //frm.Text = si.MenuName;
                //frm.ShowDialog();
                break;

            case 7003:
                fSelectMau frm2 = new fSelectMau();
                return(frm2);
            }
            return(f);
        }
예제 #5
0
파일: FO.cs 프로젝트: trancongvy/CBADev17
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 16005:
                fRoomList RList = new fRoomList();
                return(RList);

            case 16004:
                ReadCall rc = new ReadCall();
                return(rc);

            case 16003:
                fTTPhong frm3 = new fTTPhong();
                //frm.ShowDialog();
                return(frm3);

            case 16002:
                fFO frm2 = new fFO();
                //frm.ShowDialog();
                return(frm2);

            case 16001:
                fPOS frm1 = new fPOS();
                //frm.ShowDialog();
                return(frm1);
            }
            return(f);
        }
예제 #6
0
        private static StructInfo GetStructInfo(Type typeClass, Dictionary <string, StructInfo> allStructs, Dictionary <string, EnumInfo> allEnums)
        {
            var res = new StructInfo();

            res.FullName = typeClass.FullName;
            res.Name     = typeClass.Name;

            object defaultObject = Activator.CreateInstance(typeClass);

            PropertyInfo[] properties = typeClass.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            foreach (PropertyInfo p in properties)
            {
                Type t      = p.PropertyType;
                bool ignore = p.GetCustomAttribute <Ignore>() != null;
                if (ignore)
                {
                    continue;
                }
                Dimension dim = GetDimensionFromPropertyType(t);
                if (t.IsGenericType)   // Nullable or List
                {
                    t = t.GetGenericArguments()[0];
                }
                else if (t.IsArray)
                {
                    t = t.GetElementType();
                }
                DataType type            = DataValue.TypeToDataType(t);
                string   typeConstraints = "";
                if (type == DataType.Enum || type == DataType.Struct)
                {
                    typeConstraints = t.FullName;
                }

                if (type == DataType.Struct)
                {
                    if (!allStructs.ContainsKey(t.FullName))
                    {
                        allStructs[t.FullName] = new StructInfo();
                        allStructs[t.FullName] = GetStructInfo(t, allStructs, allEnums);
                    }
                }
                else if (type == DataType.Enum)
                {
                    if (!allEnums.ContainsKey(t.FullName))
                    {
                        allEnums[t.FullName] = GetEnumInfo(t);
                    }
                }

                object    value        = p.GetValue(defaultObject, null);
                DataValue?defaultValue = null;
                if (value != null)
                {
                    defaultValue = DataValue.FromObject(value);
                }
                res.Member.Add(new SimpleMember(p.Name, type, typeConstraints, dim, defaultValue, false, ""));
            }
            return(res);
        }
예제 #7
0
            public string ResolveNameConflict(UField field, string name)
            {
                UFunction function = field as UFunction;

                if (function != null)
                {
                    // Functions are a special case and must use the base-most function for name resolving.
                    // See above for more info on this.
                    UFunction originalFunction;
                    UClass    originalOwner = codeGenerator.GetOriginalFunctionOwner(function, out originalFunction);
                    if (originalOwner != Class)
                    {
                        StructInfo originalOwnerStructInfo = codeGenerator.GetStructInfo(originalOwner);
                        return(originalOwnerStructInfo.ResolveNameConflict(originalFunction, name));
                    }
                }

                string resolvedName;

                if (conflictInfo.ResolvedName.TryGetValue(field, out resolvedName))
                {
                    return(resolvedName);
                }

                return(name);
            }
예제 #8
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 7003:
                Filter frm = new Filter();
                return(frm);

                break;

            case 7004:
                fNhapKho frm1 = new fNhapKho();
                return(frm1);

                break;

            case 7005:
                fUpdateTile frm2 = new fUpdateTile();
                return(frm2);

                break;

            case 7006:
                fUpdateGia frm3 = new fUpdateGia();
                return(frm3);

                break;
            }
            return(f);
        }
예제 #9
0
        /// <summary>
        /// Serialize struct to NetDataWriter (fast)
        /// </summary>
        /// <param name="writer">Serialization target NetDataWriter</param>
        /// <param name="obj">Struct to serialize</param>
        public void Serialize <T>(NetDataWriter writer, T obj) where T : class, new()
        {
            StructInfo info = RegisterInternal <T>();

            _hasher.WriteHash(info.Hash, writer);
            info.Write(writer, obj);
        }
예제 #10
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 3501:
                fTaoHoadon frm = new fTaoHoadon();
                frm.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm);

            case 3502:
                fDieuXe frm1 = new fDieuXe();
                frm1.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm1);

            case 3503:
                fTaoPhieuXuatLSX frm2 = new fTaoPhieuXuatLSX();
                frm2.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm2);

            case 3504:
                fNhapTP frm3 = new fNhapTP();
                frm3.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm3);
            }
            return(f);
        }
예제 #11
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 1003:
                FormHTK frm = new FormHTK();
                return(frm);

            case 1004:
                fKiemkedinhky frm1 = new fKiemkedinhky();
                return(frm1);

            //frm.Text = si.MenuName;
            //frm.ShowDialog();
            case 1005:
                fBtKhuKho frm2 = new fBtKhuKho();
                return(frm2);

            //frm.Text = si.MenuName;
            //frm.ShowDialog();
            case 1006:
                fTiendoduan frm3 = new fTiendoduan();

                return(frm3);

            case 1007:
                fTiendoThanhtoan frm4 = new fTiendoThanhtoan();

                return(frm4);
            }
            return(f);
        }
예제 #12
0
        public static bool SupportsType(Type type)
        {
            if (!type.IsValueType || string.IsNullOrEmpty(type.AssemblyQualifiedName) || type.FullName == SYSTEM_VOID)
            {
                return(false);
            }

            if (typeSupportCache.TryGetValue(type.AssemblyQualifiedName, out var info))
            {
                return(info.IsSupported);
            }

            var supported = false;

            var fields = type.GetFields(INSTANCE_FLAGS);

            if (fields.Length > 0)
            {
                if (fields.Any(it => !ParseUtility.CanParse(it.FieldType)))
                {
                    supported = false;
                    info      = new StructInfo(supported, null);
                }
                else
                {
                    supported = true;
                    info      = new StructInfo(supported, fields);
                }
            }

            typeSupportCache.Add(type.AssemblyQualifiedName, info);

            return(supported);
        }
예제 #13
0
        private JObject?GetStructDefaultValue(SimpleMember m)
        {
            if (m.Type != DataType.Struct)
            {
                return(null);
            }
            string     structName = m.TypeConstraints;
            StructInfo structInfo = structTypes[structName];
            JObject    obj        = new JObject();

            foreach (var sm in structInfo.Member)
            {
                string dv;
                if (sm.DefaultValue.HasValue)
                {
                    dv = sm.DefaultValue.Value.JSON;
                }
                else if (sm.Dimension == Dimension.Optional)
                {
                    dv = "null";
                }
                else
                {
                    dv = DataValue.FromDataType(sm.Type, 1).JSON;
                }
                obj[sm.Name] = new JRaw(dv);
            }
            return(obj);
        }
예제 #14
0
                }                                                                   // <Member, ResolvedName>

                public NameConflictInfo(StructInfo structInfo)
                {
                    this.structInfo   = structInfo;
                    BaseMembersByName = new Dictionary <string, NameConflictFieldInfo>();
                    MembersByName     = new Dictionary <string, NameConflictFieldInfo>();
                    ResolvedName      = new Dictionary <UField, string>();
                }
예제 #15
0
 TypeInfo(StructInfo struct_info, int offset)
 {
     this.struct_info   = struct_info;
     this.Offset        = offset;
     this.Length        = struct_info.Length;
     this.TotalLength   = struct_info.TotalLength;
     this.SubStructInfo = struct_info.StructFields;
     this.IsStruct      = true;
 }
예제 #16
0
 public EocStruct(ProjectConverter p, StructInfo rawInfo)
 {
     P          = p ?? throw new ArgumentNullException(nameof(p));
     RawInfo    = rawInfo ?? throw new ArgumentNullException(nameof(rawInfo));
     Name       = P.GetUserDefinedName_SimpleCppName(RawInfo.Id);
     RawName    = "raw_" + Name;
     RawCppName = $"{P.TypeNamespace}::eoc_internal::{RawName}";
     CppName    = P.GetCppTypeName(rawInfo.Id).ToString();
 }
예제 #17
0
파일: flowanalysis.cs 프로젝트: psni/mono
		TypeInfo (StructInfo struct_info, int offset)
		{
			this.struct_info = struct_info;
			this.Offset = offset;
			this.Length = struct_info.Length;
			this.TotalLength = struct_info.TotalLength;
			this.SubStructInfo = struct_info.StructFields;
			this.IsStruct = true;
		}
예제 #18
0
        public static void StructType(INamedTypeSymbol symbol)
        {
            var nfo = StructInfo.FromSymbol(symbol);

            Test.Assert(nfo.TypeInfo.AsStruct() != null, "Type should be convertable to struct.");
            Test.Assert(nfo.TypeInfo.Kind == CodeGeneration.CSharp.TypeInfo.TypeKind.Struct, "Type kind should be 'Struct'");
            Test.Assert(nfo.DataTypeInfo != null, "DataTypeInfo must not be null.");
            Test.Assert(nfo.DataTypeInfo.TypeInfo.Name == "StructType", "Struct name was wrongly detected.");
        }
예제 #19
0
        /// <summary>
        /// Register and subscribe to packet receive event
        /// This metod will overwrite last received packet class on receive (less garbage)
        /// </summary>
        /// <param name="onReceive">event that will be called when packet deserialized with ReadPacket method</param>
        public void SubscribeReusable <T, TUserData>(Action <T, TUserData> onReceive) where T : class, new()
        {
            StructInfo structInfo = RegisterInternal <T>();

            structInfo.Reference = new T();
            structInfo.OnReceive = delegate(object o, object userData)
            {
                onReceive((T)o, (TUserData)userData);
            };
        }
예제 #20
0
 private void ExecuteFunctions(StructInfo si)
 {
     switch (si.MenuId)
     {
     case 6000:
         TicketPrint frm = new TicketPrint();
         frm.ShowDialog();
         break;
     }
 }
예제 #21
0
        /// <summary>
        /// Register and subscribe to packet receive event (with userData)
        /// </summary>
        /// <param name="onReceive">event that will be called when packet deserialized with ReadPacket method</param>
        /// <param name="packetConstructor">Method that constructs packet intead of slow Activator.CreateInstance</param>
        public void Subscribe <T, TUserData>(Action <T, TUserData> onReceive, Func <T> packetConstructor) where T : class, new()
        {
            StructInfo structInfo = RegisterInternal <T>();

            structInfo.CreatorFunc = (() => packetConstructor());
            structInfo.OnReceive   = delegate(object o, object userData)
            {
                onReceive((T)o, (TUserData)userData);
            };
        }
예제 #22
0
 private void ExecuteFunctions(StructInfo si)
 {
     switch (si.MenuId)
     {
     case 10001:
         Filter f = new Filter();
         f.ShowDialog();
         break;
     }
 }
예제 #23
0
 /// <summary>Assigns given struct variable. Returs ture if the info was already defined.</summary>
 public static bool getDefinition(Type t, out StructInfo info)
 {
     if (structs.ContainsKey(t))
     {
         info = structs[t]; return(true);
     }
     info = new StructInfo();
     structs.Add(t, info);
     return(false);
 }
예제 #24
0
        private StructInfo GetStructInfo(UStruct unrealStruct, bool isBlueprintType)
        {
            StructInfo structInfo;

            if (structInfos.TryGetValue(unrealStruct, out structInfo))
            {
                return(structInfo);
            }

            structInfo = new StructInfo(this, unrealStruct, isBlueprintType);
            foreach (UFunction function in unrealStruct.GetFields <UFunction>(false, true, true))
            {
                // We need to include interface functions as otherwise some interface functions wont be implemented.
                // If the interface function already has an implementation skip that function (as otherwise there will be duplicates).
                if (!structInfo.IsClass || !function.GetOwnerClass().IsChildOf <UInterface>() ||
                    structInfo.Class.FindFunctionByName(function.GetFName(), true).GetOwnerClass().IsChildOf <UInterface>())
                {
                    structInfo.AddFunction(function, CanExportFunction(function, isBlueprintType));
                }
            }

            if (isBlueprintType)
            {
                UUserDefinedStruct userDefinedStruct = unrealStruct as UUserDefinedStruct;
                if (userDefinedStruct != null)
                {
                    Dictionary <UProperty, string> variableNames = GetStructBPVariableNames(userDefinedStruct);

                    foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                    {
                        structInfo.AddProperty(property, variableNames[property], CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
                else
                {
                    foreach (UProperty property in unrealStruct.GetProperties <UProperty>(false))
                    {
                        structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
            }
            else
            {
                foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                {
                    structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                }
            }

            structInfo.ResolveCollapsedMembers();
            structInfo.PostProcess();

            structInfos.Add(unrealStruct, structInfo);
            return(structInfo);
        }
예제 #25
0
        /// <summary>
        /// Reads one packet from NetDataReader and calls OnReceive delegate
        /// </summary>
        /// <param name="reader">NetDataReader with packet</param>
        /// <param name="userData">Argument that passed to OnReceivedEvent</param>
        public void ReadPacket(NetDataReader reader, object userData)
        {
            StructInfo info = ReadInfo(reader);

            if (info.CreatorFunc != null)
            {
                info.Reference = info.CreatorFunc();
            }
            info.Read(reader);
            info.OnReceive(info.Reference, userData);
        }
예제 #26
0
        /// <summary>
        /// Sets the IsValid state for the given struct based on the state of all properties IsValid state
        /// (used when generating with safeguards enabled)
        /// </summary>
        private void AppendStructIsValid(CSharpTextBuilder builder, string structTypeName, StructInfo structInfo, UStruct parentStruct)
        {
            if (!Settings.GenerateIsValidSafeguards)
            {
                return;
            }

            List <UProperty> allProperties = new List <UProperty>();

            foreach (UProperty property in structInfo.GetProperties())
            {
                if (!structInfo.IsCollapsedProperty(property))
                {
                    allProperties.Add(property);
                }
            }

            if (parentStruct != null && (Settings.InlineBaseStruct || structInfo.StructAsClass))
            {
                UScriptStruct tempParentStruct = parentStruct as UScriptStruct;
                while (tempParentStruct != null)
                {
                    StructInfo tempParentStructInfo = GetStructInfo(tempParentStruct);
                    if (tempParentStructInfo != null)
                    {
                        foreach (UProperty property in tempParentStructInfo.GetProperties())
                        {
                            if (!tempParentStructInfo.IsCollapsedProperty(property))
                            {
                                allProperties.Add(property);
                            }
                        }
                    }
                    tempParentStruct = tempParentStruct.GetSuperStruct() as UScriptStruct;
                }
            }

            StringBuilder isValidCheck = new StringBuilder();

            isValidCheck.Append(Settings.VarNames.ClassAddress + " != IntPtr.Zero");
            foreach (UProperty property in allProperties)
            {
                string propertyName = GetMemberName(property, structInfo.GetPropertyName(property));
                isValidCheck.Append(" && " + propertyName + Settings.VarNames.IsValid);
            }

            isValidCheck.Insert(0, structTypeName + Settings.VarNames.IsValid + " = ");
            isValidCheck.Append(";");
            builder.AppendLine(isValidCheck.ToString());

            builder.AppendLine(Names.NativeReflection_LogStructIsValid + "(\"" + structInfo.Struct.GetPathName() + "\", " +
                               structTypeName + Settings.VarNames.IsValid + ");");
        }
예제 #27
0
        /// <summary>
        /// Reads packet with known type
        /// </summary>
        /// <param name="reader">NetDataReader with packet</param>
        /// <returns>Returns packet if packet in reader is matched type</returns>
        public T ReadKnownPacket <T>(NetDataReader reader) where T : class, new()
        {
            StructInfo info = ReadInfo(reader);

            if (_hasher.GetHash(typeof(T).Name) != info.Hash)
            {
                return(null);
            }
            info.Reference = ((info.CreatorFunc != null) ? info.CreatorFunc() : new T());
            info.Read(reader);
            return((T)info.Reference);
        }
예제 #28
0
            //
            // We only need one instance per type
            //
            StructInfo(TypeSpec type, IMemberContext context)
            {
                field_type_hash.Add(type, this);

                fields = MemberCache.GetAllFieldsForDefiniteAssignment(type, context);

                struct_field_hash = new Dictionary <string, TypeInfo> ();
                field_hash        = new Dictionary <string, int> (fields.Count);

                StructFields = new TypeInfo[fields.Count];
                StructInfo[] sinfo = new StructInfo[fields.Count];

                InTransit = true;

                for (int i = 0; i < fields.Count; i++)
                {
                    var field = fields [i];

                    if (field.MemberType.IsStruct)
                    {
                        sinfo [i] = GetStructInfo(field.MemberType, context);
                    }

                    if (sinfo [i] == null)
                    {
                        field_hash.Add(field.Name, ++Length);
                    }
                    else if (sinfo [i].InTransit)
                    {
                        sinfo [i] = null;
                        return;
                    }
                }

                InTransit = false;

                TotalLength = Length + 1;
                for (int i = 0; i < fields.Count; i++)
                {
                    var field = fields [i];

                    if (sinfo [i] == null)
                    {
                        continue;
                    }

                    field_hash.Add(field.Name, TotalLength);

                    StructFields [i] = new TypeInfo(sinfo [i], TotalLength);
                    struct_field_hash.Add(field.Name, StructFields [i]);
                    TotalLength += sinfo [i].TotalLength;
                }
            }
예제 #29
0
        /// <summary>
        /// Reads packet with known type (non alloc variant)
        /// </summary>
        /// <param name="reader">NetDataReader with packet</param>
        /// <param name="target">Deserialization target</param>
        /// <returns>Returns true if packet in reader is matched type</returns>
        public bool ReadKnownPacket <T>(NetDataReader reader, T target) where T : class, new()
        {
            StructInfo info = ReadInfo(reader);

            if (_hasher.GetHash(typeof(T).Name) != info.Hash)
            {
                return(false);
            }
            info.Reference = target;
            info.Read(reader);
            return(true);
        }
예제 #30
0
        /// <summary>
        /// Register packet type for direct reading (ReadKnownPacket)
        /// </summary>
        /// <param name="packetConstructor">Method that constructs packet intead of slow Activator.CreateInstance</param>
        public void Register <T>(Func <T> packetConstructor = null) where T : class, new()
        {
            StructInfo info = RegisterInternal <T>();

            if (packetConstructor != null)
            {
                info.CreatorFunc = (() => packetConstructor());
            }
            info.OnReceive = delegate
            {
            };
        }
예제 #31
0
        private Form ExecuteFunctions(StructInfo si)
        {
            Form f = new Form();

            switch (si.MenuId)
            {
            case 3500:
                fPhanboHoaDon frm = new fPhanboHoaDon();
                frm.Text = si.MenuName;
                //frm.ShowDialog();
                return(frm);
            }
            return(f);
        }
 private IEnumerable<IEmitVal> DeclareInputElementsImpl(
     IEmitBlock block,
     string name,
     StructInfo info)
 {
     foreach (var f in info.Fields)
     {
         var fieldElements = (DeclareInputElements(
             block,
             name,
             f.Info)).ToArray();
         foreach (var fe in fieldElements)
             yield return fe;
     }
 }
예제 #33
0
			// Private constructor.  To save memory usage, we only need to create one instance
			// of this class per struct type.
			private StructInfo (TypeSpec type)
			{
				this.Type = type;

				field_type_hash.Add (type, this);

				fields = MemberCache.GetAllFieldsForDefiniteAssignment (type);

				struct_field_hash = new Dictionary<string, TypeInfo> ();
				field_hash = new Dictionary<string, int> (fields.Count);

				StructFields = new TypeInfo[fields.Count];
				StructInfo[] sinfo = new StructInfo[fields.Count];

				InTransit = true;

				for (int i = 0; i < fields.Count; i++) {
					var field = fields [i];

					if (field.MemberType.IsStruct)
						sinfo [i] = GetStructInfo (field.MemberType);

					if (sinfo [i] == null)
						field_hash.Add (field.Name, ++Length);
					else if (sinfo [i].InTransit) {
						sinfo [i] = null;
						return;
					}
				}

				InTransit = false;

				TotalLength = Length + 1;
				for (int i = 0; i < fields.Count; i++) {
					var field = fields [i];

					if (sinfo [i] == null)
						continue;

					field_hash.Add (field.Name, TotalLength);

					StructFields [i] = new TypeInfo (sinfo [i], TotalLength);
					struct_field_hash.Add (field.Name, StructFields [i]);
					TotalLength += sinfo [i].TotalLength;
				}
			}
예제 #34
0
			// Private constructor.  To save memory usage, we only need to create one instance
			// of this class per struct type.
			private StructInfo (TypeSpec type)
			{
				this.Type = type;

				field_type_hash.Add (type, this);

				TypeContainer tc = type.MemberDefinition as TypeContainer;

				var public_fields = new List<FieldSpec> ();
				var non_public_fields = new List<FieldSpec> ();

				if (tc != null) {
					var fields = tc.Fields;

					if (fields != null) {
						foreach (FieldBase field in fields) {
							if ((field.ModFlags & Modifiers.STATIC) != 0)
								continue;
							if ((field.ModFlags & Modifiers.PUBLIC) != 0)
								public_fields.Add (field.Spec);
							else
								non_public_fields.Add (field.Spec);
						}
					}
				}

				CountPublic = public_fields.Count;
				CountNonPublic = non_public_fields.Count;
				Count = CountPublic + CountNonPublic;

				Fields = new FieldSpec[Count];
				public_fields.CopyTo (Fields, 0);
				non_public_fields.CopyTo (Fields, CountPublic);

				struct_field_hash = new Dictionary<string, TypeInfo> ();
				field_hash = new Dictionary<string, int> ();

				Length = 0;
				StructFields = new TypeInfo [Count];
				StructInfo[] sinfo = new StructInfo [Count];

				InTransit = true;

				for (int i = 0; i < Count; i++) {
					var field = Fields [i];

					sinfo [i] = GetStructInfo (field.MemberType);
					if (sinfo [i] == null)
						field_hash.Add (field.Name, ++Length);
					else if (sinfo [i].InTransit) {
						sinfo [i] = null;
						return;
					}
				}

				InTransit = false;

				TotalLength = Length + 1;
				for (int i = 0; i < Count; i++) {
					var field = Fields [i];

					if (sinfo [i] == null)
						continue;

					field_hash.Add (field.Name, TotalLength);

					HasStructFields = true;
					StructFields [i] = new TypeInfo (sinfo [i], TotalLength);
					struct_field_hash.Add (field.Name, StructFields [i]);
					TotalLength += sinfo [i].TotalLength;
				}
			}
예제 #35
0
		private TypeInfo (TypeSpec type)
		{
			this.Type = type;

			struct_info = StructInfo.GetStructInfo (type);
			if (struct_info != null) {
				Length = struct_info.Length;
				TotalLength = struct_info.TotalLength;
				SubStructInfo = struct_info.StructFields;
				IsStruct = true;
			} else {
				Length = 0;
				TotalLength = 1;
				IsStruct = false;
			}
		}
예제 #36
0
		private TypeInfo (TypeContainer tc)
		{
			this.Type = tc.TypeBuilder;

			struct_info = StructInfo.GetStructInfo (tc);
			if (struct_info != null) {
				Length = struct_info.Length;
				TotalLength = struct_info.TotalLength;
				SubStructInfo = struct_info.StructFields;
				IsStruct = true;
			} else {
				Length = 0;
				TotalLength = 1;
				IsStruct = false;
			}
		}
예제 #37
0
			// Private constructor.  To save memory usage, we only need to create one instance
			// of this class per struct type.
			private StructInfo (Type type)
			{
				this.Type = type;

				field_type_hash.Add (type, this);

				if (type.Module == CodeGen.Module.Builder) {
					TypeContainer tc = TypeManager.LookupTypeContainer (TypeManager.DropGenericTypeArguments (type));

					ArrayList public_fields = new ArrayList ();
					ArrayList non_public_fields = new ArrayList ();

					//
					// TODO: tc != null is needed because FixedBuffers are not cached
					//
					if (tc != null) {					
					ArrayList fields = tc.Fields;

					if (fields != null) {
						foreach (FieldBase field in fields) {
							if ((field.ModFlags & Modifiers.STATIC) != 0)
								continue;
							if ((field.ModFlags & Modifiers.PUBLIC) != 0)
								public_fields.Add (field.FieldBuilder);
							else
								non_public_fields.Add (field.FieldBuilder);
						}
					}

					if (tc.Events != null) {
						foreach (Event e in tc.Events) {
							if ((e.ModFlags & Modifiers.STATIC) != 0)
								continue;

							EventField ef = e as EventField;
							if (ef == null)
								continue;

							if ((ef.ModFlags & Modifiers.PUBLIC) != 0)
								public_fields.Add (ef.FieldBuilder);
							else
								non_public_fields.Add (ef.FieldBuilder);
						}
					}
					}

					CountPublic = public_fields.Count;
					CountNonPublic = non_public_fields.Count;
					Count = CountPublic + CountNonPublic;

					Fields = new FieldInfo [Count];
					public_fields.CopyTo (Fields, 0);
					non_public_fields.CopyTo (Fields, CountPublic);
#if GMCS_SOURCE
				} else if (type is GenericTypeParameterBuilder) {
					CountPublic = CountNonPublic = Count = 0;

					Fields = new FieldInfo [0];
#endif
				} else {
					FieldInfo[] public_fields = type.GetFields (
						BindingFlags.Instance|BindingFlags.Public);
					FieldInfo[] non_public_fields = type.GetFields (
						BindingFlags.Instance|BindingFlags.NonPublic);

					CountPublic = public_fields.Length;
					CountNonPublic = non_public_fields.Length;
					Count = CountPublic + CountNonPublic;

					Fields = new FieldInfo [Count];
					public_fields.CopyTo (Fields, 0);
					non_public_fields.CopyTo (Fields, CountPublic);
				}

				struct_field_hash = new Hashtable ();
				field_hash = new Hashtable ();

				Length = 0;
				StructFields = new TypeInfo [Count];
				StructInfo[] sinfo = new StructInfo [Count];

				InTransit = true;

				for (int i = 0; i < Count; i++) {
					FieldInfo field = (FieldInfo) Fields [i];

					sinfo [i] = GetStructInfo (field.FieldType);
					if (sinfo [i] == null)
						field_hash.Add (field.Name, ++Length);
					else if (sinfo [i].InTransit) {
						Report.Error (523, String.Format (
								      "Struct member `{0}.{1}' of type `{2}' causes " +
								      "a cycle in the structure layout",
								      type, field.Name, sinfo [i].Type));
						sinfo [i] = null;
						return;
					}
				}

				InTransit = false;

				TotalLength = Length + 1;
				for (int i = 0; i < Count; i++) {
					FieldInfo field = (FieldInfo) Fields [i];

					if (sinfo [i] == null)
						continue;

					field_hash.Add (field.Name, TotalLength);

					HasStructFields = true;
					StructFields [i] = new TypeInfo (sinfo [i], TotalLength);
					struct_field_hash.Add (field.Name, StructFields [i]);
					TotalLength += sinfo [i].TotalLength;
				}
			}