Jason Orendorff
Jason Orendorff

Reputation: 45086

How can I dump all the source code from a Squeak Smalltalk image?

I’ve downloaded the source code of Scratch, which is written in Squeak Smalltalk. I can browse the source in Squeak, but what I really want is a big text file. The image is based on Squeak 2.8.

I’m a total Squeak newbie. So far, I’m loving it, and my impression of the language and environment is that dumping all the source code in this image to a file can probably be done in about 3 lines of code, if only I knew my way around better. Can you supply the 3 lines of code?

I won’t complain if it ends up being 4 lines (or more likely, 1 line).

Upvotes: 4

Views: 908

Answers (1)

Bernat Romagosa
Bernat Romagosa

Reputation: 1202

Untested, but:

Smalltalk allClasses do: [:each | each fileOut]

This should dump three million .st files, named after each class in the system.

Welcome and happy smalltalking!

EDIT: As it seems, this wouldn't work in early squeaks, I've been testing around and it looks the following should work in a Scratch source code image:

SystemOrganization categories do: [:each | SystemOrganization fileOutCategory: each]

Upvotes: 7

Related Questions