www.delorie.com/gnu/docs/smalltalk/gst_21.html   search  
Buy GNU books!

GNU Smalltalk User's Guide

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.7.2 The Smalltalk-in-Smalltalk compiler

The Smalltalk-in-Smalltalk compiler is a nice compiler for Smalltalk code which is written in Smalltalk itself. Ideally, the C compiler would only serve to bootstrap the system, then a fully working Smalltalk compiler would start compiling methods.

The current status of the Smalltalk-in-Smalltalk compiler can be summarized thus: it does work, but it does not work well. This for many reasons: first of all it is slow (10-15 times slower than the C compiler), and it does not produce very optimized code. Anyway it is a good example of programming the GNU Smalltalk system, and its source code (found in the `compiler' directory) provides good insights into the Smalltalk virtual machine: so, after all, it is not that bad. If want to give it a try, just file in the Compiler package.

The compiler is built on a recursive descent parser which creates parse nodes in the form of instances of subclasses of STParseNode. Then the parser instantiates a compiler object which creates the actual method; more information on the inner workings of the compiler can be found in the comment for the STCompiler(6) class.

The parser's extreme flexibility can be exploited in three ways, all of which are demonstrated by source code available in the distribution:

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003