C2CRunTime.mesa
Copyright Ó 1987, 1988, 1990, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, March 3, 1988 2:47:57 pm PST
Christian Jacobi, July 25, 1990 6:02:01 pm PDT
DIRECTORY
C2CAddressing,
C2CBasics,
C2CDefs,
Rope;
C2CRunTime: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Code: TYPE = C2CDefs.Code;
AddressContainer: TYPE = C2CAddressing.AddressContainer;
Types of this procedures are different from the actual procedures generated.
E.g. the return parameter here is the generated code, and not what the actual
procedure would return.
Installation and Include files
install: READONLY Rope.ROPE;
name prefix used by Cinder
IncludeInstallationSupport: PROC [];
IncludeCedarExtra: PROC [];
Basics
MoveWords: PROC [dst, src: Code, nWords: INT] RETURNS [Code];
generates code for
MoveWords: PROC [dst: PTR, src: PTR, nWords: NAT];
Moves words from the source to the destination. The caller does not assure disjointness.
src, dst: actual code included
MoveWordsDisjoint: PROC [dst, src: Code, nWords: INT] RETURNS [Code];
generates code for
MoveWordsDisjoint: PROC [dst: PTR, src: PTR, nWords: NAT];
Moves words from the source to the destination. For efficiency, no check is made for overlapping variables, but the caller assures disjointness.
src, dst: actual code included
EqualWords: PROC [x, y: Code, nWords: INT] RETURNS [Code];
generates code for
EqualWords: PROC [x: PTR, y: PTR, nWords: NAT] RETURNS [BOOL];
Tests the two multi-word variables for equality.
src, dst: actual code included
MoveBytesDisjoint: PROC [dst, src: Code, nBytes: INT] RETURNS [Code];
generates code for
MoveBytesDisjoint: PROC [dst: PTR, src: PTR, nBytes: NAT];
Moves bytes from the source to the destination. For efficiency, no check is made for overlapping variables, but the caller assures disjointness.
src, dst: actual code included
ExtractField: PROC [src: AddressContainer, bits: INT] RETURNS [Code];
generates code for
ExtractField: PROC [base: PTR, offset: INT, bits: [0..bitsPerWord]] RETURNS [Word];
Extracts the field from any base pointer at any bit offset. The word returned is the field right-justified with zero bits on the left.
src: contains actual code for base, offset
DepositField: PROC [dst: AddressContainer, bits: INT, word: Code] RETURNS [Code];
generates code for
DepositField: PROC [base: PTR, offset: INT, bits: [0..bitsPerWord], word: Word];
Deposits the field to any base pointer at any bit offset. The word given has the bits right-justified. The other bits are ignored.
src, word: contains actual code for base, offset, word
MoveField: PROC [dst, src: AddressContainer, bits: INT] RETURNS [Code];
generates code for
MoveField: PROC [dst: PTR, dstOffset: INT, src: PTR, srcOffset: INT, bits: NAT];
Moves field that is bits wide from the src address (plus srcOffset bits) to the dst address (plus dstOffset bits). The caller does not assures disjointness.
src, dst: contains actual code for src, srcOffset, dst, dstOffset
EqualFields: PROC [x, y: AddressContainer, bits: INT] RETURNS [Code];
generates code for
EqualFields: PROC [x: PTR, xOffset: INT, y: PTR, yOffset: INT, bits: NAT] RETURNS [BOOL];
Tests fields for equality.
src, dst: contains actual code for x, xOffset, y, yOffset
FillFields: PROC [dst: AddressContainer, bits: INT, times: INT, value: Code] RETURNS [Code];
generates code for
FillFields: PROC [dst: PTR, dstOffset: INT, bits: [0..bitsPerWord], times: NAT, value: Word];
Fills contiguos fields that are each bits wide in the dst address (plus dstOffset bits) for times number of fields. The fill value will be right-justified in value.
FillWords: PROC [dst: Code, times: INT, value: Code] RETURNS [Code];
generates code for
FillWords: PROC [dst: PTR, times: NAT, value: Word];
Fills times words at the destination with value.
FillLongFields: PROC [dst, src: AddressContainer, bits: INT, times: INT] RETURNS [Code];
generates code for
FillLongFields: PROC [dst: PTR, dstOffset: INT, src: PTR, srcOffset: INT, bits: NAT, times: NAT];
Fills contiguos fields that are bits wide in the dst address (plus dstOffset bits) for times number of fields. The fill value is taken from the src address (plus srcOffset bits).
FillLongWords: PROC [dst, src: Code, times: INT, nWords: NAT] RETURNS [Code];
generates code for
FillLongWords: PROC [dst, src: PTR, nWords: NAT, times: NAT];
Fills times nWords fields at the destination (dst) with the nWords field at the source (src).
Comforts
RaiseBoundsFault: PROC [] RETURNS [Code];
RaiseBoundsFault: PROC [] = {ERROR BoundsFault};
RaiseAbstractionFault: PROC [] RETURNS [Code];
RaiseAbstractionFault: PROC [] = {ERROR ...};
RaiseArithmeticFault: PROC [] RETURNS [Code];
RaiseArithmeticFault: PROC [] RETURNS [num: INT𡤀] = {ERROR ...};
RaiseUnnamedError: PROC [] RETURNS [Code];
RaiseUnnamedError: PROC [] RETURNS [num: INT𡤀] = {ERROR};
Arithmetic
nakedBoundsError: READONLY ROPE;
BoundsFault: ERROR;
32 bit precision Signed
if macro implementation; argument may not be evaluated twice unless specified
SignedPwr: PROC [base, exp: Code] RETURNS [Code];
32 bit precision Unsigned
if macro implementation; argument may not be evaluated twice unless specified
UnsignedPwr: PROC [base, exp: Code] RETURNS [Code];
32 bit precision Floating point
if macro implementation; argument may not be evaluated twice unless specified
FloatInt: PROC [Code] RETURNS [Code];
FloatCard: PROC [Code] RETURNS [Code];
RealNeg: PROC [Code] RETURNS [Code];
RealAdd: PROC [a, b: Code] RETURNS [Code];
RealSub: PROC [a, b: Code] RETURNS [Code];
RealMul: PROC [a, b: Code] RETURNS [Code];
RealDiv: PROC [a, b: Code] RETURNS [Code];
RealGt: PROC [a, b: Code] RETURNS [Code];
RealGe: PROC [a, b: Code] RETURNS [Code];
RealEq: PROC [a, b: Code] RETURNS [Code];
RealAbs: PROC [Code] RETURNS [Code];
--may re-evaluate argument
RealMin: PROC [a, b: Code] RETURNS [Code];
--may re-evaluate arguments
RealMax: PROC [a, b: Code] RETURNS [Code];
--may re-evaluate arguments
RealPwr: PROC [base, exp: Code] RETURNS [Code];
64 bit precision Floating point
NOT YET AVAILABLE
Signaller
nakedUnnamedError: READONLY ROPE;
UnnamedError: ERROR;
nakedUnwindError: READONLY ROPE;
UnwindError: ERROR;
nakedAbortedError: READONLY ROPE;
AbortedError: ERROR;
nakedUncaughtError: READONLY ROPE;
UncaughtError: ERROR;
nakedNarrowFault: READONLY ROPE;
NarrowFault: ERROR;
PushHandler: PROC [context: Code, handler: Code] RETURNS [Code];
PushHandler: PROC [context: PTR, handler: Handler] RETURNS [exitTo: INT];
PopHandler: PROC [] RETURNS [Code];
PopHandler: PROC [];
RaiseSignal: PROC [which, rtns, args: Code] RETURNS [Code];
RaiseSignal: PROC [which: ExceptAny, rtns: PTR, args: PTR];
RaiseError: PROC [which, args: Code] RETURNS [Code];
RaiseError: PROC [which: ExceptAny, args: PTR];
Mesa Module nonsense
StartModule: PROC [retPtr, module, args: Code] RETURNS [Code];
StartModule: PROC [retPtr: PTR, module: PTR, args: PTR];
Starts a module with given arguments.
Frame allocation
ExtensionAlloc: PROC [sz: Code] RETURNS [Code];
ExtensionAlloc: PROC [nWords: INT] RETURNS [PTR];
Allocates a frame extension large enough to hold nWords worth of data.
ExtensionFree: PROC [ptr: Code] RETURNS [Code];
ExtensionFree: PROC [ptr: PTR] RETURNS [PTRNIL];
Frees a frame extension obtained by ExtensionAlloc. Ignores ptr = NIL. Always returns NIL for convenience of assigning back to the link.
Monitors & Processes
Fork: PROC [processPtr, proc: Code] RETURNS [Code];
Fork: PROC [processPtr: PTR, proc: ProcAny];
Join: PROC [process: Code] RETURNS [Code];
Join: PROC [process: PROCESS] RETURNS [retPtr: PTR];
Wait: PROC [cond, lock: Code] RETURNS [Code];
Wait: PROC [cond: CondPtr, lock: LockPtr];
Notify: PROC [cond: Code] RETURNS [Code];
Notify: PROC [cond: CondPtr];
Broadcast: PROC [cond: Code] RETURNS [Code];
Broadcast: PROC [cond: CondPtr];
MonitorEntry: PROC [lock: Code] RETURNS [Code];
MonitorEntry: PROC [lock: LockPtr];
MonitorExit: PROC [lock: Code] RETURNS [Code];
MonitorExit: PROC [lock: LockPtr];
Cedar
AssignRef: PROC [dstPtr: Code, src: Code] RETURNS [Code];
AssignRef: PROC [dstPtr: RefPtr, src: REF];
Atomically assigns a reference to a reference-containing cell.
AssignRefInit: PROC [dstPtr: Code, src: Code] RETURNS [Code];
AssignRefInit: PROC [dstPtr: RefPtr, src: REF];
Atomically assigns a reference to a reference-containing cell for initialization, without first decrementing RCs of destination.
AssignRefComposite: PROC [dst: Code, src: Code, type: Code, words: INT] RETURNS [Code];
AssignRefComposite: PROC [dst: PTR, src: PTR, type: Type, sz: NAT];
Performs dst^ ← src^, treating the copied variable as being of the specified type (containing refs). Reference-counted fields are treated properly. This operation is definitely not atomic. AssignRefCompositeFault will be raised if an an improper assignment is attempted (i.e. assignment to a variant record).
AssignRefCompositeInit: PROC [dst: Code, src: Code, type: Code, words: INT] RETURNS [Code];
AssignRefCompositeInit: PROC [dst: PTR, src: PTR, type: Type, sz: NAT];
Performs dst^ ← src^, treating the copied variable as being of the specified type. Reference-counted fields are treated properly. This operation is definitely not atomic. AssignRefCompositeFault will be raised if an an improper assignment is attempted (i.e. assignment to a variant record). Assumes this is an initialization of dst^ and therefore does not decrease RCs of destination.
NewObject: PROC [nWords: Code, type: Code] RETURNS [Code];
NewObject: PROC [nWords: INT, type: Type] RETURNS [REF];
Allocates a new object of the given type from the default zone, using at least nWords of storage, and initializing the type appropriately.
Narrow: PROC [ref: Code, type: Code] RETURNS [Code];
Narrow: PROC [ref: REF, type: Type] RETURNS [REF];
Checks to determine that the type of the object is equal to the given type, then returns the original reference. When ref = NIL, NIL is returned and no checking is performed. Raises NarrowFault if the types are different. Useful for NARROW.
GetReferentType: PROC [ref: Code] RETURNS [Code];
GetReferentType: PROC [ref: REF] RETURNS [Type];
Gets the referent type of an object from a reference to that object. Returns nullType for ref = NIL. Useful for WITH ref SELECT FROM ...
CheckProc: PROC [proc: Code] RETURNS [Code];
CheckProc: PROC [proc: ProcAny] RETURNS [theSameProc: ProcAny];
Checks the procedure for being assignable. Raises NestedProcError if the proc is nested.
END.