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> <strong>Graph</strong>s 11denoted by Cc. Only concrete classes can have class instances, thus we can only invoke the newcommand on concrete classes. A class conjunction Cn is a collection of member signatures of aset of concrete classes. Class conjunctions are used as class interfaces to describe memberwiserequirements and assumptions. A class instantiation Cj represents a new instance of a genericclass, in the <strong>for</strong>m of the generic class name followed by a substitution of type variables with typeexpressions.A command c in rcos/g is similar to those in common imperative languages. We provide structuralconstructors of commands including sequential compositions c; c, conditionals c ⊳ e ⊲ cand while-loops e ∗ c. We require that commands, including assignments, object creations andmethod invocations, should not occur in expressions, so that the evaluation of expressions has noside-effects. We also explicitly <strong>for</strong>mulate variable declarations and undeclarations as commands<strong>for</strong> local scope introductions and cleanups, respectively.A method invocation specifies the method name and the object upon which the method isinvoked, as well as how the value arguments ve are passed to and how the result arguments reare retrieved from the <strong>for</strong>mal parameters x. Upon entering the method, the value of a valueargument is copied to the corresponding <strong>for</strong>mal parameter. And upon leaving the method, thevalue of a <strong>for</strong>mal parameter is copied to the corresponding result argument. For example, themethod invocationo.m(true, 4 • x, y • p.a, q.b)invokes method m upon object o, passing true to x, 4 to y when entering, and retrieving p.afrom x, q.b from y when leaving.Expressions are <strong>for</strong>med from variables, attributes and literals through applications of membernavigations e.a, typecasts (Ce)e and primitive-type functions f(e). We denote the null objectby null, and use the special variable self to point to the currently active object. The set ofl-expressions, ranged over by le, includes variables and navigation paths, which are allowed tooccur on the left-hand side of assignments.To simplify our discussion, all variables, parameters and attributes are initialized with the defaultvalue of their types, specifically, 0 <strong>for</strong> integers, false <strong>for</strong> booleans, ε (empty) <strong>for</strong> text strings andnull <strong>for</strong> all class types.3 <strong>Type</strong> <strong>Graph</strong>sThe class declarations cdecl of an oo program define the structure of the objects of the programin terms of their types and relations. This structure can be <strong>for</strong>mally represented by a directedand labeled graph [9], called a type graph. In this paper, we develop a graph-based type system<strong>for</strong> rcos/g. For this, we extend the model in [9] to capture the extended features of the language.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!