<> <> <> <<>> <> <<>> DIRECTORY Basics USING [HighHalf, LowHalf], Imager USING [Context], ImagerColor USING [Color], ImagerPath USING [Trajectory], ImagerPixelArray USING [PixelArray], ImagerTransformation USING [Transformation], IO USING [STREAM], IPMaster USING [Body, Op, Skeleton, TypeCode], PrincOps USING [zBNDCK, zLIW], Rope USING [ROPE], Vector2 USING [VEC]; IPInterpreter: CEDAR DEFINITIONS IMPORTS Basics ~ BEGIN ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; Op: TYPE ~ IPMaster.Op; TypeCode: TYPE ~ IPMaster.TypeCode; maxInteger: INT ~ 77777777B; -- 2^24 - 1 = 16777215 maxIdLength: NAT ~ 100; -- a test for credibility, not an intrinsic limit maxStackLength: NAT ~ 1000; -- a test for credibility, not an intrinsic limit maxVecSize: NAT ~ NAT.LAST; -- for a Vector made by MAKEVEC or MAKEVECLU topFrameSize: NAT ~ 50; Any: TYPE ~ REF ANY; Integer: TYPE ~ INT--[0..maxInteger]--; CheckInteger: PROC[i: INT] RETURNS[Integer] ~ TRUSTED MACHINE CODE { PrincOps.zLIW, 1, 0; PrincOps.zBNDCK }; <> <<>> IsInteger: PROC[i: INT] RETURNS[BOOL] ~ INLINE { RETURN[Basics.HighHalf[LOOPHOLE[i]]<400B] }; <> <<>> Even: PROC[i: Integer] RETURNS[BOOL] ~ INLINE { RETURN[(Basics.LowHalf[LOOPHOLE[i]] MOD 2)=0] }; <> Number: TYPE ~ REF NumberRep; NumberRep: TYPE ~ RECORD[SELECT tag: * FROM int => [int: INT], real => [real: REAL], ENDCASE ]; Identifier: TYPE ~ REF IdentifierRep; IdentifierRep: TYPE ~ RECORD[atom: ATOM, rope: ROPE]; Marker: TYPE ~ LONG CARDINAL; -- a unique mark value associated with a context nullMarker: Marker ~ 0; VectorShape: TYPE ~ RECORD[ l: Integer, -- lower bound n: Integer -- number of elements (upper bound "u" = l+n-1) ]; Vector: TYPE ~ REF VectorRep; VectorRep: TYPE ~ RECORD[class: VectorClass, data: REF]; VectorClass: TYPE ~ REF VectorClassRep; VectorClassRep: TYPE ~ RECORD[ type: ATOM, -- $Array, $Merged, $Font, $String, ... shape: PROC[v: Vector] RETURNS[VectorShape], get: PROC[v: Vector, j: Integer] RETURNS[Any], getProp: PROC[v: Vector, propName: Any] RETURNS[found: BOOL, value: Any] _ NIL ]; Body: TYPE ~ IPMaster.Body; Operator: TYPE ~ REF OperatorRep; OperatorRep: TYPE ~ RECORD[class: OperatorClass, data: REF]; OperatorClass: TYPE ~ REF OperatorClassRep; OperatorClassRep: TYPE ~ RECORD[ type: ATOM, -- $Composed, $Pool, $Char, $Decompressor, $ColorOperator, ... do: PROC[op: Operator, state: State] ]; VEC: TYPE ~ Vector2.VEC; Transformation: TYPE ~ ImagerTransformation.Transformation; PixelArray: TYPE ~ ImagerPixelArray.PixelArray; Color: TYPE ~ ImagerColor.Color; Trajectory: TYPE ~ ImagerPath.Trajectory; Outline: TYPE ~ REF OutlineRep; OutlineRep: TYPE ~ RECORD[SEQUENCE size: NAT OF Trajectory]; Array: TYPE ~ REF ArrayRep; -- a mutable array of values, such as a frame or pool ArrayRep: TYPE ~ RECORD[ l: Integer, -- lower bound array: SEQUENCE n: [0..maxVecSize] OF Any ]; Pool: TYPE ~ REF PoolRep; -- a pool operator, from MAKEPOOL or NOPOOL PoolRep: TYPE ~ RECORD[ persistent: BOOL, level: NAT _ 0, array: Array ]; Context: TYPE ~ REF ContextRep; -- an execution context ContextRep: TYPE ~ RECORD[ caller: Context, -- caller's context marker: Marker, -- unique mark for this context index: INT, -- index of token currently being executed initialFrame: Vector, -- initial frame frame: Array, -- current frame (NIL if unchanged from initial frame) pool: Pool, -- shared pool env: Vector -- environment ]; Stack: TYPE ~ REF StackRep; -- the stack StackRep: TYPE; -- see IPStackImpl State: TYPE ~ REF StateRep; -- the state of an Interpress interpreter StateRep: TYPE ~ RECORD[ stream: STREAM _ NIL, -- input stream on the master being interpreted buffer: REF TEXT _ NIL, -- a buffer for reading strings from the master skeleton: IPMaster.Skeleton _ NIL, -- skeleton structure of the master topFrame: Vector _ NIL, -- initial frame for the top level block topEnv: Vector _ NIL, -- environment for the top level block lastMarker: Marker _ nullMarker, -- last mark value used context: Context _ NIL, -- the current context stack: Stack _ NIL, -- the stack imager: Imager.Context _ NIL, -- imager state showVec: Vector _ NIL, -- current showVec log: STREAM _ NIL -- output stream for logging errors ]; Error: ERROR; Bug: ERROR; ErrorClass: TYPE ~ { masterError, masterWarning, appearanceError, appearanceWarning, comment }; AddState: PROC[state: State, inner: PROC]; <> <<>> GetState: PROC RETURNS[State]; <> <<>> LogError: PROC[class: ErrorClass, code: ATOM, explanation: ROPE]; MasterErrorType: TYPE ~ { bug, unimplemented, boundsFault, nilFault, invalidArgs, limitExceeded, markMismatch, missingBody, notInteger, stackOverflow, stackUnderflow, undefinedOperation, undefinedProperty, unmarkFailed, wrongType }; MasterError: PROC[type: MasterErrorType, explanation: ROPE _]; MasterWarningType: TYPE ~ { bug, unimplemented, unknownToken, nullValue, illegalIdentifier, illegalString }; MasterWarning: PROC[type: MasterWarningType, explanation: ROPE _]; NumberFromInteger: PROC[Integer] RETURNS[Number]; NumberFromInt: PROC[INT] RETURNS[Number]; NumberFromReal: PROC[REAL] RETURNS[Number]; IntegerFromInt: PROC[INT] RETURNS[Integer]; IntegerFromReal: PROC[REAL] RETURNS[Integer]; IntegerFromAny: PROC[Any] RETURNS[Integer]; IntFromReal: PROC[REAL] RETURNS[INT]; IntFromAny: PROC[Any] RETURNS[INT]; RealFromAny: PROC[Any] RETURNS[REAL]; NumberFromAny: PROC[Any] RETURNS[Number]; IdentifierFromAny: PROC[Any] RETURNS[Identifier]; VectorFromAny: PROC[Any] RETURNS[Vector]; OperatorFromAny: PROC[Any] RETURNS[Operator]; TransformationFromAny: PROC[Any] RETURNS[Transformation]; PixelArrayFromAny: PROC[Any] RETURNS[PixelArray]; ColorFromAny: PROC[Any] RETURNS[Color]; TrajectoryFromAny: PROC[Any] RETURNS[Trajectory]; OutlineFromAny: PROC[Any] RETURNS[Outline]; Eq: PROC[a, b: Any] RETURNS[BOOL]; EqName: PROC[a, b: Any] RETURNS[BOOL]; Type: PROC[a: Any] RETURNS[TypeCode]; IdentifierFromRope: PROC[ROPE] RETURNS[Identifier]; RopeFromIdentifier: PROC[Identifier] RETURNS[ROPE]; Get: PROC[v: Vector, j: Integer] RETURNS[Any]; GetInteger: PROC[v: Vector, j: Integer] RETURNS[Integer]; GetReal: PROC[v: Vector, j: Integer] RETURNS[REAL]; Shape: PROC[v: Vector] RETURNS[VectorShape]; MergeProp: PROC[v1, v2: Vector] RETURNS[Vector]; GetProp: PROC[v: Vector, propName: Any] RETURNS[found: BOOL, value: Any]; GetP: PROC[v: Vector, propName: Any] RETURNS[Any]; RunSize: PROC[r: Vector] RETURNS[Integer]; RunGet: PROC[r: Vector, i: Integer] RETURNS[Any]; MakeVec: PROC[shape: VectorShape, pop: PROC RETURNS[Any]] RETURNS[Vector]; <> <> <<>> VectorFromArray: PROC[Array] RETURNS[Vector]; <> <> <<>> ArrayFromVector: PROC[Vector] RETURNS[Array]; <> <> VectorFromString: PROC[ROPE] RETURNS[Vector]; StringFromVector: PROC[Vector] RETURNS[ROPE]; <> <> <> <<>> RopeFromVector: PROC[Vector] RETURNS[ROPE]; <> NewStack: PROC[maxLength: Integer] RETURNS[Stack]; PushAny: PROC[self: State, x: Any]; PushBool: PROC[self: State, b: BOOL]; PushInteger: PROC[self: State, i: Integer]; PushInt: PROC[self: State, i: INT]; PushReal: PROC[self: State, r: REAL]; PushVec: PROC[self: State, p: VEC]; PushIdentifier: PROC[self: State, x: Identifier]; PushVector: PROC[self: State, x: Vector]; PushOperator: PROC[self: State, x: Operator]; PushTransformation: PROC[self: State, x: Transformation]; PushPixelArray: PROC[self: State, x: PixelArray]; PushColor: PROC[self: State, x: Color]; PushTrajectory: PROC[self: State, x: Trajectory]; PushOutline: PROC[self: State, x: Outline]; PopAny: PROC[self: State] RETURNS[Any]; PopBool: PROC[self: State] RETURNS[BOOL]; PopInteger: PROC[self: State] RETURNS[Integer]; PopInt: PROC[self: State] RETURNS[INT]; PopReal: PROC[self: State] RETURNS[REAL]; PopVec: PROC[self: State] RETURNS[VEC]; PopIdentifier: PROC[self: State] RETURNS[Identifier]; PopVector: PROC[self: State] RETURNS[Vector]; PopOperator: PROC[self: State] RETURNS[Operator]; PopTransformation: PROC[self: State] RETURNS[Transformation]; PopPixelArray: PROC[self: State] RETURNS[PixelArray]; PopColor: PROC[self: State] RETURNS[Color]; PopTrajectory: PROC[self: State] RETURNS[Trajectory]; PopOutline: PROC[self: State] RETURNS[Outline]; TopType: PROC[self: State] RETURNS[TypeCode]; Pop: PROC[self: State]; Copy: PROC[self: State, depth: Integer]; Roll: PROC[self: State, depth, moveFirst: Integer]; Mark: PROC[self: State, n: Integer]; Unmark: PROC[self: State, n: Integer]; Unmark0: PROC[self: State]; Count: PROC[self: State] RETURNS[Integer]; PopToMark: PROC[self: State] RETURNS[Marker]; RemoveMark: PROC[self: State, marker: Marker]; Frame: PROC[self: State] RETURNS[Vector]; FGet: PROC[self: State, j: Integer] RETURNS[Any]; FSet: PROC[self: State, x: Any, j: Integer]; PoolOp: PROC[self: State] RETURNS[Pool]; PGet: PROC[self: State, j: Integer] RETURNS[Any]; PSet: PROC[self: State, x: Any, j: Integer]; Env: PROC[self: State] RETURNS[Vector]; MakePool: PROC[v: Vector, persistent: BOOL] RETURNS[Pool]; NoPool: PROC RETURNS[Pool]; PoolFromOperator: PROC[Operator] RETURNS[Pool]; OperatorFromPool: PROC[Pool] RETURNS[Operator]; VectorFromPool: PROC[Pool] RETURNS[Vector]; MakeCO: PROC[frame: Vector, pool: Pool, env: Vector, body: Body] RETURNS[Operator]; MakeCompiledImage: PROC[frame: Vector, env: Vector, body: Body] RETURNS[Operator]; Apply: PROC[self: State, op: Op]; <> <<>> Do: PROC[self: State, op: Operator]; <> <<>> DoSave: PROC[self: State, action: PROC]; <> <<>> DoSaveAll: PROC[self: State, action: PROC]; <> <<>> DoProtected: PROC[self: State, action: PROC]; < UNMARK0.>> Call: PROC[self: State, action: PROC, frame: Vector, pool: Pool, env: Vector]; <> SkipInlineBody: PROC[self: State]; <> <<>> GetInlineBody: PROC[self: State] RETURNS[Body]; <> <<>> CallInlineBody: PROC[self: State, frame: Vector _ NIL, pool: Pool _ NIL, env: Vector _ NIL]; <> END.