3 Slots can be used to store object references. There are four diffrent types
4 of slots with differing lifetimes. All slots except parameters are initially
7 - Fields: Lifetime is from creation of object to until it is garbage
9 - Parameter: Lifetime is from sending message to until that message is
11 - Local: Lifetime is from start of message handler to end of message handler.
12 - Stack: Lifetime is from pushing reference to until it is popped or message
13 handler ends, whichever comes sooner.
15 Trying to read nonexistent slot results NIL. Trying to write to nonexistent
16 slot just discards that value.
20 Special registers can store single value of some type. Their lifetime is the
21 same as for local slots.
23 - Number register: Is initialized to 0 and used as index to field, parameter
24 and local slots and classes. Data type is integer.
25 - Alternative mode flag: Is initialized to clear (alternative mode not in
28 Comments and line continuations:
29 ================================
30 If '\' is encountered anywhere, all whitespace characters until next non-
31 whitespace character are ignored, even newlines. This can be used for
34 Any given logical line (which can span multiple physical lines if '\' is
35 used) are either comment or class declaration. If logical line is empty or
36 it has '#' as first nonwhitespace character, it is treated as comment.
38 Character set used is always ASCII, but using characters with bit 7 set
39 won't trigger error in comments.
43 Classes are numbered from 0 upwards. Each new class encountered gets number
44 one higher than previous (first getting number 0). These numbers are used
45 to refer to class in 'N' instruction. On start of program, class #0 is
46 instantiated and message is sent to instatiated object with three parameters:
47 stdin, stdout and stderr (in this order).
49 Class declaration syntax is as follows: First two numbers in base-10
50 notation using '0'-'9' seperated using whitespace. First of them is number of
51 fields and second is number of locals for message handler. Then optionally
52 comes whitespace and character string containing instructions for message
53 handler (one instruction per character).
57 In alternative mode, '+', '-' and 'E' retain their meanings. Other instructions
58 just become 'clear alternative mode flag' instructions.
60 + Increment number register.
61 - Decrement number register.
62 E Pop two elements off the stack. If they are equal, enter
64 f Pop element off the stack and store to field whose number is
65 in number register. Trying to store to nonexistent field just
67 F Load value from field whose number is in number register and
68 push it to stack. Trying to read from nonexistent field just
70 l Like f, but uses locals instead of fields.
71 L Like F, but uses locals instead of fields.
72 p Like f, but uses parameters instead of fields.
73 P Like F, but uses parameters instead of fields.
74 s Pop element off the stack, designating a object to send message
75 to. Then pop parameters in order from first to last to pass in
77 S Push reference to current object to stack.
78 N Create object of class pointed by number register and push
79 reference to stack. The object will be garbage-collectted when
82 Stdout/Stderr objects:
83 ======================
84 Stdout/Stderr objects accept 8 parameters. They check for each parameter if it
85 is NIL and convert the result MSB first to 8-bit number (where 1 is non-NIL,
86 0 is NIL) and output it.
90 Stdin object accpets single parameter. It after waiting for character sends
91 message with 9 parameters to designated object. First parameter is NIL if EOF
92 is encountered, non-NIL otherwise. If first parameter indicates not EOF, then
93 the remaining 8 are read character, as in stdout/stderr.
97 When garbage collector destroys all objects, the program halts.
101 # Hello, World! Program.
102 0 0 +LLLSLLSLPsSLSLLSSLPsLLSSLSSLPsLLSSLSSLPsSSSSLSSLPsLLSSLSLLPsLLLLLSLLPsSSS\
103 LSLSLPsSSSSLSSLPsLSLLSSSLPsLLSSLSSLPsLLSLLSSLPsSLLLLSLLPsLSLSLLLLPs
108 2 2 FlFEPF+LEf-F+EP-F+LE-fL+LENL-LE+lL-l++L-l-P+LENL-PE+lL-p++L-l+++++++P-P-P-\
109 P-P-P-P-P-FP+LL-LEEsS+F-P+LEs
111 *******************************************************************************
116 # If F0 == NULL, F1 <= P0
118 # If F0 == NULL, F0 <= P1
128 # PUSH P8,P7,P6,P5,P4,P3,P2,P1,F0
129 ++++++++P-P-P-P-P-P-P-P-F
130 # If P0 == NULL && L0 == NULL, SEND
134 # If P0 == NULL, SEND
139 L++l-L-LE[dummy]L+LE+lL-l