<> <> <> <<>> DIRECTORY IPBase USING [], IPInterpreter USING [Any, Body, CallInlineBody, Cardinal, Copy, Count, Do, DoSave, DoSaveAll, Env, Eq, FGet, Frame, FSet, Get, GetInlineBody, GetP, GetProp, MakeCO, MakeVec, MakeVecLU, Mark, MasterError, MasterWarning, MergeProp, Operator, Pop, PopAny, PopBool, PopCardinal, PopOperator, PopReal, PopVector, PushAny, PushBool, PushCardinal, PushOperator, PushReal, PushVector, Ref, ReportError, Roll, RopeFromVector, Shape, SkipInlineBody, TopType, TypeCode, Unmark, Vector, VectorShape], IPReal USING [Ceiling, Floor, Mod, Rem, Round, Trunc]; IPBaseImpl: CEDAR PROGRAM IMPORTS IPInterpreter, IPReal EXPORTS IPBase ~ BEGIN OPEN IPInterpreter; <> ApplyGET: PUBLIC PROC [self: Ref] ~ { j: Cardinal ~ PopCardinal[self]; v: Vector ~ PopVector[self]; PushAny[self, Get[v, j]]; }; ApplyMAKEVECLU: PUBLIC PROC [self: Ref] ~ { u: Cardinal ~ PopCardinal[self]; l: Cardinal ~ PopCardinal[self]; pop: PROC RETURNS [Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVecLU[l, u, pop]; PushVector[self, v]; }; ApplyMAKEVEC: PUBLIC PROC [self: Ref] ~ { n: Cardinal ~ PopCardinal[self]; pop: PROC RETURNS [Any] ~ { RETURN[PopAny[self]] }; v: Vector ~ MakeVec[n, pop]; PushVector[self, v]; }; ApplySHAPE: PUBLIC PROC [self: Ref] ~ { v: Vector ~ PopVector[self]; shape: VectorShape ~ Shape[v]; PushCardinal[self, shape.lowerBound]; PushCardinal[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]]; }; <> ApplyFGET: PUBLIC PROC [self: Ref] ~ { j: Cardinal ~ PopCardinal[self]; PushAny[self, FGet[self, j]]; }; ApplyFSET: PUBLIC PROC [self: Ref] ~ { j: Cardinal ~ PopCardinal[self]; x: Any ~ PopAny[self]; FSet[self, x, j]; }; <> ApplyMAKESIMPLECO: PUBLIC PROC [self: Ref] ~ { b: Body ~ GetInlineBody[self]; PushOperator[self, MakeCO[frame: Frame[self], 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]; }; ApplyDOSAVESIMPLEBODY: PUBLIC PROC [self: Ref] ~ { frame: Vector ~ Frame[self]; env: Vector ~ Env[self]; action: PROC ~ { CallInlineBody[self: self, frame: frame, env: env] }; DoSave[self, action]; }; ApplyFINDOPERATOR: PUBLIC PROC [self: Ref] ~ { v: Vector ~ PopVector[self]; MasterError[$unimplemented, "Not implemented: FINDOPERATOR"]; }; <> ApplyPOP: PUBLIC PROC [self: Ref] ~ { Pop[self]; }; ApplyCOPY: PUBLIC PROC [self: Ref] ~ { n: Cardinal ~ PopCardinal[self]; Copy[self: self, depth: n]; }; ApplyDUP: PUBLIC PROC [self: Ref] ~ { Copy[self: self, depth: 1]; }; ApplyROLL: PUBLIC PROC [self: Ref] ~ { moveFirst: Cardinal ~ PopCardinal[self]; depth: Cardinal ~ PopCardinal[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: Cardinal ~ PopCardinal[self]; Mark[self, n]; }; ApplyUNMARK: PUBLIC PROC [self: Ref] ~ { n: Cardinal ~ PopCardinal[self]; Unmark[self, n]; }; ApplyUNMARK0: PUBLIC PROC [self: Ref] ~ { Unmark[self, 0]; }; ApplyCOUNT: PUBLIC PROC [self: Ref] ~ { PushCardinal[self, Count[self]]; }; ApplyNOP: PUBLIC PROC [self: Ref] ~ { }; ApplyERROR: PUBLIC PROC [self: Ref] ~ { code: Cardinal ~ PopCardinal[self]; message: Vector ~ PopVector[self]; ReportError[code, $ERROR, RopeFromVector[message]]; }; <> ApplyIF: PUBLIC PROC [self: Ref] ~ { bool: BOOL ~ PopBool[self]; IF bool THEN CallInlineBody[self: self, frame: Frame[self], env: Env[self]] ELSE SkipInlineBody[self]; }; ApplyIFELSE: PUBLIC PROC [self: Ref] ~ { bool: BOOL ~ PopBool[self]; IF bool THEN CallInlineBody[self: self, frame: Frame[self], 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]; }; <> ApplyEQ: PUBLIC PROC [self: Ref] ~ { b: Any ~ PopAny[self]; a: Any ~ PopAny[self]; PushBool[self, Eq[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]; PushCardinal[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]]; }; <> <> <> <> <> <> <> <<};>> <> <> <<};>> <> <> <<};>> <> <> <<};>> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <<};>> <> <> <> <> <<};>> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <> <<};>> <> <> <> <> <> <<};>> <> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <> <<};>> <> <> <> <<};>> <> <> <> <<};>> <> <> <> <> <<};>> END.