DIRECTORY AMModel, AMTypes USING [TV], AMBridge USING [SomeRefFromTV, TVForReferent, TVForFrame], AMModelBridge, CoreContext, Interpreter USING [Evaluate], PrincOpsUtils, Rope, SymTab; CoreContextImpl: CEDAR PROGRAM IMPORTS AMBridge, AMModelBridge, Interpreter, PrincOpsUtils, SymTab EXPORTS CoreContext = BEGIN OPEN CoreContext; Create: PUBLIC PROC [] RETURNS [cx: Context] = BEGIN cx _ SymTab.Create[]; END; Copy: PUBLIC PROC [cx: Context] RETURNS [newCx: Context] = BEGIN CopyItem: SymTab.EachPairAction = { [] _ SymTab.Store[newCx, key, val]; quit _ FALSE; }; IF cx=NIL THEN ERROR; newCx _ SymTab.Create[]; [] _ SymTab.Pairs[cx, CopyItem]; END; Store: PUBLIC PROC [cx: Context, var: ROPE, value: REF _ NIL] = BEGIN [] _ SymTab.Store[cx, var, TVFromRef[value]]; END; Eval: PUBLIC PROC [cx: Context, expr: ROPE, cedarCx: AMModel.Context _ NIL] RETURNS [REF] = TRUSTED BEGIN result: AMTypes.TV; errorRope: ROPE; noResult: BOOL; IF cedarCx=NIL THEN cedarCx _ AMModelBridge.ContextForFrame[ AMBridge.TVForFrame[ PrincOpsUtils.GetReturnFrame[] ] ]; [result, errorRope, noResult] _ Interpreter.Evaluate[rope: expr, context: cedarCx, symTab: cx]; IF errorRope # NIL THEN ERROR; RETURN[RefFromTV[result]]; END; RefFromTV: PROC [tv: REF] RETURNS [REF] = BEGIN IF tv=NIL THEN RETURN [NIL]; IF ~ISTYPE [tv, AMTypes.TV] THEN ERROR; TRUSTED {RETURN [AMBridge.SomeRefFromTV[tv]]}; END; TVFromRef: PROC [ref: REF] RETURNS [AMTypes.TV] = TRUSTED BEGIN RETURN [AMBridge.TVForReferent[ref]]; END; END. "CoreContextImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Created by Pradeep Sindhu, December 12, 1985 10:10:25 pm PST Pradeep Sindhu December 13, 1985 12:06:56 pm PST Louis Monier December 13, 1985 4:12:01 pm PST Design Public Procedures Private Procedures Κέ˜™Jšœ Οmœ1™