Hi,
I'm trying to get source cod for squeak to poke around and see if I can do anything interesting. I downloaded Squeak*.sources file from www.squeak.org, which is just a huge text file that I can't decipher. Then I wandered around a bit more, and found out that much of the code can be generated automatically from Squeak itself. Could anyone tell me how to do this? (Apparently this is not easy to find on the web) Also, if you have a link to a source tar file, I would appreciate it, but I still want to see automatic generation of the code. Thanks. -Seung |
Seung H. Choi wrote on Mon, 6 Feb 2006 10:19:20 -0500
> I'm trying to get source cod for squeak to poke around and see if I > can do anything interesting. I downloaded Squeak*.sources file from > www.squeak.org, which is just a huge text file that I can't decipher. If you mean by "can't decipher" that the text looks all messed up (on huge line) then that is just because it uses the Macintosh encoding. On a Unix system you can do tr '\r' '\n' <*.sources | less to read it and in Windows the Notepad program has problems but the Wordpad one should work just fine. If, on the other hand, you mean that all those exclamation points don't make any sense to you then you would have to read about the Smalltalk-80 chunk format. It is pretty simple and actually reasonably readable but only very rarely do we actually look at code that way (see below). Note that these sources are for the parts of the system written in Smalltalk (which is most of it), meaning things like how the method called "add:" is implemented for Sets. There is another set of sources which are for the virtual machine. I am supposing you are not currently interested in that. > Then I wandered around a bit more, and found out that much of the code > can be generated automatically from Squeak itself. Could anyone tell > me how to do this? (Apparently this is not easy to find on the web) You need to execute Squeak and for that you will need at least two files: - squeak.exe (or just squeak, depending on your OS) which is the virtual machine I mentioned above - squeak3.8.image (or a similar name) which is the saved state of some previous execution With just these two files (drag the image to the .exe or whatever is the proper way of starting up on your OS) the system will run after making some complaints about not finding the sources files. Several tools inside of Squeak, of which the main one is the "system browser", allow you to see the source code for anything you want in the system. You can select the class "Set", for example, and all the methods it implements will be listed and you can select "add:" from there. But since the needed source files are missing, the system will automatically decompile from the virtual machine language (we call that "bytecodes") back to the Smalltalk source for you. It won't have any comments nor will it know the same of some variables (so it calls them "t1", "t2" and so on) but other than that it will be very close to the original source. That is what you might have heard of as "generated automatically". It would be possible to write a few lines of code to do that for everything in the system and dump that to a file but the result would be almost exactly like the .sources file you already have except a bit worse. The sources are actually stored into two separate files, of which the .sources one which you already have includes all the methods which existed when Squeak 3.0 was released. Whenever you write your own code, the source for that gets saved to a .changes file with a name corresponding to your .image file. So a squeak3.8.changes file would have the sources for everything done from Squeak 3.1 forward as well as anything you have done yourself. So the best way to develop in Squeak is to have a set of four files like this: - squeak.exe - squeakV3.sources - squeak3.8.image - squeak3.8.changes > Also, if you have a link to a source tar file, I would appreciate it, > but I still want to see automatic generation of the code. You already have the "tar" and you won't find the automatic generation of sources interesting at all. Unless you are interested in the virtual machine rather than Squeak. In that case the sources can be found in the SVN server (see http://www.squeakvm.org/) and also in the Squeak package called VMMaker (in earlier versions of Squeak this was part of the standard images). The main part of the virtual machine is written in a subset of Smalltalk (we call it "Slang") and is automatically translated into C. So if this is what you mean by "automatic generation of the code" you will probably want to start by reading the "Back to the Future" paper: http://users.ipa.net/~dwighth/squeak/oopsla_squeak.html -- Jecel |
Free forum by Nabble | Edit this page |