ExprsImpl.mesa
Last Edited by: Arnon, July 19, 1985 2:54:46 pm PDT
DIRECTORY
AlgebraClasses,
Exprs;
ExprsImpl: CEDAR PROGRAM
IMPORTS AlgebraClasses
EXPORTS Exprs
= BEGIN OPEN AC: AlgebraClasses;
Types
Object: TYPE = AC.Object;
Method: TYPE = AC.Method;
Miscellaneous Procs
Recast: AC.UnaryOp = {
toExprMethod: Method ← AC.LookupMethodForStructure[$toExpr, arg.class];
RETURN[AC.ApplyMethodNoChecks[toExprMethod, LIST[arg] ];
};
CanRecast: AC.UnaryPredicate = {
RETURN[TRUE];
};
ToExpr: AC.ToExprOp = { -- Should become a noop when MathExpr.EXPR redone as Object
data: IntData ← NARROW[in.data];
RETURN[MathConstructors.MakeInt[Convert.RopeFromInt[data^] ] ];
};
MakeCompoundExpr: AC.BinaryOp = { -- Should become a BinaryOp when MathExpr.EXPR redone as Object
};
Start Code
ExprsClass: Object ← AC.MakeClass["ExprsClass", NIL, NIL];
Exprs: PUBLIC Object ← AC.MakeStructure["Exprs", ExprsClass, NIL];
categoryMethod: Method ← AC.MakeMethod[Value, FALSE, Exprs, NEW[AC.Category ← set], NIL, NIL];
recastMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, Exprs, NEW[AC.UnaryOp ← Recast], NIL, "recast"];
canRecastMethod: Method ← AC.MakeMethod[UnaryPredicate, TRUE, Exprs, NEW[AC.UnaryPredicate ← CanRecast], NIL, "canRecast"];
toExprMethod: Method ← AC.MakeMethod[ToExprOp, TRUE, Exprs, NEW[AC.ToExprOp ← ToExpr], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "toExpr"];
compoundExprMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, Exprs, NEW[AC.BinaryOp ← MakeCompoundExpr], NIL, "compoundExpr"];
AC.AddMethodToClass[$category, categoryMethod, ExprsClass];
AC.AddMethodToClass[$recast, recastMethod, ExprsClass];
AC.AddMethodToClass[$canRecast, canRecastMethod, ExprsClass];
AC.AddMethodToClass[$toExpr, toExprMethod, ExprsClass];
AC.AddMethodToClass[$compoundExpr, compoundExprMethod, ExprsClass];
AC.InstallStructure[Exprs];
END.