DIRECTORY IPBase USING [], IPInterpreter, RealExtras USING [Ceiling, Floor, Mod, Rem, Round, Trunc], RealFns USING [ArcTanDeg, CosDeg, Log, Power, SinDeg, SqRt]; IPBaseImpl: CEDAR PROGRAM IMPORTS IPInterpreter, RealExtras, RealFns EXPORTS IPBase ~ BEGIN OPEN IPInterpreter; ApplyGET: PUBLIC PROC[self: State] ~ { j: Integer ~ PopInteger[self]; v: Vector ~ PopVector[self]; PushAny[self, Get[v, j]]; }; ApplyMAKEVECLU: PUBLIC PROC[self: State] ~ { u: Integer ~ PopInteger[self]; l: Integer ~ PopInteger[self]; n: INT ~ u-l+1; -- IN[-maxInteger+1..maxInteger+1] IF n<0 THEN MasterError[$invalidArgs, "Illegal vector bounds."] ELSE IF n>maxVecSize THEN MasterError[$limitExceeded, "Vector size exceeds maxVecSize."] ELSE { pop: PROC RETURNS[Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVec[[l: l, n: n], pop]; PushVector[self, v]; }; }; ApplyMAKEVEC: PUBLIC PROC[self: State] ~ { n: Integer ~ PopInteger[self]; pop: PROC RETURNS[Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVec[[l: 0, n: n], pop]; PushVector[self, v]; }; ApplyOPENVEC: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; shape: VectorShape ~ Shape[v]; FOR i: Integer IN[shape.l..shape.l+shape.n) DO PushAny[self, Get[v, i]] ENDLOOP; }; ApplySHAPE: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; shape: VectorShape ~ Shape[v]; PushInteger[self, shape.l]; PushInteger[self, shape.n]; }; ApplyGETPROP: PUBLIC PROC[self: State] ~ { 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: State] ~ { propName: Any ~ PopAny[self]; v: Vector ~ PopVector[self]; PushAny[self, GetP[v, propName]]; }; ApplyMERGEPROP: PUBLIC PROC[self: State] ~ { v2: Vector ~ PopVector[self]; v1: Vector ~ PopVector[self]; PushVector[self, MergeProp[v1, v2]]; }; ApplyFRAME: PUBLIC PROC[self: State] ~ { PushVector[self, Frame[self]]; }; ApplyFGET: PUBLIC PROC[self: State] ~ { j: Integer ~ PopInteger[self]; PushAny[self, FGet[self, j]]; }; ApplyFSET: PUBLIC PROC[self: State] ~ { j: Integer ~ PopInteger[self]; x: Any ~ PopAny[self]; FSet[self, x, j]; }; ApplyPOOLOP: PUBLIC PROC[self: State] ~ { PushOperator[self, OperatorFromPool[PoolOp[self]]]; }; ApplyPOOL: PUBLIC PROC[self: State] ~ { PushVector[self, VectorFromPool[PoolOp[self]]]; }; ApplyPGET: PUBLIC PROC[self: State] ~ { j: Integer ~ PopInteger[self]; PushAny[self, PGet[self, j]]; }; ApplyPSET: PUBLIC PROC[self: State] ~ { j: Integer ~ PopInteger[self]; x: Any ~ PopAny[self]; PSet[self, x, j]; }; ApplyENV: PUBLIC PROC[self: State] ~ { PushVector[self, Env[self]]; }; ApplyMAKEPOOL: PUBLIC PROC[self: State] ~ { persistent: BOOL ~ PopBool[self]; v: Vector ~ PopVector[self]; PushOperator[self, OperatorFromPool[MakePool[v, persistent]]]; }; ApplyNOPOOL: PUBLIC PROC[self: State] ~ { PushOperator[self, OperatorFromPool[NoPool[]]]; }; ApplyMAKECO: PUBLIC PROC[self: State] ~ { 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: State] ~ { b: Body ~ GetInlineBody[self]; PushOperator[self, MakeCO[frame: Frame[self], pool: NoPool[], env: Env[self], body: b]]; }; ApplyDO: PUBLIC PROC[self: State] ~ { op: Operator ~ PopOperator[self]; Do[self, op]; }; ApplyDOSAVE: PUBLIC PROC[self: State] ~ { op: Operator ~ PopOperator[self]; action: PROC ~ { Do[self, op] }; DoSave[self, action]; }; ApplyDOSAVEALL: PUBLIC PROC[self: State] ~ { op: Operator ~ PopOperator[self]; action: PROC ~ { Do[self, op] }; DoSaveAll[self, action]; }; ApplyDOBODY: PUBLIC PROC[self: State] ~ { f: Vector ~ PopVector[self]; CallInlineBody[self: self, frame: f, pool: PoolOp[self]]; }; ApplyDOSAVEBODY: PUBLIC PROC[self: State] ~ { f: Vector ~ PopVector[self]; action: PROC ~ { CallInlineBody[self: self, frame: f, pool: PoolOp[self]] }; DoSave[self, action]; }; ApplyDOSAVEALLBODY: PUBLIC PROC[self: State] ~ { f: Vector ~ PopVector[self]; action: PROC ~ { CallInlineBody[self: self, frame: f, pool: PoolOp[self]] }; DoSaveAll[self, action]; }; ApplyDOSAVESIMPLEBODY: PUBLIC PROC[self: State] ~ { action: PROC ~ { CallInlineBody[self: self] }; DoSave[self, action]; }; ApplyMAKECOMPILEDIMAGE: PUBLIC PROC[self: State] ~ { b: Body ~ GetInlineBody[self]; f: Vector ~ PopVector[self]; env: Vector ~ Env[self]; PushOperator[self, MakeCompiledImage[frame: f, env: env, body: b]]; }; ApplyPOP: PUBLIC PROC[self: State] ~ { Pop[self]; }; ApplyCOPY: PUBLIC PROC[self: State] ~ { n: Integer ~ PopInteger[self]; Copy[self: self, depth: n]; }; ApplyDUP: PUBLIC PROC[self: State] ~ { Copy[self: self, depth: 1]; }; ApplyROLL: PUBLIC PROC[self: State] ~ { moveFirst: Integer ~ PopInteger[self]; depth: Integer ~ PopInteger[self]; Roll[self: self, depth: depth, moveFirst: moveFirst]; }; ApplyEXCH: PUBLIC PROC[self: State] ~ { Roll[self: self, depth: 2, moveFirst: 1]; }; ApplyMARK: PUBLIC PROC[self: State] ~ { n: Integer ~ PopInteger[self]; Mark[self, n]; }; ApplyUNMARK: PUBLIC PROC[self: State] ~ { n: Integer ~ PopInteger[self]; Unmark[self, n]; }; ApplyUNMARK0: PUBLIC PROC[self: State] ~ { Unmark0[self]; }; ApplyCOUNT: PUBLIC PROC[self: State] ~ { PushInteger[self, Count[self]]; }; ApplyNOP: PUBLIC PROC[self: State] ~ { }; ApplyERROR: PUBLIC PROC[self: State] ~ { code: Integer ~ PopInteger[self]; message: Vector ~ PopVector[self]; IF code=0 THEN ERROR Error; }; ApplyIF: PUBLIC PROC[self: State] ~ { b: BOOL ~ PopBool[self]; IF b THEN CallInlineBody[self] ELSE SkipInlineBody[self]; }; ApplyIFELSE: PUBLIC PROC[self: State] ~ { b: BOOL ~ PopBool[self]; IF b THEN CallInlineBody[self] ELSE SkipInlineBody[self]; PushBool[self, NOT b]; }; ApplyIFCOPY: PUBLIC PROC[self: State] ~ { testCopy: Operator ~ PopOperator[self]; MasterWarning[$unimplemented, "IFCOPY is not implemented."]; SkipInlineBody[self]; }; ApplyLOOP: PUBLIC PROC[self: State] ~ { b: Body ~ GetInlineBody[self]; op: Operator ~ MakeCO[frame: Frame[self], pool: PoolOp[self], env: Env[self], body: b]; DO Do[self, op]; IF NOT PopBool[self] THEN EXIT ENDLOOP; }; ApplyEQ: PUBLIC PROC[self: State] ~ { b: Any ~ PopAny[self]; a: Any ~ PopAny[self]; PushBool[self, Eq[a, b]]; }; ApplyEQNAME: PUBLIC PROC[self: State] ~ { b: Any ~ PopAny[self]; a: Any ~ PopAny[self]; PushBool[self, EqName[a, b]]; }; ApplyGT: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushBool[self, a>b]; }; ApplyGE: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushBool[self, a>=b]; }; ApplyAND: PUBLIC PROC[self: State] ~ { b: BOOL ~ PopBool[self]; a: BOOL ~ PopBool[self]; PushBool[self, a AND b]; }; ApplyOR: PUBLIC PROC[self: State] ~ { b: BOOL ~ PopBool[self]; a: BOOL ~ PopBool[self]; PushBool[self, a OR b]; }; ApplyNOT: PUBLIC PROC[self: State] ~ { b: BOOL ~ PopBool[self]; PushBool[self, NOT b]; }; ApplyTYPE: PUBLIC PROC[self: State] ~ { code: TypeCode ~ TopType[self]; Pop[self]; PushInteger[self, ORD[code]]; }; ApplyADD: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a+b]; }; ApplySUB: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a-b]; }; ApplyNEG: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, -a]; }; ApplyABS: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, ABS[a]]; }; ApplyFLOOR: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Floor[a]]; }; ApplyCEILING: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Ceiling[a]]; }; ApplyTRUNC: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Trunc[a]]; }; ApplyROUND: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Round[a]]; }; ApplyMUL: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a*b]; }; ApplyDIV: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, a/b]; }; ApplyMOD: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Mod[a, b]]; }; ApplyREM: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, RealExtras.Rem[a, b]]; }; ApplyMAX: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, MAX[a, b]]; }; ApplyMIN: PUBLIC PROC[self: State] ~ { b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushReal[self, MIN[a, b]]; }; ApplySQRT: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.SqRt[a]]; }; ApplyEXP: PUBLIC PROC[self: State] ~ { e: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; PushReal[self, RealFns.Power[b, e]]; }; ApplyLOG: PUBLIC PROC[self: State] ~ { v: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; PushReal[self, RealFns.Log[b, v]]; }; ApplySIN: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.SinDeg[a]]; }; ApplyCOS: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushReal[self, RealFns.CosDeg[a]]; }; ApplyATAN: PUBLIC PROC[self: State] ~ { x: REAL ~ PopReal[self]; y: REAL ~ PopReal[self]; PushReal[self, RealFns.ArcTanDeg[y, x]]; }; END. VIPBaseImpl.mesa Copyright c 1984 Xerox Corporation. All rights reserved. Doug Wyatt, November 14, 1984 8:52:59 am PST Vector operators (2.4.3) Frame, pool, and environment operators (2.4.4) Operator operators (2.4.5) Stack operators (2.4.6) class: ErrorClass ~ (SELECT code FROM 0 => $masterError, 10 => $masterWarning, 50 => $appearanceError, 60 => $appearanceWarning, 100 => $comment, ENDCASE => nil); ReportError[class, $ERROR, RopeFromVector[message]]; IF class=$masterError THEN ERROR Error; Control operators (2.4.7) Test operators (2.4.8) Arithmetic operators (2.4.9) Ę Ż˜šœ™Jšœ Ďmœ.™9Jšœ,™,J™—šĎk ˜ Jšœžœ˜Jšœ˜Jšœ žœ*˜:Jšœžœ/˜J˜—šŸ œžœžœ˜)J˜/J˜—šŸ œžœžœ˜)J˜J˜J˜!J˜ZJ˜—šŸœžœžœ˜/J˜J˜XJ˜—šŸœžœžœ˜%J˜!J˜ J˜—šŸ œžœžœ˜)J˜!Jšœžœ˜ Jšœ˜J˜—šŸœžœžœ˜,J˜!Jšœžœ˜ Jšœ˜J˜—šŸ œžœžœ˜)J˜J˜9J˜—šŸœžœžœ˜-J˜Jšœžœ@˜LJšœ˜J˜—šŸœžœžœ˜0J˜Jšœžœ@˜LJšœ˜J˜—šŸœžœžœ˜3Jšœžœ"˜.Jšœ˜J˜—šŸœžœžœ˜4J˜J˜J˜JšœC˜CJ˜—J˜—J™šœ™J™šŸœžœžœ˜&J˜ J˜—šŸ œžœžœ˜'Jšœ˜Jšœ˜J˜—šŸœžœžœ˜&Jšœ˜J˜—šŸ œžœžœ˜'Jšœ&˜&Jšœ"˜"Jšœ5˜5J˜—šŸ œžœžœ˜'Jšœ)˜)J˜—šŸ œžœžœ˜'Jšœ˜J˜J˜—šŸ œžœžœ˜)Jšœ˜J˜J˜—šŸ œžœžœ˜*J˜J˜—šŸ œžœžœ˜(Jšœ˜J˜—šŸœžœžœ˜&J˜—šŸ œžœžœ˜(J˜!J˜"šœžœž™%Jšœ(™(Jšœ1™1Jšœžœ ™!—Jšœ4™4Jšžœžœžœ™'Jšžœžœžœ˜J˜—J˜—J™šœ™J™šŸœžœžœ˜%Jšœžœ˜Jšžœžœžœ˜9J˜—šŸ œžœžœ˜)Jšœžœ˜Jšžœžœžœ˜9Jšœžœ˜J˜—šŸ œžœžœ˜)J˜'Jšœ<˜