Importing PUBDEF Object File Record
This procedure processes PUBDEF
object file record ($90
) and sets data in ProceduresRecord
to the procedure defined in the object file.
Procedure OMF_PUBDEF; Far;
Var PublicIdOffset: Word;
IdentifierOffset: Word;
TypeIdentifierDataPtr: PTypeIdentifierData;
ProcedureIdentifierDataPtr: PProcedureIdentifierData absolute TypeIdentifierDataPtr;
IdToken: TToken;
ObjectTypeDefinition: PObjectTypeDefinition;
ProceduresRecord: PProceduresBlockRecord;
{$IFDEF DEBUGOMF}
PubNameCounter: Word;
{$ENDIF}
Procedure Error_Invalid_PUBLIC_Definition;
begin
IdentifierError (PString (Ptr (ObjectFileSegment, ObjectErrorStringOfs))^, Invalid_PUBLIC_Definition);
end;
begin
{$IFDEF DEBUGOMF}
Write (' PUBDEF: ');
PubNameCounter := 0;
{$ENDIF}
If ObjectFilePtr^.BaseGroupIndex <> 0 then FileError (@Identifier, Invalid_PUBLIC_Definition);
If ObjectFilePtr^.BaseSegmentIndex <> CodeSegmentIndex then FileError (@Identifier, Invalid_PUBLIC_Definition);
Inc (PChar (ObjectFilePtr), 5);
Repeat
{$IFDEF DEBUGOMF}
If PubNameCounter <> 0 then Write (' ');
Writeln (PString (ObjectFilePtr)^);
Inc (PubNameCounter);
{$ENDIF}
SetObjectNameData (PString (ObjectFilePtr));
PublicIdOffset := Word (Pointer (ObjectFilePtr)^);
Inc (PChar (ObjectFilePtr), 2);
If not Copy_OMF_RecordIdentifierToCurrentIdentifier then
begin
If not CurrentIdentifierDeclaredInCurrentScope (IdentifierOffset, Pointer (TypeIdentifierDataPtr), IdToken) then
Error_Invalid_PUBLIC_Definition;
If IdToken <> Token_TypeIdentifier then Error_Invalid_PUBLIC_Definition;
ObjectTypeDefinition := PointerFromOffsets (TypeIdentifierDataPtr^.UnitTypeOffsets);
If ObjectTypeDefinition^.BaseType <> btObject then Error_Invalid_PUBLIC_Definition;
Copy_OMF_RecordIdentifierToCurrentIdentifier;
If not IsCurrentIdentifierDeclaredAsMemberInRecordOrObject (ObjectTypeDefinition,
PVariableIdentifierData (TypeIdentifierDataPtr),
IdToken,
IdentifierOffset) then
Error_Invalid_PUBLIC_Definition;
end else If not CurrentIdentifierDeclaredInCurrentScope (IdentifierOffset, Pointer (TypeIdentifierDataPtr), IdToken) then
AddProcedureIdentifier (IdToken, ProcedureIdentifierDataPtr);
If IdToken <> Token_ProcedureIdentifier then Error_Invalid_PUBLIC_Definition;
If not (pfExternal in ProcedureIdentifierDataPtr^.Flags) then Error_Invalid_PUBLIC_Definition;
ProceduresRecord := Ptr (SymbolTable [stProcedures].Segment, ProcedureIdentifierDataPtr^.ProceduresRecordOffset);
If ProceduresRecord^.ProgramCodeBlockRecordOffset <> $FFFF then Error_Invalid_PUBLIC_Definition;
ProceduresRecord^.ProgramCodeBlockRecordOffset := SymbolTable [stCodeBlocks].UsedSize;
ProceduresRecord^.ProcIdentifierOffset := PublicIdOffset;
Inc (PChar (ObjectFilePtr));
until Ofs (ObjectFilePtr^) >= ObjectRecordChecksumOffset;
end;