{ History ------- 22/10/85 - First version for manual processing of files or structures containing file components. (agh) 08/12/85 - Modify to perform explicit call to p_preset or p_postset. (agh) } { MODULE 26 Manual Preset and Postset Code Generation } program PrologueCode; #include "globals.x" #include "semantics.pf" #include "datareps.pf" #include "objvalues.pf" #include "storage.pf" #include "varref.pf" #include "expeval.pf" #include "codeutils.pf" #include "withstmts.pf" #include "eput.pf" procedure ProcessManuals(ManualScope: DispRange; List: ManualList; PresetAction: Boolean); visible; var ThisItem: ManualEntry; procedure SaveManualBase; begin ManualScope := ManualScope + 1; OpenWith(ManualScope) end { SaveManualBase }; procedure DiscardManualBase; begin CloseWith; ManualScope := ManualScope - 1 end { DiscardManualBase }; procedure ProcessType(TheType: TypEntry; Occurrences: Scalar); var FileEntry: StackEntry; Elements: Scalar; First, Last, Index: ObjectValue; FileFields: ManualList; ThisField: IdEntry; Finished: Boolean; Routine: Intrinsic; begin with TheType^ do case Form of Files : begin Pop(FileEntry); if PresetAction then Routine := p_presetf else Routine := p_postsetf; StartCall(Routine); if NegativeStack then begin PushLiteral(Occurrences); PushAddress(FileEntry) end else begin PushAddress(FileEntry); PushLiteral(Occurrences) end; CallStdrd(Routine); FreeEntry(FileEntry) end; Arrays : begin Elements := Cardinality(InxType); if AelType^.Form = Files then ProcessType(AelType, Occurrences * Elements) else begin GetBounds(InxType, First, Last); Index := First; Finished := false; SaveManualBase; repeat WithReference(ManualScope); StackConstant(Index); InxReference (PackedArray, First, Last, AelType^.Representation); ProcessType(AelType, Occurrences); if SameValue(Index, Last) then Finished := true else AddValues(Index, OneValue, Index) until Finished; DiscardManualBase end end; Records : begin StartManuals(FileFields); ThisField := FixedPart; while ThisField <> nil do with ThisField^ do begin if EmbeddedFile(IdType) then SelectManual(FileFields, ThisField); ThisField := NextField end; SaveManualBase; ProcessManuals(ManualScope, FileFields, PresetAction); DiscardManualBase; DsposeManuals(FileFields) end end end { ProcessType }; begin ThisItem := List.FirstEntry; while ThisItem <> nil do with ThisItem^ do begin WithReference(ManualScope); FieldReference(ItsOffset, false); ProcessType(ItsType, Repeated); ThisItem := NextItem end end { ProcessManuals }; begin { end of module } end.