本文整理汇总了C#中Dot42.CompilerLib.XModel.XTypeReference.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# XTypeReference.Resolve方法的具体用法?C# XTypeReference.Resolve怎么用?C# XTypeReference.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dot42.CompilerLib.XModel.XTypeReference
的用法示例。
在下文中一共展示了XTypeReference.Resolve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertUnboxStruct
private static void ConvertUnboxStruct(AstExpression node, XTypeReference resultType, XTypeSystem typeSystem)
{
// Structs must never be null. We have to handle structs here, since a newobj
// might need generic arguments. These would be difficult to provide at "UnboxFromGeneric",
// but will be automatically filled in by the GenericInstanceConverter
// convert to (temp$ = (T)x) != null ? temp$ : default(T)
// replace any unbox, but keep if otherwise.
var clone = node.Code == AstCode.Unbox ? new AstExpression(node.Arguments[0]) : new AstExpression(node);
// make sure we don't evaluate the expression twice.
var tempVar = new AstGeneratedVariable("temp$", "") { Type = typeSystem.Object };
// T(x)
var txExpr = new AstExpression(node.SourceLocation, AstCode.SimpleCastclass, resultType, clone)
.SetType(resultType);
// temporary storage
var storeTempVar = new AstExpression(node.SourceLocation, AstCode.Stloc, tempVar, txExpr) { ExpectedType = resultType };
var loadTempVar = new AstExpression(node.SourceLocation, AstCode.Ldloc, tempVar)
.SetType(resultType);
// default (T)
var defaultT = new AstExpression(node.SourceLocation, AstCode.DefaultValue, resultType).SetType(resultType);
var constructor = StructCallConverter.GetDefaultValueCtor(resultType.Resolve());
StructCallConverter.ConvertDefaultValue(defaultT, constructor);
// Combine
var conditional = new AstExpression(node.SourceLocation, AstCode.Conditional, resultType,
storeTempVar, loadTempVar, defaultT)
.SetType(resultType);
node.CopyFrom(conditional);
}