AdvTPL11 - Translation into P<: Chapter 11 Translational...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 W. Pelz 2003-09 1 Chapter 11 Translational Semantics of Objects and Classes W. Pelz 2003-09 2 Translation into Λ P <: • Works well for classes, but not subclasses • Use expanded (not abbreviated) SOOL • IVs are protected; methods are public • Later work will include subclasses and hidden methods W. Pelz 2003-09 3 Representation of Objects • Record of instance variables • Pointer to methods appropriate to the object – more efficient than separate methods for each object • In practice, methods access instance variables through an indirect mechanism • More formally, we require each method to be parameterized by the record of IVs W. Pelz 2003-09 4 Translation of SOOL types to types in Λ P <: • [203] Figure 11.1 • Left-hand side are SOOL types • Right-hand side are Λ P <: types • T C [| . |] [| . |] is the translation function W. Pelz 2003-09 5 W. Pelz 2003-09 6 Translation of CellIV and CellM • CellIV = {|x: Integer|} • RfCellIV = {|x: Ref Integer|} • CellM = {| get: Void b Integer; set: Integer b Void; bump: Void b Void|}
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
W. Pelz 2003-09 7 Translation of VisObjectType versus ObjectType • T C [| [|VisObjectType(CellIV ref , CellM) |] |] = VisObj(RFCellIV, CellM) which we have seen previously is of type RfCellIV × (RfCellIV b CellM) • T C [| [|ObjectType CellM |] |] = Y.VisObj (Y, CellM) we know IVs exist ( Y), but no details W. Pelz 2003-09 8 closeobj closeobj Λ IVR. Λ M. λ(vo: IVR × (IVR b M)) .pack IVR, vo as Y.Y × (Y b M) (vo represents a visible object) Is a polymorphic function of type IVR. M.(IVR × (IVR b M)) b ( Y.(Y × (Y b M))) W. Pelz 2003-09 9 Theorem 11.2.1 If S and T are types in SOOL such that C S <: T, then φ T C [| [|S |] |] <: T C [| [|T |] |] in Λ P <: Proof for most cases is trivial; a detailed proof for object types is given in the text W. Pelz 2003-09 10 Translation of Expressions • [209] Figure 11.2 • [211] Figure 11.3 • Of special interest are translations involving bodies of functions, i.e., blocks, since new type and constant definitions are possible W. Pelz 2003-09 11 Translation of While If w = while E do { S } then we can write w = if E then { S; w } else { nop } W. Pelz 2003-09 12 Modeling Classes • Use initial values of instance variables and methods to create the visible object • Body of methods can refer to self which can be treated as an additional parameter self
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2011 for the course CS 542 taught by Professor Dr. thomas during the Spring '10 term at SUNY Buffalo.

Page1 / 7

AdvTPL11 - Translation into P<: Chapter 11 Translational...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online