I need help in writing a python code that takes in the Three Address Code for the Java source code and returns pseudo code. I have successfully generated pseudo code for 1-D array initialization by extracting the array names, their length, and values.
For example: For the below lines of code:
int arr1[] = {1,2,3}
int arr2[] = {11,12,13}
I am getting the output as below: 1. Initialize arr1 with values 1,2,3 2. Initialize arr2 with values 11,12,13
However, I am stuck at writing logic for generating pseudo code in case there is a loop. For example,
sum = 0
for(int i=0; i<3; i++){
sum += arr1[i]*arr2[i]
}
System.out.println(sum);
Here's the Three address code for the above code:
sum=0
i=0
L1:
if i >= 3 goto L2
T1 = addr(a)
T2 = i * 4
T3 = T1[T2]
T4 = addr(b)
T5 = i * 4
T6 = T4[T5]
T7 = T3 * T6
T8 = sum + T7
sum = T8
T9 = i + 1
i = T9
goto L1
L2:
print sum