13.07.2015 Views

A Graph-Based Generic Type System for Object-Oriented Programs

A Graph-Based Generic Type System for Object-Oriented Programs

A Graph-Based Generic Type System for Object-Oriented Programs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Type</strong> Operations 211. all effective attributes in G are included in G ′ ,a ≠ σ ∧ a −→ n ∈ clo(G) =⇒ ∃ a −→ n ′ ∈ clo(G ′ ) • G n ∼ G ′ n ′ ,2. all effective method signatures in G are included in G ′ , −−→ σ.m n ∈ clo(G) =⇒ ∃ −−→ σ.m n ′ ∈ clo(G ′ ) • G n ∼ G ′ n ′ .If a rooted graph G ′ contains an ⊲-chain from the root to a node n, G ′ is a subclass of thesubgraph rooted at n of G ′ . We call G ′ a superclass cover of a rooted graph that encodes asuperclass constraint ⊲ −→ n.Definition 11 (Superclass Cover) A rooted graph G ′ is a superclass cover of a rooted graphG, denoted as G ′ ̂⊲ G, if ⊲ −→ n ∈ G =⇒ G ′ G n.4.4 Instantiation <strong>Graph</strong>sGiven a generic class C〈α〉 with a list α of type variables, C〈α ↦→ Te〉 is a class instantiationof C〈α〉, where Te is a list of type expressions. We call 〈α ↦→ Te〉 the type substitution of theinstantiation. The root of the graph of the generic class C〈α〉 is named with C. However, theroot of the graph of an instantiation C〈α ↦→ Te〉 is a structural node. And in this instantiationgraph, all the subgraphs rooted at the type variables α in the graph of C〈α〉 are replaced by thecorresponding graphs of the actual types Te. Let u be the roots of the graphs of Te. We alsocall 〈α ↦→ u〉 the type substitution of the instantiation of the graph of C〈α〉 with the graph ofC〈α ↦→ Te〉.Generally, any rooted graph containing type variables is generic, and can be used as a template<strong>for</strong> instantiation. <strong>Type</strong> variables only appear in the graph of a generic class, or an instantiationgraph resulted by using type variables as actual types. We unify the two cases by using theshallow structure of a generic class as the template <strong>for</strong> the instantiation of the generic class. Infact, the shallow structure is type equivalent to an instantiation graph of the generic class overan identity type substitution 〈α ↦→ α〉. Moreover, since a generic class itself cannot be used as atype, there is no edge pointing to the root of its graph. Thus, in a template graph, nodes on apath to a type variable can only be structural nodes or type variables.To use a homomorphism to define the instantiation of a template G over a type substitution〈α ↦→ u〉, we define the subgraph of G terminating at the α-nodes. Given a list n of nodes ina rooted graph G, a subgraph of G terminating at n is obtained from G by removing all theoutgoing edges from n,G n ̂= G out-es(G, n).Notice that G n has the same root as G.Report No. 448, June 2011UNU-IIST, P.O. Box 3058, Macao

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!