Press enter to see results or esc to cancel.

System Functions FilePos and FileSize

This procedure processes system functions FilePos and FileSize. It expects file variable as parameter and generates a call to appropriate compiler function passed as parameter to this procedure.

Procedure Func_FilePos_FileSize; Far;
begin
  ExpectTokenAndGetNext (Token_LeftParenthesis);
  Expression^.ExpectFileVariableAndPushPointerToMemory;
  If Expression^.TypeDefPtr^.BaseType <> btFile then Error (InvalidFileType);
  ExpectTokenAndGetNext (Token_RightParenthesis);
  Expression^.Calculate;
  GenerateInstruction_CALL_FAR (FuncParameter);
  GenerateIOErrorCheckingCode;
  With Expression^ do
    begin
      Expression^.EndIntermediateCodeSubroutine;
      Location := elRegister;
      DataType := itLongInt;
      UsedRegisters := [urBX, urDX, urCX, urAX];
      LocationData.Register := rDX_AX;
      TypeDefPtr := Ptr (SystemUnitSegment, LongInt_TypeOffset);
    end;
end;