本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例6: IsZeroSized
public override bool IsZeroSized(Core.Session session)
{
var st = session.GetStruct(this.structIndex);
return !st.primitive && st.fieldTypes.Count == 0;
}