<> <> <> <<>> DIRECTORY IPBase USING [], IPInterpreter USING [Any, Body, CallInlineBody, Copy, Count, Do, DoSave, DoSaveAll, Env, Eq, EqName, ErrorClass, FGet, Frame, FSet, Get, GetInlineBody, GetP, GetProp, Integer, MakeCO, MakeCompiledImage, MakePool, MakeVec, MakeVecLU, Mark, MasterWarning, MergeProp, NoPool, Operator, OperatorFromPool, PGet, Pool, PoolFromOperator, PoolOp, Pop, PopAny, PopBool, PopInteger, PopOperator, PopReal, PopVector, PSet, PushAny, PushBool, PushInteger, PushOperator, PushReal, PushVector, Ref, ReportError, Roll, RopeFromVector, Shape, SkipInlineBody, TopType, TypeCode, Unmark, Vector, VectorFromPool, VectorShape], RealFns USING [ArcTanDeg, CosDeg, Log, Power, SinDeg, SqRt], IPReal USING [Ceiling, Floor, Mod, Rem, Round, Trunc]; IPBaseImpl: CEDAR PROGRAM IMPORTS IPInterpreter, IPReal, RealFns EXPORTS IPBase ~ BEGIN OPEN IPInterpreter; <> ApplyGET: PUBLIC PROC [self: Ref] ~ { j: Integer ~ PopInteger[self]; v: Vector ~ PopVector[self]; PushAny[self, Get[v, j]]; }; ApplyMAKEVECLU: PUBLIC PROC [self: Ref] ~ { u: Integer ~ PopInteger[self]; l: Integer ~ PopInteger[self]; pop: PROC RETURNS [Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVecLU[l, u, pop]; PushVector[self, v]; }; ApplyMAKEVEC: PUBLIC PROC [self: Ref] ~ { n: Integer ~ PopInteger[self]; pop: PROC RETURNS [Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVec[n, pop]; PushVector[self, v]; }; ApplyOPENVEC: PUBLIC PROC [self: Ref] ~ { v: Vector ~ PopVector[self]; shape: VectorShape ~ Shape[v]; FOR i: Integer IN[shape.lowerBound..shape.lowerBound+shape.size) DO PushAny[self, Get[v, i]]; ENDLOOP; }; ApplySHAPE: PUBLIC PROC [self: Ref] ~ { v: Vector ~ PopVector[self]; shape: VectorShape ~ Shape[v]; PushInteger[self, shape.lowerBound]; PushInteger[self, shape.size]; }; ApplyGETPROP: PUBLIC PROC [self: Ref] ~ { propName: Any ~ PopAny[self]; v: Vector ~ PopVector[self]; found: BOOL; value: Any; [found, value] _ GetProp[v, propName]; IF found THEN PushAny[self, value]; PushBool[self, found]; }; ApplyGETP: PUBLIC PROC [self: Ref] ~ { propName: Any ~ PopAny[self]; v: Vector ~ PopVector[self]; PushAny[self, GetP[v, propName]]; }; ApplyMERGEPROP: PUBLIC PROC [self: Ref] ~ { v2: Vector ~ PopVector[self]; v1: Vector ~ PopVector[self]; PushVector[self, MergeProp[v1, v2]]; }; <> ApplyFRAME: PUBLIC PROC [self: Ref] ~ { PushVector[self, Frame[self]]; }; ApplyFGET: PUBLIC PROC [self: Ref] ~ { j: Integer ~ PopInteger[self]; PushAny[self, FGet[self, j]]; }; ApplyFSET: PUBLIC PROC [self: Ref] ~ { j: Integer ~ PopInteger[self]; x: Any ~ PopAny[self]; FSet[self, x, j]; }; ApplyPOOLOP: PUBLIC PROC [self: Ref] ~ { PushOperator[self, OperatorFromPool[PoolOp[self]]]; }; ApplyPOOL: PUBLIC PROC [self: Ref] ~ { PushVector[self, VectorFromPool[PoolOp[self]]]; }; ApplyPGET: PUBLIC PROC [self: Ref] ~ { j: Integer ~ PopInteger[self]; PushAny[self, PGet[self, j]]; }; ApplyPSET: PUBLIC PROC [self: Ref] ~ { j: Integer ~ PopInteger[self]; x: Any ~ PopAny[self]; PSet[self, x, j]; }; ApplyENV: PUBLIC PROC [self: Ref] ~ { PushVector[self, Env[self]]; }; <> ApplyMAKEPOOL: PUBLIC PROC [self: Ref] ~ { persistent: BOOL ~ PopBool[self]; v: Vector ~ PopVector[self]; PushOperator[self, OperatorFromPool[MakePool[v, persistent]]]; }; ApplyNOPOOL: PUBLIC PROC [self: Ref] ~ { PushOperator[self, OperatorFromPool[NoPool[]]]; }; ApplyMAKECO: PUBLIC PROC [self: Ref] ~ { b: Body ~ GetInlineBody[self]; f: Vector ~ PopVector[self]; po: Operator ~ PopOperator[self]; PushOperator[self, MakeCO[frame: f, pool: PoolFromOperator[po], env: Env[self], body: b]]; }; ApplyMAKESIMPLECO: PUBLIC PROC [self: Ref] ~ { b: Body ~ GetInlineBody[self]; PushOperator[self, MakeCO[frame: Frame[self], pool: NoPool[], env: Env[self], body: b]]; }; ApplyDO: PUBLIC PROC [self: Ref] ~ { op: Operator ~ PopOperator[self]; Do[self, op]; }; ApplyDOSAVE: PUBLIC PROC [self: Ref] ~ { op: Operator ~ PopOperator[self]; action: PROC ~ { Do[self, op] }; DoSave[self, action]; }; ApplyDOSAVEALL: PUBLIC PROC [self: Ref] ~ { op: Operator ~ PopOperator[self]; action: PROC ~ { Do[self, op] }; DoSaveAll[self, action]; }; ApplyDOBODY: PUBLIC PROC [self: Ref] ~ { frame: Vector ~ PopVector[self]; pool: Pool ~ PoolOp[self]; env: Vector ~ Env[self]; CallInlineBody[self: self, frame: frame, pool: pool, env: env]; }; ApplyDOSAVEBODY: PUBLIC PROC [self: Ref] ~ { frame: Vector ~ PopVector[self]; pool: Pool ~ PoolOp[self]; env: Vector ~ Env[self]; action: PROC ~ { CallInlineBody[self: self, frame: frame, pool: pool, env: env] }; DoSave[self, action]; }; ApplyDOSAVEALLBODY: PUBLIC PROC [self: Ref] ~ { frame: Vector ~ PopVector[self]; pool: Pool ~ PoolOp[self]; env: Vector ~ Env[self]; action: PROC ~ { CallInlineBody[self: self, frame: frame, pool: pool, env: env] }; DoSaveAll[self, action]; }; ApplyDOSAVESIMPLEBODY: PUBLIC PROC [self: Ref] ~ { frame: Vector ~ Frame[self]; pool: Pool ~ NoPool[]; env: Vector ~ Env[self]; action: PROC ~ { CallInlineBody[self: self, frame: frame, pool: pool, env: env] }; DoSave[self, action]; }; ApplyMAKECOMPILEDIMAGE: PUBLIC PROC [self: Ref] ~ { body: Body ~ GetInlineBody[self]; frame: Vector ~ PopVector[self]; env: Vector ~ Env[self]; PushOperator[self, MakeCompiledImage[frame: frame, env: env, body: body]]; }; <> ApplyPOP: PUBLIC PROC [self: Ref] ~ { Pop[self]; }; ApplyCOPY: PUBLIC PROC [self: Ref] ~ { n: Integer ~ PopInteger[self]; Copy[self: self, depth: n]; }; ApplyDUP: PUBLIC PROC [self: Ref] ~ { Copy[self: self, depth: 1]; }; ApplyROLL: PUBLIC PROC [self: Ref] ~ { moveFirst: Integer ~ PopInteger[self]; depth: Integer ~ PopInteger[self]; Roll[self: self, depth: depth, moveFirst: moveFirst]; }; ApplyEXCH: PUBLIC PROC [self: Ref] ~ { Roll[self: self, depth: 2, moveFirst: 1]; }; ApplyMARK: PUBLIC PROC [self: Ref] ~ { n: Integer ~ PopInteger[self]; Mark[self, n]; }; ApplyUNMARK: PUBLIC PROC [self: Ref] ~ { n: Integer ~ PopInteger[self]; Unmark[self, n]; }; ApplyUNMARK0: PUBLIC PROC [self: Ref] ~ { Unmark[self, 0]; }; ApplyCOUNT: PUBLIC PROC [self: Ref] ~ { PushInteger[self, Count[self]]; }; ApplyNOP: PUBLIC PROC [self: Ref] ~ { }; ApplyERROR: PUBLIC PROC [self: Ref] ~ { code: Integer ~ PopInteger[self]; message: Vector ~ PopVector[self]; class: ErrorClass _ nil; SELECT code FROM 0 => class _ masterError; 10 => class _ masterWarning; 50 => class _ appearanceError; 60 => class _ appearanceWarning; 100 => class _ comment; ENDCASE; ReportError[class, $ERROR, RopeFromVector[message]]; }; <> ApplyIF: PUBLIC PROC [self: Ref] ~ { bool: BOOL ~ PopBool[self]; IF bool THEN CallInlineBody[self: self, frame: Frame[self], pool: NoPool[], env: Env[self]] ELSE SkipInlineBody[self]; }; ApplyIFELSE: PUBLIC PROC [self: Ref] ~ { bool: BOOL ~ PopBool[self]; IF bool THEN CallInlineBody[self: self, frame: Frame[self], pool: NoPool[], env: Env[self]] ELSE SkipInlineBody[self]; PushBool[self, NOT bool]; }; ApplyIFCOPY: PUBLIC PROC [self: Ref] ~ { testCopy: Operator ~ PopOperator[self]; MasterWarning[$unimplemented, "Not implemented: IFCOPY"]; SkipInlineBody[self]; }; ApplyLOOP: PUBLIC PROC [self: Ref] ~ { body: Body ~ GetInlineBody[self]; op: Operator ~ MakeCO[frame: Frame[self], pool: PoolOp[self], env: Env[self], body: body]; DO Do[self, op]; IF NOT PopBool[self] THEN EXIT ENDLOOP; }; <> ApplyEQ: PUBLIC PROC [self: Ref] ~ { b: Any ~ PopAny[self]; a: Any ~ PopAny[self]; PushBool[self, Eq[a, b]]; }; ApplyEQNAME: PUBLIC PROC [self: Ref] ~ { b: Any ~ PopAny[self]; a: Any ~ PopAny[self]; PushBool[self, EqName[a, b]]; }; ApplyGT: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushBool[self, a>b]; }; ApplyGE: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushBool[self, a>=b]; }; ApplyAND: PUBLIC PROC [self: Ref] ~ { b: BOOL ~ PopBool[self]; a: BOOL ~ PopBool[self]; PushBool[self, a AND b]; }; ApplyOR: PUBLIC PROC [self: Ref] ~ { b: BOOL ~ PopBool[self]; a: BOOL ~ PopBool[self]; PushBool[self, a OR b]; }; ApplyNOT: PUBLIC PROC [self: Ref] ~ { b: BOOL ~ PopBool[self]; PushBool[self, NOT b]; }; ApplyTYPE: PUBLIC PROC [self: Ref] ~ { code: TypeCode ~ TopType[self]; Pop[self]; PushInteger[self, ORD[code]]; }; <> ApplyADD: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a+b]; }; ApplySUB: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a-b]; }; ApplyNEG: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, -a]; }; ApplyABS: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, ABS[a]]; }; ApplyFLOOR: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, IPReal.Floor[a]]; }; ApplyCEILING: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, IPReal.Ceiling[a]]; }; ApplyTRUNC: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, IPReal.Trunc[a]]; }; ApplyROUND: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, IPReal.Round[a]]; }; ApplyMUL: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a*b]; }; ApplyDIV: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a/b]; }; ApplyMOD: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, IPReal.Mod[a, b]]; }; ApplyREM: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, IPReal.Rem[a, b]]; }; ApplyMAX: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, MAX[a, b]]; }; ApplyMIN: PUBLIC PROC [self: Ref] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, MIN[a, b]]; }; ApplySQRT: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.SqRt[a]]; }; ApplyEXP: PUBLIC PROC [self: Ref] ~ { e: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; PushReal[self, RealFns.Power[b, e]]; }; ApplyLOG: PUBLIC PROC [self: Ref] ~ { v: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; PushReal[self, RealFns.Log[b, v]]; }; ApplySIN: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.SinDeg[a]]; }; ApplyCOS: PUBLIC PROC [self: Ref] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.CosDeg[a]]; }; ApplyATAN: PUBLIC PROC [self: Ref] ~ { x: REAL ~ PopReal[self]; y: REAL ~ PopReal[self]; PushReal[self, RealFns.ArcTanDeg[y, x]]; }; END.