DIRECTORY Atom USING [PropList], IO USING [STREAM], RefTab USING [Ref], Rope USING [ROPE]; TJaM: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; Any: TYPE ~ REF ANY; Object: TYPE ~ Any; -- for compatibility Ob: TYPE ~ REF ObRep; ObRep: TYPE ~ RECORD [tag: ObTag, body: Any]; ObTag: TYPE ~ {literal, executable}; TypeCode: TYPE ~ {nil, number, atom, rope, stream, cmd, dict, array, mark, other}; Number: TYPE ~ REF NumberRep; NumberRep: TYPE ~ RECORD [ SELECT tag: * FROM int => [int: INT], real => [real: REAL], ENDCASE ]; CommandProc: TYPE ~ PROC [frame: Frame, cmd: Cmd]; Cmd: TYPE ~ REF CmdRep; CmdRep: TYPE ~ RECORD [proc: CommandProc, data: REF, name: ATOM]; Dict: TYPE ~ REF DictRep; DictRep: TYPE ~ RECORD [refTab: RefTab.Ref, attach: LIST OF Dict]; Array: TYPE ~ REF ArrayRep; ArrayRep: TYPE ~ RECORD [base: Sequence, start, len: NAT]; Sequence: TYPE ~ REF SequenceRep; SequenceRep: TYPE ~ RECORD [SEQUENCE size: NAT OF Object]; Mark: TYPE ~ REF MarkRep; MarkRep: TYPE ~ RECORD [id: INT ¬ 0]; Frame: TYPE ~ REF FrameRep; FrameRep: TYPE ~ RECORD [ impl: REF FrameImplRep, propList: Atom.PropList ¬ NIL ]; FrameImplRep: TYPE; -- see TJaMPrivate Equal: PROC [a, b: Any] RETURNS [BOOL]; Length: PROC [x: Any] RETURNS [INT]; Type: PROC [x: Any] RETURNS [TypeCode]; IntFromReal: PROC [real: REAL] RETURNS [INT]; IntFromNum: PROC [n: NumberRep] RETURNS [INT]; RealFromNum: PROC [n: NumberRep] RETURNS [REAL]; IntFromAny: PROC [x: Any] RETURNS [INT]; RealFromAny: PROC [x: Any] RETURNS [REAL]; NumberFromAny: PROC [x: Any] RETURNS [Number]; AtomFromAny: PROC [x: Any] RETURNS [ATOM]; RopeFromAny: PROC [x: Any] RETURNS [ROPE]; StreamFromAny: PROC [x: Any] RETURNS [STREAM]; CmdFromAny: PROC [x: Any] RETURNS [Cmd]; ArrayFromAny: PROC [x: Any] RETURNS [Array]; DictFromAny: PROC [x: Any] RETURNS [Dict]; MarkFromAny: PROC [x: Any] RETURNS [Mark]; RopeFromAtom: PROC [ATOM] RETURNS [ROPE]; AtomFromRope: PROC [ROPE] RETURNS [ATOM]; CvX: PROC [x: Any] RETURNS [Any]; CvLit: PROC [x: Any] RETURNS [Any]; Push: PROC [frame: Frame, val: Any]; PushBool: PROC [frame: Frame, val: BOOL]; PushInt: PROC [frame: Frame, val: INT]; PushReal: PROC [frame: Frame, val: REAL]; PushNum: PROC [frame: Frame, val: NumberRep]; PushAtom: PROC [frame: Frame, val: ATOM]; PushRope: PROC [frame: Frame, val: ROPE]; PushStream: PROC [frame: Frame, val: STREAM]; PushCmd: PROC [frame: Frame, val: Cmd]; PushArray: PROC [frame: Frame, val: Array]; PushDict: PROC [frame: Frame, val: Dict]; PushMark: PROC [frame: Frame, val: Mark]; Pop: PROC [frame: Frame] RETURNS [Any]; PopBool: PROC [frame: Frame] RETURNS [BOOL]; PopInt: PROC [frame: Frame] RETURNS [INT]; PopReal: PROC [frame: Frame] RETURNS [REAL]; PopNum: PROC [frame: Frame] RETURNS [NumberRep]; PopAtom: PROC [frame: Frame] RETURNS [ATOM]; PopRope: PROC [frame: Frame] RETURNS [ROPE]; PopStream: PROC [frame: Frame] RETURNS [STREAM]; PopCmd: PROC [frame: Frame] RETURNS [Cmd]; PopArray: PROC [frame: Frame] RETURNS [Array]; PopDict: PROC [frame: Frame] RETURNS [Dict]; PopMark: PROC [frame: Frame] RETURNS [Mark]; Top: PROC [frame: Frame] RETURNS [Any]; TopType: PROC [frame: Frame] RETURNS [TypeCode]; Copy: PROC [frame: Frame, n: INT]; Dup: PROC [frame: Frame]; Roll: PROC [frame: Frame, n, k: INT]; Exch: PROC [frame: Frame]; ClearStack: PROC [frame: Frame]; CountStack: PROC [frame: Frame] RETURNS [INT]; StackIsEmpty: PROC [frame: Frame] RETURNS [BOOL]; ClearToMark: PROC [frame: Frame]; CountToMark: PROC [frame: Frame] RETURNS [INT]; Index: PROC [frame: Frame, i: INT] RETURNS [Any]; NewArray: PROC [len: INT] RETURNS [Array]; ACopy: PROC [array: Array, expand: INT ¬ 0] RETURNS [Array]; ASub: PROC [array: Array, start, len: INT] RETURNS [Array]; APut: PROC [array: Array, i: INT, val: Any]; AGet: PROC [array: Array, i: INT] RETURNS [Any]; AFind: PROC [array: Array, val: Any] RETURNS [INT]; -- returns -1 if not found ABind: PROC [array: Array, dict: Dict]; AnyAction: TYPE ~ PROC [x: Any] RETURNS [quit: BOOL ¬ FALSE]; ArrayForAll: PROC [array: Array, action: AnyAction] RETURNS [BOOL]; AStore: PROC [frame: Frame, array: Array]; ALoad: PROC [frame: Frame, array: Array]; NewDict: PROC [mod: NAT ¬ 17] RETURNS [Dict]; DictLength: PROC [dict: Dict] RETURNS [INT]; TryToGet: PROC [dict: Dict, key: ATOM] RETURNS [found: BOOL, val: Any]; Get: PROC [dict: Dict, key: ATOM] RETURNS [val: Any]; Put: PROC [dict: Dict, key: ATOM, val: Any]; Del: PROC [dict: Dict, key: ATOM]; ClrDict: PROC [dict: Dict]; TupleAction: TYPE ~ PROC [key: ATOM, val: Any] RETURNS [quit: BOOL ¬ FALSE]; DictForAll: PROC [dict: Dict, action: TupleAction] RETURNS [BOOL]; AttachDict: PROC [dict1, dict2: Dict]; DetachDict: PROC [dict1, dict2: Dict]; DetachAll: PROC [dict: Dict]; DictAction: TYPE ~ PROC [dict: Dict] RETURNS [quit: BOOL ¬ FALSE]; AttachedForAll: PROC [dict: Dict, action: DictAction] RETURNS [BOOL]; Where: PROC [frame: Frame, key: ATOM] RETURNS [found: BOOL, where: Dict]; TryToLoad: PROC [frame: Frame, key: ATOM] RETURNS [found: BOOL, val: Any]; Load: PROC [frame: Frame, key: ATOM] RETURNS [val: Any]; Def: PROC [frame: Frame, key: ATOM, val: Any]; Store: PROC [frame: Frame, key: ATOM, val: Any]; Begin: PROC [frame: Frame, dict: Dict]; End: PROC [frame: Frame]; DictTop: PROC [frame: Frame] RETURNS [Dict]; SysDict: PROC [frame: Frame] RETURNS [Dict]; Error: ERROR[error: ATOM]; Exit: SIGNAL; Stop: ERROR; ErrorType: TYPE ~ { nil, -- no error undefinedKey, -- dictionary lookup failed to find key wrongType, -- an object has the wrong type boundsFault, -- an array index is out of bounds invalidArgs, -- some operator was given invalid arguments numericOverflow, -- a numerical operation or conversion overflowed stackUnderflow, -- the operand stack underflowed stackOverflow, -- the operand stack overflowed dictionaryUnderflow, -- the dictionary stack underflowed dictionaryOverflow, -- the dictionary stack overflowed attachmentCycle, -- attaching dictionary would create a circularity notAttached, -- tried to detach a dictionary not currently attached syntaxError, -- the scanner detected bad syntax (probably in a string literal) endOfStream, -- unexpected end of stream bug -- some consistency check in the JaM implementation failed }; ProduceError: PROC [type: ErrorType]; ExecuteStream: PROC [frame: Frame, stream: STREAM, closeAtEnd: BOOL ¬ TRUE]; ExecuteRope: PROC [frame: Frame, rope: ROPE]; LineComplete: PROC [rope: ROPE] RETURNS [BOOL]; Execute: PROC [frame: Frame, x: Any]; ExecuteAtom: PROC [frame: Frame, atom: ATOM]; ExecuteArray: PROC [frame: Frame, array: Array]; NewFrame: PROC RETURNS [Frame]; Register: PROC [frame: Frame, name: ATOM, proc: CommandProc, data: REF ¬ NIL]; RegisterPrimitive: PROC [name: ROPE, proc: CommandProc, data: REF ¬ NIL]; END.  TJaM.mesa Copyright Σ 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved. Last changed by Bill Paxton, 30-Jan-82 8:42:23 Michael Plass, February 14, 1985 10:26:01 am PST Doug Wyatt, December 26, 1992 10:52 pm PST Types Number, ATOM, ROPE, STREAM, Cmd, Dict, Array, Mark, ... Type attributes, conversion The Stack ... push an object onto the operand stack ... pop an object from the operand stack ... returns the object on top of the operand stack (does not pop) ! Error[stackunderflow] if the stack is empty ... returns the type of the object on top of the operand stack ! Error[stackunderflow] if the stack is empty ... pops the operand stack until it is empty ... returns the number of elements on the operand stack ... equivalent to CountStack[frame]=0, but faster Arrays ... creates a new array with specified length ... calls action for each array element in order; returns TRUE iff some action returns TRUE Dictionaries ... creates a new dictionary with suggested hash size ... returns the number of entries in dict ... looks up key in dict; returns [TRUE, val] if found, [FALSE, NIL] otherwise ... returns val associated with key in dict ! Error[undefkey] if not found ... inserts (key, val) in dict; overwrites any previous definition ... removes key from dict ! Error[undefkey] if not found ... removes all entries from dict (but not from attachments) ... calls action for each tuple in dict (not including attachments) ... inserts dict2 at the head of dict1's attachment list; noop if already attached ! Error[attachmentcycle] if attachment would create a circularity ... removes dict2 from dict1's attachment list ! Error[notattached] if dict2 was not attached to dict1 ... removes all attachments from dict ... calls action for each attachment in order (most recently attached first) ... looks up key in frame, top dict first; if found, returns containing dict ... looks up key in frame, top dict first; returns [TRUE, val] if found, [FALSE, NIL] otherwise ... looks up key in frame, top dict first, returns corresponding val ! Error[undefkey] if not found ... Puts (key, val) in frame's top dict ... looks up key in frame, replaces val if found, else does a Def ... pushes dict onto the dictionary stack ... pops the dictionary stack ... returns the top of the dictionary stack (without popping) ... returns the system dictionary Execution ... raises Error with a suitable ATOM for the specified error type. ... defines a Command in frame's top dictionary (using Def). ... defines a Command in a global dictionary of primitives. Κ –(cedarcode) style•NewlineDelimiter ™codešœ ™ Kšœ ΟeœC™NKšœ0™0K™0K™*—K˜šΟk ˜ Kšœžœ ˜Kšžœžœžœ˜Kšœžœ˜Kšœžœžœ˜—K˜šΟnœžœž œž˜K˜Kšžœžœžœ˜Kšžœžœžœžœ˜—head™Kšœžœžœžœ˜šœžœΟc˜(Jšœžœ™7—K˜Kšœžœžœ˜Kšœžœžœ˜-Kšœžœ˜$K˜Kšœ žœD˜RK˜Kšœžœžœ ˜šœ žœžœ˜šžœž˜Kšœ žœ˜Kšœžœ˜Kšž˜—K˜—K˜šœ žœžœ˜2K˜—Kšœžœžœ˜Kš œžœžœžœžœ˜AK˜Kšœžœžœ ˜Kš œ žœžœžœžœ˜BK˜Kšœžœžœ ˜Kšœ žœžœžœ˜:Kšœ žœžœ ˜!Kš œ žœžœžœžœžœ ˜:K˜Kšœžœžœ ˜Kšœ žœžœžœ˜%K˜Kšœžœžœ ˜šœ žœžœ˜Kšœžœ˜Kšœž˜K˜K˜—Kšœžœ ˜&—™KšŸœžœ žœžœ˜'KšŸœžœ žœžœ˜$KšŸœžœ žœ ˜'K˜Kš Ÿ œžœžœžœžœ˜-KšŸ œžœžœžœ˜.KšŸ œžœžœžœ˜0K˜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šŸœžœžœ ˜0KšŸœžœžœžœ˜,KšŸœžœžœžœ˜,KšŸ œžœžœžœ˜0KšŸœžœžœ˜*KšŸœžœžœ ˜.KšŸœžœžœ˜,šŸœžœžœ˜,Kšœ(™(—K˜šŸœžœžœ˜'KšœA™AK™-K™—šŸœžœžœ ˜0Kšœ>™>K™-—K˜KšŸœžœžœ˜"KšŸœžœ˜KšŸœžœžœ˜%šŸœžœ˜K˜—šŸ œžœ˜ K™,K˜—šŸ œžœžœžœ˜.K™7K˜—šŸ œžœžœžœ˜1K™1K™—KšŸ œžœ˜!KšŸ œžœžœžœ˜/KšŸœžœžœžœ˜1—™šŸœžœžœžœ ˜*Kšœ-™-K™—KšŸœžœžœžœ ˜Kšœ˜K˜—šŸ œžœ˜%Kšœ!žœ™CK˜—K˜Kš Ÿ œžœžœžœžœ˜LKšŸ œžœžœ˜-Kš Ÿ œžœžœžœžœ˜/K˜KšŸœžœ˜%KšŸ œžœžœ˜-KšŸ œžœ˜0K˜KšŸœžœžœ ˜K˜š Ÿœžœžœžœžœ˜NJ™