本文整理汇总了C#中SynthesizedLocalKind类的典型用法代码示例。如果您正苦于以下问题:C# SynthesizedLocalKind类的具体用法?C# SynthesizedLocalKind怎么用?C# SynthesizedLocalKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SynthesizedLocalKind类属于命名空间,在下文中一共展示了SynthesizedLocalKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssignLocalOrdinal
public int AssignLocalOrdinal(SynthesizedLocalKind localKind, int syntaxOffset)
{
#if !DEBUG
// Optimization (avoid growing the dictionary below):
// User-defined locals have to have a distinct syntax offset, thus ordinal is always 0.
if (localKind == SynthesizedLocalKind.UserDefined)
{
return 0;
}
#endif
int ordinal;
long key = MakeKey(localKind, syntaxOffset);
// Group by syntax offset and kind.
// Variables associated with the same syntax and kind will be assigned different ordinals.
if (_lazyMap == null)
{
_lazyMap = PooledDictionary<long, int>.GetInstance();
ordinal = 0;
}
else if (!_lazyMap.TryGetValue(key, out ordinal))
{
ordinal = 0;
}
_lazyMap[key] = ordinal + 1;
Debug.Assert(ordinal == 0 || localKind != SynthesizedLocalKind.UserDefined);
return ordinal;
}
示例2: TryGetPreviousHoistedLocalSlotIndex
/// <summary>
/// Returns an index of a slot that stores specified hoisted local variable in the previous generation.
/// </summary>
public abstract bool TryGetPreviousHoistedLocalSlotIndex(
SyntaxNode currentDeclarator,
Cci.ITypeReference currentType,
SynthesizedLocalKind synthesizedKind,
LocalDebugId currentId,
DiagnosticBag diagnostics,
out int slotIndex);
示例3: EncHoistedLocalMetadata
public EncHoistedLocalMetadata(string name, Cci.ITypeReference type, SynthesizedLocalKind synthesizedKind)
{
Debug.Assert(name != null);
Debug.Assert(type != null);
Debug.Assert(synthesizedKind.IsLongLived());
this.Name = name;
this.Type = type;
this.SynthesizedKind = synthesizedKind;
}
示例4: GetPreviousLocal
public abstract LocalDefinition GetPreviousLocal(
Cci.ITypeReference type,
ILocalSymbolInternal symbol,
string nameOpt,
SynthesizedLocalKind kind,
LocalDebugId id,
LocalVariableAttributes pdbAttributes,
LocalSlotConstraints constraints,
bool isDynamic,
ImmutableArray<TypedConstant> dynamicTransformFlags);
示例5: WithSynthesizedLocalKind
internal SynthesizedLocal WithSynthesizedLocalKind(SynthesizedLocalKind kind)
{
return new SynthesizedLocal(
this.containingMethodOpt,
this.type,
kind,
this.syntaxOpt,
this.isPinned,
this.refKind);
}
示例6: WithSynthesizedLocalKindAndSyntax
internal SynthesizedLocal WithSynthesizedLocalKindAndSyntax(SynthesizedLocalKind kind, SyntaxNode syntax)
{
return new SynthesizedLocal(
_containingMethodOpt,
_type,
kind,
syntax,
_isPinned,
_refKind);
}
示例7: SynthesizedLocal
internal SynthesizedLocal(
MethodSymbol containingMethodOpt,
TypeSymbol type,
SynthesizedLocalKind kind,
SyntaxNode syntaxOpt = null,
bool isPinned = false,
RefKind refKind = RefKind.None)
{
_containingMethodOpt = containingMethodOpt;
_type = type;
_kind = kind;
_syntaxOpt = syntaxOpt;
_isPinned = isPinned;
_refKind = refKind;
}
示例8: SynthesizedLocal
internal SynthesizedLocal(
MethodSymbol containingMethodOpt,
TypeSymbol type,
SynthesizedLocalKind kind,
CSharpSyntaxNode syntaxOpt = null,
bool isPinned = false,
RefKind refKind = RefKind.None)
{
this.containingMethodOpt = containingMethodOpt;
this.type = type;
this.kind = kind;
this.syntaxOpt = syntaxOpt;
this.isPinned = isPinned;
this.refKind = refKind;
}
示例9: LocalDefinition
/// <summary>
/// Creates a new LocalDefinition.
/// </summary>
/// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
/// <param name="nameOpt">Name associated with the slot.</param>
/// <param name="type">Type associated with the slot.</param>
/// <param name="slot">Slot position in the signature.</param>
/// <param name="dynamicTransformFlags">Contains the synthesized dynamic attributes of the local</param>
/// <param name="synthesizedKind">Local kind.</param>
/// <param name="id">Local id.</param>
/// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
/// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
/// <param name="isDynamic">Specifies if the type is Dynamic.</param>
public LocalDefinition(
ILocalSymbol symbolOpt,
string nameOpt,
Cci.ITypeReference type,
int slot,
SynthesizedLocalKind synthesizedKind,
LocalDebugId id,
uint pdbAttributes,
LocalSlotConstraints constraints,
bool isDynamic,
ImmutableArray<TypedConstant> dynamicTransformFlags)
{
_symbolOpt = symbolOpt;
_nameOpt = nameOpt;
_type = type;
_slot = slot;
_slotInfo = new LocalSlotDebugInfo(synthesizedKind, id);
_pdbAttributes = pdbAttributes;
_dynamicTransformFlags = dynamicTransformFlags;
_constraints = constraints;
_isDynamic = isDynamic;
}
示例10: LocalDefinition
/// <summary>
/// Creates a new LocalDefinition.
/// </summary>
/// <param name="symbolOpt">Local symbol, used by edit and continue only, null otherwise.</param>
/// <param name="nameOpt">Name associated with the slot.</param>
/// <param name="type">Type associated with the slot.</param>
/// <param name="slot">Slot position in the signature.</param>
/// <param name="synthesizedKind">Local kind.</param>
/// <param name="id">Local id.</param>
/// <param name="pdbAttributes">Value to emit in the attributes field in the PDB.</param>
/// <param name="constraints">Specifies whether slot type should have pinned modifier and whether slot should have byref constraint.</param>
/// <param name="dynamicTransformFlags">The synthesized dynamic attributes of the local.</param>
/// <param name="tupleElementNames">Tuple element names of the local.</param>
public LocalDefinition(
ILocalSymbol symbolOpt,
string nameOpt,
Cci.ITypeReference type,
int slot,
SynthesizedLocalKind synthesizedKind,
LocalDebugId id,
LocalVariableAttributes pdbAttributes,
LocalSlotConstraints constraints,
ImmutableArray<TypedConstant> dynamicTransformFlags,
ImmutableArray<TypedConstant> tupleElementNames)
{
_symbolOpt = symbolOpt;
_nameOpt = nameOpt;
_type = type;
_slot = slot;
_slotInfo = new LocalSlotDebugInfo(synthesizedKind, id);
_pdbAttributes = pdbAttributes;
_dynamicTransformFlags = dynamicTransformFlags.NullToEmpty();
_tupleElementNames = tupleElementNames.NullToEmpty();
_constraints = constraints;
}
示例11: MakeSynthesizedLocalName
internal static string MakeSynthesizedLocalName(SynthesizedLocalKind kind, ref int uniqueId)
{
Debug.Assert(kind.IsLongLived());
// Lambda display class local has to be named. EE depends on the name format.
if (kind == SynthesizedLocalKind.LambdaDisplayClass)
{
return MakeLambdaDisplayLocalName(uniqueId++);
}
return null;
}
示例12: MakeHoistedLocalFieldName
internal static string MakeHoistedLocalFieldName(SynthesizedLocalKind kind, int slotIndex, string localNameOpt = null)
{
Debug.Assert((localNameOpt != null) == (kind == SynthesizedLocalKind.UserDefined));
Debug.Assert(slotIndex >= 0);
Debug.Assert(kind.IsLongLived());
// Lambda display class local follows a different naming pattern.
// EE depends on the name format.
// There's logic in the EE to recognize locals that have been captured by a lambda
// and would have been hoisted for the state machine. Basically, we just hoist the local containing
// the instance of the lambda display class and retain its original name (rather than using an
// iterator local name). See FUNCBRECEE::ImportIteratorMethodInheritedLocals.
var result = PooledStringBuilder.GetInstance();
var builder = result.Builder;
builder.Append('<');
if (localNameOpt != null)
{
Debug.Assert(localNameOpt.IndexOf('.') == -1);
builder.Append(localNameOpt);
}
builder.Append('>');
if (kind == SynthesizedLocalKind.LambdaDisplayClass)
{
builder.Append((char)GeneratedNameKind.DisplayClassLocalOrField);
}
else if (kind == SynthesizedLocalKind.UserDefined)
{
builder.Append((char)GeneratedNameKind.HoistedLocalField);
}
else
{
builder.Append((char)GeneratedNameKind.HoistedSynthesizedLocalField);
}
builder.Append("__");
builder.Append(slotIndex + 1);
return result.ToStringAndFree();
}
示例13: TryGetPreviousHoistedLocalSlotIndex
public override bool TryGetPreviousHoistedLocalSlotIndex(SyntaxNode currentDeclarator, Cci.ITypeReference currentType, SynthesizedLocalKind synthesizedKind, LocalDebugId currentId, out int slotIndex)
{
Debug.Assert(_hoistedLocalSlotsOpt != null);
LocalDebugId previousId;
if (!TryGetPreviousLocalId(currentDeclarator, currentId, out previousId))
{
slotIndex = -1;
return false;
}
var previousType = _symbolMap.MapReference(currentType);
if (previousType == null)
{
slotIndex = -1;
return false;
}
// TODO (bug #781309): Should report a warning if the type of the local has changed
// and the previous value will be dropped.
var localKey = new EncHoistedLocalInfo(new LocalSlotDebugInfo(synthesizedKind, previousId), previousType);
return _hoistedLocalSlotsOpt.TryGetValue(localKey, out slotIndex);
}
示例14: GetPreviousLocal
public override LocalDefinition GetPreviousLocal(
Cci.ITypeReference currentType,
ILocalSymbolInternal currentLocalSymbol,
string nameOpt,
SynthesizedLocalKind kind,
LocalDebugId id,
uint pdbAttributes,
LocalSlotConstraints constraints,
bool isDynamic,
ImmutableArray<TypedConstant> dynamicTransformFlags)
{
if (id.IsNone)
{
return null;
}
LocalDebugId previousId;
if (!TryGetPreviousLocalId(currentLocalSymbol.GetDeclaratorSyntax(), id, out previousId))
{
return null;
}
var previousType = _symbolMap.MapReference(currentType);
if (previousType == null)
{
return null;
}
// TODO (bug #781309): Should report a warning if the type of the local has changed
// and the previous value will be dropped.
var localKey = new EncLocalInfo(new LocalSlotDebugInfo(kind, previousId), previousType, constraints, signature: null);
int slot;
if (!_previousLocalSlots.TryGetValue(localKey, out slot))
{
return null;
}
return new LocalDefinition(
currentLocalSymbol,
nameOpt,
currentType,
slot,
kind,
id,
pdbAttributes,
constraints,
isDynamic,
dynamicTransformFlags);
}
示例15: StateMachineFieldSymbol
public StateMachineFieldSymbol(NamedTypeSymbol stateMachineType, TypeSymbol type, string name, SynthesizedLocalKind synthesizedKind, int slotIndex, bool isPublic)
: this(stateMachineType, type, name, new LocalSlotDebugInfo(synthesizedKind, LocalDebugId.None), slotIndex, isPublic: isPublic)
{
}