File: IPInstructions.mesa
Last edited by castillo: 17-Dec-86 10: 48: 49
Copyright (C) Xerox Corporation 1986. All rights reserved.
Allan Wax: December 22, 1986 10:10:34 am PST
This interface assumes knowledge of the way instructions are structured into vectors. Although it hides from client the way they are represented internally.
It also allows the client to input instructions (as represented externally by the client), and to get instructions values as well
DIRECTORY
Interpress USING [Master],
Rope USING [ROPE];
IPInstructions: CEDAR DEFINITIONS =
BEGIN
To input instructions the client will provide the interpreter with a handle to the InstructionsRecord. This record contains a handle to the input instructions (in a format defined by client), and an InputProc callback. The interpreter will call the client for any instruction it needs. It will specify whether the instruction should come from the default (default=TRUE) package or the external (FALSE). It will provide an instruction ID (the name of the instruction is the name as defined in the Interpress 3.0 Standard as an ATOM) that will identify that particular instruction, and a collection of procedures that the client will need to provide this information to the client. It is expected that the client will know how the instruction is stored into vectors, altough it does not need to know how the vectors are actually represented internally. The client will use all the push operations and may terminate them with a makeVec call if the value is a vector. For IDs not defined in the interface the client should form it's own atom
Cardinal: TYPE ~ INT --[0..maxCardinal]--;
ROPE: TYPE ~ Rope.ROPE;
StackOpProcs: TYPE = RECORD [
pushIdentifier: PROCEDURE [id: ATOM]← NIL,
pushInteger: PROCEDURE [int: INT] ← NIL,
pushNothing: PROCEDURE -- No value or NOP --NIL,
pushRational: PROCEDURE [n, d: INT]← NIL,
pushReal: PROCEDURE [r: REAL]← NIL,
pushString: PROCEDURE [s: ROPE]← NIL,
makeVec: PROCEDURE [cnt: Cardinal]← NIL
];
StackOps: TYPE = REF StackOpProcs;
InstPtr: TYPE = REF; -- to external or default instructions as defined by client
InputProc: TYPE = PROCEDURE [
instr: InstPtr, default: BOOLEAN, instID: ATOM, ops: StackOps];
InstructionsRecord: TYPE = RECORD [-- opaque type referenced in Interpress
instr: InstPtr ← NIL,
inputProc: InputProc];
Instructions: TYPE = REF InstructionsRecord;
To output instructions first it is assumed that the client know how an instruction is represented in a vector (not caring how a vector is represented internally). The client will call GetInstruction given a master handle, a page number and the instruction ID to get a handle to its representation. The client will be given a handle to an opaque type (Any), and the type of the handle. Given the type of the AnyHandle, a *FromAny proc could be used to extract its content, if it is a vector, then other Get* procs are available to further expand the vector. If the AnyHandle is NIL then the instruction was not there.
BaseTypes: TYPE = {number, identifier, vector};
Any: TYPE = REF; -- to instructions as defined internally
Vector: TYPE = REF; -- to internal representation of a vector
GetInstruction: PROCEDURE [master: Interpress.Master, page: CARDINAL, id: ATOM]
RETURNS [ref: Any, type: BaseTypes];
GetProperty: PROCEDURE [id: ATOM, vec: Vector] RETURNS [ref: Any, type: BaseTypes];
Get: PROCEDURE [ix: Cardinal, vec: Vector] RETURNS [ref: Any, type: BaseTypes];
RunGet: PROCEDURE [ix: Cardinal, vec: Vector] RETURNS [ref: Any, type: BaseTypes];
RunSize: PROCEDURE [vec: Vector] RETURNS [Cardinal];
VectorShape: PROCEDURE [vec: Vector] RETURNS [lowerBound: Cardinal, size: INT -- [0..maxCardinal+1] --];
VectorFromAny: PROCEDURE [a: Any] RETURNS [Vector];
CardinalFromAny: PROCEDURE [a: Any] RETURNS [Cardinal];
RealFromAny: PROCEDURE [a: Any] RETURNS [REAL];
IdentifierFromAny: PROCEDURE [a: Any] RETURNS [ATOM];
END.
LOG
17Dec86 - castillo.