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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Type</strong> <strong>Graph</strong>s 13aa generic classa static tablea primitive typeSxxm 1m 2βσσCβb⊲Da classa type variableσ m 4m 3xaZyxBa method frameFigure 1: A <strong>Type</strong> <strong>Graph</strong>We use s a −→ t to represent an a-labeled edge from s to t, and call s the source node and t thetarget node of the edge. We use s a −→ · to represent an a-labeled outgoing edge from s and · a−→ tan a-labeled incoming edge to t. For a given graph Γ = 〈N, E〉, we use Γ.ns to denote the set Nof nodes, and Γ.es the set E of edges.Let Γ be a type graph and n a list of nodes of Γ. We define the set out-es(Γ, n) of outgoingedges from the nodes in n, and the set adj -ns(Γ, n) of nodes adjacent to any of the nodes in n.Formally,out-es(Γ, n) ̂= {s a −→ t ∈ Γ | s ∈ n},adj -ns(Γ, n) ̂= {t | · −→ t ∈ out-es(Γ, n)}.aA path p is a sequence of consecutive edges, denoted as n10 −→ n1 · · · n k−1 −→ nk or simplya 1 .a 2 ...ank0 −−−−−−→ nk if we are not concerned with its intermediate nodes. We also overload thenotation of set membership “∈”, using n ∈ Γ, e ∈ Γ and p ∈ Γ to denote that a node n, an edgee and a path p are in Γ, respectively.For a path p, let source(p) and target(p) be the starting and final node, respectively. We saythat a node n 2 is reachable from a node n 1 , denoted by n 1 −→ ∗ n 2 , if there is a path from n 1 ton 2 . A path n 1a −→ · · · a −→ n2 is simply denoted as n 1a −→ ∗ n 2 .a k3.2 Rooted <strong>Graph</strong>sGiven the type graph Γ of a program, an individual type T , say a class, is represented by a noder of Γ, the nodes reachable from r and the edges between these nodes. These nodes and edges<strong>for</strong>m a subgraph of Γ with r being designated as the root, and this rooted graph represents thetype T .Definition 2 (Rooted <strong>Graph</strong>) Given a node r in a graph Γ = 〈N, E〉, the rooting operationΓ r returns the subgraph 〈N ′ , E ′ , r〉 of Γ such thatN ′ = {n | r −→ ∗ n ∈ Γ},E ′ = {n 1a −→ n2 ∈ Γ | n 1 , n 2 ∈ N ′ }.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!