Esempio n. 1
0
        private AnalysisNet.IInstruction ProcessStoreArrayElement(Cecil.Cil.Instruction op)
        {
            AnalysisNet.Types.ArrayType arrayType = null;

            switch (op.OpCode.Code)
            {
            //case Mono.Cecil.Cil.Code.Array_Set:
            //    arrayType = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference) as ArrayType;
            //    break;
            //case Mono.Cecil.Cil.Code.Stelem:
            case Mono.Cecil.Cil.Code.Stelem_Any:
                AnalysisNet.Types.IType extractedType = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference);
                arrayType = new AnalysisNet.Types.ArrayType(extractedType);
                break;

            default:
                arrayType = new AnalysisNet.Types.ArrayType(OperationHelper.GetOperationType(op.OpCode.Code));
                break;
            }

            if (arrayType == null)
            {
                throw new NotImplementedException();
            }

            AnalysisNetBytecode.StoreArrayElementInstruction instruction = new AnalysisNetBytecode.StoreArrayElementInstruction((uint)op.Offset, arrayType);
            return(instruction);
        }
Esempio n. 2
0
        private AnalysisNet.IInstruction ProcessLoadArrayElement(Cecil.Cil.Instruction op, AnalysisNetBytecode.LoadArrayElementOperation operation)
        {
            AnalysisNet.Types.ArrayType arrayType = null;

            switch (op.OpCode.Code)
            {
            /*case Mono.Cecil.Cil.Code.Array_Addr:
             * case Mono.Cecil.Cil.Code.Array_Create:
             * case Mono.Cecil.Cil.Code.Array_Create_WithLowerBound:
             * case Mono.Cecil.Cil.Code.Array_Get:
             * case Mono.Cecil.Cil.Code.Array_Set:
             *  arrayType = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference) as ArrayType;
             *  break;*/
            //case Mono.Cecil.Cil.Code.Ldelem:
            case Mono.Cecil.Cil.Code.Ldelem_Any:
            case Mono.Cecil.Cil.Code.Ldelema:
                arrayType = new AnalysisNet.Types.ArrayType(typeExtractor.ExtractType(op.Operand as Cecil.TypeReference));
                break;

            default:
                arrayType = new AnalysisNet.Types.ArrayType(OperationHelper.GetOperationType(op.OpCode.Code));
                break;
            }

            if (arrayType == null)
            {
                throw new NotImplementedException();
            }

            AnalysisNetBytecode.LoadArrayElementInstruction instruction = new AnalysisNetBytecode.LoadArrayElementInstruction((uint)op.Offset, operation, arrayType);
            return(instruction);
        }
Esempio n. 3
0
        private AnalysisNet.IInstruction ProcessConversion(Cecil.Cil.Instruction op)
        {
            AnalysisNetBytecode.ConvertOperation operation = OperationHelper.ToConvertOperation(op.OpCode.Code);
            bool overflow = OperationHelper.PerformsOverflowCheck(op.OpCode.Code);
            bool unsigned = OperationHelper.OperandsAreUnsigned(op.OpCode.Code);

            Cecil.TypeReference     cciType = op.Operand as Cecil.TypeReference;
            AnalysisNet.Types.IType ourType = OperationHelper.GetOperationType(op.OpCode.Code);

            if (operation == AnalysisNetBytecode.ConvertOperation.Box)
            {
                ourType = typeExtractor.ExtractType(cciType);
            }
            else if (operation == AnalysisNetBytecode.ConvertOperation.Conv)
            {
                ourType = OperationHelper.GetOperationType(op.OpCode.Code);
            }
            else if (operation == AnalysisNetBytecode.ConvertOperation.Cast)
            {
                ourType = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference);
            }

            AnalysisNetBytecode.ConvertInstruction instruction = new AnalysisNetBytecode.ConvertInstruction((uint)op.Offset, operation, ourType)
            {
                OverflowCheck    = overflow,
                UnsignedOperands = unsigned
            };
            return(instruction);
        }
Esempio n. 4
0
        private AnalysisNet.IInstruction ProcessStoreIndirect(Cecil.Cil.Instruction op)
        {
            AnalysisNet.Types.IType type = OperationHelper.GetOperationType(op.OpCode.Code);
            if (op.OpCode.Code == Mono.Cecil.Cil.Code.Stobj)
            {
                type = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference);
            }

            AnalysisNetBytecode.StoreIndirectInstruction instruction = new AnalysisNetBytecode.StoreIndirectInstruction((uint)op.Offset, type);
            return(instruction);
        }
Esempio n. 5
0
        private AnalysisNet.IInstruction ProcessLoadConstant(Cecil.Cil.Instruction op)
        {
            AnalysisNetBytecode.LoadOperation operation = OperationHelper.ToLoadOperation(op.OpCode.Code);
            AnalysisNet.Types.IType           type      = OperationHelper.GetOperationType(op.OpCode.Code);
            object value = OperationHelper.GetOperationConstant(op);

            AnalysisNetTac.Values.Constant source = new AnalysisNetTac.Values.Constant(value)
            {
                Type = type
            };

            AnalysisNetBytecode.LoadInstruction instruction = new AnalysisNetBytecode.LoadInstruction((uint)op.Offset, operation, source);
            return(instruction);
        }