<<>> <> <> <> <<>> DIRECTORY SafeStorage, IO, Atom, Rope, Basics, Imager, MathExpr; MathObjects: CEDAR DEFINITIONS = BEGIN <> ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; <> Object: TYPE = REF ObjectRep; ObjectRep: TYPE; -- internal concrete rep <> <> 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}; <> <<>> Method: TYPE = REF MethodRec; MethodRec: TYPE = RECORD [ staticType: ATOM, name of method's "static signature", which is a specification of the numbers (arities) of its inputs and outputs, and some information about their "types". I.e. static signatures denote families of similar methods. Used for "dispatch on name of static signature" invocation of methods (following verfication that actual parameters conform to this method's "dynamic signature", 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. <> <> ApplyToObject: PROC [method: REF, structure: Object, argList: LIST OF Object, recast: BOOL] RETURNS[value: Object]; m: Method; ok: BOOL _ TRUE; IF NARROW[method, Method] THEN m _ method ELSE m _ LookupMethodInStructure[method, structure]; -- FALSE => method arg is actually an ATOM methodSelector; use it to lookup the method IF recast THEN [ok, outArgs] _ RecastArgs[m, structure, argList] ELSE outArgs _ argList; IF ok THEN <> ELSE ERROR; <<>> attributes: Atom.PropList, <<"constant" attributes stored e.g. as [$commutative, $commutative]; NIL value field would confuse with absence of attribute>> 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 ]; MethodDictionary: TYPE = Atom.PropList; <> <> <> <<>> <> MakeMethod: PROC [type: MethodType, operator: BOOL, value: REF, desiredArgStructures: REF UnaryToListOp, doc: ROPE] RETURNS[Method]; DesiredArgStructures: PROC [methodSelector: ATOM, structure: Object] RETURNS[LIST OF Object]; <> DefaultDesiredArgStructures: UnaryToListOp; <> <<>> GetMethodAndRecastArgs: PROC [methodSelector: ATOM, structure: Object, inArgs: LIST OF Object] RETURNS [ok: BOOL, method: Method, outArgs: LIST OF Object _ NIL]; <> <<>> RecastArgs: PROC [method: Method, structure: Object, inArgs: LIST OF Object] RETURNS [ok: BOOL, outArgs: LIST OF Object _ NIL]; <> ApplyLegalFirstCharMethod: PROC [method: Method, char: CHAR, structure: Object _ NIL] RETURNS[BOOL]; ApplyFromRopeMethod: PROC [method: Method, in: ROPE, structure: Object _ NIL] RETURNS[Object]; ApplyReadMethod: PROC [method: Method, in: STREAM, structure: Object _ NIL] RETURNS[Object]; ApplyFromExprMethod: PROC [method: Method, in: EXPR, structure: Object] RETURNS[Object]; ApplyCompareToZeroMethod: PROC [method: Method, arg: Object] RETURNS[Basics.Comparison]; ApplyBinaryCompareMethod: PROC [method: Method, firstArg, secondArg: Object] RETURNS[Basics.Comparison]; ApplyBinaryImbedMethod: PROC [method: Method, data1: Object, data2: REF, structure: Object] RETURNS[Object]; ApplyMixedMethod: PROC [method: Method, objectArgs: LIST OF Object, refArg: REF] RETURNS[Object]; ApplyPredNoLkpNoRecast: PROC [method: Method, argList: LIST OF Object] RETURNS[BOOL]; ApplyPredNoLkpRecast: PROC [method: Method, structure: Object, argList: LIST OF Object] RETURNS[BOOL]; ApplyPredLkpNoRecast: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[BOOL]; <> <> ApplyPredLkpRecast: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[BOOL]; ApplyNoLkpNoRecastRef: PROC [method: Method, argList: LIST OF Object] RETURNS[value: REF]; <> ApplyNoLkpRecastRef: PROC [method: Method, structure: Object, argList: LIST OF Object] RETURNS[value: REF]; ApplyLkpNoRecastRef: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: REF]; <> <> ApplyLkpRecastRef: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: REF]; <> ApplyNoLkpNoRecastObject: PROC [method: Method, argList: LIST OF Object] RETURNS[value: Object]; <> ApplyNoLkpRecastObject: PROC [method: Method, structure: Object, argList: LIST OF Object] RETURNS[value: Object]; ApplyLkpNoRecastObject: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: Object]; <> <> <<>> <<>> ApplyLkpRecastObject: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: Object]; <> ApplyNoLkpNoRecastExpr: PROC [method: Method, argList: LIST OF Object] RETURNS[value: EXPR]; <> <> <<>> ApplyNoLkpRecastExpr: PROC [method: Method, structure: Object, argList: LIST OF Object] RETURNS[value: EXPR]; ApplyLkpRecastExpr: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: EXPR]; <> <> <<>> ApplyLkpNoRecastExpr: PROC [methodSelector: ATOM, structure: Object, argList: LIST OF Object] RETURNS[value: EXPR]; <> <> <> SideEffect: TYPE = PROC [] RETURNS []; TrueNullaryOp: TYPE = PROC [] RETURNS [result: Object]; UnaryOp: TYPE = PROC [arg: Object] RETURNS [result: Object]; UnaryPredicate: TYPE = PROC [arg: Object] RETURNS [BOOL]; <<>> UnaryInPlaceOp: TYPE = PROC [arg: Object]; UnaryToListOp: TYPE = PROC [arg: Object] RETURNS [result: LIST OF Object]; BinaryOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [result: Object]; BinaryPredicate: TYPE = PROC [firstArg, secondArg: Object] RETURNS [BOOL]; EqualityOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [BOOL]; -- redundant BinaryInPlaceOp: TYPE = PROC [firstArg: Object, secondArg: REF]; BinaryMixedOp: TYPE = PROC [firstArg: Object, secondArg: REF] RETURNS [result: Object]; BinaryToPairOp: TYPE = PROC [firstArg: Object, secondArg: REF] RETURNS [firstResult, secondResult: Object]; TernaryOp: TYPE = PROC [firstArg, secondArg, thirdArg: Object] RETURNS [result: Object]; TernaryMixedOp: TYPE = PROC [firstArg, secondArg: Object, thirdArg: REF] RETURNS [result: Object]; QuaternaryOp: TYPE = PROC [firstArg, secondArg, thirdArg, fourthArg: Object] RETURNS [result: Object]; <> MakeClass: PROC [name: Rope.ROPE, superClass: Object, methodDictionary: MethodDictionary _ NIL] RETURNS[class: Object]; <> AddMethodToClass: PROC [methodSelector: ATOM, method: Method, class: Object]; <> SetSuperClass: PROC [object: Object, superClass: Object]; <> <<>> LookupMethodInClass: PROC [methodSelector: ATOM, class: Object] RETURNS[method: Method]; <> <<>> BuildClassOperators: PROC [class: Object] RETURNS[opNames: LIST OF ROPE, operators: LIST OF Method]; <> Category: TYPE ~ {set, lattice, group, ring, field, module, vectorSpace, algebra, divisionAlgebra}; <> PrintNameProc: TYPE = PROC [structure: Object] RETURNS [Rope.ROPE]; -- redundant with ToRopeOp <> StructureToExprOp: TYPE = PROC [structure: Object] RETURNS [out: EXPR]; StructureEqualityTest: TYPE = PROC [thisStructure, otherStructure: Object] RETURNS [BOOL]; <> StructureRankOp: TYPE = PROC [structure: Object] RETURNS [CARDINAL]; <> <<>> ReportOpsProc: TYPE = PROC [structure: Object] RETURNS [opNames: LIST OF Rope.ROPE, refOps: LIST OF REF]; <> <> <<>> BinaryStructureLUBOp: TYPE = PROC [firstStructure, secondStructure: Object] RETURNS [LUBStructure: Object]; <> <> StructureFromSetConstructor: TYPE = PROC [set: Object] RETURNS [structure: Object]; <> VectorStructureConstructor: TYPE = PROC [coordinateStructure: Object, dimension: NAT, row: BOOL _ TRUE] RETURNS [vectorStructure: Object]; <> SequenceStructureConstructor: TYPE = PROC [elementStructure: Object, row: BOOL _ TRUE] RETURNS [sequenceStructure: Object]; <> MatrixStructureConstructor: TYPE = PROC [elementStructure: Object, nRows, nCols: NAT] RETURNS [matrixStructure: Object]; <> PolynomialStructureConstructor: TYPE = PROC [coeffRing, variableSeq: Object] RETURNS [polynomialStructure: Object]; <> <> <> <> IsCategory: PROC [structure: Object, category: Category] RETURNS [BOOL]; HasProperty: PROC [structure: Object, property: ATOM] RETURNS [BOOL]; MakeStructure: PROC [name: Rope.ROPE, class: Object, instanceData: REF] RETURNS[structure: Object]; StructureEqual: PROC [structure1, structure2: Object] RETURNS [BOOL]; <> <<>> LookupMethodInStructure: PROC [methodSelector: ATOM, structure: Object] RETURNS[Method]; <> <<>> LookupMethodInAllStructures: PROC [methodSelector: ATOM] RETURNS[method: Method, structure: Object]; <> <> <> <<>> <> <<>> ResetStructureRegistry: PROC[]; InstallStructure: PROC[structure: Object]; <> LookupStructure: PROC[name: ROPE] RETURNS[structure: Object]; <> << returns NIL if not found>> <<>> KillStructure: PROC[name: ROPE]; <> <> LegalFirstCharOp: TYPE = PROC [char: CHAR, structure: Object] RETURNS [BOOL]; << True if char is legal first char in an external rep of a structure element.>> <<>> ReadOp: TYPE = PROC [in: IO.STREAM, structure: Object _ NIL] RETURNS [out: Object]; FromRopeOp: TYPE = PROC [in: Rope.ROPE, structure: Object _ NIL] RETURNS [out: Object]; ToRopeOp: TYPE = PROC [in: Object] RETURNS [out: Rope.ROPE]; WriteOp: TYPE = PROC [stream: IO.STREAM, in: Object]; FromExprOp: TYPE = PROC [in: EXPR, structure: Object] RETURNS [out: Object]; ToExprOp: TYPE = PROC [in: Object] RETURNS [out: EXPR]; FromBOOLOp: TYPE = PROC [in: BOOL, structure: Object _ NIL] RETURNS [out: Object]; FromINTOp: TYPE = PROC [in: INT, structure: Object _ NIL] RETURNS [out: Object]; NullaryOp: TYPE = PROC[structure: Object] RETURNS [result: Object]; <> CompareToZeroOp: TYPE = PROC [arg: Object] RETURNS [Basics.Comparison]; BinaryCompareOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [Basics.Comparison]; StructuredToGroundOp: TYPE = PROC [structuredElt: Object] RETURNS [groundElement: Object]; <> <<>> ElementRankOp: TYPE = PROC [arg: Object] RETURNS [CARDINAL]; <> <<>> <<>> Display2DOp: TYPE = PROC [object: Object, context: Imager.Context, dotWidth, segmentWidth: REAL]; <> <> Copy: UnaryOp; ElementOf: PROC [object: Object, structure: Object] RETURNS [BOOL]; << True if object is an element of structure. (check equality of its structure's name with this structure's name)>> <<>> <> UnaryImbedOp: TYPE = PROC [in: Object, structure: Object] RETURNS [out: Object]; <> <<>> BinaryImbedOp: TYPE = PROC [data1: Object, data2: REF, structure: Object] RETURNS [out: Object]; <> <> <<>> ListImbedOp: TYPE = PROC [data: LIST OF Object, structure: Object] RETURNS [out: Object]; <> <<>> MatrixImbedOp: TYPE = PROC [elements: LIST OF Object, structure: Object] RETURNS [out: Object]; <> <<*Old* Structure Class Record Defn>> <> <<>> <> <> <<>> <> <> <<>> <> <> <<"Ints">> <<"BigRats">> <<"Points">> <<"Polynomials">> <<"Matrices">> <<"Quotients">> <<"Structures">> <<>> <> <> <> <> <> <> <> <> <> <<>> <<>> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <<>> <> <> <> <> <> <> <<>> <> <> <<>> <> <> <<>> <> <> <<>> <> <> <> <<>> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <<>> <> <<];>> END.