-- Dir.Mesa, last edit 14-Feb-82 14:23:21
-- Pilot 6.0/ Mesa 7.0
-- definitions file for the disk cache of the modeller


DIRECTORY
  CompilerOps: TYPE USING [LetterSwitches],
  File: TYPE USING [Capability, nullCapability],
  FileParms: TYPE USING [nullSymbolSpace, SymbolSpace],
  LowLoader: TYPE USING [LoadInfoSeq],
  TimeStamp: TYPE USING [Null, Stamp];
			
Dir: DEFINITIONS = {

-- used by MDModel LOC to point to local files 
-- rule:
-- 	bcd may not correspond to src
--	src and bcd may not correspond to version listed in model
-- 	DepSeq's, Capabilities always correspond to file create dates
--	if not present, can't use Capabilities, DepSeq's, Create dates
--	(bcdVers may have time field set independently)
FileInfo: TYPE = LONG POINTER TO FileInfoRecord;
FileInfoRecord: TYPE = RECORD[
	isBcd: BOOL ← FALSE,	-- LOC is a "Bcd", rather than normal Mesa
	--
	bcdPresent: BOOL ← FALSE,	-- T => is on local disk
	bcdFileName: LONG STRING ← NIL,	-- for this LOC
	bcdVers: TimeStamp.Stamp ← TimeStamp.Null,	-- version stamp, not create
	bcdCreate: LONG CARDINAL ← 0,	-- file create time
	bcdDepSeq: DepSeq ← NIL,	-- for the Bcd
	bcdCap: File.Capability ← File.nullCapability,
	loadInfoSeq: LowLoader.LoadInfoSeq ← NIL,	-- for the loaded bcd
	--
	srcPresent: BOOL ← FALSE,	-- T => is on local disk
	srcFileName: LONG STRING ← NIL,	-- for this LOC
	srcCreate: LONG CARDINAL ← 0,	-- file create time
	srcDepSeq: DepSeq ← NIL,	-- for the Bcd
	srcCap: File.Capability ← File.nullCapability,
	srcNotSaved: BOOL ← FALSE,	-- used by Permanent
	--
	moduleName: LONG STRING ← NIL,
	alreadyLookedFor: BOOL ← FALSE
	];
	
-- be sure to examine LoadDB and DumpDB in DBStashImpl before
-- changing this record
DepSeq: TYPE = LONG POINTER TO DepSeqRecord;
DepSeqRecord: TYPE = RECORD[
	bcdFileName: LONG STRING ← NIL,	-- ends in ".bcd"
	-- this is the version stamp, not the create time
	bcdVers: TimeStamp.Stamp ← TimeStamp.Null,
	srcFileName: LONG STRING ← NIL,	-- ends in ".mesa"
	srcCreate: LONG CARDINAL ← 0,	-- source file create time
	moduleName: LONG STRING ← NIL,
	CopyString: PROC[LONG STRING, UNCOUNTED ZONE ← NIL] 
		RETURNS[LONG STRING]← NIL,	-- use to allocate strings
	-- compiler switch /a, etc.
	switches: CompilerOps.LetterSwitches ← ALL[FALSE],
	isdefns: BOOL ← FALSE,
	isconfig: BOOL ← FALSE,
	fromsource: BOOL ← FALSE,	-- T => info from source file
	istablecompiled: BOOL ← FALSE,
	symbolSpace: FileParms.SymbolSpace ← FileParms.nullSymbolSpace,
	size: CARDINAL ← 0,
	body: SEQUENCE maxsize: CARDINAL OF ADepRecord
	];

ModType: TYPE = MACHINE DEPENDENT {errortype(0), imports(1), 
	exports(2), directory(3), last(64000)};
ADepRecord: TYPE = RECORD[
	relation: ModType ← errortype,
	moduleName: LONG STRING ← NIL,
	bcdFileName: LONG STRING ← NIL,
	bcdVers: TimeStamp.Stamp ← TimeStamp.Null -- this is the version stamp, not the create time
	];

MaximumDepSize: CARDINAL = 160;	-- biggest is CoPilotDorado.Config (165)

-- procedures 

-- if src = TRUE, then see if there is a new version of source file
-- else look for new version of bcd file
NewVersion: PROC[fi: FileInfo, src: BOOL] RETURNS[newVersion: BOOL];

-- utilities for depseq's
AddToDep: PROC[depseq: DepSeq, padeprecord: POINTER TO ADepRecord];

}.