Пример #1
0
        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);
        }