-- RandomCodeTypes.mesa last edited by Sturgis: October 4, 1984 4:36:53 pm PDT
DIRECTORY
IO USING[STREAM],
Rope USING[ROPE];
RandomCodeTypes: CEDAR DEFINITIONS =
BEGIN
WordType: TYPE = REF WordTypeBody;
WordTypeBody: TYPE = RECORD[
type: WordTypeCase,
index: CARDINAL,
body: REF ANY];
TypeSet: TYPE = REF TypeSetBody;
TypeSetBody: TYPE;
WordTypeCase: TYPE = {uninitialized, ordinary, pointer, procedure};
ProcedureType: TYPE = REF ProcedureTypeBody;
ProcedureTypeBody: TYPE;
SeqType: TYPE = REF SeqTypeBody;
SeqTypeBody: TYPE;
-- Type creation operations
CreateTypeSet: PROCEDURE[maxNTypes: CARDINAL] RETURNS[TypeSet];
GetSizeOfTypeSet: PROCEDURE[TypeSet] RETURNS[CARDINAL];
GetUninitializedWordType: PROCEDURE[TypeSet] RETURNS[WordType];
GetOrdinaryWordType: PROCEDURE[TypeSet] RETURNS[WordType];
GetWordTypeFromIndex: PROCEDURE[TypeSet, CARDINAL] RETURNS[WordType];
CreatePointerType: PROCEDURE[TypeSet, SeqType] RETURNS[WordType];
CreateProcedureType: PROCEDURE[typeSet: TypeSet, printName: Rope.ROPE, allowedArgs: SeqType, possibleResults: SeqType] RETURNS[WordType];
CreateSeqType: PROCEDURE[typeSet: TypeSet, printName: Rope.ROPE, nWords: CARDINAL] RETURNS[SeqType];
-- type inspection routines
GetIndex: PROCEDURE[WordType] RETURNS[CARDINAL];
GetSeqTypeOfPointerType: PROCEDURE[WordType] RETURNS[SeqType];
GetArgsResultsOfProcedureType: PROCEDURE[WordType] RETURNS[args, results: SeqType];
GetTypeSetOfSeq: PROCEDURE[SeqType] RETURNS[TypeSet];
GetLength: PROCEDURE[SeqType] RETURNS[CARDINAL];
TopOfSeq: PROCEDURE[s: SeqType, baseSize: CARDINAL] RETURNS[SeqType];
TopTwoOfSeq: PROCEDURE[SeqType] RETURNS[s0, s1: WordType];
GetWordTypeFromOffset: PROCEDURE[s: SeqType, offset: CARDINAL] RETURNS[WordType];
FindFirstDiff: PROCEDURE[a, b: SeqType] RETURNS[CARDINAL];
-- Type manipulation operations
FillSeqType: PROCEDURE[seq: SeqType, genWordTypes: PROCEDURE[CARDINAL] RETURNS[WordType]];
MergeTypes: PROCEDURE[a, b: SeqType] RETURNS[SeqType];
SubtractAddTypes: PROCEDURE[first, minus, plus: SeqType] RETURNS[SeqType];
PopSomeTypes: PROCEDURE[model: SeqType, nPop: CARDINAL] RETURNS[SeqType];
PushOneType: PROCEDURE[model: SeqType, type: WordType] RETURNS[SeqType];
CopySeqType: PROCEDURE[in: SeqType] RETURNS[SeqType];
CopyWithOneTypeChanged: PROCEDURE[in: SeqType, at: CARDINAL, new: WordType] RETURNS[SeqType];
CreateTypeExtendingPartOfType: PROCEDURE[in: SeqType, baseCount: CARDINAL, extension: SeqType] RETURNS[SeqType];
-- type checking operations
WordStorableAs: PROCEDURE[WordType, WordType] RETURNS[BOOLEAN];
LoadIndirectTypeCheck: PROCEDURE[pointer: WordType, offset: CARDINAL, stackType: SeqType];
StoreIndirectTypeCheck: PROCEDURE[stackType: SeqType, pointer: WordType, offset: CARDINAL];
StackBaseCheck: PROCEDURE[source, target: SeqType, nArgs, nResults: CARDINAL];
FrameVarsCheck: PROCEDURE[source, target: SeqType, skip: CARDINAL];
ArgPairTypeCheck: PROCEDURE[stackType: SeqType, a0, a1: WordType];
ArgSeqTypeCheck: PROCEDURE[stackType, allowedArgs: SeqType, skipOne: BOOLEAN ← FALSE];
ResultWordTypeCheck: PROCEDURE[r0: WordType, stackType: SeqType];
ResultSeqTypeCheck: PROCEDURE[possibleResults, stackType: SeqType];
-- used during random construction of procedures
GetLocalOffset: PROCEDURE[s: SeqType, t: WordType, random: CARDINAL] RETURNS[CARDINAL];
GetRemoteOffset: PROCEDURE[s: SeqType, t: WordType, random: CARDINAL] RETURNS[l,r: CARDINAL];
-- print routines
PrintWordType: PROCEDURE[w: WordType, on: IO.STREAM];
PrintSeqType: PROCEDURE[t: SeqType, on: IO.STREAM];
END.
MODULE HISTORY
Initial by: Sturgis, October 4, 1984 4:36:29 pm PDT, edited from RandomCodeInternal.
re-arrange: October 5, 1984 11:45:49 am PDT