MODULE*************************************************************************** Wrapper for RootGO.T ***************************************************************************; IMPORT GraphicsBase, ObAux, ObCommand, ObLib, ObProtoLoader, ObProxiedObj, ObValue, Obliq, SynLocation; CONST pkgname = "GraphicsBase"; ObGraphicsBase
REVEAL T = ObProxiedObj.T BRANDED "ObGraphicsBase.T" OBJECT END; PROCEDURE*************************************************************************** Setup procedures ***************************************************************************GetArg (args : ObValue.ArgArray; idx : INTEGER; package : ObLib.T; opCode : ObLib.OpCode; loc : SynLocation.T) : GraphicsBase.T RAISES {ObValue.Error, ObValue.Exception} = BEGIN WITH raw = Obliq.ObjectSelect (args[idx], "raw") DO TYPECASE raw OF | T (node) => RETURN node.po; ELSE ObValue.BadArgType (idx, pkgname, package.name, opCode.name, loc); RETURN NIL; (* ... only to suppress compiler warning *) END; END; END GetArg;
PROCEDURE*************************************************************************** Execution machinery ***************************************************************************SetupPackage () = PROCEDURE NewOpCode (name : TEXT; arity : INTEGER; code : Code) : OpCode = BEGIN RETURN NEW (OpCode, name := name, arity := arity, code := code); END NewOpCode; TYPE OpCodes = ARRAY OF ObLib.OpCode; VAR opCodes: REF OpCodes; BEGIN opCodes := NEW (REF OpCodes, NUMBER (Code)); opCodes^ := OpCodes { NewOpCode ("Failure", -1, Code.Failure) }; Failure := NEW (ObValue.ValException, name := pkgname & "_Failure"); ObLib.Register (NEW (Package, name := pkgname, opCodes := opCodes)); ObLib.RegisterHelp (pkgname, Help); END SetupPackage; PROCEDURESetupModule (loader : ObProtoLoader.T) = BEGIN loader.load ("GraphicsBase.obl"); END SetupModule;
TYPE Code = {Failure}; OpCode = ObLib.OpCode OBJECT code: Code; END; Package = ObLib.T OBJECT OVERRIDES Eval := DoEval; END; PROCEDURE*************************************************************************** Help ***************************************************************************DoEval (<* UNUSED *> self : Package; opCode : ObLib.OpCode; <* UNUSED *> arity : ObLib.OpArity; <* UNUSED *> READONLY args: ObValue.ArgArray; <* UNUSED *> temp : BOOLEAN; <* UNUSED *> loc : SynLocation.T) : ObValue.Val = BEGIN CASE NARROW (opCode, OpCode).code OF Code.Failure => RETURN Failure; END; END DoEval;
PROCEDUREHelp (self : ObCommand.T; arg : TEXT; <* UNUSED *> data : REFANY) = BEGIN ObAux.Help (self, arg, pkgname); END Help; BEGIN END ObGraphicsBase.