This chapter covers the prelude — the Rexx part of the REXX package,
taken from ooRexx's own CoreClasses.orx and
StreamClasses.orx — how it is built and regenerated for
both hosts, and the class library seen by programs: which classes and
methods are native and which are Rexx, the notable behaviours of the
collections, Stem, String and MutableBuffer, and the iteration order of
hashed collections. It assumes the object model of 08-objects.md (behaviours, natives, delegation,
conversions) and the R-code cache of 03-compiler.md. Streams,
.File and RexxQueue are in 13-io-and-commands.md.
In native ooRexx the REXX package is built at image-build time from
C++ classes plus CoreClasses.orx (which in turn calls
StreamClasses.orx and PlatformObjects.orx).
The RVM does the same: the primitive classes are built by
RVM.World~init / World constructor with native
methods (08);
everything that ooRexx writes in Rexx is ooRexx's own Rexx
source, compiled by the RVM's compiler and loaded as the
prelude.
| File | What it is | Loaded as |
|---|---|---|
../prelude.orx |
CoreClasses.orx cut by makeprelude.rex,
with prelude-rvm.orx appended after its last line |
the REXX package (program name REXX) |
../prelude-rvm.orx |
the RVM's own part: class RVM.ArraySort and routine
SortArray |
(inside prelude.orx) |
../prelude-streams.orx |
StreamClasses.orx cut the same way:
InputStream/OutputStream/InputOutputStream mixins, Stream,
StreamSupplier, RexxQueue, File |
a second program, REXX too, whose public classes become
the REXX package's |
../prelude.orx.rcode,
../prelude-streams.orx.rcode |
their R-code (the ordinary .rcode cache), shipped |
ooRexx host |
../js/rvm-prelude.mjs, ../js/rvm-prelude-streams.mjs |
the same R-code as JS string constants PRELUDE_RCODE,
PRELUDE_STREAMS_RCODE |
JS host (Node and browser) |
makeprelude.rex copies the source line by line and
blanks what it removes instead of deleting it, so every
remaining line keeps its number in the ooRexx file. What it changes:
CoreClasses.orx: only the two prolog lines that call
other files (call 'StreamClasses.orx' rexxPackage,
call 'PlatformObjects.orx' rexxPackage; any prolog line
containing .orx'). Every class is kept, and the prolog
itself runs (Loading). The list of dropped
classes (dropped) exists in the script but is empty.StreamClasses.orx (second argument
streams): its leading copyright box is kept, its prolog is
blanked (its job — registering the public classes — is done by
ensurePrelude), and RexxQueue's
::METHOD linein EXTERNAL 'LIBRARY REXX rexx_linein_queue'
becomes UNGUARDED (native rexx_linein_queue
releases the guard while it waits; the RVM has no way for a native to do
that).prelude.orx only: prelude-rvm.orx (read
from the directory of makeprelude.rex itself, via
PARSE SOURCE) is appended after the last line of
CoreClasses.orx.Because the lines match, an error inside a prelude method is reported exactly as natively (verified in both hosts):
477 *-* Method UNION with scope "Set" in package "REXX" (no source available).
2 *-* say s~union()
Error 93 running REXX line 477: Incorrect call to method.
Error 93.901: Not enough arguments for method; 1 expected.
The clauses of the prelude carry no source text
(ensurePrelude sets each clause's text to
.Nil; the program's source is
.Nil), which gives the "(no source available)" form.
Prelude methods run with their own package's settings, so a user
TRACE I does not trace inside them (as natively).
CoreClasses.orx ──makeprelude.rex──► prelude.orx ──rvm -l──► prelude.orx.rcode ──genprelude.rex──► js/rvm-prelude.mjs
(+ prelude-rvm.orx appended)
StreamClasses.orx ──makeprelude.rex streams──► prelude-streams.orx ──► prelude-streams.orx.rcode ──► js/rvm-prelude-streams.mjs
CoreClasses.orx and StreamClasses.orx are
not in this repository: they are ooRexx's, in its
source tree under interpreter/RexxClasses/. Take them from
ooRexx's Subversion repository at the revision of the native ooRexx used
as the oracle (rexx -v prints it, e.g. r13237;
the shipped prelude files are reproduced byte for byte from that
revision):
REV=13237 # the r number printed by rexx -v
URL=https://svn.code.sf.net/p/oorexx/code-0/main/trunk/interpreter/RexxClasses
svn export -r $REV $URL/CoreClasses.orx OOREXX/interpreter/RexxClasses/CoreClasses.orx
svn export -r $REV $URL/StreamClasses.orx OOREXX/interpreter/RexxClasses/StreamClasses.orx
(svn export writes LF line endings;
makeprelude.rex gives the same output for a CRLF copy.)
Then, from bin/modules/rvm/:
rexx makeprelude.rex OOREXX/interpreter/RexxClasses/CoreClasses.orx > prelude.orx
rexx makeprelude.rex OOREXX/interpreter/RexxClasses/StreamClasses.orx streams > prelude-streams.orx
./rvm -l prelude.orx > prelude.orx.rcode
./rvm -l prelude-streams.orx > prelude-streams.orx.rcode
cd js
rexx genprelude.rex ../prelude.orx.rcode > rvm-prelude.mjs
rexx genprelude.rex ../prelude-streams.orx.rcode PRELUDE_STREAMS_RCODE > rvm-prelude-streams.mjs
./rvm -c prelude.orx writes the same
prelude.orx.rcode. The launcher ./rvm sets
REXX_PATH so that rvm.rex finds the parser; a
bare rexx rvm.rex -l ... needs REXX_PATH
pointing at bin/ (otherwise 43.901 on
parser.cls). Compiling the prelude in the ooRexx host takes
about 10 seconds; loading its R-code a fraction of that.
Both generators write the name of their input file into what
they make: makeprelude.rex into the copyright box ("Derived
from ooRexx's CoreClasses.orx"), genprelude.rex into the
header ("the R-code of prelude.orx"). The inputs must therefore keep
their names (CoreClasses.orx,
StreamClasses.orx, prelude.orx.rcode,
prelude-streams.orx.rcode; the directory does not matter)
for the output to be byte-identical to the shipped files.
genprelude.rex FILE [CONST] checks the input starts with
RCODE, writes a CPL header box (CPLHeader: the
content derives from ooRexx), then
export const CONST = [ ...lines... ].join("\n"); with each
line JS-escaped, and replaces the PROGRAM line by
PROGRAM "REXX". The .rcode files
themselves contain the absolute path of the .orx they were
compiled from in their PROGRAM line; that line is not part
of the cache check (RCODE, COMPILER,
SOURCE; see 03) and the loader renames the
program REXX anyway, so the shipped caches work on any
machine.
The pipeline is deterministic: re-running it on the same inputs
reproduces the shipped prelude*.orx, .rcode
(except the PROGRAM path) and .mjs byte for
byte.
When to regenerate:
| Change | Redo |
|---|---|
CoreClasses.orx / StreamClasses.orx (new
ooRexx) or makeprelude.rex |
all steps |
prelude-rvm.orx |
prelude.orx, its .rcode,
rvm-prelude.mjs |
RVM.Compiler~VERSION, RVM.ISA~VERSION,
RVM.RCode~VERSION, or any compiler change that alters
generated code |
both .rcode and both .mjs |
Changing only prelude-rvm.orx without the ooRexx
files. prelude.orx is the cut
CoreClasses.orx followed by prelude-rvm.orx,
so it can also be rebuilt from itself: keep its first N lines,
where N is its line count minus that of
prelude-rvm.orx before the edit, and
append the edited prelude-rvm.orx:
n=$(( $(wc -l < prelude.orx) - $(wc -l < prelude-rvm.orx) )) # before editing
# ... edit prelude-rvm.orx ...
{ head -n $n prelude.orx; cat prelude-rvm.orx; } > prelude.orx.new && mv prelude.orx.new prelude.orx
This gives the same file makeprelude.rex makes. A new
method there is reachable from its target class only once
World~bootstrap copies it there, in both hosts (Native versus Rexx, 21).
A stale .rcode in the ooRexx host only costs a
recompilation on each run (it is rewritten with rvm -w). In
the JS host readRCode checks only the R-code format and ISA
versions of the embedded text (a mismatch is 93.900 "compile the program
again" on the first object use); a compiler change that keeps both
versions, or an edited prelude.orx, is not
detected: regenerating the .mjs files is part of any
compiler or prelude change (20-maintaining.md).
Licensing of the generated files (CPL headers from
genprelude.rex, makeprelude.rex keeping the
StreamClasses box, rvm-data.mjs from
gendata.rex): 19-licensing.md.
gendata.rex../js/gendata.rex is the
other generator of the JS host (run as
REXX_PATH=.../bin rexx gendata.rex > rvm-data.mjs). It
is not part of the prelude: it writes ERROR_TEXT (ERRORTEXT
0–99), SECONDARY (the host's ErrorText of
every code that has one), BIF_INFO (argument signatures
from .Parser.BIFInfo) and MESSAGES (the host's
SysGetMessage texts 1–1999, if REXXUTIL is available).
Regenerate it when the error texts or the BIF table of the parser change
(06, 11).
The mechanism is in 08 and 05; in brief,
RVM.World~ensurePrelude / World.ensurePrelude
runs the first time something is not found natively (a method lookup
miss, an environment symbol, ISA, HASMETHOD,
INSTANCEMETHOD, SUPERCLASSES, REQUEST, a
COMPARETO sort, .local, any message to
.environment, DO OVER it...):
RVM.PreludeLoader~load
(loadFile("prelude.orx") through LoadProgram,
so the cache is used; JS: loadText(PRELUDE_RCODE)); path
set to REXX, no source.installNow makes its classes without the machine; each
is marked rexx (a class of the REXX package: DEFINE/INHERIT
later → 98.985).bootstrap: copies RVM.ArraySort's methods
into Array (Sorting).building = .True;
loader~runProlog(program, REXX package object) runs the
CoreClasses prolog synchronously (RVM.Machine~runSync) with
the package as its argument, exactly as ooRexx's image build:
addClass of LocalServer, SupplierMixin, ManyItemMixin,
SetMixin, BagMixin; object names of .environment and the
package;.environment and
addPublicClass;.String~defineClassMethod;inheritInstanceMethods: SupplierMixin into Supplier,
ManyItemMixin into Relation and Bag, SetMixin into Set, BagMixin into
Bag (methods copied with the receiving class as scope);INHERITs: String ← Comparable; Array, List, Queue
← OrderedCollection; IdentityTable, Table, StringTable, Directory,
Relation, Set, Bag, Stem ← MapCollection; Set, Bag ← SetCollection;
Message ← MessageNotification, AlarmNotification.building is set the REXX package accepts additions
(otherwise 98.984) and its classes accept INHERIT/DEFINE.refresh rebuilds every behaviour in
place, so objects created before (strings, arrays of the program...) see
the new methods.loadStreams (when prelude-streams.orx
exists) is installed the same way, after MergeRequired
makes the prelude's classes visible to it; its classes join the
prelude's classObjs, and its public classes the package's
publicClasses and .environment.There are three kinds of implementation (see also 08):
| Kind | Where | Traceback line | Traced |
|---|---|---|---|
| Native method | CallNative (RVM.Objects.cls) /
callNative (objects.mjs), keyed
FAMILY.WHAT |
*-* Compiled method "M" with scope "C". when it leads
to user code or raises |
no |
| Prelude method (ooRexx's Rexx) | prelude.orx, prelude-streams.orx |
NNN *-* Method M with scope "C" in package "REXX" (no source available). |
no |
| RVM compiled method | prelude-rvm.orx, copied with
compiled = .True |
one Compiled method line, its clauses hidden
(KeepNativeLines, context~hidden) |
no |
The rule. A native never calls user code (the
machine is never nested: 05). So the
split follows ooRexx — what ooRexx writes in Rexx is Rexx here too, from
its own source — with one exception: what is native in ooRexx
but calls Rexx code (Array's SORTWITH, and
SORT/STABLESORT of objects with a COMPARETO) is written in Rexx in
prelude-rvm.orx and dressed as the compiled method it is
natively. EXTERNAL 'LIBRARY REXX f' methods of the prelude
(Alarm/Ticker timers, the
stream_*/file_*/rexx_*queue*
methods) dispatch to the X.f natives (07, 13).
Natives that need a user method's result (an object index with a Rexx
HASHCODE or ==; STRING/MAKESTRING conversions) obtain it
either by re-execution (NeedString, 08) or by a synchronous
send (PreludeLoader~sendSync /
loader.sendSync).
Implementation per host: "host" means the ooRexx host stores a host
ooRexx object of the same class as the RVM object's native
and forwards most methods to it (family key *.HOST), so
checks, errors, capacities and ordering are ooRexx's own; "port" means a
JS class porting the ooRexx C++.
| Class | ooRexx host native | JS native | Rexx in the prelude |
|---|---|---|---|
| String | host string, S.* / B.n /
OP |
JS string, stringMethod |
class constants NL...XDIGIT; Comparable |
| MutableBuffer | RVM.MBuffer (MBufferNative) |
MBuffer (mbufferNative) |
— |
| Array | host .Array (V.HOST) +
V.* |
RArray (arrayNative) |
OrderedCollection, Collection; SORTWITH etc. from
prelude-rvm.orx |
| List | host .List (L.HOST,
ListNative) |
RList (listNative) |
OrderedCollection |
| Queue | host .Queue (L.HOST) |
RQueue (queueNative) |
OrderedCollection |
| CircularQueue | — | — | entirely (subclass of Queue) |
| Directory, StringTable | host .Directory (D.*) |
RexxMap |
MapCollection |
| Table | host .Table |
TableMap |
MapCollection |
| IdentityTable | host .IdentityTable |
TableMap, kind IDTABLE |
MapCollection |
| Set, Bag, Relation | host .Set/.Bag/.Relation
(H.HOST, HashNative) |
RHash (hashNative) |
SetMixin / BagMixin / ManyItemMixin; MapCollection, SetCollection |
| Supplier | RVM.SupplierState (U.*) |
SupplierState |
SupplierMixin (ALLITEMS, ALLINDEXES, SUPPLIER) |
| Stem | RVM.Stem (StemNative) |
Stem (stemNative) |
MapCollection |
| Properties, TraceObject | (Directory, StringTable) | (same) | entirely |
| Comparable, Orderable, Comparator and its subclasses, DateTime, TimeSpan, Validate, ArgUtil, Singleton, Monitor, Alarm, Ticker, MessageNotification, AlarmNotification, LocalServer | — | — | entirely |
| Stream and mixins, StreamSupplier, RexxQueue, File | — | — | entirely (prelude-streams.orx), natives
X.* |
The instance and class methods each class defines
(.C~methods(.C), .C~instanceMethods(.C)) are
native's for every class of .environment (test
cls-methlists). Natives the RVM needs that ooRexx inherits
are not added to a class: String has no STRING of its own (Object's
gives a String-subclass instance its value, as
RexxString::stringValue), and Array's APPENDALL is
OrderedCollection's, in the prelude. Class's HASHCODE is its id's, as
native's; Pointer has its comparisons and ISNULL, though no pointer
exists (NEW: 93.967).
NEW of the collections is their own class method (a
traceback names the class, e.g. scope "List"); argument errors of NEW
come from INIT, as natively. A List/Set/Bag/Relation's contents are made
by INIT (with its capacity); if a subclass's INIT does not forward, the
default contents are made on first use (ListNative,
HashNative, hashContents), as native does
after NEW.
All 117 native methods exist. The spec table in
StringMethods / stringMethods maps each name
to:
B.n — a method with a built-in function of the same
name: the receiver is inserted as argument n (POS, LASTPOS,
COUNTSTR, WORDPOS, CHANGESTR, INSERT, OVERLAY: 2; most others: 1) and
the BIF is called;S.name — methods without a BIF (CASELESS*, STARTSWITH,
MATCH, MODULO, ?, ROUND, ENCODEBASE64, [],
APPEND, SUBCHAR, MAKEARRAY...);OP — the operators (StringOperator, which
converts the argument to a number for arithmetic:
'1'~'+'(2)).Argument checking follows ooRexx's String methods:
RVM.StringArgs~specs / STRING_ARGS give, per
method, the kind of each argument (S required string,
s optional, P/p position,
L/l length, n number,
d pad, o:LIST option, t:LIST
DATATYPE type, *, M, # checked by
the method). StringMethodArgs checks too many arguments
first (93.902), then each in order: missing 93.903, no string value
88.909, position 93.924, length 93.923, non-negative 93.906, pad 93.922,
option 93.915. A BIF error raised inside a B.n method is
turned into the method's error (BifMethodError carried in
ADDITIONAL; C2D/X2D 40.35 → 93.936/93.935), so
'abc'~left(-1) is 93.923. The BIFs that ooRexx runs as
these methods run StringMethod too, after their own checks,
so LEFT('abc',-1) is 93.923 as well (11). Receiver checks: ABS, SIGN, TRUNC,
FORMAT, MAX, MIN, MODULO 93.943; X2*/B2X 93.931–93.934,
93.976/93.977.
String subclasses, conversions and NOSTRING are in 08; string values and arithmetic in 02.
Port of MutableBufferClass.cpp. The native value is
RVM.MBuffer / MBuffer: text,
capacity cap (ooRexx's bufferLength, shown by
GETBUFFERSIZE) and dflt (default size);
ensure(added) grows it as ensureCapacity does
(to max(needed, 2·cap)). Methods that change the buffer
(APPEND, INSERT, OVERLAY, REPLACEAT, []=, DELETE/DELSTR,
SETTEXT, SETBUFFERSIZE, CHANGESTR, UPPER, LOWER, TRANSLATE, SPACE,
DELWORD...) are implemented in MBufferNative; the others
call the String method of the same name on the text (ooRexx's use the
same StringUtil code). Arguments are checked as String's
(RVM.StringArgs), REPLACEAT and []= by name
(88.901, 88.912, 88.911, 88.910). Native quirks reproduced: DELETE's
default length is computed from the capacity, not the text; a growing
CHANGESTR ensures the result length; SPACE compacts then ensures.
.mutableBuffer~new('abcdef', 4)~getBufferSize is 6;
appending 2 makes it 12.
.Array; most methods ([], []=,
AT, PUT, APPEND, INSERT, DELETE, REMOVE, ITEMS, SIZE, DIMENSION(S),
FIRST/LAST/NEXT/PREVIOUS, FIRSTITEM/LASTITEM, HASINDEX, ISEMPTY, EMPTY,
FILL, ALLITEMS, ALLINDEXES, MAKEARRAY, SECTION) are the host's
(V.HOST): the same checks and messages.RArray, a port of
ArrayClass.cpp (items 1..size, last,
count, dims). A multidimensional array is the
flat array with the first subscript varying fastest
(multiIndex: 93.924/93.925/93.926; extendMulti
with the ported ElementCopier; 93.954 for APPEND, INSERT,
DELETE, SECTION on multidimensional arrays).equalValue: an object by identity — or by its Rexx
== —, a string by string value, .nil never),
MAKESTRING/TOSTRING (items converted as below), SUPPLIER,
SORT/STABLESORT (next section).SORT/STABLESORT (V.SORT) are
native and port ooRexx's merge sort (ArrayClass::mergeSort,
merge, find) step by step, so the same pairs
are compared in the same order and the same errors arise: a hole 98.975;
an item that is an object without COMPARETO 97.1; a second operand
without a string value 88.909. A multidimensional array is sorted as its
flat array. Zero or one items: returned as is.
When an item is an object whose COMPARETO is Rexx code, the native
cannot call it: it delegates (RVM.Delegate with
method = world~sortMethods[SORT|STABLESORT])
to the prelude's RVM.ArraySort~sort, removing its own
native traceback line so the traceback shows one
Compiled method "SORT" line.
SORTWITH/STABLESORTWITH always call the
comparator's COMPARE, so they are the Rexx code of
prelude-rvm.orx: method RVM.ArraySort~sortWith
(arg count first, 93.902, then missing, 93.903) and routine
SortArray, a port of the same merge sort with
Compare sending COMPARE (or COMPARETO). A result that is
not a whole number gives 26.903 (COMPARE) / 26.902 (COMPARETO); no
result 91.999. Errors are raised with RAISE ... RETURN so
they land in the caller of the method and the traps of intermediate
activations are not skipped. bootstrap copies
sortWith into Array as SORTWITH and STABLESORTWITH, and
sort into sortMethods, all with
compiled = .True:
*-* Compiled method "SORTWITH" with scope "Array".
9 *-* a~sortWith(.bad~new)
Error 26.903: Result of a COMPARE method call did not result in a whole number; found "x".
A multidimensional array is sorted, in place, as its flat sequence
(the first subscript varies fastest, as ArrayClass stores
it): SortArray works on an RVM.FlatArray, a
view whose [], []= and HASINDEX
take a flat position and send the subscripts to the array; holes are
looked for at positions 1 to ITEMS (98.975 names the position), and a
comparator that fails leaves the array as far as the sort got, as
natively. The delegation of SORT for objects does the same for any
number of dimensions.
The comparators (Comparator, CaselessComparator, DescendingComparator, ColumnComparator, NumericComparator, InvertingComparator...) are the prelude's.
ListContents (base 0, default capacity 8, a freed slot
reused first, growth ×2 — ×1.5 past 2000 — keeping indexes, free chain
rebuilt lowest first). The ooRexx host gets this from the host
.List; JS ports it (RList).
AT/[] without index 93.903 (argument 2); a bad
index 93.918; PREVIOUS/NEXT/REMOVE of a non-index .nil; no
MAKESTRING (97.1); OF runs INIT first.ArrayClass: JS
RQueue keeps size (16 at creation) and
max as ooRexx does; PUT/INSERT outside the occupied range
93.966 "Incorrect queue index"; DELETE does not check; PUSH, PULL, PEEK,
QUEUE, SIZE natives.HostIndex, HostNumber /
indexNumber).One native family D.* for the four. Directory and
StringTable have ENTRY/SETENTRY/HASENTRY/REMOVEENTRY (uppercased names)
and UNKNOWN (NAME= is SETENTRY — with no value it removes
—, NAME is ENTRY; the name is checked as a string, 88.909,
before the arguments are made an array:
UnknownArgs/unknownArgs); Directory also has
its own protected SETMETHOD/UNSETMETHOD (08). Table: indexes compare by string value for
strings (1 = '1', 1.0 is
different), by identity for objects (or HASHCODE/== in
Rexx, 08);
.nil is a valid item. An object index of a
Directory/StringTable is its REQUEST STRING (none: 88.909 "index").
REMOVEENTRY returns the removed item. IdentityTable: indexes by
identity; HASITEM/INDEX/REMOVEITEM compare items by identity if objects,
by value if strings (native interns literals, so
t['x'] = 3; t~hasItem(3) is 1 natively; RVM strings are not
interned).
The host's collections in the ooRexx host (finding an index is the
host's; comparing items is the RVM's ItemMatch, through
RVM.ItemKey for Relation HASITEM/REMOVEITEM with an index),
RHash in JS (a Map from index key to entries, newest first,
plus a HashShadow). Facts: Set PUT(item, other index)
93.949; HASITEM = HASINDEX for Set; Bag HASITEM/REMOVEITEM with a
different index .nil; Relation keeps the newest item first,
has ALLAT, UNIQUEINDEXES, REMOVEALL, ALLINDEX, no OF. UNION,
INTERSECTION, XOR, DIFFERENCE, SUBSET, PUTALL are Rexx (SetMixin,
BagMixin, ManyItemMixin, Collection).
Native AVAILABLE, INDEX, ITEM, NEXT, INIT; ALLITEMS, ALLINDEXES and
SUPPLIER come from SupplierMixin (prelude).
.supplier~new(items, indexes) requires both (93.903) and
takes a snapshot (SupplierArray: MAKEARRAY of a collection
— indexes of Directory/Table/Set/Bag/Relation, items of List/Queue).
AVAILABLE while the position is within the items; a missing index is
.nil; ITEM/INDEX/NEXT when exhausted 93.937.
ALLITEMS/ALLINDEXES return the rest and drain the supplier (AVAILABLE
then 0) without moving it. StreamSupplier (a Supplier subclass) and DO
WITH: the machine sends NEXT/AVAILABLE/INDEX/ITEM when the supplier is
not a plain Supplier (05).
The Stem object wraps the variable's RVM.Stem /
Stem (tail tree, default, name: 05), made once per stem
(World~stemObjectOf). Its 19 methods (ST.*) as
natively:
[]/AT with no argument → the default; otherwise the
value or the compound name, never NOVALUE. Arguments are joined with
dots (a.~put(4,'Y',3) sets A.Y.3; omitted ones
are "").[]=/PUT with only a value → new default, all tails
dropped (a Stem argument 98.976). HASINDEX with no argument → 1. REMOVE
with no argument returns the default and resets it to the name.equalValue), in
tail order; ITEMS, ISEMPTY, EMPTY (keeps the default), ALLINDEXES,
ALLITEMS, MAKEARRAY, SUPPLIER, TODIRECTORY; REQUEST('ARRAY') gives the
tails (a subclass: its MAKEARRAY; other classes: REQUEST of the
default); UNKNOWN forwards to the default value..Nil entries
in imethods), so m. == n. goes through UNKNOWN
to the defaults (as natively: HASMETHOD('==') is 0)..stem~new('ZZ')[1] is ZZ1; NEW's first
argument is the name, the rest go to INIT (.stem~new(1,2)
93.902).ooRexx converts objects in collections in three different ways, and
the RVM follows each (stringValue, stringOnly,
requestString are defined in 08):
| Use | Conversion | Without one |
|---|---|---|
| index of List/Queue; EQUALS | MAKESTRING if defined, else STRING | — (EQUALS with .nil is 0) |
| argument of a String method; second operand of SORT/COMPARETO | MAKESTRING | 88.909 |
items of Array MAKESTRING/TOSTRING, say of an
Array |
the item's object name (a Stem: its default) | — |
ADDITIONAL of the related errors (97.1, 93.918, 93.907, 98.913, 93.957, 93.972) holds the object itself; messages name it by its object name.
Natively, Directory, StringTable, Table, Set, Bag and Relation
iterate in the order of HashContents: buckets in order (a
string's hash is getStringHash, h = 31·h
+ c with c a signed char, modulo 2⁶⁴; an object's is
its address), each with its overflow chain. A program that prints
allIndexes depends on it, so the RVM reproduces it:
RexxMap (Directory,
StringTable, Table, IdentityTable) and RHash (Set, Bag,
Relation) iterate through a HashShadow: buckets of a size
from bucketSizeFor (at least 17, odd; INIT's capacity),
add at the end of a chain, addFront for a
further item of an existing index in Bag/Relation, growth to 4·size+1
when the overflow fills (checkFull, entries re-added in
iteration order), stringHash = getStringHash.
An object index hashes by its identity number (oid), or by
its Rexx HASHCODE (customIndex,
objectHashCode).Verified identical to native in both hosts for Directory,
StringTable, Table, Set, Bag and Relation with string indexes (a Bag or
Relation adds a new index at the front of its chain, as native's
MultiValueContents; Table and the others at the end).
Limits: an object index can never follow native order (native uses
addresses); IdentityTable order is not reproduced.
Stem tails iterate in native order in both hosts: the tail tree is a
port of CompoundVariableTable walked post-order (so the
order depends on insertion history, and a COPY may differ from its
original).
| Aspect | ooRexx host | JS host |
|---|---|---|
| Prelude R-code | prelude*.orx.rcode next to the sources (cache,
recompiled if stale) |
embedded in rvm-prelude*.mjs (format and ISA versions
checked only) |
| Array, List, Queue | host objects | ports RArray, RList,
RQueue |
| Hashed collections | host objects; order free | RexxMap/RHash +
HashShadow |
Object index with Rexx HASHCODE/== |
RVM.HashKey wrapper, unwrapped by
Unhashed/UnhashedArray |
customIndex, mapLocate,
equalIndex |
| String subclass instance as an index | RVM.StringKey (a host String subclass), unwrapped the
same way |
TableMap (strObjs, stringKey,
tableKeyOf) |
| String identity (IdentityTable) | distinct strings are distinct indexes | equal strings are the same index ("22" and
"2"||"2") |
CoreClasses.orx/StreamClasses.orx rather than
rewritten, because ooRexx is the oracle: the same code gives the same
behaviour and the same errors. Only what has a performance problem would
move to natives.building window, then removes them. The load is triggered
from inside a native that needs an answer at once, while the prolog (and
Monitor, LocalServer, .local) is Rexx code: a synchronous
run to completion is the only clean way, and it is the mechanism
ooRexx's image build uses.prelude-rvm.orx, ported line by line from
the C++ merge sort (same comparisons, same errors), shown as compiled
methods. A resumable native merge sort per host was rejected as far more
machinery for the same result.ListContents, ArrayClass and
HashContents to get them ("copy the quirks").prelude.orx.rcode is shipped so the
ooRexx host need not compile CoreClasses (seconds) on first use; the
PROGRAM path inside it is irrelevant.rvm-prelude*.mjs
beyond its R-code format and ISA versions.