public void oldConvertPointerToInt( final ILocation loc, final ExpressionResult rexp, final CPrimitive newType) { assert newType.isIntegerType(); assert rexp.lrVal.getCType() instanceof CPointer; if (OVERAPPROXIMATE_INT_POINTER_CONVERSION) { super.convertPointerToInt(loc, rexp, newType); } else { final Expression pointerExpression = rexp.lrVal.getValue(); final Expression intExpression; if (mTypeSizes.useFixedTypeSizes()) { final BigInteger maxPtrValuePlusOne = mTypeSizes.getMaxValueOfPointer().add(BigInteger.ONE); final IntegerLiteral maxPointer = new IntegerLiteral(loc, maxPtrValuePlusOne.toString()); intExpression = constructArithmeticExpression( loc, IASTBinaryExpression.op_plus, constructArithmeticExpression( loc, IASTBinaryExpression.op_multiply, MemoryHandler.getPointerBaseAddress(pointerExpression, loc), newType, maxPointer, newType), newType, MemoryHandler.getPointerOffset(pointerExpression, loc), newType); } else { intExpression = MemoryHandler.getPointerOffset(pointerExpression, loc); } final RValue rValue = new RValue(intExpression, newType, false, true); rexp.lrVal = rValue; } }
public void oldConvertIntToPointer( final ILocation loc, final ExpressionResult rexp, final CPointer newType) { if (OVERAPPROXIMATE_INT_POINTER_CONVERSION) { super.convertIntToPointer(loc, rexp, newType); } else { final Expression intExpression = rexp.lrVal.getValue(); final Expression baseAdress; final Expression offsetAdress; if (mTypeSizes.useFixedTypeSizes()) { final BigInteger maxPtrValuePlusOne = mTypeSizes.getMaxValueOfPointer().add(BigInteger.ONE); final IntegerLiteral maxPointer = new IntegerLiteral(loc, maxPtrValuePlusOne.toString()); baseAdress = constructArithmeticExpression( loc, IASTBinaryExpression.op_divide, intExpression, getCTypeOfPointerComponents(), maxPointer, getCTypeOfPointerComponents()); offsetAdress = constructArithmeticExpression( loc, IASTBinaryExpression.op_modulo, intExpression, getCTypeOfPointerComponents(), maxPointer, getCTypeOfPointerComponents()); } else { baseAdress = constructLiteralForIntegerType(loc, getCTypeOfPointerComponents(), BigInteger.ZERO); offsetAdress = intExpression; } final Expression pointerExpression = MemoryHandler.constructPointerFromBaseAndOffset(baseAdress, offsetAdress, loc); final RValue rValue = new RValue(pointerExpression, newType, false, false); rexp.lrVal = rValue; } }