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. r TJaMMathImpl.mesa Copyright Σ 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved. Original version by John Warnock, February 27, 1979 Bill Paxton, December 19, 1980 9:35 AM McGregor, September 10, 1982 11:17 am Doug Wyatt, November 27, 1992 1:43 pm PST ApplyBitNot: CommandProc ~ { a: INT ~ PopInt[frame]; PushInt[frame, Basics.DoubleNot[[li[a]]].li]; }; ApplyBitAnd: CommandProc ~ { b: INT ~ PopInt[frame]; a: INT ~ PopInt[frame]; PushInt[frame, Basics.DoubleAnd[[li[a]], [li[b]]].li]; }; ApplyBitOr: CommandProc ~ { b: INT ~ PopInt[frame]; a: INT ~ PopInt[frame]; PushInt[frame, Basics.DoubleOr[[li[a]], [li[b]]].li]; }; ApplyBitXor: CommandProc ~ { b: INT ~ PopInt[frame]; a: INT ~ PopInt[frame]; PushInt[frame, Basics.DoubleXor[[li[a]], [li[b]]].li]; }; ApplyBitShift: CommandProc ~ { b: INT ~ PopInt[frame]; a: INT ~ PopInt[frame]; PushInt[frame, Basics.DoubleShift[[li[a]], b].li]; }; RegisterPrimitive[".bitnot", ApplyBitNot]; RegisterPrimitive[".bitand", ApplyBitAnd]; RegisterPrimitive[".bitor", ApplyBitOr]; RegisterPrimitive[".bitxor", ApplyBitXor]; RegisterPrimitive[".bitshift", ApplyBitShift]; ΚL–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ ΟeœC™NKšœ3™3Kšœ'™'Kšœ%™%K™)—K˜šΟk ˜ Kšœ˜Kšœžœ/˜<—K˜KšΠbl œžœž˜Kšžœ˜Kšœžœžœ˜K˜šΟnœœ˜Kšœžœ˜Kšœžœ˜K˜K˜K˜—š œœ˜Kšœžœ˜Kšœžœ˜K˜K˜K˜—š œœ˜Kšœžœ˜Kšœžœ˜K˜K˜K˜—š œœ˜Kšœžœ˜Kšœžœ˜K˜K˜K˜—š  œœ˜Kšœžœ˜Kšœžœ˜K˜K˜K˜—š œœ˜Kšœžœ˜K˜K˜K˜—š œœ˜Kšœžœ˜K˜#K˜K˜—š œœ˜Kšœžœ˜K˜#K˜K˜—š  œœ˜Kšœžœ˜Kšœžœ˜Kšœ)žœžœ˜