<<>> <> <> <> <<>> DIRECTORY SafeStorage, IO, Atom, Rope, Basics, Imager, MathExpr, MathObjects; MathObjectsImpl: CEDAR PROGRAM IMPORTS Rope EXPORTS MathObjects = BEGIN <> ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; <> ObjectRep: TYPE = RECORD [ class: Object _ NIL, data: REF _ NIL ]; Object: TYPE ~ REF ObjectRep; -- inside impl module, use rep <<>> MethodRep: TYPE = RECORD [ staticType: ATOM, name of method's "static type", which is a specification of the numbers (arities) of its inputs and outputs, and "some" information about their types. I.e. static types denote families of similar methods. Used for "dispatch on name of static type" invocation of methods (following check (and possible parameter recasting) that actual parameters conform to this method's "dynamic type", which is computed afresh at each invocation of this method) via a global Alist of method types and corresponding method apply procs. The actual ATOM here is a selector into that global AList. <> <> <<>> dynamicType: REF UnaryToTwoListsOp _ NIL, <> <> <> <> <> <> <> <> If output LIST OF arg Structures has i < n = (# args this method) Structures, then args i, i+1, ..., n expected to belong to last (ith) Structure of the list (useful e.g. for vector and matrix constructors). <> <<>> value: REF -- REF Proc The "impl" of the method attributes: Atom.PropList, <<"constant" attributes stored e.g. as [$commutative, $commutative]; NIL value field would confuse with absence of attribute>> <> ]; Method: TYPE ~ REF MethodRep; -- inside impl module, use rep <<>> MethodDictionaryRep: TYPE = Atom.PropList; MethodDictionary: TYPE = REF MethodDictionaryRep; <<>> <> StaticTypes: PUBLIC Atom.PropList _ NIL; ApplyMethod: PUBLIC PROC [method: REF, structure: Object, argList: LIST OF REF, recast: BOOL] RETURNS[value: REF] = m: Method; ok: BOOL _ TRUE; IF NARROW[method, Method] THEN m _ method ELSE m _ LookupMethodInStructure[method, structure]; -- FALSE => method arg is actually an ATOM method key; use it to lookup the method IF recast THEN [ok, outArgs] _ RecastArgs[m, structure, argList] ELSE outArgs _ argList; -- note that RecastArgs must handle argList as a list of REF's IF ok THEN <> ELSE ERROR; END; <> MethodType: TYPE = {Value, SideEffect, TrueNullaryOp, NullaryOp, UnaryOp, BinaryOp, BinaryMixedOp, TernaryOp, TernaryMixedOp, QuaternaryOp, LegalFirstCharOp, ReadOp, FromRopeOp, ToRopeOp, ToExprOp, FromExprOp, FromBOOLOp, FromINTOp, UnaryPredicate, BinaryPredicate, CompareToZeroOp, BinaryCompareOp, StructuredToGroundOp, ElementRankOp, UnaryImbedOp, BinaryImbedOp, ListImbedOp, MatrixImbedOp, StructureFromSetConstructor, VectorStructureConstructor, SequenceStructureConstructor, MatrixStructureConstructor, PolynomialStructureConstructor}; <<>> END.