DIRECTORY SafeStorage, IO, Atom, Rope, Basics, Imager, MathExpr; ASObjects: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; EXPR: TYPE = MathExpr.EXPR; ObjectFlavor: TYPE = {StructureElement, Structure, Class, NoFlavor}; Object: TYPE = REF ObjectRec; ObjectRec: TYPE ~ RECORD [ primaryKey: ROPE, -- key for search of a LoganBerry DB openDB: LoganBerry.OpenDB, -- which DB SELECT type:* FROM onLine => [ name: Rope.ROPE _ NIL, -- Structure => nonNIL (needed in addition to primaryKey field?) flavor: ObjectFlavor, -- 3/87 unclear this field needed; even if so, could bundle it into name field; all in all, redundant (no - used for Structure, StructureElement distinctions in superclass searches) class: Object _ NIL, -- StructureElement => Structure; Structure => Class; Class => Class (the superclass) data: REF _ NIL -- StructureElement => value; Structure => instanceData; Class => Method Dictionary ]; offLine => []; ENDCASE ]; MethodDictionary: TYPE = Atom.PropList; MethodType: TYPE = {Value, SideEffect, TrueNullaryOp, NullaryOp, UnaryOp, BinaryOp, BinaryMixedOp, TernaryOp, TernaryMixedOp, QuaternaryOp, NaryOp, 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 [ type: MethodType, operator: BOOL _ TRUE, -- TRUE if this method is an Operator, as opposed to a Constructor. Only Operators are offered in a user menu of a Structure's methods value: REF, -- REF proc if type # Value; should never be NIL, since confuses with absence of method. If don't care about Value, set value _ methodKey desiredArgStructures: REF UnaryToListOp _ NIL, -- Proc[Structure -> LIST OF Structure]; if ouptut LIST contains only one Structure, then expected that all args belong to it (useful e.g. for vector and matrix constructors). doc: ROPE ]; 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]; NaryOp: TYPE = PROC [args: LIST OF 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]; END. ¨ASObjects.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Arnon, November 23, 1987 10:16:14 am PST Types From Imported Interfaces Object Types Method (and Property) Dictionary Types Properties are thought of as Methods of type Value Method Operations Does method lookup RETURN[ LIST[structure] ]; (arg is expected to be a Structure) Lookup method in structure, and recast args Try to recast args LookupMethodForStructure, RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. Apply method from structure. It is assumed that method exists, and that correct number and types of args are supplied. LookupMethodForStructure, RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. ApplyNoLkpNoRecastRef[GetMethodAndRecastArgs]; It is assumed that method exists, that correct number of args are supplied, and that args are recastable to desiredArgStructure. Error if anything at all goes wrong. ERROR if method output type is not imbeddable as an Object LookupMethodForStructure, RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. ApplyNoLkpNoRecastObject[GetMethodAndRecastArgs]; It is assumed that method exists, that correct number of args are supplied, and that args are recastable to desiredArgStructure. Error if anything at all goes wrong. RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. LookupMethodForStructure, RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. LookupMethodForStructure, RETURN[NARROW[ApplyNoLkpNoRecastRef]]. Error if anything at all goes wrong. Object Operation Types Class Operations Typically a class is created with MethodDictionary = NIL, then MethodDictionary loaded with AddMethodToClass Existing method, if any (generally there shouldn't be), is replaced Sets class field of a Class, or class.class field of a Structure Look up method in this class and its superclasses. ΚΘ– "Mesa" style˜codešœ Οc™Kšœ Οmœ1™