Press enter to see results or esc to cancel.

System Procedure Dispose

This function processes system procedure Dispose.

Function Proc_Dispose: Word; Far;
Var PointerExpression: Texpression;
    PointerBaseType: PTypeDefinition;
begin
  ExpectTokenAndGetNext (Token_LeftParenthesis);
  PointerExpression.ExpectPointerExpression;
  PointerBaseType := PointerFromOffsets (PPointerTypeDefinition (PointerExpression.TypeDefPtr)^.PointerBaseTypeOffset);
  If (PointerBaseType^.BaseType = btObject) and (CheckAndGetNextToken (Token_Comma)) then
    begin
      PointerExpression.DereferencePointer;
      PointerExpression.FindAndProcessMethodCall (PointerBaseType, [pfDestructor], [mcDispose], DestructorIdentifierExpected);
      PointerExpression.CallProcedure;
    end else begin
               PointerExpression.Calculate;
               PointerExpression.Push;
               GenerateCodeToPushWord (PointerBaseType^.Size);
               GenerateInstruction_CALL_FAR (SysProc_DisposePtr);
               PointerExpression.EndIntermediateCodeSubroutine;
             end;
  ExpectTokenAndGetNext (Token_RightParenthesis);
  Proc_Dispose := PointerExpression.IntermediateCodeOffset;
end;