Appendix - How to pick criteria
Prev |  | Next

## Appendix - How to pick criteria

As mentioned before, the criteria for slicing is a Jimple statement. When a Java statement is picked, the user is allowed to select one of the corresponding Jimple statements as the criteria. The following examples show how to choose the correct Jimple statement depending on the requirement.

### Examples of picking Jimple criteria

Example 3. Setting up criteria for an assignment statement

Consider the simple statement : `nw++` , where nw is a integer. The equivalent Jimple for this statement consists of the following:

- `$i2 = r0.<myPackage.Monitor: int nw>`

- `$i3 = $i2 + 1`

- `r0.<myPackage.Monitor: int nw> = $i3`

Here `r0.<myPackage.Monitor: int nw>` corresponds to the variable nw. So to pick `nw = nw + 1` as a criteria you would pick the last statement `r0.<myPackage.Monitor: int nw> = $i3` as in that statement the final value of nw is assigned.

Example 4. Setting up criteria for a function call

Consider the expression `monitor.start_write()` . The Jimple for this consists of two statements:

- `r1 = r0.<myPackage.Writers: myPackage.Monitor mon>`
- `virtualinvoke r1.<myPackage.Monitor: void start_write()>()`

To pick the function call, the second statement `virtualinvoke r1.<myPackage.Monitor: void start_write()>()` is to be selected as it involves the call to the function `start_write()` in the `Monitor` class.

Example 5. Setting up criteria for a conditional

Consider the expression: `if (!empty(Clist))` . The equivalent Jimple for this statement is:

- `$r4 = r0.<temp.DiskScheduler:java.util.LinkedList Clist>`

- `$z0 = virtualinvoke r0.<temp.DiskScheduler: boolean empty(java.util.LinkedList)>($r4)`

- `if $z0 != 0 goto $r7 = r0.<temp.DiskScheduler:java.util.LinkedList NList>`

To pick the function call `empty(Clist)` you would choose the second statement `$z0 = virtualinvoke r0.<temp.DiskScheduler: boolean empty(java.util.LinkedList)>` as it invokes the `empty()` method. On the other hand if you wanted to choose the `if` conditional you would choose the last line `if $z0 != 0 goto $r7 = r0.<temp.DiskScheduler:java.util.LinkedList NList>`

Prev | Up | Next
Features | Home | Appendix - Creating Scope Specifications