当前位置: 首页>>代码示例>>C#>>正文


C# MosaType类代码示例

本文整理汇总了C#中MosaType的典型用法代码示例。如果您正苦于以下问题:C# MosaType类的具体用法?C# MosaType怎么用?C# MosaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MosaType类属于命名空间,在下文中一共展示了MosaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的MosaType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。