本文整理汇总了C#中System.Compiler.TypeNode.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.GetField方法的具体用法?C# TypeNode.GetField怎么用?C# TypeNode.GetField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.TypeNode
的用法示例。
在下文中一共展示了TypeNode.GetField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInstanceField
private static Field GetInstanceField(TypeNode originalReturnType, Field possiblyGenericField, TypeNode instanceDeclaringType)
{
Contract.Requires(instanceDeclaringType != null);
if (instanceDeclaringType.Template == null) return possiblyGenericField;
var declaringTemplate = instanceDeclaringType;
while (declaringTemplate.Template != null) { declaringTemplate = declaringTemplate.Template; }
Contract.Assume(declaringTemplate == possiblyGenericField.DeclaringType);
return Rewriter.GetFieldInstanceReference(possiblyGenericField, instanceDeclaringType);
#if false
Field f = instanceDeclaringType.GetField(possiblyGenericField.Name);
if (f != null)
{
// already instantiated
return f;
}
// pseudo instance
Field instance = new Field(instanceDeclaringType, possiblyGenericField.Attributes, possiblyGenericField.Flags, possiblyGenericField.Name, originalReturnType, null);
instanceDeclaringType.Members.Add(instance);
return instance;
#endif
}
示例2: GetReturnValueClosureField
private Field GetReturnValueClosureField(TypeNode declaringType, TypeNode resultType, FieldFlags flags, int uniqueKey)
{
Contract.Requires(declaringType != null);
Contract.Assume(declaringType.Template == null);
Identifier name = Identifier.For("_result" + uniqueKey.ToString()); // unique name for this field
Field f = declaringType.GetField(name);
if (f != null) return f;
f = new Field(declaringType,
null,
flags,
name,
resultType,
null);
declaringType.Members.Add(f);
// remember we added it so we can make it part of initializations
if (f.IsStatic)
{
topLevelStaticResultField = f;
}
else
{
topLevelClosureResultField = f;
}
return f;
}