Public Procedures.
CreateBreakWorld:
PUBLIC
PROCEDURE [
peekContents: BreakWorldArchitecture.PeekContentsProc,
pokeContents: BreakWorldArchitecture.PokeContentsProc,
getProcAddress: BreakWorldArchitecture.GetProcAddressProc,
getPatchArea: BreakWorldArchitecture.GetPatchAreaProc,
monitoredCall: BreakWorldArchitecture.MonitoredCallProc,
worldAccessData: BreakWorldArchitecture.WorldAccessData]
RETURNS [BreakWorldArchitecture.BreakWorld] ~ {
worldAccess: BreakWorldArchitecture.WorldAccess ~
CreateWorldAccess[
peekContents: peekContents,
pokeContents: pokeContents,
getProcAddress: getProcAddress,
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 [
peekContents: BreakWorldArchitecture.PeekContentsProc,
pokeContents: BreakWorldArchitecture.PokeContentsProc,
getProcAddress: BreakWorldArchitecture.GetProcAddressProc,
getPatchArea: BreakWorldArchitecture.GetPatchAreaProc,
monitoredCall: BreakWorldArchitecture.MonitoredCallProc,
worldAccessData: BreakWorldArchitecture.WorldAccessData]
RETURNS [BreakWorldArchitecture.WorldAccess] ~ {
procs: BreakWorldArchitecture.WorldAccessProcs ~
NEW[BreakWorldArchitecture.WorldAccessProcsRep ← [
peekContents: peekContents,
pokeContents: pokeContents,
getProcAddress: getProcAddress,
getPatchArea: getPatchArea,
monitoredCall: monitoredCall]];
worldAccess: BreakWorldArchitecture.WorldAccess ~
NEW[BreakWorldArchitecture.WorldAccessRep ← [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];
};
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;
};
}.