예제 #1
0
/* returns TRUE if able to fit in one $STACK(level,...) of information in global variable structure "dollar_stack".
 * returns FALSE otherwise */
static	boolean_t	fill_dollar_stack_level(int array_level, int frame_level, int cur_zlevel)
{
	mstr			*mstrptr;
	mval			tmpmval;
	dollar_stack_struct	*dstack;

	assert(FALSE == dollar_stack.incomplete);	/* we should not have come here if previous $STACK levels were incomplete */
	dstack = &dollar_stack.array[array_level];
	/* fill in $STACK(level) */
	if (frame_level)
		get_frame_creation_info(frame_level, cur_zlevel, &tmpmval);
	else
		get_command_line(&tmpmval, FALSE);	/* FALSE to indicate we want actual (not processed) command line */
	/* note that tmpmval at this point will most likely point to the stringpool. but we rely on stp_gcol to free it up */
	mstrptr = &dstack->mode_str;
	if (FALSE == fill_dollar_stack_info(&tmpmval, mstrptr))
		return FALSE;
	/* fill in $STACK(level,"ECODE") */
	dstack->ecode_ptr = (frame_level == (cur_zlevel - 1)) ? &dollar_ecode.array[dollar_ecode.index - 1] : NULL;

	/* fill in $STACK(level,"PLACE") */
	get_frame_place_mcode(frame_level, DOLLAR_STACK_PLACE, cur_zlevel, &tmpmval);
	mstrptr = &dstack->place_str;
	if (FALSE == fill_dollar_stack_info(&tmpmval, mstrptr))
		return FALSE;
	/* fill in $STACK(level,"MCODE") */
	get_frame_place_mcode(frame_level, DOLLAR_STACK_MCODE, cur_zlevel, &tmpmval);
	mstrptr = &dstack->mcode_str;
	if (FALSE == fill_dollar_stack_info(&tmpmval, mstrptr))
		return FALSE;
	return TRUE;
}
예제 #2
0
void op_fnstack1(int level, mval *result)
{
 	int		cur_zlevel;

	result->mvtype = MV_STR;
	cur_zlevel = dollar_zlevel();

	if (-1 == level)
	{
		if (!dollar_ecode.index)
		{
			MV_FORCE_MVAL(result, cur_zlevel - 1);
		} else if ((1 < dollar_ecode.index) || (error_frame != dollar_ecode.first_ecode_error_frame))
			MV_FORCE_MVAL(result, dollar_stack.index - 1);
		else
		{	/* we are in first ECODE error-handler */
			if (cur_zlevel > dollar_stack.index)
			{
				MV_FORCE_MVAL(result, cur_zlevel - 1);
			} else
			{
				MV_FORCE_MVAL(result, dollar_stack.index - 1);
			}
		}
	} else if (0 > level)
		result->str.len = 0;
	else if (0 == level)
		get_command_line(result, FALSE);	/* FALSE to indicate we want actual (not processed) command line */
	else if (!dollar_stack.index)
	{
		if (level < cur_zlevel)
			get_frame_creation_info(level, cur_zlevel, result);
		else
			result->str.len = 0;
	} else if (level < dollar_stack.index)
		get_dollar_stack_info(level, DOLLAR_STACK_MODE, result);
	else if (!dollar_stack.incomplete && (1 == dollar_ecode.index)
			&& (error_frame == dollar_ecode.first_ecode_error_frame) && (level < cur_zlevel))
		get_frame_creation_info(level, cur_zlevel, result);
	else
		result->str.len = 0;
	return;
}