DIRECTORY BreakWorldArchitecture, TargetArchitecture, Breakpoint, Rope USING [ROPE]; BreakWorldArchitectureImpl: CEDAR PROGRAM IMPORTS TargetArchitecture, Breakpoint, BreakWorldArchitecture EXPORTS BreakWorldArchitecture ~ { BreakWorld: PUBLIC TYPE ~ REF BreakWorldRep ¬ BreakWorldArchitecture.nullBreakWorld; BreakWorldRep: PUBLIC TYPE ~ RECORD [ worldAccess: BreakWorldArchitecture.WorldAccess, breakAccess: BreakWorldArchitecture.BreakAccess ]; CreateBreakWorld: PUBLIC PROCEDURE [ name: Rope.ROPE, peekContents: BreakWorldArchitecture.PeekContentsProc, pokeContents: BreakWorldArchitecture.PokeContentsProc, getProcAddress: BreakWorldArchitecture.GetProcAddressProc, getProcDataSegment: BreakWorldArchitecture.GetProcDataSegmentProc, getPatchArea: BreakWorldArchitecture.GetPatchAreaProc, monitoredCall: BreakWorldArchitecture.MonitoredCallProc, worldAccessData: BreakWorldArchitecture.WorldAccessData] RETURNS [BreakWorldArchitecture.BreakWorld] ~ { worldAccess: BreakWorldArchitecture.WorldAccess ~ CreateWorldAccess[ name: name, peekContents: peekContents, pokeContents: pokeContents, getProcAddress: getProcAddress, getProcDataSegment: getProcDataSegment, getPatchArea: getPatchArea, monitoredCall: monitoredCall, worldAccessData: worldAccessData]; breakWorld: BreakWorldArchitecture.BreakWorld ~ BreakWorldFromWorldAccess[ worldAccess: worldAccess]; IF worldAccess = BreakWorldArchitecture.nullWorldAccess THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullWorldAccess, message: "CreateBreakWorld[nullWorldAccess]"]; }; IF breakWorld = BreakWorldArchitecture.nullBreakWorld THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakWorld, message: "CreateBreakWorld[nullBreakWorld]"]; }; RETURN [breakWorld]; }; CreateWorldAccess: PUBLIC PROCEDURE [ name: Rope.ROPE, peekContents: BreakWorldArchitecture.PeekContentsProc, pokeContents: BreakWorldArchitecture.PokeContentsProc, getProcAddress: BreakWorldArchitecture.GetProcAddressProc, getProcDataSegment: BreakWorldArchitecture.GetProcDataSegmentProc, getPatchArea: BreakWorldArchitecture.GetPatchAreaProc, monitoredCall: BreakWorldArchitecture.MonitoredCallProc, worldAccessData: BreakWorldArchitecture.WorldAccessData] RETURNS [BreakWorldArchitecture.WorldAccess] ~ { procs: BreakWorldArchitecture.WorldAccessProcs ~ NEW[BreakWorldArchitecture.WorldAccessProcsRep ¬ [ peekContents: peekContents, pokeContents: pokeContents, getProcAddress: getProcAddress, getProcDataSegment: getProcDataSegment, getPatchArea: getPatchArea, monitoredCall: monitoredCall]]; worldAccess: BreakWorldArchitecture.WorldAccess ~ NEW[BreakWorldArchitecture.WorldAccessRep ¬ [name: name, procs: procs, data: worldAccessData]]; IF procs = BreakWorldArchitecture.nullWorldAccessProcs THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullWorldAccessProcs, message: "CreateWorldAccess[nullWorldAccessProcs]"]; }; IF worldAccess = BreakWorldArchitecture.nullWorldAccess THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullWorldAccess, message: "CreateWorldAccess[nullWorldAccess]"]; }; RETURN [worldAccess]; }; IsNullBreakWorld: PUBLIC PROCEDURE [breakWorld: BreakWorldArchitecture.BreakWorld] RETURNS [BOOLEAN] ~ { RETURN [breakWorld = BreakWorldArchitecture.nullBreakWorld]; }; BreakWorldFromWorldAccess: PUBLIC PROCEDURE [ worldAccess: BreakWorldArchitecture.WorldAccess] RETURNS [BreakWorldArchitecture.BreakWorld] ~ { breakAccess: BreakWorldArchitecture.BreakAccess ~ Breakpoint.NewBreakAccess[]; breakWorld: BreakWorldArchitecture.BreakWorld ~ NEW[BreakWorldRep ¬ [ worldAccess: worldAccess, breakAccess: breakAccess]]; IF worldAccess = BreakWorldArchitecture.nullWorldAccess THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullWorldAccess, message: "BreakWorldFromWorldAccess[nullWorldAccess]"]; }; IF breakAccess = BreakWorldArchitecture.nullBreakAccess THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakAccess, message: "BreakWorldFromWorldAccess[nullBreakAccess]"]; }; IF breakWorld.IsNullBreakWorld[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakWorld, message: "BreakWorldFromWorldAccess[nullBreakWorld]"]; }; RETURN [breakWorld]; }; WorldAccessFromBreakWorld: PUBLIC PROCEDURE [ breakWorld: BreakWorldArchitecture.BreakWorld] RETURNS [BreakWorldArchitecture.WorldAccess] ~ { IF breakWorld.IsNullBreakWorld[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakWorld, message: "WorldAccessFromBreakWorld[nullBreakWorld]"]; }; RETURN [breakWorld.worldAccess]; }; BreakAccessFromBreakWorld: PUBLIC PROCEDURE [ breakWorld: BreakWorldArchitecture.BreakWorld] RETURNS [BreakWorldArchitecture.BreakAccess] ~ { IF breakWorld.IsNullBreakWorld[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakWorld, message: "BreakAccessFromBreakWorld[nullBreakWorld]"]; }; RETURN [breakWorld.breakAccess]; }; PeekContents: PUBLIC PROCEDURE [ address: BreakWorldArchitecture.Address, displacement: TargetArchitecture.Displacement ¬ TargetArchitecture.nullDisplacement] RETURNS [TargetArchitecture.Contents] ~ { breakWorld: BreakWorldArchitecture.BreakWorld ~ address.BreakWorldFromBreakWorldAddress[]; worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; peekContents: BreakWorldArchitecture.PeekContentsProc ~ worldAccess.procs.peekContents; displaced: BreakWorldArchitecture.Address ~ AddressFromDisplacement[ address: address, displacement: displacement]; contents: TargetArchitecture.Contents ~ peekContents[address: displaced]; RETURN [contents]; }; PokeContents: PUBLIC PROCEDURE [ address: BreakWorldArchitecture.Address, displacement: TargetArchitecture.Displacement ¬ TargetArchitecture.nullDisplacement, contents: TargetArchitecture.Contents] RETURNS [] ~ { breakWorld: BreakWorldArchitecture.BreakWorld ~ address.BreakWorldFromBreakWorldAddress[]; worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; pokeContents: BreakWorldArchitecture.PokeContentsProc ~ worldAccess.procs.pokeContents; displaced: BreakWorldArchitecture.Address ~ AddressFromDisplacement[ address: address, displacement: displacement]; pokeContents[address: displaced, contents: contents]; RETURN; }; GetProcAddress: PUBLIC PROCEDURE [ breakWorld: BreakWorldArchitecture.BreakWorld, procName: Rope.ROPE] RETURNS [BreakWorldArchitecture.Address] ~ { worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; getProcAddress: BreakWorldArchitecture.GetProcAddressProc ~ worldAccess.procs.getProcAddress; address: BreakWorldArchitecture.Address ~ getProcAddress[breakWorld: breakWorld, procName: procName]; RETURN [address]; }; GetProcDataSegment: PUBLIC PROCEDURE [ breakWorld: BreakWorldArchitecture.BreakWorld, address: BreakWorldArchitecture.Address] RETURNS [BreakWorldArchitecture.Address] ~ { worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; getProcDataSegment: BreakWorldArchitecture.GetProcDataSegmentProc ~ worldAccess.procs.getProcDataSegment; dataSegment: BreakWorldArchitecture.Address ~ getProcDataSegment[breakWorld: breakWorld, address: address]; RETURN [dataSegment]; }; GetPatchArea: PUBLIC PROCEDURE [address: BreakWorldArchitecture.Address] RETURNS [BreakWorldArchitecture.PatchArea] ~ { breakWorld: BreakWorldArchitecture.BreakWorld ~ address.BreakWorldFromBreakWorldAddress[]; worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; getPatchArea: BreakWorldArchitecture.GetPatchAreaProc ~ worldAccess.procs.getPatchArea; patchAreaRep: BreakWorldArchitecture.PatchAreaRep ~ getPatchArea[address: address]; patchArea: BreakWorldArchitecture.PatchArea ¬ BreakWorldArchitecture.nullPatchArea; IF patchAreaRep.address.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "patchAreaRep.address.IsNullAddress"]; }; IF patchAreaRep.byteSize = 0 THEN { ERROR BreakWorldArchitecture.Cant[ code: $ZeroLengthPatchArea, message: "zero length patchAreaRep.address"]; }; patchArea ¬ NEW[BreakWorldArchitecture.PatchAreaRep ¬ patchAreaRep]; RETURN [patchArea]; }; MonitoredCall: PUBLIC PROCEDURE [ address: BreakWorldArchitecture.Address, proc: PROCEDURE [] RETURNS []] RETURNS [] ~ { breakWorld: BreakWorldArchitecture.BreakWorld ~ address.BreakWorldFromBreakWorldAddress[]; worldAccess: BreakWorldArchitecture.WorldAccess ~ breakWorld.WorldAccessFromBreakWorld[]; monitoredCall: BreakWorldArchitecture.MonitoredCallProc ~ worldAccess.procs.monitoredCall; monitoredCall[address: address, proc: proc]; RETURN; }; IsNullPatchArea: PUBLIC PROCEDURE [patchArea: BreakWorldArchitecture.PatchArea] RETURNS [BOOLEAN] ~ { RETURN [patchArea = BreakWorldArchitecture.nullPatchArea]; }; NewAddress: PUBLIC PROCEDURE [ breakWorld: BreakWorldArchitecture.BreakWorld, address: TargetArchitecture.Address] RETURNS [BreakWorldArchitecture.Address] ~ { new: BreakWorldArchitecture.Address ¬ NEW[BreakWorldArchitecture.AddressRep ¬ [ breakWorld: breakWorld, address: address]]; IF breakWorld.IsNullBreakWorld[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullBreakWorld, message: "NewAddress[nullBreakWorld]"]; }; IF address.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "NewAddress[nullAddress]"]; }; RETURN [new]; }; IsNullAddress: PUBLIC PROCEDURE [address: BreakWorldArchitecture.Address] RETURNS [BOOLEAN] ~ { RETURN [address = BreakWorldArchitecture.nullAddress]; }; AddressEqual: PUBLIC PROCEDURE [ this: BreakWorldArchitecture.Address, that: BreakWorldArchitecture.Address] RETURNS [BOOLEAN] ~ { IF this.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "AddressEqual[this.IsNullAddress]"]; }; IF that.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "AddressEqual[that.IsNullAddress]"]; }; RETURN [(this.breakWorld = that.breakWorld) AND (this.address = that.address)]; }; AddressFromDisplacement: PUBLIC PROCEDURE [ address: BreakWorldArchitecture.Address, displacement: TargetArchitecture.Displacement] RETURNS [BreakWorldArchitecture.Address] ~ { targetAddress: TargetArchitecture.Address ~ TargetAddressFromBreakWorldAddress[address: address]; displaced: TargetArchitecture.Address ~ TargetArchitecture.AddressFromDisplacement[ address: targetAddress, displacement: displacement]; breakWorldDisplaced: BreakWorldArchitecture.Address ~ NewAddress[ breakWorld: address.BreakWorldFromBreakWorldAddress[], address: displaced]; RETURN [breakWorldDisplaced]; }; TargetAddressFromBreakWorldAddress: PUBLIC PROCEDURE [ address: BreakWorldArchitecture.Address] RETURNS [TargetArchitecture.Address] ~ { IF address.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "TargetAddressFromBreakWorldAddress[nullAddress]"]; }; RETURN [address.address]; }; BreakWorldFromBreakWorldAddress: PUBLIC PROCEDURE [address: BreakWorldArchitecture.Address] RETURNS [BreakWorldArchitecture.BreakWorld] ~ { IF address.IsNullAddress[] THEN { ERROR BreakWorldArchitecture.Cant[ code: $NullAddress, message: "BreakWorldFromBreakWorldAddress[nullAddress]"]; }; RETURN [address.breakWorld]; }; NextInstruction: PUBLIC PROCEDURE [pc: BreakWorldArchitecture.Address] RETURNS [BreakWorldArchitecture.Address] ~ { nextTargetAddress: TargetArchitecture.Address ~ TargetArchitecture.NextInstruction[pc: pc.TargetAddressFromBreakWorldAddress[]]; nextAddress: BreakWorldArchitecture.Address ~ NewAddress[ breakWorld: pc.BreakWorldFromBreakWorldAddress[], address: nextTargetAddress]; RETURN [nextAddress]; }; PrevInstruction: PUBLIC PROCEDURE [pc: BreakWorldArchitecture.Address] RETURNS [BreakWorldArchitecture.Address] ~ { prevTargetAddress: TargetArchitecture.Address ~ TargetArchitecture.PrevInstruction[pc: pc.TargetAddressFromBreakWorldAddress[]]; prevAddress: BreakWorldArchitecture.Address ~ NewAddress[ breakWorld: pc.BreakWorldFromBreakWorldAddress[], address: prevTargetAddress]; RETURN [prevAddress]; }; PeekInstruction: PUBLIC PROCEDURE [ pc: BreakWorldArchitecture.Address, displacement: TargetArchitecture.Displacement ¬ TargetArchitecture.nullDisplacement] RETURNS [TargetArchitecture.Instruction] ~ { contents: TargetArchitecture.Contents ~ BreakWorldArchitecture.PeekContents[address: pc, displacement: displacement]; instruction: TargetArchitecture.Instruction ~ contents.InstructionFromContents[]; RETURN [instruction]; }; PokeInstruction: PUBLIC PROCEDURE [ pc: BreakWorldArchitecture.Address, displacement: TargetArchitecture.Displacement ¬ TargetArchitecture.nullDisplacement, instruction: TargetArchitecture.Instruction] RETURNS [] ~ { contents: TargetArchitecture.Contents ~ instruction.ContentsFromInstruction[]; BreakWorldArchitecture.PokeContents[ address: pc, displacement: displacement, contents: contents]; RETURN; }; Cant: PUBLIC ERROR [ code: BreakWorldArchitecture.ErrorCode, message: BreakWorldArchitecture.ErrorMessage] ~ CODE; WouldBlock: PUBLIC ERROR [message: BreakWorldArchitecture.ErrorMessage] ~ CODE; }.  BreakWorldArchitectureImpl.mesa Copyright Ó 1989, 1990, 1991, 1992 by Xerox Corporation. All rights reserved. Peter B. Kessler, April 18, 1990 9:12:05 pm PDT Laurie Horton, March 4, 1992 4:05 pm PST EXPORT'ed types. Public Procedures. Errors. Raised by MonitoredCall. Ê l–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ ÐerœC™NK™/K™(K™šÏk ˜ Kšœ˜K˜Kšœ ˜ Kšœžœžœ˜——K˜unitšÏnœžœž˜)Kšžœ7˜>Kšžœ˜Kšœ˜head™šœ žœžœžœ7˜Tšœžœžœžœ˜%Kšœ0˜0Kšœ/˜/Kšœ˜—K˜——™š Ÿœžœž œžœ›žœ(˜þšœ2˜2šœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ'˜'Kšœ˜Kšœ˜Kšœ"˜"——šœJ˜JKšœ˜—K˜šžœ6žœ˜>šžœ˜"KšœF˜F—Kšœ˜—šžœ4žœ˜<šžœ˜"KšœD˜D—Kšœ˜—Kšžœ˜Kšœ˜K˜—š Ÿœžœž œžœšžœ)˜ÿšœ1˜1šžœ/˜2Kšœ˜Kšœ˜Kšœ˜Kšœ'˜'Kšœ˜Kšœ˜——šœ2˜2Kšžœ\˜_—K˜šžœ5žœ˜=šžœ˜"KšœQ˜Q—Kšœ˜—šžœ6žœ˜>šžœ˜"KšœG˜G—Kšœ˜—Kšžœ˜Kšœ˜K˜—š Ÿœžœž œ1žœžœ˜iKšžœ6˜šžœ˜"KšœO˜O—Kšœ˜—šžœ6žœ˜>šžœ˜"KšœO˜O—Kšœ˜—šžœžœ˜'šžœ˜"KšœM˜M—Kšœ˜—Kšžœ˜Kšœ˜K˜—šŸœžœž œ3žœ)˜Žšžœžœ˜'šžœ˜"KšœM˜M—Kšœ˜—Kšžœ˜ Kšœ˜K˜—šŸœžœž œ3žœ)˜Žšžœžœ˜'šžœ˜"KšœM˜M—Kšœ˜—Kšžœ˜ Kšœ˜K˜—šŸ œžœž œƒžœ"˜Êšœ0˜0Kšœ*˜*—šœ2˜2Kšœ'˜'—šœ8˜8Kšœ˜—šœD˜DK˜.—KšœI˜IK˜Kšžœ ˜Kšœ˜K˜—šŸ œžœž œªžœ˜Öšœ0˜0Kšœ*˜*—šœ2˜2Kšœ'˜'—šœ8˜8Kšœ˜—šœD˜DK˜.—K˜Kšœ5˜5Kšžœ˜Kšœ˜K˜—š Ÿœžœž œBžœžœ%˜•šœ2˜2Kšœ'˜'—šœ<˜˜>—K˜—šžœžœ˜!šžœ˜"Kšœ8˜8—K˜—Kšžœ˜ Kšœ˜K˜—š Ÿ œžœž œ,žœžœ˜`Kšžœ0˜6šœ˜K˜——š Ÿ œžœž œPžœžœ˜ƒšžœžœ˜šžœ˜"KšœA˜A—K˜—šžœžœ˜šžœ˜"KšœA˜A—K˜—Kšžœ&žœ ˜OKšœ˜K˜—šŸœžœž œ]žœ%˜²˜,Kšœ5˜5—˜SK˜4—šœA˜AKšœK˜K—K˜Kšžœ˜Kšœ˜K˜—šŸ"œžœž œ-žœ!˜‰šžœžœ˜!šžœ˜"KšœP˜P—Kšœ˜—Kšžœ˜Kšœ˜K˜—šŸœžœž œ+žœ(˜Œšžœžœ˜!šžœ˜"KšœM˜M—Kšœ˜—Kšžœ˜Kšœ˜K˜—šŸœžœž œ'žœ%˜tšœ0˜0KšœP˜P—šœ9˜9KšœN˜N—K˜Kšžœ˜Kšœ˜K˜—šŸœžœž œ&žœ%˜tšœ0˜0KšœP˜P—šœ9˜9KšœN˜N—K˜Kšžœ˜Kšœ˜K˜—šŸœžœž œ}žœ%˜Êšœ(˜(KšœM˜M—KšœQ˜QK˜Kšžœ˜Kšœ˜K˜—šŸœžœž œ¬žœ˜ÛKšœN˜NK˜šœ$˜$Kšœ=˜=—Kšžœ˜Kšœ˜K˜——™šŸœžœžœ\žœ˜sK˜—šŸ œžœžœ2žœ˜OK™K˜——L˜——…—2Þ>`