Traversal of Object Structures Karl Lieberherr Definition of
Traversal of Object Structures Karl Lieberherr
Definition of traversals • Traversals of object graphs. • Informally, a traversal is a (possibly infinite) set of concrete class graph paths; when used in conjunction with an object graph, it results in a sequence of objects, called the traversal history. • The traversal history is a depth-first traversal of the object graph along object paths agreeing with the given concrete path set.
Definition of Traversals For a set of sequences R subset of S* for an alphabet S, define • head(R) = {x in S | exists a. (xa in R)} • tail(R, x)= {a | xa in R for some x in S}. Intuitively, head(R) is the set of all first elements of R, and tail(R, x) is the set of all ``tails'' of sequences of R that start with x (where a tail of a sequence is the whole sequence except its first element).
Definition of Traversals Fix a class graph G. If O is an acyclic object graph which is an instance of G, o an object in O, R a set of concrete paths corresponding to paths of G, and H a sequence of objects, then the judgment Judge(O, o, R, H) means that when traversing the object graph O starting with o, and guided by the concrete path set R, then H is the traversal history. This judgment holds when it is derivable using the following rules:
Definition of Traversals -----------------------Judge(O, o, R, epsilon) if tail(R, Class(o))={} where epsilon denotes the empty history, and Judge(O, o_i, tail(R, Class(o)), l_i), H_i) forall i in 1. . n ----------------------------------------O vdash_s o: R rhd o H_1. . . H_n Judge(O, o, R, H_1. . . H_n if head(tail(R, Class(o))) = {l_i | i in 1. . n}, edge o {l_i} {o_i} is in O, i in 1. . n, and l_j < l_k for 1 <= j < k <= n. }
Discussion of semantics • R may be an infinite set, so semantics does not immediately provide an interpreter. • What we need for an interpreter is a finite representation of R
- Slides: 6