本文整理汇总了C#中ILCompiler.DependencyAnalysis.ObjectDataBuilder.EmitShort方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectDataBuilder.EmitShort方法的具体用法?C# ObjectDataBuilder.EmitShort怎么用?C# ObjectDataBuilder.EmitShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.DependencyAnalysis.ObjectDataBuilder
的用法示例。
在下文中一共展示了ObjectDataBuilder.EmitShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeData
public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly)
{
dataBuilder.EmitZeroPointer(); // Sync block
DefType systemStringType = factory.TypeSystemContext.GetWellKnownType(WellKnownType.String);
//
// The GC requires a direct reference to frozen objects' EETypes. If System.String will be compiled into a separate
// binary, it must be cloned into this one.
//
if (factory.CompilationModuleGroup.ShouldReferenceThroughImportTable(systemStringType))
{
dataBuilder.EmitPointerReloc(factory.ConstructedClonedTypeSymbol(systemStringType));
}
else
{
dataBuilder.EmitPointerReloc(factory.ConstructedTypeSymbol(systemStringType));
}
dataBuilder.EmitInt(_data.Length);
foreach (char c in _data)
{
dataBuilder.EmitShort((short)c);
}
// Null-terminate for friendliness with interop
dataBuilder.EmitShort(0);
}
示例2: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder dataBuilder = new ObjectDataBuilder(factory);
dataBuilder.Alignment = 16;
dataBuilder.DefinedSymbols.Add(this);
short flags = (short)EETypeKind.GenericTypeDefEEType;
if (_type.IsValueType)
flags |= (short)EETypeFlags.ValueTypeFlag;
if (_type.IsInterface)
flags |= (short)EETypeFlags.IsInterfaceFlag;
dataBuilder.EmitShort((short)_type.Instantiation.Length);
dataBuilder.EmitShort(flags);
dataBuilder.EmitInt(0); // Base size is always 0
dataBuilder.EmitZeroPointer(); // No related type
dataBuilder.EmitShort(0); // No VTable
dataBuilder.EmitShort(0); // No interface map
dataBuilder.EmitInt(_type.GetHashCode());
dataBuilder.EmitPointerReloc(factory.ModuleManagerIndirection);
return dataBuilder.ToObjectData();
}
示例3: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder dataBuilder = new ObjectDataBuilder(factory);
dataBuilder.Alignment = dataBuilder.TargetPointerSize;
dataBuilder.DefinedSymbols.Add(this);
EETypeRareFlags rareFlags = 0;
short flags = (short)EETypeKind.GenericTypeDefEEType;
if (_type.IsValueType)
flags |= (short)EETypeFlags.ValueTypeFlag;
if (_type.IsInterface)
flags |= (short)EETypeFlags.IsInterfaceFlag;
if (factory.TypeSystemContext.HasLazyStaticConstructor(_type))
rareFlags = rareFlags | EETypeRareFlags.HasCctorFlag;
if (rareFlags != 0)
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.RareFlags, (uint)rareFlags);
if (_optionalFieldsBuilder.IsAtLeastOneFieldUsed())
flags |= (short)EETypeFlags.OptionalFieldsFlag;
dataBuilder.EmitShort((short)_type.Instantiation.Length);
dataBuilder.EmitShort(flags);
dataBuilder.EmitInt(0); // Base size is always 0
dataBuilder.EmitZeroPointer(); // No related type
dataBuilder.EmitShort(0); // No VTable
dataBuilder.EmitShort(0); // No interface map
dataBuilder.EmitInt(_type.GetHashCode());
dataBuilder.EmitPointerReloc(factory.ModuleManagerIndirection);
if (_optionalFieldsBuilder.IsAtLeastOneFieldUsed())
{
dataBuilder.EmitPointerReloc(factory.EETypeOptionalFields(_optionalFieldsBuilder));
}
return dataBuilder.ToObjectData();
}
示例4: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
{
ObjectDataBuilder dataBuilder = new ObjectDataBuilder(factory);
dataBuilder.Alignment = 16;
dataBuilder.DefinedSymbols.Add(this);
// +2 for SyncBlock and EETypePtr field
int totalSize = (_gcMap.Size + 2) * _target.PointerSize;
// We only need to check for containsPointers because ThreadStatics are always allocated
// on the GC heap (no matter what "HasGCStaticBase" says).
// If that ever changes, we can assume "true" and switch this to an assert.
bool containsPointers = _gcMap.NumSeries > 0;
if (containsPointers)
{
GCDescEncoder.EncodeStandardGCDesc(ref dataBuilder, _gcMap, totalSize, 0);
}
Debug.Assert(dataBuilder.CountBytes == Offset);
dataBuilder.EmitShort(0); // ComponentSize is always 0
short flags = 0;
if (containsPointers)
flags |= (short)EETypeFlags.HasPointersFlag;
dataBuilder.EmitShort(flags);
totalSize = Math.Max(totalSize, _target.PointerSize * 3); // minimum GC eetype size is 3 pointers
dataBuilder.EmitInt(totalSize);
// Related type: System.Object. This allows storing an instance of this type in an array of objects.
dataBuilder.EmitPointerReloc(factory.NecessaryTypeSymbol(factory.TypeSystemContext.GetWellKnownType(WellKnownType.Object)));
return dataBuilder.ToObjectData();
}
示例5: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
{
ObjectDataBuilder dataBuilder = new ObjectDataBuilder(factory);
dataBuilder.Alignment = 16;
dataBuilder.DefinedSymbols.Add(this);
// +2 for SyncBlock and EETypePtr field
int totalSize = (_gcMap.Size + 2) * _target.PointerSize;
// We only need to check for containsPointers because ThreadStatics are always allocated
// on the GC heap (no matter what "HasGCStaticBase" says).
// If that ever changes, we can assume "true" and switch this to an assert.
bool containsPointers = _gcMap.NumSeries > 0;
if (containsPointers)
{
GCDescEncoder.EncodeStandardGCDesc(ref dataBuilder, _gcMap, totalSize, 0);
}
Debug.Assert(dataBuilder.CountBytes == ((ISymbolNode)this).Offset);
dataBuilder.EmitShort(0); // ComponentSize is always 0
short flags = 0;
if (containsPointers)
flags |= (short)EETypeFlags.HasPointersFlag;
dataBuilder.EmitShort(flags);
totalSize = Math.Max(totalSize, _target.PointerSize * 3); // minimum GC eetype size is 3 pointers
dataBuilder.EmitInt(totalSize);
// This is just so that EEType::Validate doesn't blow up at runtime
dataBuilder.EmitPointerReloc(this); // Related type: itself
return dataBuilder.ToObjectData();
}
示例6: OutputFlags
private void OutputFlags(NodeFactory factory, ref ObjectDataBuilder objData)
{
UInt16 flags = EETypeBuilderHelpers.ComputeFlags(_type);
if (_type.GetTypeDefinition() == factory.ArrayOfTEnumeratorType)
{
// Generic array enumerators use special variance rules recognized by the runtime
flags |= (UInt16)EETypeFlags.GenericVarianceFlag;
}
// Todo: RelatedTypeViaIATFlag when we support cross-module EETypes
// Todo: Generic Type Definition EETypes
if (HasOptionalFields)
{
flags |= (UInt16)EETypeFlags.OptionalFieldsFlag;
}
objData.EmitShort((short)flags);
}
示例7: OutputVirtualSlotAndInterfaceCount
protected virtual void OutputVirtualSlotAndInterfaceCount(NodeFactory factory, ref ObjectDataBuilder objData)
{
objData.EmitShort(0);
objData.EmitShort(0);
}
示例8: OutputVirtualSlotAndInterfaceCount
protected override void OutputVirtualSlotAndInterfaceCount(NodeFactory factory, ref ObjectDataBuilder objData)
{
int virtualSlotCount = 0;
TypeDesc currentTypeSlice = _type.GetClosestDefType();
while (currentTypeSlice != null)
{
if (currentTypeSlice.HasGenericDictionarySlot())
virtualSlotCount++;
virtualSlotCount += factory.VTable(currentTypeSlice).Slots.Count;
currentTypeSlice = currentTypeSlice.BaseType;
}
objData.EmitShort(checked((short)virtualSlotCount));
objData.EmitShort(checked((short)_type.RuntimeInterfaces.Length));
}
示例9: OutputComponentSize
private void OutputComponentSize(ref ObjectDataBuilder objData)
{
if (_type.IsArray)
{
int elementSize = ((ArrayType)_type).ElementType.GetElementSize();
// We validated that this will fit the short when the node was constructed. No need for nice messages.
objData.EmitShort((short)checked((ushort)elementSize));
}
else if (_type.IsString)
{
objData.EmitShort(2);
}
else
{
objData.EmitShort(0);
}
}
示例10: OutputVirtualSlotAndInterfaceCount
private void OutputVirtualSlotAndInterfaceCount(NodeFactory factory, ref ObjectDataBuilder objData)
{
if (!_constructed)
{
objData.EmitShort(0);
objData.EmitShort(0);
return;
}
int virtualSlotCount = 0;
TypeDesc currentTypeSlice = _type;
while (currentTypeSlice != null)
{
List<MethodDesc> virtualSlots;
factory.VirtualSlots.TryGetValue(currentTypeSlice, out virtualSlots);
if (virtualSlots != null)
{
virtualSlotCount += virtualSlots.Count;
}
currentTypeSlice = currentTypeSlice.BaseType;
}
objData.EmitShort(checked((short)virtualSlotCount));
objData.EmitShort(checked((short)_type.RuntimeInterfaces.Length));
}
示例11: OutputVirtualSlotAndInterfaceCount
private void OutputVirtualSlotAndInterfaceCount(NodeFactory factory, ref ObjectDataBuilder objData)
{
if (!_constructed)
{
objData.EmitShort(0);
objData.EmitShort(0);
return;
}
Debug.Assert(!_type.IsGenericDefinition);
int virtualSlotCount = 0;
TypeDesc currentTypeSlice = _type.GetClosestMetadataType();
while (currentTypeSlice != null)
{
virtualSlotCount += factory.VTable(currentTypeSlice).Slots.Count;
currentTypeSlice = currentTypeSlice.BaseType;
}
objData.EmitShort(checked((short)virtualSlotCount));
objData.EmitShort(checked((short)_type.RuntimeInterfaces.Length));
}
示例12: OutputComponentSize
private void OutputComponentSize(ref ObjectDataBuilder objData)
{
if (_type.IsArray)
{
objData.EmitShort((short)((ArrayType)_type).ElementType.GetElementSize());
}
else if (_type.IsString)
{
objData.EmitShort(2);
}
else
{
objData.EmitShort(0);
}
}
示例13: OutputFlags
private void OutputFlags(NodeFactory factory, ref ObjectDataBuilder objData)
{
UInt16 flags = EETypeBuilderHelpers.ComputeFlags(_type);
// Todo: RelatedTypeViaIATFlag when we support cross-module EETypes
// Todo: GenericVarianceFlag when we support variance
// Todo: Generic Type Definition EETypes
if (_optionalFieldsBuilder.IsAtLeastOneFieldUsed())
{
flags |= (UInt16)EETypeFlags.OptionalFieldsFlag;
}
objData.EmitShort((short)flags);
}
示例14: EmitDispatchMap
void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory)
{
var entryCountReservation = builder.ReserveInt();
int entryCount = 0;
for (int interfaceIndex = 0; interfaceIndex < _type.RuntimeInterfaces.Length; interfaceIndex++)
{
var interfaceType = _type.RuntimeInterfaces[interfaceIndex];
Debug.Assert(interfaceType.IsInterface);
IReadOnlyList<MethodDesc> virtualSlots = factory.VTable(interfaceType).Slots;
for (int interfaceMethodSlot = 0; interfaceMethodSlot < virtualSlots.Count; interfaceMethodSlot++)
{
MethodDesc declMethod = virtualSlots[interfaceMethodSlot];
var implMethod = _type.GetClosestDefType().ResolveInterfaceMethodToVirtualMethodOnType(declMethod);
// Interface methods first implemented by a base type in the hierarchy will return null for the implMethod (runtime interface
// dispatch will walk the inheritance chain).
if (implMethod != null)
{
builder.EmitShort(checked((short)interfaceIndex));
builder.EmitShort(checked((short)interfaceMethodSlot));
builder.EmitShort(checked((short)VirtualMethodSlotHelper.GetVirtualMethodSlot(factory, implMethod)));
entryCount++;
}
}
}
builder.EmitInt(entryCountReservation, entryCount);
}
示例15: OutputVirtualSlotAndInterfaceCount
private void OutputVirtualSlotAndInterfaceCount(NodeFactory factory, ref ObjectDataBuilder objData)
{
int virtualSlotCount = 0;
TypeDesc currentTypeSlice = _type;
while (currentTypeSlice != null)
{
List<MethodDesc> virtualSlots;
factory.VirtualSlots.TryGetValue(currentTypeSlice, out virtualSlots);
if (virtualSlots != null)
{
virtualSlotCount += virtualSlots.Count;
}
currentTypeSlice = currentTypeSlice.BaseType;
}
objData.EmitShort(checked((short)virtualSlotCount));
// Todo: Number of slots of EEInterfaceInfo when we add interface support
objData.EmitShort(0);
}