Function: ccl-execute

ccl-execute is a function defined in ccl.c.

Signature

(ccl-execute CCL-PROG REG)

Documentation

Execute CCL-PROGRAM with registers initialized by REGISTERS.

CCL-PROGRAM is a CCL program name (symbol) or compiled code generated by ccl-compile (for backward compatibility. In the latter case, the execution overhead is bigger than in the former). No I/O commands should appear in CCL-PROGRAM.

REGISTERS is a vector of [R0 R1 ... R7] where RN is an initial value for the Nth register.

As side effect, each element of REGISTERS holds the value of the corresponding register after the execution.

See the documentation of define-ccl-program for a definition of CCL programs.

Source Code

// Defined in /usr/src/emacs/src/ccl.c
{
  struct ccl_program ccl;
  int i;

  if (! setup_ccl_program (&ccl, ccl_prog))
    error ("Invalid CCL program");

  CHECK_VECTOR (reg);
  if (ASIZE (reg) != 8)
    error ("Length of vector REGISTERS is not 8");

  for (i = 0; i < 8; i++)
    {
      intmax_t n;
      ccl.reg[i] = ((INTEGERP (AREF (reg, i))
		     && integer_to_intmax (AREF (reg, i), &n)
		     && INT_MIN <= n && n <= INT_MAX)
		    ? n : 0);
    }

  ccl_driver (&ccl, NULL, NULL, 0, 0, Qnil);
  maybe_quit ();
  if (ccl.status != CCL_STAT_SUCCESS)
    error ("Error in CCL program at %dth code", ccl.ic);

  for (i = 0; i < 8; i++)
    ASET (reg, i, make_int (ccl.reg[i]));
  return Qnil;
}