Week6:

This week I am still working on the extract local variable project. I have gotten it to work for variables defined in the main function and put into other statements in main, but I have 2 problems with it. First I've excluded checks for the main block statement (so it replaces all instances of the expression rather than stopping when redefined like it checks in other block statements inside the main), and second I can't get it to work for expressions defined later in the program that also appear earlier (but with a different definition than the one selected).

I found out this week there is a way to do it, but I'd have to learn the ways compiles deal with direction and each scope (since we don't have enough time for me to learn it, he told me to focus on the single extraction part and comment out the multiple extraction part). I was told to think of test cases that would break the program I have so far. I thought of one out of the 23 test cases I have so far that did break it, and I had to add in some checks to detect if a switch case was present since my code puts the new variable definition above the spot where it replaces the old variables. I also put in an if/else statement to determine if it was a switch/for loop, or all other statements (since it will behave differently for each).

Go Back to Journal entry page

Go Back to Main Page