ImageReader
X

Menu
// changed at Mon Jan 06 2014 21:26:39 GMT-0800 (PST) by Dan  
this.addScript(function printObj(oop) {  // this.printObj(0)
    // print first 32 objects
    // for (var oop=0; oop<80; oop+=4) {console.log(this.printObj(oop))}
    // print first 32 classes
    // for (var oop=0x40; oop<0x800; oop+=0x40) {console.log(this.printObj(oop))}
    
    // Decipher and print the object with the given oop
    var str = oop.toString(16) + ": ";
    var entry = this.OTat(oop);  // ot entry
    str += "entry=" + entry.toString(16) + "; ";
    // str += "refct=" + ((entry>>16)&0xFF) + "; ";
    str += "otherBits=" + (entry>>24).toString(2) + "; ";
    var addr = this.dataAddress(oop);
    str += "addr=" + addr.toString(16) + "; ";
    var oClass = this.classOfOop(oop);
    str += "class=" + oClass.toString(16);
    str += "(" + this.classNameOfOop(oop) + "); ";
    var lenBits = this.lengthBitsAtAddr(addr);
    str += "lenBits=" + lenBits.toString(16) + "; ";
    if (this.isPointers(entry)) {
        str += "data={";
        for(var i=1; i<lenBits/2; i++) {
            str += this.shortPrint(this.fieldOfObject(i, oop));
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- ALL --
classNameOfOop
classOfOop
dataAddress
fieldOfObject
integerValueOf
isInteger
isPointers
lengthBitsAtAddr
OTat
printObj
reset
shortPrint
snippets
Scripts
-- ALL --
Connections
+
+
-
-
<lively.morphic.Box#54AD1... - ImageReader>
Tag:
all
run
save
Tests

ObjectEditor
X

Menu
Project Outline
X

Menu
Reviving Smalltalk-76
+
Reading a NoteTaker image
The panel 'ImageReader' has two properties, ot and data, each are JS byte arrays.
Formats
ot is the object table, a sequence of 4-byte entries, retrievable by this.OTat(oop), where oop is an object pointer with the bottom two bits = 0. The entry encodes the data address, along with some other bits including a reference count that we can now ignore. The method dataAddress(oop) will retrieve the address, also taking into account the "dataBias" which I won't explain.
data is the object data space, a sequence of 2-byte words, retrievable by this.fieldOfObject(i, oop), where oop is an object pointer with the bottom two bits = 0, and i is the instance field number, with 1 being the index of the first field. An index of 0 would retrieve the class pointer of an object, but this must be masked by 0xFFC0 because the bottom 6 bits of the class word are used for the object's size in bytes. The method classOfOop will do this for you. This implies that all class oops have zero in the bottom 6 bits. This worked out nicely for OOZE's zones, but we will drop all that and go to the Squeak object format or whatever Bert is using internally. Note that if the size field is zero, then there is a word before the class with a 16-bit length. The method lengthBitsAt decodes this for you. It appears that the size field is the size in bytes, including the class(and size), so a string of length 1 has size=3, and a Point would have a size = 6.
The format of classes is (quoting from the system itself... title "<String> for identification, printing" myinstvars "<String> partnames for compiling, printing" instsize "<Integer> for storage management" messagedict "<MessageDict> for communication, compiling" classvars "<Dictionary/nil> compiler checks here" superclass "<Class> for execution of inherited behavior" environment "<Vector of SymbolTables> for external refs" fieldtype The instsize is an integer (ie low bit = 1) with the following interpretation: 0x8000 - fields are pointers, else not 0x4000 - fields are words, else bytes 0x2000 - instances are variable length 0x0FFE - instance size in words including class Thus Point has instsize = 0x8006 and Float has instsize = 04008 (nasty 3-word binary format)

The current strategy is first to read and decipher a NoteTaker image. Then we will get it running, as is, in Bert's SqueakJS, with Helge's code as a guide to particularities of the ST-76 VM and primitives. Then we should rescue the original source code by deciphering one of the full ST-76 systems or simply locating an appropriate sources file. Hopefully we can also reinstate the simple class context that got replaced in the NoteTaker.
We begin by capturing and deciphering a NoteTaker image as manifest in the pair of files, ObjectTable.nt and ObjectSpace.nt. This is the purpose of the 'ImageReader' panel.
Current State of things
In the Object Editor, the method printObj has two executable comments at the top. The first will print the first 32 objects in the image, the second will print the first 32 classes.