-- JaMBasic.mesa
-- Last changed by Doug Wyatt,  2-Oct-81  9:32:33
-- Last changed by Bill Paxton,  30-Jan-82  8:42:23

JaMBasic: DEFINITIONS = {

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

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): TextPtr, 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): DictPtr],
    array => [length(1:0..15): CARDINAL, base(2:0..31): ArrayPtr],
    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;

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

DictPtr: TYPE = 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: TuplePtr, -- beginning and end of tuple table
  curatt: CARDINAL, -- current number of attachments
  attach: array Object -- array of attached dictionaries
  ];
TuplePtr: TYPE = LONG POINTER TO Tuple;
Tuple: TYPE = MACHINE DEPENDENT RECORD[key,value: Object];

ArrayPtr: TYPE = 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
  ];

}.