| www.delorie.com/gnu/docs/smalltalk/gst_21.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
STParser that
can be overridden in different STParser subclasses. This is done
by the compiler itself, in which a subclass of STParser (class
STFileInParser) hands the parse trees to the STCompiler
class.
To build the documentation for the various class libraries, also, Smalltalk source code is interpreted and objects for the classes and methods being read in are created; then, polymorphism allows one to treat these exactly like usual classes. This machinery is contained in two files, `compiler/STLoader.st' (the parser) and `compiler/STLoaderObjs.st' (the classes that implement embryonic classes and namespaces read from the file).
STFormatter.
STPluggableParser and BCode classes.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |