本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.BoundConversion.Update方法的典型用法代码示例。如果您正苦于以下问题:C# BoundConversion.Update方法的具体用法?C# BoundConversion.Update怎么用?C# BoundConversion.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.BoundConversion
的用法示例。
在下文中一共展示了BoundConversion.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitConversion
public override BoundNode VisitConversion(BoundConversion node)
{
BoundSpillSequence2 ss = null;
var operand = VisitExpression(ref ss, node.Operand);
return UpdateExpression(
ss,
node.Update(
operand,
node.ConversionKind,
node.ResultKind,
isBaseConversion: node.IsBaseConversion,
symbolOpt: node.SymbolOpt,
@checked: node.Checked,
explicitCastInCode: node.ExplicitCastInCode,
isExtensionMethod: node.IsExtensionMethod,
isArrayIndex: node.IsArrayIndex,
constantValueOpt: node.ConstantValueOpt,
type: node.Type));
}
示例2: RewriteIntPtrConversion
private BoundExpression RewriteIntPtrConversion(
BoundConversion oldNode,
CSharpSyntaxNode syntax,
BoundExpression rewrittenOperand,
ConversionKind conversionKind,
MethodSymbol symbolOpt,
bool @checked,
bool explicitCastInCode,
bool isExtensionMethod,
bool isArrayIndex,
ConstantValue constantValueOpt,
TypeSymbol rewrittenType)
{
Debug.Assert(rewrittenOperand != null);
Debug.Assert((object)rewrittenType != null);
TypeSymbol source = rewrittenOperand.Type;
TypeSymbol target = rewrittenType;
TypeSymbol t0 = target.StrippedType();
TypeSymbol s0 = source.StrippedType();
if (t0 != target && s0 != source)
{
// UNDONE: RewriteLiftedIntPtrConversion
return oldNode != null ?
oldNode.Update(
rewrittenOperand,
conversionKind,
oldNode.ResultKind,
isBaseConversion: oldNode.IsBaseConversion,
symbolOpt: symbolOpt,
@checked: @checked,
explicitCastInCode: explicitCastInCode,
isExtensionMethod: isExtensionMethod,
isArrayIndex: isArrayIndex,
constantValueOpt: constantValueOpt,
type: rewrittenType) :
new BoundConversion(
syntax,
rewrittenOperand,
conversionKind,
LookupResultKind.Viable,
isBaseConversion: false,
symbolOpt: symbolOpt,
@checked: @checked,
explicitCastInCode: explicitCastInCode,
isExtensionMethod: isExtensionMethod,
isArrayIndex: isArrayIndex,
constantValueOpt: constantValueOpt,
type: rewrittenType);
}
SpecialMember member = GetIntPtrConversionMethod(source: rewrittenOperand.Type, target: rewrittenType);
MethodSymbol method = GetSpecialTypeMethod(syntax, member);
Debug.Assert(!method.ReturnsVoid);
Debug.Assert(method.ParameterCount == 1);
rewrittenOperand = MakeConversion(rewrittenOperand, method.ParameterTypes[0], @checked);
var returnType = method.ReturnType;
Debug.Assert((object)returnType != null);
if (inExpressionLambda)
{
return BoundConversion.Synthesized(syntax, rewrittenOperand, new Conversion(conversionKind, method, false), @checked, explicitCastInCode, constantValueOpt, rewrittenType);
}
var rewrittenCall =
inExpressionLambda && oldNode != null
? new BoundConversion(syntax, rewrittenOperand, new Conversion(conversionKind, method, false), @checked, explicitCastInCode, constantValueOpt, returnType)
: MakeCall(
syntax: syntax,
rewrittenReceiver: null,
method: method,
rewrittenArguments: ImmutableArray.Create<BoundExpression>(rewrittenOperand),
type: returnType);
return MakeConversion(rewrittenCall, rewrittenType, @checked);
}
示例3: RewriteDecimalConversion
private BoundExpression RewriteDecimalConversion(BoundConversion oldNode, CSharpSyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType)
{
Debug.Assert(fromType.SpecialType == SpecialType.System_Decimal || toType.SpecialType == SpecialType.System_Decimal);
// call the method
SpecialMember member = DecimalConversionMethod(fromType, toType);
var method = (MethodSymbol)this.compilation.Assembly.GetSpecialTypeMember(member);
Debug.Assert((object)method != null); // Should have been checked during Warnings pass
if (inExpressionLambda && oldNode != null)
{
ConversionKind conversionKind = oldNode.ConversionKind.IsImplicitConversion() ? ConversionKind.ImplicitUserDefined : ConversionKind.ExplicitUserDefined;
return oldNode.Update(
operand,
conversionKind,
oldNode.ResultKind,
isBaseConversion: oldNode.IsBaseConversion,
symbolOpt: method,
@checked: oldNode.Checked,
explicitCastInCode: oldNode.ExplicitCastInCode,
isExtensionMethod: oldNode.IsExtensionMethod,
isArrayIndex: oldNode.IsArrayIndex,
constantValueOpt: oldNode.ConstantValueOpt,
type: toType);
}
else
{
Debug.Assert(method.ReturnType == toType);
return BoundCall.Synthesized(syntax, null, method, operand);
}
}
示例4: MakeConversion
//.........这里部分代码省略.........
syntax,
operand,
ConversionKind.ImplicitNullable,
symbolOpt,
@checked,
explicitCastInCode,
isExtensionMethod,
isArrayIndex,
constantValueOpt,
rewrittenType);
}
goto case ConversionKind.ExplicitEnumeration;
case ConversionKind.ExplicitEnumeration:
if (!rewrittenType.IsNullableType() &&
rewrittenOperand.IsDefaultValue() &&
(!inExpressionLambda || !explicitCastInCode))
{
return new BoundDefaultOperator(syntax, rewrittenType);
}
if (rewrittenType.SpecialType == SpecialType.System_Decimal)
{
Debug.Assert(rewrittenOperand.Type.IsEnumType());
var underlyingTypeFrom = rewrittenOperand.Type.GetEnumUnderlyingType();
rewrittenOperand = MakeConversion(rewrittenOperand, underlyingTypeFrom, false);
return RewriteDecimalConversion(oldNode, syntax, rewrittenOperand, underlyingTypeFrom, rewrittenType);
}
else if (rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal)
{
// This is where we handle conversion from Decimal to Enum: e.g., E e = (E) d;
// where 'e' is of type Enum E and 'd' is of type Decimal.
// Conversion can be simply done by applying its underlying numeric type to RewriteDecimalConversion().
Debug.Assert(rewrittenType.IsEnumType());
var underlyingTypeTo = rewrittenType.GetEnumUnderlyingType();
var rewrittenNode = RewriteDecimalConversion(oldNode, syntax, rewrittenOperand, rewrittenOperand.Type, underlyingTypeTo);
// However, the type of the rewritten node becomes underlying numeric type, not Enum type,
// which violates the overall constraint saying the type cannot be changed during rewriting (see LocalRewriter.cs).
// Instead of loosening this constraint, we return BoundConversion from underlying numeric type to Enum type,
// which will be eliminated during emitting (see EmitEnumConversion): e.g., E e = (E)(int) d;
return new BoundConversion(
syntax,
rewrittenNode,
conversionKind,
LookupResultKind.Viable,
isBaseConversion: false,
symbolOpt: symbolOpt,
@checked: false,
explicitCastInCode: explicitCastInCode,
isExtensionMethod: isExtensionMethod,
isArrayIndex: false,
constantValueOpt: constantValueOpt,
type: rewrittenType);
}
break;
case ConversionKind.ImplicitDynamic:
case ConversionKind.ExplicitDynamic:
Debug.Assert((object)symbolOpt == null);
Debug.Assert(!isExtensionMethod);
Debug.Assert(constantValueOpt == null);
return dynamicFactory.MakeDynamicConversion(rewrittenOperand, explicitCastInCode || conversionKind == ConversionKind.ExplicitDynamic, isArrayIndex, @checked, rewrittenType).ToExpression();
default:
break;
}
return oldNode != null ?
oldNode.Update(
rewrittenOperand,
conversionKind,
oldNode.ResultKind,
isBaseConversion: oldNode.IsBaseConversion,
symbolOpt: symbolOpt,
@checked: @checked,
explicitCastInCode: explicitCastInCode,
isExtensionMethod: isExtensionMethod,
isArrayIndex: isArrayIndex,
constantValueOpt: constantValueOpt,
type: rewrittenType) :
new BoundConversion(
syntax,
rewrittenOperand,
conversionKind,
LookupResultKind.Viable,
isBaseConversion: false,
symbolOpt: symbolOpt,
@checked: @checked,
explicitCastInCode: explicitCastInCode,
isExtensionMethod: isExtensionMethod,
isArrayIndex: isArrayIndex,
constantValueOpt: constantValueOpt,
type: rewrittenType);
}
示例5: VisitConversion
public override BoundNode VisitConversion(BoundConversion node)
{
BoundExpression operand = (BoundExpression)this.Visit(node.Operand);
TypeSymbol type = this.VisitType(node.Type);
if (operand.Kind != BoundKind.SpillSequence)
{
return node.Update(operand, node.ConversionKind, node.SymbolOpt, node.Checked, node.ExplicitCastInCode, node.IsExtensionMethod, node.IsArrayIndex, node.ConstantValueOpt, node.ResultKind, type);
}
var spill = (BoundSpillSequence)operand;
return RewriteSpillSequence(spill,
node.Update(
spill.Value,
node.ConversionKind,
node.SymbolOpt,
node.Checked,
node.ExplicitCastInCode,
node.IsExtensionMethod,
node.IsArrayIndex,
node.ConstantValueOpt,
node.ResultKind,
type));
}