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


C# Compiler.GetTypeDataFromType方法代码示例

本文整理汇总了C#中Compiler.GetTypeDataFromType方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.GetTypeDataFromType方法的具体用法?C# Compiler.GetTypeDataFromType怎么用?C# Compiler.GetTypeDataFromType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Compiler的用法示例。


在下文中一共展示了Compiler.GetTypeDataFromType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        public override void Process(Compiler compiler, MethodData methodData, Instruction instruction)
        {
            // Get .ctor method from operand and get the class associated with it
            MethodReference ctor = instruction.Operand as MethodReference;
            TypeReference type = ctor.DeclaringType;

            // If the object type is native, we ignore the IL object and don't emit a NEWOBJ
            // After that, we call the .CTOR which will be in runtime
            // The .CTOR in runtime will also initialize this object
            if(Util.IsNativeType(type))
            {
                // Create call to .CTOR
                Instruction call = Instruction.Create(OpCodes.Call, ctor);
                compiler.HandleInstruction(call, methodData);
                return;
            }

            // Write opcode and class ID
            int classID = compiler.GetTypeDataFromType(type.Resolve()).Id;
            methodData.AddInstruction(instruction.OpCode.Value);
            methodData.AddInstruction(classID);

            // Write CALL to .ctor
            // Count one extra parameter for the "this" object
            MethodDefinition methodDef = ctor.Resolve();
            int ctorID = compiler.GetMethodID(methodDef);
            if (ctorID == -1)
                ctorID = compiler.ProcessMethod(methodDef);

            methodData.AddInstruction(ctorID);
            methodData.AddInstruction(ctor.Parameters.Count);
        }
开发者ID:NielsDev,项目名称:IL2VM,代码行数:32,代码来源:NEWOBJ.cs

示例2: Process

        public override void Process(Compiler compiler, MethodData methodData, Instruction instruction)
        {
            // Get field and class data
            FieldDefinition field = instruction.Operand as FieldDefinition;
            TypeData classData = compiler.GetTypeDataFromType(field.DeclaringType);

            // Output opcode followed by field ID
            methodData.AddInstruction(instruction.OpCode.Value);
            methodData.AddInstruction(classData.GetMemberFieldId(field));
        }
开发者ID:NielsDev,项目名称:IL2VM,代码行数:10,代码来源:LDSTFLD.cs

示例3: Process

        public override void Process(Compiler compiler, MethodData methodData, Instruction instruction)
        {
            // Get type ID
            TypeReference type = instruction.Operand as TypeReference;
            int id = compiler.GetTypeDataFromType(type.Resolve()).Id;

            // Write opcode and type ID
            methodData.AddInstruction(instruction.OpCode.Value);
            methodData.AddInstruction(id);
        }
开发者ID:NielsDev,项目名称:IL2VM,代码行数:10,代码来源:InitOBJ.cs

示例4: Process

        public override void Process(Compiler compiler, MethodData methodData, Instruction instruction)
        {
            // Get field and class data
            FieldDefinition field = (instruction.Operand as FieldReference).Resolve();
            TypeData classData = compiler.GetTypeDataFromType(field.DeclaringType);

            // Output opcode followed by class ID followed by field ID
            methodData.AddInstruction(instruction.OpCode.Value);
            methodData.AddInstruction(classData.Id);
            methodData.AddInstruction(classData.GetStaticFieldId(field));
        }
开发者ID:NielsDev,项目名称:IL2VM,代码行数:11,代码来源:LDSFLD.cs


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