|We have a program segment and want to analyze the control flow through it.
We have already replaced the
actual code with simpler code that captures just the control logic. The
code we want to analyze consists of a sequence of statements in which each statement
is one of the following two types:
Execution of an IF statement is followed by execution of one of its two
Each target is an integer referring to a zero-based position in the
code sequence. The two targets may be identical. Execution of a RETURN statement ends the execution path.
- IF target1 ELSE target2
We want to find all the dead code. A statement is
"dead" if there is no execution path that contains it, where an
execution path must start at the first
statement (statement 0) in the segment and conclude by executing a RETURN statement.
Create a class DeadCode that contains a method deadCount that is given a String
code containing the sequence of statements and that returns the number of dead