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); }
private AnalysisNet.IInstruction ProcessMethodCall(Cecil.Cil.Instruction op) { AnalysisNetBytecode.MethodCallOperation operation = OperationHelper.ToMethodCallOperation(op.OpCode.Code); Cecil.MethodReference cciMethod = op.Operand as Cecil.MethodReference; AnalysisNet.Types.IMethodReference ourMethod = typeExtractor.ExtractMethod(cciMethod); AnalysisNet.IInstruction instruction; if (ourMethod.ContainingType is FakeArrayType fakeArrayType) { AnalysisNet.Types.ArrayType arrayType = fakeArrayType.Type; if (ourMethod.Name == "Set") { instruction = ProcessStoreArrayElement(op, arrayType); return(instruction); } else { AnalysisNetBytecode.LoadArrayElementOperation arrayOp = OperationHelper.ToLoadArrayElementOperation(ourMethod.Name); instruction = ProcessLoadArrayElement(op, arrayOp, arrayType); return(instruction); } } instruction = new AnalysisNetBytecode.MethodCallInstruction((uint)op.Offset, operation, ourMethod); return(instruction); }
private AnalysisNet.IInstruction ProcessCreateArray(Cecil.Cil.Instruction op) { Cecil.ArrayType cciArrayType = Cecil.Rocks.TypeReferenceRocks.MakeArrayType(op.Operand as Cecil.TypeReference); AnalysisNet.Types.ArrayType ourArrayType = typeExtractor.ExtractType(cciArrayType) as AnalysisNet.Types.ArrayType; return(CreateArray((uint)op.Offset, ourArrayType)); }
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); }
private AnalysisNet.Types.ArrayType ExtractType(Cecil.ArrayType typeref) { AnalysisNet.Types.IType elements = ExtractType(typeref.ElementType); AnalysisNet.Types.ArrayType type = new AnalysisNet.Types.ArrayType(elements, (uint)typeref.Rank); return(type); }
private AnalysisNet.IInstruction CreateArray(uint offset, AnalysisNet.Types.ArrayType arrayType, bool withLowerBound = false) { AnalysisNetBytecode.CreateArrayInstruction instruction = new AnalysisNetBytecode.CreateArrayInstruction(offset, arrayType) { WithLowerBound = withLowerBound }; return(instruction); }
private AnalysisNet.IInstruction ProcessStoreArrayElement(Cecil.Cil.Instruction op, AnalysisNet.Types.ArrayType arrayType) { AnalysisNetBytecode.StoreArrayElementInstruction instruction = new AnalysisNetBytecode.StoreArrayElementInstruction((uint)op.Offset, arrayType); return(instruction); }
private AnalysisNet.IInstruction ProcessLoadArrayElement(Cecil.Cil.Instruction op, AnalysisNetBytecode.LoadArrayElementOperation operation, AnalysisNet.Types.ArrayType arrayType = null) { AnalysisNetBytecode.LoadArrayElementInstruction instruction = new AnalysisNetBytecode.LoadArrayElementInstruction((uint)op.Offset, operation, arrayType); return(instruction); }
public FakeArrayType(AnalysisNet.Types.ArrayType type) { Type = type; }