Angel \”Java\” Lopez on Blog

December 22, 2008

AjTalk: my Smalltalk-like interpreter project updated

Filed under: .NET, AjTalk, C Sharp, Smalltalk — ajlopez @ 7:30 am

I committed new code to my Google code project AjTalk:

The previous version was described in my post

AjTalk- a Smalltalk-like interpreter

It’s an interpreter written using C#. This post describes the work in progress in this solution:

There are interfaces and base classes to support objects and classes:

Every method is compiled to bytecodes. Block and Method are the classes that contains bytecodes programs:

Blocks are anonymous code block. A Method has name and belongs to a class.

The bytecodes are described in an enumeration:

using System; namespace AjTalk { public enum ByteCode : byte { Nop = 0, GetVariable = 1, SetVariable = 2, GetArgument = 3, SetArgument = 4, GetConstant = 5, GetLocal = 6, SetLocal = 7, GetClassVariable = 8, SetClassVariable = 9, GetGlobalVariable = 10, SetGlobalVariable = 11, GetBlock = 12, GetSelf = 20, GetClass = 21, GetSuperClass = 22, NewObject = 23, Pop = 24, ReturnSub = 25, ReturnPop = 26, Add = 40, Substract = 41, Multiply = 42, Divide = 43, Send = 50 } }

In this committed version, there is support to create and access .NET objects. You can write

@System.IO.FileInfo new: ‘aFile.txt’

to create a new .NET object (@ is used to mark a name with special chars like ‘.’).

In this version, I added support to load .st files. It’s not an standard .st file: I will use this files to define the initial class library. Now, there are used only in tests. An example:

nil subclass: #Figure instanceVariables: 'x y' !Figure methods! x ^x ! y ^y ! x: newX x := newX ! y: newY y := newY ! ! Figure subclass: #Rectangle instanceVariables: 'width height' !Rectangle methods! width ^width ! height ^height !

 I bootstrapped the system with a global nil variable. In the loader tests, the nil variable is bound to understand messages like subclass: and ifFalse:.

I changed the unit test to use VS test support. All in green:

The code coverage is good, 84.29%:

I added support to blocks in method, but there is no parameter support, yet:

nil ifFalse: [GlobalName := ‘foo’]

Next steps

The proposed roadmap is:

– Add more .NET object support

– Write the initial class in base library

– Implements Class, Metaclass, Behaviour “a la” Smalltalk-80

– Load initial library in console application

– Invoke AjTalk from .NET application

– Implements indexed variables

– Extends the bytecode set

As usual, I had fun written this code!

Angel “Java” Lopez

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: