Lecture 6 Notes

# In the example variables and are dened and variables

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .  E1Ew   ©  ¨ © ¨ A a DJ traversal speciﬁcation may include a clause c1 specifying that the portion of the path in which this clause occurs may not pass through an object of class c1 . The DJ library also includes ways to specify strategy graphs [10]. d PqE 9 EquationSystem equations Equation_List * Equation rhs lhs * Variable Expression Ident Simple Compound op      Figure 3: Class graph for Expression_List g qqd Operator h i1 Numerical args . f 1e In our example, let us say that a variable is deﬁned if it appears on the lefthand side of an equation and that it is used if it appears on the right-hand. In the example, variables , and are deﬁned, and variables , and are used. The purpose of our Java program is to collect the deﬁned and used variables. r EX Y `X k gE  d   w8 d  h 1 h 1  w8  j 1e j 1e  1E d w8Gw1 h E  wxEE1whi1  h  g qGd      f 1e E  g `qd      f 1e  i1  h  l qiw  k g1   E h E   wmVEEmE  h g qnd      f 1e  E  g `Gd      f 8e  iE  h h l GV   k gE    l  1E l GVw   k  o   i  p V8E8l 1 In a real application, this would probably done globally rather than on a per-class basis. 10  e EX The code for this task is shown in ﬁgure 4. The static member contains a object that contains a representation of the current class diagram1 .  i 1X The DJ library uses reﬂection to compute the relevant FIRST sets. This has two advantages: ﬁrst, it allows the same code to be reused even if the class structure changes. We say this behavior is adaptive [8]. Second, it allows the ksystem to be implemented as a pure Java library rather than as a preprocessor. l GVw e 1X There are of course many ways of specifying the same traversals. For example the ﬁrst could have been written as , and the second could have been written as . h i 1X To solve this problem, we identify two traversals. The ﬁrst traversal may be written as The second may be written as . . ¥ 11 Figure 4: Finding the variables in an equation system ¥ ¥ ±r szs G1P|1Py { }{ztt²u ||VwiVVVwi8PwP|1Pwi }ztts yt~}{zysxwu {¡± t s yq rr {q tz y 8VwiV|&quot;viEii }xy  ´4G8Piiw48iVPVwws   ts}z¡³y y~t ¥ ±r szs 1i||1v1iPy {y t x{ }{ztt²u P|VVwViPi...
View Full Document

## This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online