Macro: END_PROCEDURE

Module location: FMAC line 10335 (view source)

changes: 1. declare an error if not within a procedure or function 2. Check for mismatched Begin/End blocks. 3. Check for child objects within end_object

  // This tracks number of nested objects in method.
  // !Zn is the level of !n when the proc/funct started. Upon
  // completion !n should be that value. If not error.
  // If error, compiler stack is messed up
  #IF (!Zn = !n)
  #ELSE
    #ERROR DFERR_COMP_UNRESOVLED_CONTROL_BLOCK Mismatch in Method
    #SET B$ (!b | 4) // stack is screwed up..we have no idea if we are in proc
  #ENDIF

  // When Proc started we set !Zm to 0. It counts nested objects. It
  // should be zero. If not we have an error.
  // If error, compiler stack is messed up
  #IF (!Zm > 0)
    #ERROR DFERR_COMP_MISSING_END_OBJECT Mismatch in Method
    #SET B$ (!b | 4) // stack is screwed up..we have no idea if we are in proc
  #ENDIF

#IFDEF MANGLE_NAMES
  // Let NUM_ARGUMENTS get referenced again in the code, if it has been turned off.
  #ALLOW  NUM_ARGUMENTS
  #UNDEF __@INSIDE_FUNCTION@__     // Leaving function/proc.

#ENDIF

  #IF (!b & 4)              // are we within a Procedure
    #SET B$ (!b & 3)        // reset flag to in_procedure
    #POP U$
    #REPLACE OBJ$!Za$LNUM |CI!Zg     // Update the count in the local cmd.
    //  !A [] OBJ$END$HANDLER |CI0
    !A [] $0455 |CI0
    #REPLACE OBJ$!Za$ENDPROC !a
    #POP U$
    #POP ZG$

    #STKSYM
  #ELSE
    #ERROR DFERR_COMP_ILLEGAL_CODE_PLACEMENT End_Funct/End_proc command .not. within a method
  #ENDIF