本文整理汇总了C#中ConstantValue类的典型用法代码示例。如果您正苦于以下问题:C# ConstantValue类的具体用法?C# ConstantValue怎么用?C# ConstantValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstantValue类属于命名空间,在下文中一共展示了ConstantValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SourceStrictComplexParameterSymbol
internal SourceStrictComplexParameterSymbol(
DiagnosticBag diagnostics,
Binder binder,
Symbol owner,
int ordinal,
TypeSymbol parameterType,
RefKind refKind,
string name,
ImmutableArray<Location> locations,
SyntaxReference syntaxRef,
ConstantValue defaultSyntaxValue,
bool isParams,
bool isExtensionMethodThis)
: base(
owner: owner,
ordinal: ordinal,
parameterType: parameterType,
refKind: refKind,
name: name,
locations: locations,
syntaxRef: syntaxRef,
defaultSyntaxValue: defaultSyntaxValue,
isParams: isParams,
isExtensionMethodThis: isExtensionMethodThis)
{
_tempBinder = binder;
var unused = GetAttributesBag(diagnostics);
_lazyDefaultSyntaxValue = MakeDefaultExpression(diagnostics, binder);
_tempBinder = null; // no need to keep it around anymore, just uses up a lot of memory
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:SourceStrictComplexParameterSymbol.cs
示例2: MakeLiteral
private BoundExpression MakeLiteral(CSharpSyntaxNode syntax, ConstantValue constantValue, TypeSymbol type, BoundLiteral oldNodeOpt = null)
{
Debug.Assert(constantValue != null);
if (constantValue.IsDecimal)
{
// Rewrite decimal literal
Debug.Assert((object)type != null);
Debug.Assert(type.SpecialType == SpecialType.System_Decimal);
return MakeDecimalLiteral(syntax, constantValue);
}
else if (constantValue.IsDateTime)
{
// C# does not support DateTime constants but VB does; we might have obtained a
// DateTime constant by calling a method with an optional parameter with a DateTime
// for its default value.
Debug.Assert((object)type != null);
Debug.Assert(type.SpecialType == SpecialType.System_DateTime);
return MakeDateTimeLiteral(syntax, constantValue);
}
else if (oldNodeOpt != null)
{
return oldNodeOpt.Update(constantValue, type);
}
else
{
return new BoundLiteral(syntax, constantValue, type, hasErrors: constantValue.IsBad);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:LocalRewriter_Literal.cs
示例3: MultiplicationMemoryOp
public MultiplicationMemoryOp(int offset, int scalar, ConstantValue constant, ConstantValue multiplicationConstant)
{
Offset = offset;
Scalar = scalar;
Constant = constant;
MultiplicationConstant = multiplicationConstant;
}
开发者ID:dreasgrech,项目名称:yabfcompiler,代码行数:7,代码来源:MultiplicationMemoryOp.cs
示例4: PrepareCriteria
public CriteriaOperator PrepareCriteria(CriteriaOperator op)
{
if (op is FunctionOperator)
{
var funcOp = new FunctionOperator();
for (int i = 0; i < (op as FunctionOperator).Operands.Count; i++)
funcOp.Operands.Add(PrepareCriteria((op as FunctionOperator).Operands[i]));
return funcOp;
}
else if (op is ConstantValue)
{
var cnst = new ConstantValue((op as ConstantValue).Value);
if (String.Concat((op as ConstantValue).Value).ToLower().IndexOf("@this") > -1)
{
IMemberInfo info;
cnst.Value = ObjectFormatValues.GetValueRecursive((op as ConstantValue).Value.ToString().Replace("@This.", "").Replace("@This", "").Replace("@this.", "").Replace("@this", ""), CurrentObject, out info);
}
return cnst;
}
else if (op is BinaryOperator)
{
var binary = new BinaryOperator();
binary.LeftOperand = PrepareCriteria((op as BinaryOperator).LeftOperand);
binary.RightOperand = PrepareCriteria((op as BinaryOperator).RightOperand);
return binary;
}
else
{
return op;
}
}
开发者ID:Terricks,项目名称:XAFBootstrap,代码行数:31,代码来源:XafBootstrapTagPropertyEditor.cs
示例5: RewriteConditionalOperator
private static BoundExpression RewriteConditionalOperator(
CSharpSyntaxNode syntax,
BoundExpression rewrittenCondition,
BoundExpression rewrittenConsequence,
BoundExpression rewrittenAlternative,
ConstantValue constantValueOpt,
TypeSymbol rewrittenType)
{
// NOTE: This optimization assumes that a constant has no side effects. In the future we
// might wish to represent nodes that are known to the optimizer as having constant
// values as a sequence of side effects and a constant value; in that case the result
// of this should be a sequence containing the side effect and the consequence or alternative.
ConstantValue conditionConstantValue = rewrittenCondition.ConstantValue;
if (conditionConstantValue == ConstantValue.True)
{
return rewrittenConsequence;
}
else if (conditionConstantValue == ConstantValue.False)
{
return rewrittenAlternative;
}
else
{
return new BoundConditionalOperator(
syntax,
rewrittenCondition,
rewrittenConsequence,
rewrittenAlternative,
constantValueOpt,
rewrittenType);
}
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:33,代码来源:LocalRewriter_ConditionalOperator.cs
示例6: MakeFieldAccess
private BoundExpression MakeFieldAccess(
CSharpSyntaxNode syntax,
BoundExpression rewrittenReceiver,
FieldSymbol fieldSymbol,
ConstantValue constantValueOpt,
LookupResultKind resultKind,
TypeSymbol type,
BoundFieldAccess oldNodeOpt = null)
{
if (fieldSymbol.IsTupleField)
{
return MakeTupleFieldAccess(syntax, fieldSymbol, rewrittenReceiver, constantValueOpt, resultKind);
}
BoundExpression result = oldNodeOpt != null ?
oldNodeOpt.Update(rewrittenReceiver, fieldSymbol, constantValueOpt, resultKind, type) :
new BoundFieldAccess(syntax, rewrittenReceiver, fieldSymbol, constantValueOpt, resultKind, type);
if (fieldSymbol.IsFixed)
{
// a reference to a fixed buffer is translated into its address
result = new BoundConversion(syntax,
new BoundAddressOfOperator(syntax, result, syntax != null && SyntaxFacts.IsFixedStatementExpression(syntax), type, false),
new Conversion(ConversionKind.PointerToPointer), false, false, default(ConstantValue), type, false);
}
return result;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:29,代码来源:LocalRewriter_Field.cs
示例7: SourceLabelSymbol
public SourceLabelSymbol(
MethodSymbol containingMethod,
ConstantValue switchCaseLabelConstant)
{
_containingMethod = containingMethod;
_identifierNodeOrToken = default(SyntaxToken);
_switchCaseLabelConstant = switchCaseLabelConstant;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:SourceLabelSymbol.cs
示例8: Update
public BoundFieldAccess Update(
BoundExpression receiver,
FieldSymbol fieldSymbol,
ConstantValue constantValueOpt,
LookupResultKind resultKind,
TypeSymbol typeSymbol)
{
return this.Update(receiver, fieldSymbol, constantValueOpt, resultKind, this.IsByValue, typeSymbol);
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:Constructors.cs
示例9: BoundFieldAccess
public BoundFieldAccess(
CSharpSyntaxNode syntax,
BoundExpression receiver,
FieldSymbol fieldSymbol,
ConstantValue constantValueOpt,
bool hasErrors = false)
: this(syntax, receiver, fieldSymbol, constantValueOpt, LookupResultKind.Viable, fieldSymbol.Type, hasErrors)
{
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:Constructors.cs
示例10: SourceLabelSymbol
public SourceLabelSymbol(
MethodSymbol containingMethod,
ConstantValue switchCaseLabelConstant = null)
: base(switchCaseLabelConstant.ToString())
{
this.containingMethod = containingMethod;
this.identifierNodeOrToken = default(SyntaxToken);
this.switchCaseLabelConstant = switchCaseLabelConstant;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:SourceLabelSymbol.cs
示例11: SynthesizedFieldSymbol
public SynthesizedFieldSymbol(
NamedTypeSymbol containing,
TypeSymbol type,
string name,
Accessibility accessibility,
ConstantValue constant)
:this(containing, type, name, accessibility, true)
{
_const = constant;
}
开发者ID:iolevel,项目名称:peachpie,代码行数:10,代码来源:SynthesizedFieldSymbol.cs
示例12: EELocalConstantSymbol
public EELocalConstantSymbol(
MethodSymbol method,
string name,
TypeSymbol type,
ConstantValue value)
{
_method = method;
_name = name;
_type = type;
_value = value;
}
开发者ID:daking2014,项目名称:roslyn,代码行数:11,代码来源:EELocalConstantSymbol.cs
示例13: Create
public static ITypeRef Create(ConstantValue c)
{
Contract.ThrowIfNull(c);
switch (c.SpecialType)
{
case SpecialType.System_Int32:
case SpecialType.System_Int64: return LongTypeRef;
case SpecialType.System_String: return StringTypeRef;
case SpecialType.System_Double: return DoubleTypeRef;
case SpecialType.System_Boolean: return BoolTypeRef;
default:
throw new NotImplementedException();
}
}
开发者ID:iolevel,项目名称:peachpie,代码行数:15,代码来源:TypeRefFactory.cs
示例14: MakeTupleFieldAccess
/// <summary>
/// Converts access to a tuple instance into access into the underlying ValueTuple(s).
///
/// For instance, tuple.Item8
/// produces fieldAccess(field=Item1, receiver=fieldAccess(field=Rest, receiver=ValueTuple for tuple))
/// </summary>
private BoundExpression MakeTupleFieldAccess(
CSharpSyntaxNode syntax,
FieldSymbol tupleField,
BoundExpression rewrittenReceiver,
ConstantValue constantValueOpt,
LookupResultKind resultKind,
TypeSymbol type)
{
var tupleType = tupleField.ContainingType;
NamedTypeSymbol currentLinkType = tupleType.TupleUnderlyingType;
FieldSymbol underlyingField = tupleField.TupleUnderlyingField;
if ((object)underlyingField == null)
{
// Use-site error must have been reported elsewhere.
return new BoundFieldAccess(syntax, rewrittenReceiver, tupleField, constantValueOpt, resultKind, type, hasErrors: true);
}
if (underlyingField.ContainingType != currentLinkType)
{
WellKnownMember wellKnownTupleRest = TupleTypeSymbol.GetTupleTypeMember(TupleTypeSymbol.RestPosition, TupleTypeSymbol.RestPosition);
var tupleRestField = (FieldSymbol)TupleTypeSymbol.GetWellKnownMemberInType(currentLinkType.OriginalDefinition, wellKnownTupleRest, _diagnostics, syntax);
if ((object)tupleRestField == null)
{
// error tolerance for cases when Rest is missing
return new BoundFieldAccess(syntax, rewrittenReceiver, tupleField, constantValueOpt, resultKind, type, hasErrors: true);
}
// make nested field accesses to Rest
do
{
FieldSymbol nestedFieldSymbol = tupleRestField.AsMember(currentLinkType);
currentLinkType = currentLinkType.TypeArgumentsNoUseSiteDiagnostics[TupleTypeSymbol.RestPosition - 1].TupleUnderlyingType;
rewrittenReceiver = new BoundFieldAccess(syntax, rewrittenReceiver, nestedFieldSymbol, ConstantValue.NotAvailable, LookupResultKind.Viable, currentLinkType);
}
while (underlyingField.ContainingType != currentLinkType);
}
// make a field access for the most local access
return new BoundFieldAccess(syntax, rewrittenReceiver, underlyingField, constantValueOpt, resultKind, type);
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:50,代码来源:LocalRewriter_Field.cs
示例15: SourcePrimaryConstructorParameterSymbolWithBackingField
internal SourcePrimaryConstructorParameterSymbolWithBackingField(
Symbol owner,
int ordinal,
TypeSymbol parameterType,
RefKind refKind,
string name,
ImmutableArray<Location> locations,
ParameterSyntax syntax,
ConstantValue defaultSyntaxValue,
bool isParams,
bool isExtensionMethodThis,
DiagnosticBag diagnostics
) : base(owner, ordinal, parameterType, refKind, ImmutableArray<CustomModifier>.Empty, false, name, locations, syntax.GetReference(), defaultSyntaxValue, isParams, isExtensionMethodThis)
{
bool modifierErrors;
var modifiers = SourceMemberFieldSymbol.MakeModifiers(owner.ContainingType, syntax.Identifier, syntax.Modifiers, diagnostics, out modifierErrors, ignoreParameterModifiers: true);
backingField = new BackingField(this, modifiers, modifierErrors, diagnostics);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:19,代码来源:SourcePrimaryConstructorParameterSymbolWithBackingField.cs
示例16: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var methodDeclaration = _highlighting.MethodDeclaration;
methodDeclaration.SetStatic(true);
var factory = CSharpElementFactory.GetInstance(methodDeclaration.GetPsiModule());
var type = TypeFactory.CreateTypeByCLRName(DllImportMissingAnalyzer.DllImportAttribute, methodDeclaration.GetPsiModule());
var constantValue = new ConstantValue("name.dll", methodDeclaration.GetPsiModule());
var attributeValue = new AttributeValue(constantValue);
var attribute = factory.CreateAttribute(type.GetTypeElement(), new[] { attributeValue }, new Pair<string, AttributeValue>[0]);
var addedAttribute = methodDeclaration.AddAttributeAfter(attribute, null);
var firstParameter = addedAttribute.ConstructorArgumentExpressions.FirstOrDefault();
if (firstParameter == null)
{
return null;
}
var documentRange = firstParameter.GetDocumentRange();
documentRange = documentRange.TrimLeft(1).TrimRight(1);
var rangeMarker = documentRange.CreateRangeMarker(DocumentManager.GetInstance(solution));
return control => control.Selection.SetRange(rangeMarker.Range);
}
开发者ID:vcsjones,项目名称:ResharperInteropHelpers,代码行数:20,代码来源:DllImportMissingAddDllImportQuickFix.cs
示例17: GetBucketSize
private static ulong GetBucketSize(ConstantValue startConstant, ConstantValue endConstant)
{
Debug.Assert(!BucketOverflowUInt64Limit(startConstant, endConstant));
Debug.Assert(endConstant.Discriminator == startConstant.Discriminator);
ulong bucketSize;
if (startConstant.IsNegativeNumeric || endConstant.IsNegativeNumeric)
{
Debug.Assert(endConstant.Int64Value >= startConstant.Int64Value);
bucketSize = unchecked((ulong)(endConstant.Int64Value - startConstant.Int64Value + 1));
}
else
{
Debug.Assert(endConstant.UInt64Value >= startConstant.UInt64Value);
bucketSize = endConstant.UInt64Value - startConstant.UInt64Value + 1;
}
return bucketSize;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:SwitchIntegralJumpTableEmitter.SwitchBucket.cs
示例18: AddRequirement
/// <summary>
/// Add a registry requirement to an existing deployment type
/// </summary>
public static void AddRequirement(string applicationName, string authoringScopeId, string logicalName, string settingLogicalName, string value, string dataType, string expressionOperator, string server)
{
Application app = CMApplication.GetApplicationByName(applicationName, server);
DeploymentType deploymentType = app.DeploymentTypes[0];
CustomCollection<ExpressionBase> settingsOperands = new CustomCollection<ExpressionBase>();
GlobalSettingReference settingReferences = null;
ConstantValue constant = null;
switch (dataType)
{
case "Version":
settingReferences = new GlobalSettingReference(authoringScopeId, logicalName, DataType.Version, settingLogicalName, ConfigurationItemSettingSourceType.Registry);
constant = new ConstantValue(value, DataType.Version);
break;
default:
break;
}
settingsOperands.Add(settingReferences);
settingsOperands.Add(constant);
Expression expression = null;
switch (expressionOperator)
{
case "IsEquals":
expression = new Expression(ExpressionOperator.IsEquals, settingsOperands);
break;
case "LessEquals":
expression = new Expression(ExpressionOperator.LessEquals, settingsOperands);
break;
default:
break;
}
Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.Critical, null, expression);
deploymentType.Requirements.Add(rule);
CMApplication.Save(app, server);
}
开发者ID:timbodv,项目名称:xCM,代码行数:44,代码来源:CMDeploymentType.cs
示例19: SourceComplexParameterSymbol
internal SourceComplexParameterSymbol(
Symbol owner,
int ordinal,
TypeSymbol parameterType,
RefKind refKind,
ImmutableArray<CustomModifier> customModifiers,
bool hasByRefBeforeCustomModifiers,
string name,
ImmutableArray<Location> locations,
SyntaxReference syntaxRef,
ConstantValue defaultSyntaxValue,
bool isParams,
bool isExtensionMethodThis)
: base(owner, parameterType, ordinal, refKind, name, locations)
{
Debug.Assert((syntaxRef == null) || (syntaxRef.GetSyntax().IsKind(SyntaxKind.Parameter)));
Debug.Assert(!customModifiers.IsDefault);
_lazyHasOptionalAttribute = ThreeState.Unknown;
_syntaxRef = syntaxRef;
if (isParams)
{
_parameterSyntaxKind |= ParameterSyntaxKind.ParamsParameter;
}
if (isExtensionMethodThis)
{
_parameterSyntaxKind |= ParameterSyntaxKind.ExtensionThisParameter;
}
var parameterSyntax = this.CSharpSyntaxNode;
if (parameterSyntax != null && parameterSyntax.Default != null)
{
_parameterSyntaxKind |= ParameterSyntaxKind.DefaultParameter;
}
_lazyDefaultSyntaxValue = defaultSyntaxValue;
_customModifiers = customModifiers;
_hasByRefBeforeCustomModifiers = hasByRefBeforeCustomModifiers;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:41,代码来源:SourceComplexParameterSymbol.cs
示例20: SynthesizedParameterSymbol
public SynthesizedParameterSymbol(
MethodSymbol container,
TypeSymbol type,
int ordinal,
RefKind refKind,
string name = "",
ImmutableArray<CustomModifier> customModifiers = default(ImmutableArray<CustomModifier>),
ushort countOfCustomModifiersPrecedingByRef = 0,
ConstantValue explicitDefaultConstantValue = null)
{
Debug.Assert((object)type != null);
Debug.Assert(name != null);
Debug.Assert(ordinal >= 0);
_container = container;
_type = type;
_ordinal = ordinal;
_refKind = refKind;
_name = name;
_customModifiers = customModifiers.NullToEmpty();
_countOfCustomModifiersPrecedingByRef = countOfCustomModifiersPrecedingByRef;
_explicitDefaultConstantValue = explicitDefaultConstantValue;
}
开发者ID:iolevel,项目名称:peachpie,代码行数:23,代码来源:SynthesizedParameterSymbol.cs
注:本文中的ConstantValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论