DIRECTORY IPBasePrimitives USING [], IPBasic USING [Any, Integer, Number, Operator, State, Vector, VectorShape], IPErrors USING [MasterError], IPExec USING [FGet, FSet, MakeCO, MakeSimpleCO, Do, DoBody, DoSimpleBody, If, IfCopy], IPOps USING [Eq, EqN, Gt, Ge, Type, Add, Sub, Neg, Abs, Floor, Ceiling, Trunc, Round, Mul, Div, Mod, Rem], IPStack USING [PopAny, PopBool, PopInteger, PopNumber, PopOperator, PopVector, PushAny, PushBool, PushInteger, PushNumber, PushOperator, PushVector, Copy, Roll, Mark, Unmark, Count], IPVector USING [Get, MakeVecLU, MakeVec, Shape, GetProp, MergeProp]; IPBasePrimitivesImpl: CEDAR PROGRAM IMPORTS IPErrors, IPExec, IPOps, IPStack, IPVector EXPORTS IPBasePrimitives = BEGIN OPEN IPBasic; ApplyGET: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; v: Vector = IPStack.PopVector[self]; x: Any = IPVector.Get[v, n]; IPStack.PushAny[self, x]; }; ApplyMAKEVECLU: PUBLIC PROC[self: State] = { u: Integer = IPStack.PopInteger[self]; l: Integer = IPStack.PopInteger[self]; v: Vector = IPVector.MakeVecLU[self, l, u]; IPStack.PushVector[self, v]; }; ApplyMAKEVEC: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; v: Vector = IPVector.MakeVec[self, n]; IPStack.PushVector[self, v]; }; ApplySHAPE: PUBLIC PROC[self: State] = { v: Vector = IPStack.PopVector[self]; shape: VectorShape = IPVector.Shape[v]; IPStack.PushInteger[self, shape.l]; IPStack.PushInteger[self, shape.n]; }; ApplyOPENVEC: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyGETPROP: PUBLIC PROC[self: State] = { propName: Any = IPStack.PopAny[self]; v: Vector = IPStack.PopVector[self]; x: Any; b: BOOL; [x, b] _ IPVector.GetProp[v, propName]; IF b THEN IPStack.PushAny[self, x]; IPStack.PushBool[self, b]; }; ApplyGETP: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyMERGEPROP: PUBLIC PROC[self: State] = { v2: Vector = IPStack.PopVector[self]; v1: Vector = IPStack.PopVector[self]; v3: Vector = IPVector.MergeProp[v1, v2]; IPStack.PushVector[self, v3]; }; ApplyFGET: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; x: Any = IPExec.FGet[self, n]; IPStack.PushAny[self, x]; }; ApplyFSET: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; x: Any = IPStack.PopAny[self]; IPExec.FSet[self, x, n]; }; ApplyFRAME: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyPOOLOP: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyPOOL: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyPGET: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyPSET: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyENV: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyMAKESIMPLECO: PUBLIC PROC[self: State] = { o: Operator = IPExec.MakeSimpleCO[self]; -- body operator IPStack.PushOperator[self, o]; }; ApplyMAKECO: PUBLIC PROC[self: State] = { f: Vector = IPStack.PopVector[self]; o: Operator = IPExec.MakeCO[self, f]; -- body operator IPStack.PushOperator[self, o]; }; ApplyMAKECOMPILEDIMAGE: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyMAKEPOOL: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyNOPOOL: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyDO: PUBLIC PROC[self: State] = { o: Operator = IPStack.PopOperator[self]; IPExec.Do[self, o]; }; ApplyDOSAVE: PUBLIC PROC[self: State] = { o: Operator = IPStack.PopOperator[self]; IPExec.Do[self, o, save]; }; ApplyDOSAVEALL: PUBLIC PROC[self: State] = { o: Operator = IPStack.PopOperator[self]; IPExec.Do[self, o, saveAll]; }; ApplyDOBODY: PUBLIC PROC[self: State] = { f: Vector = IPStack.PopVector[self]; IPExec.DoBody[self, f]; -- body operator }; ApplyDOSAVEBODY: PUBLIC PROC[self: State] = { f: Vector = IPStack.PopVector[self]; IPExec.DoBody[self, f, save]; -- body operator }; ApplyDOSAVEALLBODY: PUBLIC PROC[self: State] = { f: Vector = IPStack.PopVector[self]; IPExec.DoBody[self, f, saveAll]; -- body operator }; ApplyDOSAVESIMPLEBODY: PUBLIC PROC[self: State] = { IPExec.DoSimpleBody[self, save]; -- body operator }; ApplyPOP: PUBLIC PROC[self: State] = { [] _ IPStack.PopAny[self]; }; ApplyCOPY: PUBLIC PROC[self: State] = { depth: Integer = IPStack.PopInteger[self]; IPStack.Copy[self, depth]; }; ApplyDUP: PUBLIC PROC[self: State] = { IPStack.Copy[self, 1]; }; ApplyROLL: PUBLIC PROC[self: State] = { moveFirst: Integer = IPStack.PopInteger[self]; depth: Integer = IPStack.PopInteger[self]; IPStack.Roll[self, depth, moveFirst]; }; ApplyEXCH: PUBLIC PROC[self: State] = { IPStack.Roll[self, 2, 1]; }; ApplyMARK: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; IPStack.Mark[self, n]; }; ApplyUNMARK: PUBLIC PROC[self: State] = { n: Integer = IPStack.PopInteger[self]; IPStack.Unmark[self, n]; }; ApplyUNMARK0: PUBLIC PROC[self: State] = { IPStack.Unmark[self, 0]; }; ApplyCOUNT: PUBLIC PROC[self: State] = { n: Integer = IPStack.Count[self]; IPStack.PushInteger[self, n]; }; ApplyNOP: PUBLIC PROC[self: State] = { }; ApplyIF: PUBLIC PROC[self: State] = { b: BOOL = IPStack.PopBool[self]; IPExec.If[self, b]; -- body operator }; ApplyIFELSE: PUBLIC PROC[self: State] = { b: BOOL = IPStack.PopBool[self]; IPExec.If[self, b]; -- body operator IPStack.PushBool[self, NOT b]; }; ApplyIFCOPY: PUBLIC PROC[self: State] = { testCopy: Operator = IPStack.PopOperator[self]; IPExec.IfCopy[self, testCopy]; -- body operator }; ApplyLOOP: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyEQ: PUBLIC PROC[self: State] = { b: Any = IPStack.PopAny[self]; a: Any = IPStack.PopAny[self]; c: BOOL = IPOps.Eq[a, b]; IPStack.PushBool[self, c]; }; ApplyEQN: PUBLIC PROC[self: State] = { b: Any = IPStack.PopAny[self]; a: Any = IPStack.PopAny[self]; c: BOOL = IPOps.EqN[a, b]; IPStack.PushBool[self, c]; }; ApplyGT: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: BOOL = IPOps.Gt[a, b]; IPStack.PushBool[self, c]; }; ApplyGE: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: BOOL = IPOps.Ge[a, b]; IPStack.PushBool[self, c]; }; ApplyAND: PUBLIC PROC[self: State] = { b: BOOL = IPStack.PopBool[self]; a: BOOL = IPStack.PopBool[self]; c: BOOL = a AND b; IPStack.PushBool[self, c]; }; ApplyOR: PUBLIC PROC[self: State] = { b: BOOL = IPStack.PopBool[self]; a: BOOL = IPStack.PopBool[self]; c: BOOL = a OR b; IPStack.PushBool[self, c]; }; ApplyNOT: PUBLIC PROC[self: State] = { b: BOOL = IPStack.PopBool[self]; c: BOOL = NOT b; IPStack.PushBool[self, c]; }; ApplyTYPE: PUBLIC PROC[self: State] = { a: Any = IPStack.PopAny[self]; c: Integer = IPOps.Type[a]; IPStack.PushInteger[self, c]; }; ApplyADD: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Add[a, b]; IPStack.PushNumber[self, c]; }; ApplySUB: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Sub[a, b]; IPStack.PushNumber[self, c]; }; ApplyNEG: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Neg[a]; IPStack.PushNumber[self, c]; }; ApplyABS: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Abs[a]; IPStack.PushNumber[self, c]; }; ApplyFLOOR: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Floor[a]; IPStack.PushNumber[self, c]; }; ApplyCEILING: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Ceiling[a]; IPStack.PushNumber[self, c]; }; ApplyTRUNC: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Trunc[a]; IPStack.PushNumber[self, c]; }; ApplyROUND: PUBLIC PROC[self: State] = { a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Round[a]; IPStack.PushNumber[self, c]; }; ApplyMUL: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Mul[a, b]; IPStack.PushNumber[self, c]; }; ApplyDIV: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Div[a, b]; IPStack.PushNumber[self, c]; }; ApplyMOD: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Mod[a, b]; IPStack.PushNumber[self, c]; }; ApplyREM: PUBLIC PROC[self: State] = { b: Number = IPStack.PopNumber[self]; a: Number = IPStack.PopNumber[self]; c: Number = IPOps.Rem[a, b]; IPStack.PushNumber[self, c]; }; ApplyMAX: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyMIN: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplySQRT: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyEXP: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyLOG: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplySIN: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyCOS: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; ApplyATAN: PUBLIC PROC[self: State] = { ERROR IPErrors.MasterError[Unimplemented]; }; END. IPBasePrimitivesImpl.mesa Last edited by: Doug Wyatt, April 29, 1983 1:47 pm 2.4.3 Vector operators 2.4.4 Frame operators 2.4.5 Operator operators 2.4.6 Stack operators 2.4.7 Control operators 2.4.8 Test operators 2.4.9 Arithmetic operators Κ #˜headšœ™šœ™Jšœ"™"—J˜šΟk ˜ Jšœœ˜Jšœœ>˜KJšœ œ˜JšœœJ˜VJšœœ_˜jJšœœ©˜ΆJšœ œ6˜D—J˜—šœœ˜#Jšœ+˜2Jšœ˜Jšœœœ ˜J˜Kšœ™šΟnœœœ˜&Jšœ&˜&Jšœ$˜$Jšœ˜J˜J˜—šžœœœ˜,Jšœ&˜&Jšœ&˜&Jšœ+˜+J˜J˜—šž œœœ˜*Jšœ&˜&Jšœ&˜&J˜J˜—šž œœœ˜(J˜$J˜'J˜GJ˜—šž œœœ˜*Jšœ%˜*J˜—šž œœœ˜*J˜%J˜$Jšœ œ˜Jšœ'˜'Jšœœ˜#Jšœ˜J˜—šž œœœ˜'Jšœ%˜*J˜—šžœœœ˜,J˜KJšœ(˜(J˜J˜—J™Kšœ™šž œœœ˜'Jšœ&˜&Jšœ˜Jšœ˜J˜—šž œœœ˜'Jšœ&˜&Jšœ˜Jšœ˜J˜—šž œœœ˜(Jšœ%˜*J˜—šž œœœ˜)Jšœ%˜*J˜—šž œœœ˜'Jšœ%˜*J˜—šž œœœ˜'Jšœ%˜*J˜—šž œœœ˜'Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—J™Kšœ™šžœœœ˜/Jšœ)Οc˜9Jšœ˜J˜—šž œœœ˜)J˜$Jšœ&Ÿ˜6Jšœ˜J˜—šžœœœ˜4Jšœ%˜*J˜—šž œœœ˜+Jšœ%˜*J˜—šž œœœ˜)Jšœ%˜*J˜—šžœœœ˜%J˜(Jšœ˜J˜—šž œœœ˜)J˜(Jšœ˜J˜—šžœœœ˜,J˜(Jšœ˜J˜—šž œœœ˜)J˜$JšœŸ˜(J˜—šžœœœ˜-J˜$JšœŸ˜.J˜—šžœœœ˜0J˜$Jšœ!Ÿ˜1J˜—šžœœœ˜3Jšœ!Ÿ˜1J˜—J™Kšœ™šžœœœ˜&J˜J˜—šž œœœ˜'Jšœ*˜*Jšœ˜J˜—šžœœœ˜&Jšœ˜J˜—šž œœœ˜'Jšœ.˜.Jšœ*˜*Jšœ%˜%J˜—šž œœœ˜'Jšœ˜J˜—šž œœœ˜'Jšœ&˜&Jšœ˜J˜—šž œœœ˜)Jšœ&˜&Jšœ˜J˜—šž œœœ˜*Jšœ˜J˜—šž œœœ˜(Jšœ!˜!J˜J˜—šžœœœ˜&Jšœ˜—J™Kšœ™šžœœœ˜%Jšœœ˜ JšœŸ˜$J˜—šž œœœ˜)Jšœœ˜ JšœŸ˜$Jšœœ˜J˜—šž œœœ˜)J˜/JšœŸ˜/J˜—šž œœœ˜'Jšœ%˜*J˜—J™Kšœ™šžœœœ˜%J˜J˜Jšœœ˜Jšœ˜J˜—šžœœœ˜&J˜J˜Jšœœ˜Jšœ˜J˜—šžœœœ˜%J˜$J˜$Jšœœ˜Jšœ˜J˜—šžœœœ˜%J˜$J˜$Jšœœ˜Jšœ˜J˜—šžœœœ˜&Jšœœ˜ Jšœœ˜ Jšœœœ˜Jšœ˜J˜—šžœœœ˜%Jšœœ˜ Jšœœ˜ Jšœœœ˜Jšœ˜J˜—šžœœœ˜&Jšœœ˜ Jšœœœ˜Jšœ˜J˜—šž œœœ˜'J˜Jšœ˜J˜J˜—J™Kšœ™šžœœœ˜&J˜$J˜$J˜J˜J˜—šžœœœ˜&J˜$J˜$J˜J˜J˜—šžœœœ˜&Jšœ$˜$Jšœ˜J˜J˜—šžœœœ˜&Jšœ$˜$Jšœ˜J˜J˜—šž œœœ˜(Jšœ$˜$Jšœ˜Jšœ˜J˜—šž œœœ˜*Jšœ$˜$Jšœ˜Jšœ˜J˜—šž œœœ˜(Jšœ$˜$Jšœ˜Jšœ˜J˜—šž œœœ˜(Jšœ$˜$Jšœ˜Jšœ˜J˜—šžœœœ˜&Jšœ$˜$Jšœ$˜$Jšœ˜J˜J˜—šžœœœ˜&Jšœ$˜$Jšœ$˜$Jšœ˜J˜J˜—šžœœœ˜&Jšœ$˜$Jšœ$˜$Jšœ˜Jšœ˜J˜—šžœœœ˜&Jšœ$˜$Jšœ$˜$Jšœ˜Jšœ˜J˜—šžœœœ˜&Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—šž œœœ˜'Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—šžœœœ˜&Jšœ%˜*J˜—šž œœœ˜'Jšœ%˜*J˜—J˜Jšœ˜——…—$ή1