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 4348 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 4323 Mismatch in Method
#SET B$ (!b | 4) // stack is screwed up..we have no idea if we are in 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 300 End_Funct/End_proc command .not. within a method
#ENDIF