Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!husc6!linus!philabs!pwa-b!mmintl!franka
From: franka@mmintl.UUCP (Frank Adams)
Newsgroups: comp.lang.smalltalk
Subject: Re: literals
Message-ID: <2255@mmintl.UUCP>
Date: Thu, 23-Jul-87 17:16:04 EDT
Article-I.D.: mmintl.2255
Posted: Thu Jul 23 17:16:04 1987
Date-Received: Sat, 25-Jul-87 21:45:23 EDT
References: <938@argus.UUCP> <80500010@uiucdcsp> <805@unc.cs.unc.edu>
Reply-To: franka@mmintl.UUCP (Frank Adams)
Organization: Multimate International, E. Hartford, CT.
Lines: 46

In article <805@unc.cs.unc.edu> steele@unc.UUCP (Oliver Steele) writes:
>In article <80500010@uiucdcsp> johnson@uiucdcsp.cs.uiuc.edu writes:
>>jan@tekchips says that if I want constants, I should make them by subclasses.
>>That is exactly my complaint.  The flaw in Smalltalk is that I cannot.
>
>This isn't the problem.  I just created ConstantString and ConstantArray,
>....  Then I changed Scanner|xStringLit and Scanner|scanVector ...
>to return their contents asConstantString and asConstantArray ...

This is fine for Smalltalk/80[TM].  Unfortunately, the folks at Digitalk saw
fit to hide their compiler.  This is the only serious complaint I have about
Smalltalk/V[TM].

Not so incidently, I have reverse-engineered their compiler, and now have
source code for everything on my system.  At some point, I will try to
separate this from all the other changes I have made, and maybe even post it
(if there is sufficient demand).  Don't expect it any time real soon, though.

Some hints if you wish to try this yourself:

The compiler is in a group of classes whose names are all blank (e.g, 
"'  ' asSymbol").  There are various places in the system which skip over
all classes with such names -- notably the Class Hierarchy Browser; also a
method in SystemDictionary called (if I remember right) "getSourceClasses".

The first 3 bytes of a CompiledMethod are header information.  The first
byte is the primitive number.  The second byte represents the number of
local variables, including block arguments.  This byte is ones-complemented
if the method contains blocks which are not optimized away.  The third byte
is the number of arguments to the method.

The last 3 bytes of a compiled method are the pointer to the source code.
They will be zero for those methods for which the source code is unavailable.
If the 4th byte from the end is less than 134, it is the size of the literal
table immediately preceding; otherwise there is no literal table.  The
literal table is used only by the memory manager; literals used by the
method are encoding directly in the byte code stream as necessary.

The Smalltalk/V[TM] virtual machine is similar to that of Smalltalk/80[TM],
but uses entirely different byte codes.  The byte code set is sparse.  Note
that different byte codes are used for accessing local variables and for
returning in methods which have blocks.
-- 

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Ashton-Tate          52 Oakland Ave North         E. Hartford, CT 06108