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.

Operational Semantics 44RanulllnkCalnknullxfalsetruebblnkb a iσ σσ...σσAbbfalsez$y0x $i0Figure 8: A State <strong>Graph</strong> and a Corresponding Environment <strong>Graph</strong>G6. a static table in G must also be a static table in dom(R.sm).A state graph G is shown as solid lines in Fig. 8.Besides extending the stack operations on type contexts to state graphs, we define the swingoperation to change the targets of a list of edges in a state graph. Formally, given G = 〈N, E, r〉,d = n ′ a −→ · ∈ E, and n ∈ N ∪ L , we define swing(G, d, n) ̂= 〈N ′ , E ′ 〉 r, whereN ′ = N ∪ {n}, E ′ = E n ′ a −→ n.The M e map operation sequentially adds mappings e to M, and overrides the existing mappings.Formally,M (a ↦→ b, s ↦→ t) ̂= ({x ↦→ y ∈ M | x ≠ a} ∪ {a ↦→ b}) s ↦→ t.7.2 Execution Environment LookupThe static table nodes connect objects to their runtime class in<strong>for</strong>mation in the environmentgraph. Via static tables, we can lookup superclasses, method names and method body commands.A static table is introduced to a state graph by object creation, which can be simplified as shallowcopying all the outgoing edges of a type node in the environment graph to the state graph withthe substitution of a new object node <strong>for</strong> the type node.Besides the static table of an object, we can also access the environment graph through theenvironment dependent ⌈t⌋.new command. Given an environment graph R, a type node t ∈ R,a state graph G and an edge d ∈ G, we define the function new to add a new instance of t tothe state graph and swing d to the instance. Formally, given G = 〈N, E, r〉 and d = n a −→ · ∈ E,we define new(R, G, t, d) ̂= 〈N ′ , E ′ 〉 r, whereN ′ = N ∪ {o} ∪ {l | t b −→ l ∈ R},E ′ = E ∪ {o b −→ l | t b −→ l ∈ R} n a −→ o,o ∈ O 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!