<<>> <> <> <> <> <> <> DIRECTORY TJaM, RealFns USING [ArcTanDeg, CosDeg, Log, Power, SinDeg, SqRt]; TJaMMathImpl: CEDAR PROGRAM IMPORTS TJaM, RealFns = BEGIN OPEN TJaM; ApplyAdd: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, a+b]; }; ApplySub: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, a-b]; }; ApplyMul: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, a*b]; }; ApplyDiv: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, a/b]; }; ApplyIDiv: CommandProc ~ { b: INT ~ PopInt[frame]; a: INT ~ PopInt[frame]; PushInt[frame, a/b]; }; ApplyNeg: CommandProc ~ { a: REAL ~ PopReal[frame]; PushReal[frame, -a]; }; ApplySin: CommandProc ~ { a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.SinDeg[a]]; }; ApplyCos: CommandProc ~ { a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.CosDeg[a]]; }; ApplyATan: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.ArcTanDeg[a, b ! ANY => GOTO Fail]]; EXITS Fail => ProduceError[numericOverflow]; }; ApplyExp: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.Power[a, b ! ANY => GOTO Fail]]; EXITS Fail => ProduceError[numericOverflow]; }; ApplyLog: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.Log[a, b ! ANY => GOTO Fail]] EXITS Fail => ProduceError[numericOverflow]; }; ApplySqRt: CommandProc ~ { a: REAL ~ PopReal[frame]; PushReal[frame, RealFns.SqRt[a ! ANY => GOTO Fail]] EXITS Fail => ProduceError[numericOverflow]; }; ApplyEq: CommandProc ~ { b: REF ~ Pop[frame]; a: REF ~ Pop[frame]; PushBool[frame, Equal[a,b]]; }; ApplyLt: CommandProc ~ { b: REAL ~ PopReal[frame]; a: REAL ~ PopReal[frame]; PushBool[frame, ab]; }; ApplyNot: CommandProc ~ { a: BOOL ~ PopBool[frame]; PushBool[frame, NOT a]; }; ApplyAnd: CommandProc ~ { b: BOOL ~ PopBool[frame]; a: BOOL ~ PopBool[frame]; PushBool[frame, a AND b]; }; ApplyOr: CommandProc ~ { b: BOOL ~ PopBool[frame]; a: BOOL ~ PopBool[frame]; PushBool[frame, a OR b]; }; ApplyXor: CommandProc ~ { b: BOOL ~ PopBool[frame]; a: BOOL ~ PopBool[frame]; PushBool[frame, a # b]; }; <> <> <> <<};>> <<>> <> <> <> <> <<};>> <<>> <> <> <> <> <<};>> <<>> <> <> <> <> <<};>> <<>> <> <> <> <> <<};>> <<>> RegisterPrimitive[".add", ApplyAdd]; RegisterPrimitive[".sub", ApplySub]; RegisterPrimitive[".mul", ApplyMul]; RegisterPrimitive[".div", ApplyDiv]; RegisterPrimitive[".idiv", ApplyIDiv]; RegisterPrimitive[".neg", ApplyNeg]; RegisterPrimitive[".sin", ApplySin]; RegisterPrimitive[".cos", ApplyCos]; RegisterPrimitive[".atan", ApplyATan]; RegisterPrimitive[".exp", ApplyExp]; RegisterPrimitive[".log", ApplyLog]; RegisterPrimitive[".sqrt", ApplySqRt]; RegisterPrimitive[".eq", ApplyEq]; RegisterPrimitive[".lt", ApplyLt]; RegisterPrimitive[".gt", ApplyGt]; RegisterPrimitive[".not", ApplyNot]; RegisterPrimitive[".and", ApplyAnd]; RegisterPrimitive[".or", ApplyOr]; RegisterPrimitive[".xor", ApplyXor]; <<>> <> <> <> <> <> END.