本文整理汇总了C#中MosaType类的典型用法代码示例。如果您正苦于以下问题:C# MosaType类的具体用法?C# MosaType怎么用?C# MosaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MosaType类属于命名空间,在下文中一共展示了MosaType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CompilerTypeData
public CompilerTypeData(MosaType mosaType)
{
if (mosaType == null)
throw new ArgumentNullException("mosaType");
MosaType = mosaType;
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:7,代码来源:CompilerTypeData.cs
示例2: GetResult
public override object GetResult(ISimAdapter simAdapter, MosaType type)
{
var x86 = simAdapter.SimCPU as CPUx86;
if (type.IsI1)
return (object)(sbyte)x86.EAX.Value;
else if (type.IsI2)
return (object)(short)x86.EAX.Value;
else if (type.IsI4)
return (object)(int)x86.EAX.Value;
else if (type.IsI8)
return (object)(long)(((ulong)x86.EAX.Value) | ((ulong)x86.EDX.Value << 32));
else if (type.IsU1)
return (object)(byte)x86.EAX.Value;
else if (type.IsU2)
return (object)(ushort)x86.EAX.Value;
else if (type.IsU4)
return (object)(uint)x86.EAX.Value;
else if (type.IsU8)
return (object)(ulong)(((ulong)x86.EAX.Value) | ((ulong)x86.EDX.Value << 32));
else if (type.IsChar)
return (object)(char)x86.EAX.Value;
else if (type.IsBoolean)
return (object)(bool)(x86.EAX.Value != 0);
else if (type.IsR4)
return (object)(float)x86.XMM0.Value.LowF;
else if (type.IsR8)
return (object)(double)x86.XMM0.Value.Low;
else if (type.IsVoid)
return null;
return null;
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:33,代码来源:TestPlatform.cs
示例3: GetResult
public static object GetResult(MosaType type, List<byte> data)
{
if (type.IsI1)
return (sbyte)data[0];
else if (type.IsI2)
return (short)(data[0] | (data[1] << 8));
else if (type.IsI4)
return (int)(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
else if (type.IsI8)
{
ulong low = (uint)(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
ulong high = (uint)(data[4] | (data[5] << 8) | (data[6] << 16) | (data[7] << 24));
return (long)(low | (high << 32));
}
else if (type.IsU1)
return (byte)data[0];
else if (type.IsU2)
return (ushort)(data[0] | (data[1] << 8));
else if (type.IsU4)
return (uint)(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
else if (type.IsU8)
{
ulong low = (uint)(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
ulong high = (uint)(data[4] | (data[5] << 8) | (data[6] << 16) | (data[7] << 24));
return (ulong)(low | (high << 32));
}
else if (type.IsChar)
return (char)(data[0] | (data[1] << 8));
else if (type.IsBoolean)
return (bool)(data[0] != 0);
else if (type.IsR4)
{
var value = new byte[8];
for (int i = 0; i < 8; i++)
value[i] = data[i];
var d = BitConverter.ToSingle(value, 0);
return d;
}
else if (type.IsR8)
{
var value = new byte[8];
for (int i = 0; i < 8; i++)
value[i] = data[i];
var d = BitConverter.ToDouble(value, 0);
return d;
}
else if (type.IsVoid)
return null;
return null;
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:59,代码来源:UnitTestRequest.cs
示例4: GetTypeDefinition
private string GetTypeDefinition(MosaType allocatedType)
{
if (!allocatedType.IsValueType)
{
return allocatedType.FullName + Metadata.TypeDefinition;
}
return null;
}
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:8,代码来源:StaticAllocationResolutionStage.cs
示例5: GetMethodTableForType
private string GetMethodTableForType(MosaType allocatedType)
{
if (!allocatedType.IsValueType)
{
return allocatedType.FullName + @"$mtable";
}
return null;
}
开发者ID:tea,项目名称:MOSA-Project,代码行数:9,代码来源:StaticAllocationResolutionStage.cs
示例6: GetField
private static MosaField GetField(MosaType type, string name)
{
foreach (var field in type.Fields)
{
if (field.Name == name)
return field;
}
return GetField(type.BaseType, name);
}
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:10,代码来源:DelegatePatcher.cs
示例7: InsertLoadBeforeInstruction
private Operand InsertLoadBeforeInstruction(Context context, string symbolName, MosaType type)
{
var before = context.InsertBefore();
Operand result = MethodCompiler.CreateVirtualRegister(type);
Operand op = Operand.CreateManagedSymbol(type, symbolName);
before.SetInstruction(CILInstruction.Get(OpCode.Ldc_i4), result, op);
return result;
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:10,代码来源:StaticAllocationResolutionStage.cs
示例8: AllocateStaticFields
private void AllocateStaticFields(MosaType type)
{
foreach (var field in type.Fields)
{
// TODO: Inline literal field constants
if (field.IsStatic)
{
// Assign a memory slot to the static & initialize it, if there's initial data set
CreateStaticField(field);
}
}
}
开发者ID:tea,项目名称:MOSA-Project,代码行数:12,代码来源:TypeLayoutStage.cs
示例9: ComputeArgumentSize
private int ComputeArgumentSize(MosaType type, object value)
{
if (type.IsEnum)
type = type.GetEnumUnderlyingType();
switch (type.TypeCode)
{
// 1 byte
case MosaTypeCode.Boolean:
case MosaTypeCode.U1:
case MosaTypeCode.I1:
return 1;
// 2 bytes
case MosaTypeCode.Char:
case MosaTypeCode.U2:
case MosaTypeCode.I2:
return 2;
// 4 bytes
case MosaTypeCode.U4:
case MosaTypeCode.I4:
case MosaTypeCode.R4:
return 4;
// 8 bytes
case MosaTypeCode.U8:
case MosaTypeCode.I8:
case MosaTypeCode.R8:
return 8;
// SZArray
case MosaTypeCode.SZArray:
Debug.Assert(value is MosaCustomAttribute.Argument[]);
var arr = (MosaCustomAttribute.Argument[])value;
int size = 0;
foreach (var elem in arr)
size += ComputeArgumentSize(elem.Type, elem.Value);
return size;
// String
case MosaTypeCode.String:
return TypeLayout.NativePointerSize;
default:
if (type.FullName == "System.Type")
{
return TypeLayout.NativePointerSize;
}
else
throw new NotSupportedException();
}
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:52,代码来源:MetadataStage.cs
示例10: MosaExceptionHandler
public MosaExceptionHandler(ExceptionHandlerType ehType, int tryStart, int tryEnd, int handlerStart, int handlerEnd, MosaType type, int? filterOffset)
{
HandlerType = ehType;
TryStart = tryStart;
TryEnd = tryEnd;
HandlerStart = handlerStart;
HandlerEnd = handlerEnd;
Type = type;
FilterOffset = filterOffset;
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:13,代码来源:MosaExceptionHandler.cs
示例11: UpdateType
public static void UpdateType(MosaType type)
{
StringBuilder result = new StringBuilder();
if (type.ElementType != null)
{
result.Append(type.ElementType.Signature);
}
if (type.GenericArguments.Count > 0)
{
result.Append("<");
for (int i = 0; i < type.GenericArguments.Count; i++)
{
if (i != 0)
result.Append(", ");
result.Append(type.GenericArguments[i].FullName);
}
result.Append(">");
}
switch (type.TypeCode)
{
case MosaTypeCode.UnmanagedPointer:
result.Append("*");
break;
case MosaTypeCode.ManagedPointer:
result.Append("&");
break;
case MosaTypeCode.SZArray:
case MosaTypeCode.Array:
result.Append(type.ArrayInfo.ToString());
break;
case MosaTypeCode.FunctionPointer:
result.Append(type.FunctionPtrSig.ToString());
break;
default:
break;
}
if (type.Modifier != null)
{
result.Append(" mod(");
result.Append(type.Modifier.Name);
result.Append(")");
}
type.Signature = result.ToString();
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:50,代码来源:SignatureName.cs
示例12: GetCompilerTypeData
public CompilerTypeData GetCompilerTypeData(MosaType type)
{
lock (compilerTypes)
{
CompilerTypeData compilerType;
if (!compilerTypes.TryGetValue(type, out compilerType))
{
compilerType = new CompilerTypeData(type);
compilerTypes.Add(type, compilerType);
}
return compilerType;
}
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:15,代码来源:CompilerData.cs
示例13: Schedule
public void Schedule(MosaType type)
{
if (type.IsModule)
return;
if (type.IsInterface)
return;
if (type.HasOpenGenericParams || type.IsPointer)
return;
foreach (var method in type.Methods)
{
Schedule(method);
}
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:16,代码来源:CompilationScheduler.cs
示例14: CreateFieldDefinitions
private void CreateFieldDefinitions(MosaType type)
{
foreach (MosaField field in type.Fields)
{
string fieldNameSymbol = field.FullName + @"$name";
// Emit field name
using (Stream stream = Linker.Allocate(fieldNameSymbol, SectionKind.ROData, 0, TypeLayout.NativePointerAlignment))
{
using (EndianAwareBinaryWriter writer = new EndianAwareBinaryWriter(stream, Architecture.Endianness))
{
EmitStringWithLength(writer, field.Name);
}
}
string fieldDescSymbol = field.FullName + @"$desc";
// Emit field descriptor
using (Stream stream = Linker.Allocate(fieldDescSymbol, SectionKind.ROData, 0, TypeLayout.NativePointerAlignment))
{
using (EndianAwareBinaryWriter writer = new EndianAwareBinaryWriter(stream, Architecture.Endianness))
{
// 1. Offset / Address
if (field.IsStatic && !field.IsLiteral)
{
Linker.Link(LinkType.AbsoluteAddress | LinkType.I4, BuiltInPatch.I4, fieldDescSymbol, (int)writer.Position, 0, field.FullName, 0);
}
else
{
writer.Write(TypeLayout.GetFieldOffset(field));
writer.Position -= 4;
}
writer.Position += TypeLayout.NativePointerSize;
// 2. Name
Linker.Link(LinkType.AbsoluteAddress | LinkType.I4, BuiltInPatch.I4, fieldDescSymbol, (int)writer.Position, 0, fieldNameSymbol, 0);
writer.Position += TypeLayout.NativePointerSize;
// 3. Size
writer.Write((uint)TypeLayout.GetFieldSize(field));
// 4. Metadata Token
writer.Write((uint)0); //FIXME!
}
}
}
}
开发者ID:tea,项目名称:MOSA-Project,代码行数:47,代码来源:MetadataStage.cs
示例15: GetInterfaces
private static List<MosaType> GetInterfaces(MosaType type)
{
var interfaces = new List<MosaType>();
var baseType = type;
while (baseType != null)
{
foreach (var interfaceType in baseType.Interfaces)
{
interfaces.AddIfNew(interfaceType);
}
baseType = baseType.BaseType;
}
return interfaces;
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:17,代码来源:MetadataStage.cs
示例16: CreateTypeDefinitionTable
private void CreateTypeDefinitionTable(MosaType type)
{
string typeNameSymbol = type + @"$tname";
// Emit type name
using (Stream stream = Linker.Allocate(typeNameSymbol, SectionKind.ROData, 0, TypeLayout.NativePointerAlignment))
{
using (EndianAwareBinaryWriter writer = new EndianAwareBinaryWriter(stream, Architecture.Endianness))
{
EmitStringWithLength(writer, type.FullName);
}
}
string typeTableSymbol = type.FullName + @"$dtable";
using (Stream stream = Linker.Allocate(typeTableSymbol, SectionKind.ROData, 0, TypeLayout.NativePointerAlignment))
{
using (EndianAwareBinaryWriter writer = new EndianAwareBinaryWriter(stream, Architecture.Endianness))
{
// 1. Size
writer.Write((uint)TypeLayout.GetTypeSize(type));
// 2. Metadata Token
//writer.Write((uint)type.Token.ToUInt32());
writer.Write((uint)0); //FIXME! ^^^
// 3. Pointer to Name
Linker.Link(LinkType.AbsoluteAddress | LinkType.I4, BuiltInPatch.I4, typeTableSymbol, (int)writer.Position, 0, typeNameSymbol, 0);
writer.Position += TypeLayout.NativePointerSize;
// 4. Pointer to Assembly Definition
//linker.Link(LinkType.AbsoluteAddress | LinkType.I4, BuiltInPatch.I4, typeTableSymbol, (int)writer.Position, 0, assemblySymbol, 0);
writer.Position += TypeLayout.NativePointerSize;
// 5. TODO: Constructor that accepts no parameters, if any, for this type
writer.WriteZeroBytes(TypeLayout.NativePointerSize);
// 6. Flag: IsInterface
writer.WriteByte((byte)(type.IsInterface ? 1 : 0));
}
}
CreateFieldDefinitions(type);
}
开发者ID:tea,项目名称:MOSA-Project,代码行数:44,代码来源:MetadataStage.cs
示例17: CreateProtectedRegionDefinition
private LinkerSymbol CreateProtectedRegionDefinition(string name, uint start, uint end, uint handler, ExceptionHandlerType handlerType, MosaType exceptionType)
{
// Emit parameter table
var protectedRegionDefinitionSymbol = MethodCompiler.Linker.CreateSymbol(name, SectionKind.ROData, TypeLayout.NativePointerAlignment, 0);
var writer1 = new EndianAwareBinaryWriter(protectedRegionDefinitionSymbol.Stream, Architecture.Endianness);
// 1. Offset to start
writer1.Write(start, TypeLayout.NativePointerSize);
// 2. Offset to end
writer1.Write(end, TypeLayout.NativePointerSize);
// 3. Offset to handler
writer1.Write(handler, TypeLayout.NativePointerSize);
// 4. Handler type
writer1.Write((uint)handlerType, TypeLayout.NativePointerSize);
// 5. Exception object type
if (handlerType == ExceptionHandlerType.Exception)
{
// Store method table pointer of the exception object type
// The VES exception runtime will uses this to compare exception object types
MethodCompiler.Linker.Link(LinkType.AbsoluteAddress, NativePatchType, protectedRegionDefinitionSymbol, (int)writer1.Position, 0, exceptionType.FullName + Metadata.TypeDefinition, SectionKind.ROData, 0);
}
else if (handlerType == ExceptionHandlerType.Filter)
{
// TODO: There are no plans in the short term to support filtered exception clause as C# does not use them
}
else
{
}
writer1.WriteZeroBytes(TypeLayout.NativePointerSize);
// Return protectedRegionSymbol for linker usage
return protectedRegionDefinitionSymbol;
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:38,代码来源:ProtectedRegionLayoutStage.cs
示例18: TrackTypeAllocated
public void TrackTypeAllocated(MosaType type)
{
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:3,代码来源:CompilationScheduler.cs
示例19: ResolveType
private void ResolveType(MosaType type)
{
GenericArgumentResolver resolver = new GenericArgumentResolver();
MosaType srcType = type;
if (type.GenericArguments.Count > 0)
{
resolver.PushTypeGenericArguments(type.GenericArguments.GetGenericArguments());
srcType = type.ElementType;
Debug.Assert(srcType != null);
}
using (var mosaType = metadata.Controller.MutateType(type))
{
if (srcType.BaseType != null)
mosaType.BaseType = metadata.Loader.GetType(resolver.Resolve(srcType.BaseType.GetTypeSig()));
if (srcType.DeclaringType != null)
{
mosaType.DeclaringType = metadata.Loader.GetType(resolver.Resolve(srcType.DeclaringType.GetTypeSig()));
mosaType.Namespace = srcType.DeclaringType.Namespace;
}
var ifaces = new List<MosaType>(srcType.Interfaces);
mosaType.Interfaces.Clear();
for (int i = 0; i < ifaces.Count; i++)
mosaType.Interfaces.Add(metadata.Loader.GetType(resolver.Resolve(ifaces[i].GetTypeSig())));
mosaType.HasOpenGenericParams = type.GetTypeSig().HasOpenGenericParameter();
ResolveCustomAttributes(mosaType, srcType.GetUnderlyingObject<UnitDesc<TypeDef, TypeSig>>().Definition);
}
// Add type again to make it easier to find
metadata.Controller.AddType(type);
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:36,代码来源:MetadataResolver.cs
示例20: EnqueueForArrayResolve
public void EnqueueForArrayResolve(MosaType type)
{
arrayResolveQueue.Enqueue(type);
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:4,代码来源:MetadataResolver.cs
注:本文中的MosaType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论