-- JaMBasic.mesa
-- Last changed by Doug Wyatt,  2-Oct-81  9:32:33

JaMBasic: DEFINITIONS = {

-- Declarations for data structures stored in the JaM VM.

Base: TYPE = LONG BASE POINTER TO Root;
vmNIL: Base RELATIVE LONG POINTER = LOOPHOLE[LONG[0]];

Object: TYPE = MACHINE DEPENDENT RECORD [
  tag(0:0..0): Tag,
  variant(0:1..63): SELECT type(0:1..15): ObType FROM
    null => [],
    integer => [ivalue(1:0..31): LONG INTEGER],
    real => [rvalue(1:0..31): REAL],
    boolean => [bvalue(1:0..15): BOOLEAN],
    name => [id(1:0..15): NameID],
    string => [length(1:1..15): StringLength,
      text(2:0..31): TextRptr, offset(1:0..0): [0..1]],
    stream => [index(1:0..15): CARDINAL, stamp(2:0..15): Stamp],
    command => [index(1:0..15): CARDINAL],
    dict => [dict(1:0..31): DictRptr],
    array => [length(1:0..15): CARDINAL, base(2:0..31): ArrayRptr],
    mark => [],
    user => [data(1:0..31): LONG UNSPECIFIED, stamp(3:0..15): Stamp],
    -- For internal use only:
    exec => [], loop => [],
    scope => [top(1:0..15): CARDINAL, id(2:0..15): NameID],
    ENDCASE];

Tag: TYPE = MACHINE DEPENDENT {X(0), L(1)}; -- eXecutable or Literal
ObType: TYPE = MACHINE DEPENDENT {null(0), integer(1), real(2), boolean(3), name(4),
  string(5), stream(6), command(7), dict(8), array(9), mark(10), user(11),
  exec(12), loop(13), scope(14) };

StringLength,NameIndex: TYPE = [0..77777B];
NameID: TYPE = MACHINE DEPENDENT RECORD[local: BOOLEAN, index: NameIndex];
Stamp: TYPE = CARDINAL;

TextRptr: TYPE = Base RELATIVE LONG POINTER TO TextBody;
TextBody: TYPE = RECORD[PACKED SEQUENCE COMPUTED CARDINAL OF CHARACTER];

DictRptr: TYPE = Base RELATIVE LONG POINTER TO DictBody;
DictBody: TYPE = MACHINE DEPENDENT RECORD [
  curlen,maxlen: CARDINAL, -- current and maximum number of tuples
  size: CARDINAL, -- size of tuple table
  beg,end: TupleRptr, -- beginning and end of tuple table
  curatt: CARDINAL, -- current number of attachments
  attach: array Object -- array of attached dictionaries
  ];
TupleRptr: TYPE = Base RELATIVE LONG POINTER TO Tuple;
Tuple: TYPE = MACHINE DEPENDENT RECORD[key,value: Object];

ArrayRptr: TYPE = Base RELATIVE LONG POINTER TO ArrayBody;
ArrayBody: TYPE = RECORD[SEQUENCE COMPUTED CARDINAL OF Object];

Root: TYPE = MACHINE DEPENDENT RECORD [
  stamp: Stamp,
  sysDict: dict Object,
  commandCount: CARDINAL,
  commandArray: array Object,
  nameCount: CARDINAL,
  nameArray: array Object,
  nameDict: dict Object
  ];

}.