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 49Proof. The proof is in general by induction on the structure of the command c. Suppose noneof the exceptional cases happens.– Case c is skip.Since Γ, ∆ ⊢ skip can only be resulted from (T-Skip), we have ∆ ⋄ = ∆. By (Skip), we have〈skip, G〉 → G. Thus G is well-typed w.r.t. ∆ ⋄ .– Case c is ⌈u⌋.new(le ′ ).Since Γ, ∆ ⊢ ⌈u⌋.new(le ′ ) can only be resulted from (T-New), we have ∆ ⋄ = ∆, Γ, ∆ ⊢ le ′ : u ′ ,Γ ⊢ u u ′ and Γ ⊢ Cc → u <strong>for</strong> some concrete class Cc. Thus, u is a concrete class nodeand u ′ is a class node. By Lemma 12, we have d = l-eval(G, le) exists. There<strong>for</strong>e, G ′ =new(R, G, u, d) is defined. By the definition of new and (attributes) in the construction ofenvironment graphs, G ′ is also well-typed w.r.t. Γ, since (1) the newly introduced object nodehas all the attributes of u, (2) the attributes point to their initial values, and (3) Γ, ∆ ⊢ le ′ : u ′implies either Γ(G, source(d)) ⊲ −→ ∗ a −→ u ′ ∈ Γ <strong>for</strong> some attribute a or ∆(G, source(d)) x −→ u ′ ∈ ∆<strong>for</strong> some variable x. Note that new does not affect scope nodes, thus G ′ is also well-typedw.r.t. ∆. By (New), we have 〈Cc.new(le), G〉 → G ′ .– Case c is le ′ := e ′ .Since Γ, ∆ ⊢ le ′ := e ′ can only be resulted from (T-Assign), we have ∆ ⋄ = ∆, Γ, ∆ ⊢ le ′ : t,Γ, ∆ ⊢ e ′ : t ′ and Γ ⊢ t ′ t. By Lemma 12, we have d = l-eval(le) and n = eval(e)exist and Γ ⊢ Γ(G, n) t ′ . There<strong>for</strong>e, G ′ = swing(G, d, n) is defined and well-typed w.r.tΓ, since Γ, ∆ ⊢ le ′ : t implies either Γ(G, source(d)) ⊲ −→ ∗ a −→ t ∈ Γ <strong>for</strong> some attribute a or∆(G, source(d)) x −→ t ∈ ∆ <strong>for</strong> some variable x. Note that swing does not affect scope nodes,thus G ′ is also well-typed w.r.t. ∆. By (Assign), we have 〈le := e, G〉 → G ′ .– Case c is var ⌈t⌋ x.Since Γ, ∆ → ∆ ⋄ ⊢ var ⌈t⌋ x can only be resulted from (T-Decl), we have ∆ ⋄ = push(∆, x, t).Let G ′ = push(G, x, ini(t)). By (Decl), we have 〈var Te x, G〉 → G ′ . Note that G ′ is welltypedw.r.t. (Γ, ∆ ⋄ ), since var(G ′ ) = {x} = var(∆ ⋄ ) and x point to their initial values.– Case c is end x.Since Γ, ∆ → ∆ ⋄ ⊢ end x can only be resulted from (T-End), we have ∆ ⋄ = pop(∆), thuspop(G) is consistent with ∆ ⋄ . By (End), we have 〈end x, G〉 → pop(G).– Case c is e.m(ve • x • re).A well-typed method invocation Γ, ∆ ⊢ e.m(ve • x • re) is deduced from (T-Invk). Thus, wehave Γ ⊢ e : u and mfr(Γ u, m). Hence, o = eval(G, e) exists and −−→ σ.m · ∈ clo(Γ u).Since Γ ⊢ u ′ = Γ(G, o) u, we have −−→ σ.m · ∈ clo(Γ u ′ ). By the definition in Table 9, wehave u ′ σ m σ −→ s −→ k ∈ R and o −→ s ∈ G. There<strong>for</strong>e, by (Invk), the method invocation can bereduced to 〈enter(o, ve, x, re); k; leave(x, re), G〉.Also, we have Γ ⊢ ve : t, x : t ′′ , re : t ′ , t t ′′ . It implies that (a) n = eval(G, ve) exist andΓ ⊢ Γ(G, n) t, and (b) re must be l-expressions, either variables or attributes. Hence,q = po(G, re) exist. There<strong>for</strong>e, by the enter auxiliary command, G is trans<strong>for</strong>med to G 1 =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!