Up: Sequenced Expression Evaluation   [Index]


3.16.1 Sequenced Expression Evaluation Example

An expression evaluation that may requested as:

    status = x1f4_link_expression(expression, output);

See x1f4_link_expression.

may be sequenced as:

    /* the sequenced evaluation context */
    void *slip;

    /* create the sequenced evaluation context */
    status = x1f4_head_expression(expression, &slip);
    if (status) {
    } else {
	int excess, slipping;

	while (1) {
	    struct x1f4_transfer_type transfer;

	    /* evaluate expression until error, function call or completion */
	    /*
	     * the 4th argument is supposed to indicate the number of function
	     * calls for which the evaluation is _not_ to be sequenced
	     */
	    status = x1f4_slip_expression
		(expression, slip, 0, &slipping, output, &transfer);
	    if (status) {
		/*
		 * the error case, interrupt
		 */
		break;
	    } else {
		/* _slipping_ selects function call or completion */
		if (slipping) {
		    /*
		     * function call - need to evaluate function
		     */
		    /*
		     * _transfer_ records all the information for the
		     * sequenced function call: the function itself, the input,
		     * output, and the eventual function specific execution
		     * context
		     */
		    if (transfer.function_data->flags & X1f4_E4_TEXT_LINK) {
			status = transfer.function_data->function
			    (transfer.context, transfer.output,
			     transfer.input);
		    } else {
			status = transfer.function_data->function
			    (NULL, transfer.output, transfer.input);
		    }

		    if (status) {
			break;
		    }
		} else {
		    /*
		     * expression evaluation completed, output is in _output_
		     */
		    break;
		}
	    }
	}

	/* destroy the sequenced evaluation context */
	excess = x1f4_tail_expression(expression, &slip);
	if (excess) {
	    if (status) {
	    } else {
		status = excess;
	    }
	}
    }

See Per Function Execution Context.

See Function Flags.

See x1f4_head_expression.

See x1f4_slip_expression.

See x1f4_tail_expression.

See struct x1f4_function_type.

See struct x1f4_transfer_type.