<> <> <> DIRECTORY Imager USING [DoSave, DoSaveAll], IPInterpreter USING [Any, Array, ArrayFromVector, Cardinal, Context, ContextRep, Get, MasterError, Ref, Vector, VectorFromArray]; IPContextImpl: CEDAR PROGRAM IMPORTS Imager, IPInterpreter EXPORTS IPInterpreter ~ BEGIN OPEN IPInterpreter; contextCountMax: Cardinal _ 100; ContextOverflow: PROC ~ { MasterError[$contextOverflow, "Execution contexts nested too deeply"]; }; PushContext: PROC [self: Ref, frame: Vector, env: Vector] ~ { context: Context _ NIL; IF self.contextFree=NIL THEN { IF NOT self.contextCount PopContext[self]]; PopContext[self]; }; AGet: PROC [a: Array, i: Cardinal] RETURNS [Any] ~ INLINE { RETURN[a[i-a.lowerBound]] }; ASet: PROC [a: Array, i: Cardinal, x: Any] ~ INLINE { a[i-a.lowerBound] _ x }; Frame: PUBLIC PROC [self: Ref] RETURNS [Vector] ~ { context: Context ~ self.context; IF context.frameV=NIL THEN context.frameV _ VectorFromArray[context.frameA]; RETURN[context.frameV]; }; FGet: PUBLIC PROC [self: Ref, i: Cardinal] RETURNS [Any] ~ { context: Context ~ self.context; IF context.frameA#NIL THEN RETURN[AGet[context.frameA, i]] ELSE RETURN[Get[context.frameV, i]]; }; FSet: PUBLIC PROC [self: Ref, x: Any, i: Cardinal] ~ { context: Context ~ self.context; IF context.frameA=NIL THEN context.frameA _ ArrayFromVector[context.frameV]; context.frameV _ NIL; ASet[context.frameA, i, x]; }; Env: PUBLIC PROC [self: Ref] RETURNS [Vector] ~ { context: Context ~ self.context; RETURN[context.env]; }; DoSave: PUBLIC PROC [self: Ref, action: PROC] ~ { <> Imager.DoSave[self.imager, action]; }; DoSaveAll: PUBLIC PROC [self: Ref, action: PROC] ~ { <> Imager.DoSaveAll[self.imager, action]; }; <> <> <> <<};>> <<>> <> <> <> <> <<};>> <<>> <> <> <> <<-- SavePool[self, pool, ...]; -->> <> <<};>> <<>> <> <<>> <> <> <<};>> <<>> <> <<>> <> <<>> <> <> <<};>> <<>> <> <<>> <> <> <> <<};>> <<>> <> <> <<};>> <<>> <> <> < RETURN[pool]; ENDCASE => ERROR Bug;>> <<};>> <<>> <<>> END.