当前位置: 首页>>代码示例>>C#>>正文


C# Core.GetStruct方法代码示例

本文整理汇总了C#中Core.GetStruct方法的典型用法代码示例。如果您正苦于以下问题:C# Core.GetStruct方法的具体用法?C# Core.GetStruct怎么用?C# Core.GetStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core的用法示例。


在下文中一共展示了Core.GetStruct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckField

        private static bool CheckField(
            Core.Session session, int structIndex, int fieldIndex,
            Core.Type innerType, Stack<int> seenStructs)
        {
            var fieldStruct = innerType as Core.TypeStruct;
            if (fieldStruct == null)
                return false;

            var st = session.GetStruct(structIndex);

            Core.Name fieldName;
            st.fieldNames.FindByValue(fieldIndex, out fieldName);

            session.PushContext(
                "in struct '" + session.GetStructName(structIndex).GetString() + "', " +
                "field '" + fieldName.GetString() + "'",
                st.GetFieldNameSpan(fieldIndex));

            var err = false;
            if (seenStructs.Contains(fieldStruct.structIndex))
            {
                err = true;
                session.AddMessage(
                    Diagnostics.MessageKind.Error,
                    Diagnostics.MessageCode.StructRecursion,
                    "struct recursion",
                    session.GetStruct(fieldStruct.structIndex).GetNameSpan(),
                    st.GetFieldNameSpan(fieldIndex));
            }

            if (!err)
                CheckStruct(session, fieldStruct.structIndex, seenStructs);

            session.PopContext();
            return err;
        }
开发者ID:hlorenzi,项目名称:trapl,代码行数:36,代码来源:struct_recursion_checker.cs

示例2: CheckStruct

        private static bool CheckStruct(Core.Session session, int structIndex, Stack<int> seenStructs)
        {
            var st = session.GetStruct(structIndex);
            var err = false;

            seenStructs.Push(structIndex);

            for (var i = 0; i < st.fieldTypes.Count; i++)
            {
                err |= CheckField(session, structIndex, i, st.fieldTypes[i], seenStructs);

                var fieldTuple = st.fieldTypes[i] as Core.TypeTuple;
                if (fieldTuple != null)
                {
                    for (var j = 0; j < fieldTuple.elementTypes.Length; j++)
                        err |= CheckField(session, structIndex, i, fieldTuple.elementTypes[j], seenStructs);
                }
            }

            seenStructs.Pop();
            return err;
        }
开发者ID:hlorenzi,项目名称:trapl,代码行数:22,代码来源:struct_recursion_checker.cs

示例3: GetFieldName

        public static Core.Name GetFieldName(
            Core.Session session,
            Core.Type baseType,
            int fieldIndex)
        {
            var baseStruct = baseType as Core.TypeStruct;
            if (baseStruct != null)
            {
                Core.Name name;
                session.GetStruct(baseStruct.structIndex).fieldNames.FindByValue(fieldIndex, out name);
                return name;
            }

            var baseTuple = baseType as Core.TypeTuple;
            if (baseTuple != null)
                return Core.Name.FromPath(fieldIndex.ToString());

            return null;
        }
开发者ID:hlorenzi,项目名称:trapl,代码行数:19,代码来源:type_resolver.cs

示例4: GetFieldType

        public static Core.Type GetFieldType(
            Core.Session session,
            Core.Type baseType,
            int fieldIndex)
        {
            var baseStruct = baseType as Core.TypeStruct;
            if (baseStruct != null)
                return session.GetStruct(baseStruct.structIndex).fieldTypes[fieldIndex];

            var baseTuple = baseType as Core.TypeTuple;
            if (baseTuple != null)
                return baseTuple.elementTypes[fieldIndex];

            return new Core.TypeError();
        }
开发者ID:hlorenzi,项目名称:trapl,代码行数:15,代码来源:type_resolver.cs

示例5: GetFieldNum

        public static int GetFieldNum(
            Core.Session session,
            Core.Type baseType)
        {
            var baseStruct = baseType as Core.TypeStruct;
            if (baseStruct != null)
                return session.GetStruct(baseStruct.structIndex).fieldTypes.Count;

            var baseTuple = baseType as Core.TypeTuple;
            if (baseTuple != null)
                return baseTuple.elementTypes.Length;

            return 0;
        }
开发者ID:hlorenzi,项目名称:trapl,代码行数:14,代码来源:type_resolver.cs

示例6: IsZeroSized

 public override bool IsZeroSized(Core.Session session)
 {
     var st = session.GetStruct(this.structIndex);
     return !st.primitive && st.fieldTypes.Count == 0;
 }
开发者ID:hlorenzi,项目名称:trapl,代码行数:5,代码来源:struct.cs


注:本文中的Core.GetStruct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。