-- JaMVM.mesa
-- Last edit by Bill Paxton, 14-Jan-82 14:03:03

DIRECTORY
  JaMBasic USING [Base, DictBody, Object, Root, StringLength, Tuple, TupleRptr];

JaMVM: DEFINITIONS = {
OPEN JaMBasic;

Start: PROC[name: LONG STRING, maxPages: CARDINAL] RETURNS[BOOLEAN];

BadVMPassword: SIGNAL; -- raised by Start; if continue, acts as if file had not existed

Check: PROC;
Flush: PROC;

-- Virtual memory access

vm: READONLY Base;

AllocString: PROC[length: StringLength] RETURNS[string Object];
AllocArray: PROC[length: CARDINAL] RETURNS[array Object];
AllocDict: PROC[size: CARDINAL] RETURNS[dict Object];

GetRoot: PROC[root: LONG POINTER TO Root] = INLINE { root↑ ← vm↑ };
PutRoot: PROC[root: LONG POINTER TO Root] = INLINE { vm↑ ← root↑ };

GetDict: PROC[dict: dict Object]
  RETURNS[DictBody] = INLINE { RETURN[vm[dict.dict]] };
PutDict: PROC[dict: dict Object,
  dd: DictBody] = INLINE { vm[dict.dict] ← dd };

GetTuple: PROC[slot: TupleRptr]
  RETURNS[Tuple] = INLINE { RETURN[vm[slot]] };
PutTuple: PROC[slot: TupleRptr,
  tuple: Tuple] = INLINE { vm[slot] ← tuple };

GetElem: PROC[array: array Object, i: CARDINAL]
  RETURNS[Object] = INLINE { RETURN[vm[array.base][i]] };
PutElem: PROC[array: array Object, i: CARDINAL,
  object: Object] = INLINE { vm[array.base][i] ← object };

GetChar: PROC[string: string Object, i: CARDINAL]
  RETURNS[CHARACTER] = INLINE { RETURN[vm[string.text][i+string.offset]] };
PutChar: PROC[string: string Object, i: CARDINAL,
  char: CHARACTER] = INLINE { vm[string.text][i+string.offset] ← char };

CopyArray: PROC[src,dst: array Object];
-- copies MIN[src.length,dst.length] objects

CopyString: PROC[src,dst: string Object];
-- copies MIN[src.length,dst.length] characters

GetText: PROC[string: string Object, text: LONG STRING];
PutText: PROC[string: string Object, text: LONG STRING];
-- these transfer MIN[string.length,text.maxlength] characters

}.