Document Type Master's Dissertation Author Engelbrecht, Roelof Lourens URN etd-10052005-141150 Document Title Implementing a smalltalk to Java translator Degree MSc (Computer Science) Department Computer Science Supervisor
Advisor Name Title Prof D G Kourie Keywords
- Smalltalk 80 computer program language
- translators computer program
- Java computer program language
Date 2002-09-05 Availability unrestricted AbstractA number of essential issues in translating Smalltalk to Java are addressed. The fIrst chapter gives a brief overview of Smalltalk and Java with respect to the relevant language features that will be translated. In the next section a convention is proposed for mapping Smalltalk method selectors to Java method names. The dynamic nature of Smalltalk instance methods is compared with Java's static type model as well as a solution to simulate the dynamic nature of Smalltalk in Java. A Java class hierarchy that parallels the Smalltalk class hierarchy (including the metaclass objects) is suggested. A further proposal is given for translating the dynamic attributes of Smalltalk class methods to the same behaviour to Java. These proposals are used to support ways of mapping both Smalltalk instance methods, as well as Smalltalk class methods to their Java counterparts. Ways of translating Smalltalk class variables, Smalltalk class instance variables and Smalltalk global variables are illustrated.
A method for translating Smalltalk blocks to Java inner classes is implemented using Java exceptions to unwind the call stack. Various types of Small talk blocks are translated with increasing complexity. The various types of blocks translated are simple blocks; blocks with references to variables in the enclosing context; blocks with block arguments; blocks that need to refer to their own context executed from other contexts; blocks with multiple exit points as well as nested blocks. Some performance tests to illustrate the impact of using exceptions in Java are also reported.
The next section introduces the Small talk grammar with the necessary productions used to implement a parser. Lexical and syntax analysis are explained. A brief overview of a recursive descent parser is given where an example of Smalltalk source code is parsed and all the relevant parse nodes illustrated. The encoding in each parse node to Java source is shown.
The last section focuses on similar initiatives being pursued and compares the solutions in the dissertation against them. This dissertation focuses on key areas of the Smalltalk to Java translation process, but a few peculiar and unique Smalltalk features are not addressed. These are discussed in the last section and some suggestions are made on how the translations can be achieved.
© 2002, University of Pretoria. All rights reserved. The copyright in this work vests in the University of Pretoria. No part of this work may be reproduced or transmitted in any form or by any means, without the prior written permission of the University of Pretoria.
Please cite as follows:
Engelbrecht, RL 2002 Implementing a smalltalk to Java translator, MSc dissertation, University of Pretoria, Pretoria, viewed yymmdd < http://upetd.up.ac.za/thesis/available/etd-10052005-141150/ >
Filename Size Approximate Download Time (Hours:Minutes:Seconds)
28.8 Modem 56K Modem ISDN (64 Kb) ISDN (128 Kb) Higher-speed Access dissertation.pdf 3.14 Mb 00:14:31 00:07:28 00:06:32 00:03:16 00:00:16