-- JaMStart.mesa -- Written by John Warnock, Feb., 1979. -- Last changed by Doug Wyatt, January 9, 1981 3:36 PM DIRECTORY JaMStartDefs, JaMMasterDefs USING [Frame, Object], JaMControlDefs USING [GetCurrentFrame, NotifyStringObject], JaMExecDefs USING [Execute], JaMInterruptDefs USING [InitJaMBreak], JaMIODefs USING [MakeIntoEditedStream], JaMStackDefs USING [Push], AltoFileDefs USING [CFA], ImageDefs USING [CleanupReason, CleanupItem, CleanupMask, AddCleanupProcedure], MiscDefs USING [CommandLineCFA], SegmentDefs USING [FindFile], StreamDefs USING [StreamHandle, CreateByteStream, NewByteStream, Read, GetDefaultKey, JumpToFA]; JaMStart: PROGRAM IMPORTS JaMControlDefs,JaMExecDefs,JaMInterruptDefs,JaMIODefs, JaMStackDefs,ImageDefs,MiscDefs,SegmentDefs,StreamDefs EXPORTS JaMStartDefs = BEGIN OPEN JaMMasterDefs; -- This is the main control program for JaM. -- It creates an edited stream, and then transfers execution control. jamstreamhandle: StreamDefs.StreamHandle; stream: StreamType Object; prmpt: StringType Object; strt: StringType Object; GetJaMStream: PUBLIC PROCEDURE RETURNS[StreamDefs.StreamHandle] = BEGIN RETURN[jamstreamhandle] END; restarted: BOOLEAN _ FALSE; DoCommandLine: PROCEDURE = { OPEN StreamDefs; frame: Frame _ JaMControlDefs.GetCurrentFrame[]; s: StreamHandle _ NIL; IF restarted THEN { s _ NewByteStream[name: "Com.cm"L, access: Read]; -- skip first token in command line UNTIL s.endof[s] DO IF s.get[s]=' THEN EXIT ENDLOOP; } ELSE { cfa: POINTER TO AltoFileDefs.CFA _ MiscDefs.CommandLineCFA[]; s _ CreateByteStream[file: SegmentDefs.FindFile[@cfa.fp], access: Read]; JumpToFA[s, @cfa.fa]; }; JaMStackDefs.Push[[nolit,StreamType[s]],frame.execstk]; JaMExecDefs.Execute[]; }; RunJaM: PUBLIC PROCEDURE = BEGIN frame: Frame _ JaMControlDefs.GetCurrentFrame[]; -- do start macro JaMStackDefs.Push[strt,frame.execstk]; JaMExecDefs.Execute[]; -- do command line DoCommandLine[]; -- The Main Loop DO JaMStackDefs.Push[stream,frame.execstk]; JaMStackDefs.Push[prmpt,frame.execstk]; JaMExecDefs.Execute[]; ENDLOOP; END; StartStart: PROCEDURE = BEGIN OPEN JaMControlDefs; NotifyStringObject[@prmpt, ".prompt"L]; NotifyStringObject[@strt, ".start"L]; END; NoteRestart: PROCEDURE[why: ImageDefs.CleanupReason] = { restarted _ TRUE }; item: ImageDefs.CleanupItem _ [link: NIL, proc: NoteRestart, mask: ImageDefs.CleanupMask[Restore] + ImageDefs.CleanupMask[Restart]]; -- Initialization ImageDefs.AddCleanupProcedure[@item]; jamstreamhandle_JaMIODefs.MakeIntoEditedStream[StreamDefs.GetDefaultKey[]]; stream_[nolit,StreamType[jamstreamhandle]]; JaMInterruptDefs.InitJaMBreak[]; StartStart; END. MN March 10, 1980 5:32 PM added start macro, command-line input DKW March 25, 1980 1:57 PM no longer calls RealDefs.InitFloat DKW March 29, 1980 11:51 AM Initialization substantially changed. Most START code has been moved to JaMControl, which is now JaM's control module. Added StartStart, RunJaM. DKW July 25, 1980 3:12 PM changed DoCommandLine to use MiscDefs.CommandLineCFA DKW January 9, 1981 3:23 PM DoCommandLine doesn't use CommandLineCFA if JaM is an image file (600)