本文整理汇总了C#中System.Compiler.TypeNode.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.Clone方法的具体用法?C# TypeNode.Clone怎么用?C# TypeNode.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.TypeNode
的用法示例。
在下文中一共展示了TypeNode.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeReference
public override TypeNode VisitTypeReference(TypeNode type)
{
if (type == null) return null;
TypeNode dup = (TypeNode)this.DuplicateFor[type.UniqueKey];
if (dup != null && (dup.Template != type || this.RecordOriginalAsTemplate)) return dup;
switch (type.NodeType)
{
case NodeType.ArrayType:
ArrayType arrType = (ArrayType)type;
TypeNode elemType = this.VisitTypeReference(arrType.ElementType);
if (elemType == arrType.ElementType) return arrType;
if (elemType == null) { Debug.Fail(""); return null; }
this.TypesToBeDuplicated[arrType.UniqueKey] = arrType;
dup = elemType.GetArrayType(arrType.Rank, arrType.Sizes, arrType.LowerBounds);
break;
case NodeType.ClassParameter:
case NodeType.TypeParameter:
if (this.RecordOriginalAsTemplate) return type;
if (this.TypesToBeDuplicated[type.UniqueKey] == null) return type;
dup = this.VisitTypeNode(type);
break;
case NodeType.DelegateNode:
{
FunctionType ftype = type as FunctionType;
if (ftype == null) goto default;
dup = FunctionType.For(this.VisitTypeReference(ftype.ReturnType), this.VisitParameterList(ftype.Parameters), this.TargetType);
break;
}
case NodeType.Pointer:
Pointer pType = (Pointer)type;
elemType = this.VisitTypeReference(pType.ElementType);
if (elemType == pType.ElementType) return pType;
if (elemType == null) { Debug.Fail(""); return null; }
dup = elemType.GetPointerType();
break;
case NodeType.Reference:
Reference rType = (Reference)type;
elemType = this.VisitTypeReference(rType.ElementType);
if (elemType == rType.ElementType) return rType;
if (elemType == null) { Debug.Fail(""); return null; }
dup = elemType.GetReferenceType();
break;
//These types typically have only one reference and do not have pointer identity. Just duplicate them.
case NodeType.ArrayTypeExpression:
ArrayTypeExpression aExpr = (ArrayTypeExpression)type.Clone();
elemType = this.VisitTypeReference(aExpr.ElementType);
if (elemType == null) { Debug.Fail(""); return aExpr; }
aExpr.ElementType = elemType;
return aExpr;
case NodeType.BoxedTypeExpression:
BoxedTypeExpression bExpr = (BoxedTypeExpression)type.Clone();
bExpr.ElementType = this.VisitTypeReference(bExpr.ElementType);
return bExpr;
case NodeType.ClassExpression:
ClassExpression cExpr = (ClassExpression)type.Clone();
cExpr.Expression = this.VisitExpression(cExpr.Expression);
cExpr.TemplateArguments = this.VisitTypeReferenceList(cExpr.TemplateArguments);
return cExpr;
case NodeType.FlexArrayTypeExpression:
FlexArrayTypeExpression flExpr = (FlexArrayTypeExpression)type.Clone();
flExpr.ElementType = this.VisitTypeReference(flExpr.ElementType);
return flExpr;
case NodeType.FunctionPointer:
FunctionPointer funcPointer = (FunctionPointer)type.Clone();
funcPointer.ParameterTypes = this.VisitTypeReferenceList(funcPointer.ParameterTypes);
funcPointer.ReturnType = this.VisitTypeReference(funcPointer.ReturnType);
return funcPointer;
case NodeType.FunctionTypeExpression:
FunctionTypeExpression ftExpr = (FunctionTypeExpression)type.Clone();
ftExpr.Parameters = this.VisitParameterList(ftExpr.Parameters);
ftExpr.ReturnType = this.VisitTypeReference(ftExpr.ReturnType);
return ftExpr;
case NodeType.InvariantTypeExpression:
InvariantTypeExpression invExpr = (InvariantTypeExpression)type.Clone();
invExpr.ElementType = this.VisitTypeReference(invExpr.ElementType);
return invExpr;
case NodeType.InterfaceExpression:
InterfaceExpression iExpr = (InterfaceExpression)type.Clone();
iExpr.Expression = this.VisitExpression(iExpr.Expression);
iExpr.TemplateArguments = this.VisitTypeReferenceList(iExpr.TemplateArguments);
return iExpr;
case NodeType.NonEmptyStreamTypeExpression:
NonEmptyStreamTypeExpression neExpr = (NonEmptyStreamTypeExpression)type.Clone();
neExpr.ElementType = this.VisitTypeReference(neExpr.ElementType);
return neExpr;
case NodeType.NonNullTypeExpression:
NonNullTypeExpression nnExpr = (NonNullTypeExpression)type.Clone();
nnExpr.ElementType = this.VisitTypeReference(nnExpr.ElementType);
return nnExpr;
case NodeType.NonNullableTypeExpression:
NonNullableTypeExpression nbExpr = (NonNullableTypeExpression)type.Clone();
nbExpr.ElementType = this.VisitTypeReference(nbExpr.ElementType);
//.........这里部分代码省略.........
示例2: VisitTypeNode
internal TypeNode VisitTypeNode(TypeNode type, Identifier mangledName, TypeNodeList templateArguments, TypeNode template, bool delayVisitToNestedTypes)
{
if (type == null) return null;
TypeNode dup = (TypeNode)this.DuplicateFor[type.UniqueKey];
if (dup != null) return dup;
this.DuplicateFor[type.UniqueKey] = dup = (TypeNode)type.Clone();
if (mangledName != null)
{
this.TargetModule.StructurallyEquivalentType[mangledName.UniqueIdKey] = dup;
dup.TemplateArguments = templateArguments;
}
dup.arrayTypes = null;
dup.constructors = null;
dup.consolidatedTemplateArguments = null;
dup.consolidatedTemplateParameters = null;
#if DEBUG
dup.DebugLabel = null;
#endif
dup.DocumentationId = null;
if (this.CopyDocumentation) dup.Documentation = type.Documentation;
dup.defaultMembers = null;
dup.explicitCoercionFromTable = null;
dup.explicitCoercionMethods = null;
dup.implicitCoercionFromTable = null;
dup.implicitCoercionMethods = null;
dup.implicitCoercionToTable = null;
dup.memberCount = 0;
dup.memberTable = null;
dup.modifierTable = null;
dup.NestedTypes = null;
dup.pointerType = null;
dup.ProviderHandle = null;
dup.ProvideTypeAttributes = null;
dup.ProvideTypeMembers = null;
dup.ProvideNestedTypes = null;
dup.referenceType = null;
dup.runtimeType = null;
dup.structurallyEquivalentMethod = null;
TypeParameter tp = dup as TypeParameter;
if (tp != null) tp.structuralElementTypes = null;
ClassParameter cp = dup as ClassParameter;
if (cp != null) cp.structuralElementTypes = null;
dup.szArrayTypes = null;
if (this.RecordOriginalAsTemplate) dup.Template = type;
dup.TemplateArguments = null;
dup.TemplateInstances = null;
dup.DeclaringModule = this.TargetModule;
dup.DeclaringType = this.TargetType;
TypeNode savedTargetType = this.TargetType;
this.TargetType = dup;
dup.Attributes = this.VisitAttributeList(type.Attributes);
dup.SecurityAttributes = this.VisitSecurityAttributeList(type.SecurityAttributes);
Class c = dup as Class;
if (c != null) c.BaseClass = (Class)this.VisitTypeReference(c.BaseClass);
dup.Interfaces = this.VisitInterfaceReferenceList(dup.Interfaces);
dup.TemplateParameters = this.VisitTypeReferenceList(type.TemplateParameters);
dup.consolidatedTemplateParameters = null;
if (dup is MethodScope)
dup.members = this.VisitMemberList(type.members);
else
if (!this.RecordOriginalAsTemplate)
{
if (!delayVisitToNestedTypes)
dup.nestedTypes = this.VisitNestedTypes(dup, type.NestedTypes);
dup.members = null;
dup.ProvideTypeMembers = new TypeNode.TypeMemberProvider(this.ProvideTypeMembers);
dup.ProviderHandle = type;
}
else
{
dup.members = null;
dup.ProvideNestedTypes = new TypeNode.NestedTypeProvider(this.ProvideNestedTypes);
dup.ProvideTypeMembers = new TypeNode.TypeMemberProvider(this.ProvideTypeMembers);
dup.ProviderHandle = type;
}
DelegateNode delegateNode = dup as DelegateNode;
if (delegateNode != null)
{
if (!delegateNode.IsNormalized || !this.RecordOriginalAsTemplate)
{
if (!delegateNode.IsNormalized)
((DelegateNode)type).ProvideMembers();
delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
}
else
{
delegateNode.Parameters = null;
delegateNode.ReturnType = null;
}
}
//.........这里部分代码省略.........