Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Program slicing
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Example === For example, consider the C program below. Let's compute the slice for ( write(sum), sum ). The value of sum is directly affected by the statements "sum = sum + i + w" if N>1 and "int sum = 0" if N <= 1. So, slice( write(sum), sum) is the union of three slices and the "int sum = 0" statement which has no dependencies: <ol> <li>slice( sum = sum + i + w, sum),</li> <li>slice( sum = sum + i + w, i),</li> <li>slice( sum = sum + i + w, w), and</li> <li>{ int sum=0 }.</li> </ol> It is fairly easy to see that slice( sum = sum + i + w, sum) consists of "sum = sum + i + w" and "int sum = 0" because those are the only two prior statements that can affect the value of sum at "sum = sum + i + w". Similarly, slice( sum = sum + i + w, i) only contains "for(i = 1; i < N; ++i) {" and slice( sum = sum + i + w, w) only contains the statement "int w = 7". When we union all of those statements, we do not have executable code, so to make the slice an executable slice we merely add the end brace for the for loop and the declaration of i. The resulting static executable slice is shown below the original code below. <syntaxhighlight lang="c"> int i; int sum = 0; int product = 1; int w = 7; for(i = 1; i < N; ++i) { sum = sum + i + w; product = product * i; } write(sum); write(product); </syntaxhighlight> The static executable slice for criteria (<code>write(sum)</code>, sum) is the new program shown below. <syntaxhighlight lang="c"> int i; int sum = 0; int w = 7; for(i = 1; i < N; ++i) { sum = sum + i + w; } write(sum); </syntaxhighlight> In fact, most static slicing techniques, including Weiser's own technique, will also remove the <code>write(sum)</code> statement. Since, at the statement <code>write(sum)</code>, the value of <code>sum</code> is not dependent on the statement itself. Often a slice for a particular statement x will include more than one variable. If V is a set of variables in a statement x, then the slice for (x, V) is the union of all slices with criteria (x, v) where v is a variable in the set V.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)