carolahp / PharoCandle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PharoCandle

WARNING: This project contains the current development branch of PharoCandle.
For a stable version, check other branches.

PharoCandle is a minimal Pharo distribution, based on MicroSqueak, work of John Maloney. This distribution is currently for research purposes, but you can take it and use it for your own purposes.

The main purpose of this project is the Bootstrap of a PharoCandle image using the sourcecode under the source folder. In order to bootstrap, we need to install the bootstrap library into a Pharo environment. Look at installation and usage for more details.

Installation

In order to download the complete environment to bootsrap PharoCandle, there is only need for execute the following bash script on the master folder.

build/build.sh

Once downloaded and built, a results folder will be created. The results folder will contain a complete Pharo environment, with the following files:

  • pharo_vm: a folder containing the Pharo Virtual Machine
  • pharo and pharo_ui scripts to run the VM
  • PharoCandleBootstrap.image: Pharo 2.0 image file with the pharo candle project installed
  • PharoCandleBootstrap.changes: the changes log of the correspondent image with the same name
  • package-cache: a folder for caching Pharo's monticello packages

Usage

To create a PharoCandle image from source code, we bootstrap it following the process described in here. To run the bootstrap you need to open the PharoCandleBootstrap.image with the VM supporting ui. That can be done in the command line with the following script:

cd results
pharo-ui PharoCandleBootstrap.image

The Pharo image will contain the Pharo 2.0 welcome workspace, and a workspace with the code to run the PharoCandleBootstrap.

Load the sourcecode into the image:

seed := PharoCandleSeed new
    fromDirectoryNamed: '../source';
    buildSeed.

Create an object space that will use an AST evaluator to run code during the bootstrap. An objectspace is an object enclosing the bootstrapped image.

objectSpace := OzObjectSpace onOzVM.
objectSpace withExternalSymbolTable. "we need this to bootstrap"
objectSpace worldConfiguration: OzPharoCandle world.
objectSpace interpreter: (AtASTEvaluator new codeProvider: seed; yourself).

Create a PharoCandle builder, and tell it to bootstrap. Voilá, the objectSpace will be full

builder := PharoCandleBuilder new.
builder objectSpace: objectSpace.
builder kernelSpec: seed.
builder	buildKernel.

Browse the bootstrapped objectSpace by evaluating

objectSpace browse.

You can serialize the objectSpace into an image file (Cog format) by evaluating

objectSpace serializeInFileNamed: 'PharoCandle.image'.

PharoCandle's Overview

PharoCandle is a minimal Pharo distribution containing only 49 classes. Those 49 classes define a whole Pharo kernel including classes such as PCString, PCObject, PCClass or PCSmallInteger. Additionally, it contains a minimal Collection library. PharoCandle classes are prefixed with 'PC' only for documentation purposes, but the prefix is not necessary for the bootstrap.

When run, a PharoCandle image runs the method PCSystem>>start. This method satisfies the role of a main method of other languages. The current distribution's start method is as:

PCSystem >> start
	self log: 'Welcome to Pharo Candle edition!'.
	self log: self tinyBenchmarks.
	self log: PCForm new primScreenSize printString.
	self beep.
	PCObject superclass ifNil: [ self quit ]

Currently, to run a PharoCandle distribution, a special VM is needed that allows the context switch between different images inside the same VM process. The ability for serializing an image into a file will be re-added soon.

TODOs

  • Autogenerate this script :)

About

License:MIT License


Languages

Language:Smalltalk 98.8%Language:Shell 1.2%