/[emacs]/emacs/src/ccl.c
ViewVC logotype

Diff of /emacs/src/ccl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.75 by pj, Mon Nov 12 07:28:40 2001 UTC revision 1.76 by monnier, Wed Nov 28 07:25:03 2001 UTC
# Line 1076  ccl_driver (ccl, source, destination, sr Line 1076  ccl_driver (ccl, source, destination, sr
1076    
1077              if (stack_idx >= 256              if (stack_idx >= 256
1078                  || prog_id < 0                  || prog_id < 0
1079                  || prog_id >= XVECTOR (Vccl_program_table)->size                  || prog_id >= ASIZE (Vccl_program_table)
1080                  || (slot = XVECTOR (Vccl_program_table)->contents[prog_id],                  || (slot = AREF (Vccl_program_table, prog_id), !VECTORP (slot))
1081                      !VECTORP (slot))                  || !VECTORP (AREF (slot, 1)))
                 || !VECTORP (XVECTOR (slot)->contents[1]))  
1082                {                {
1083                  if (stack_idx > 0)                  if (stack_idx > 0)
1084                    {                    {
# Line 1092  ccl_driver (ccl, source, destination, sr Line 1091  ccl_driver (ccl, source, destination, sr
1091              ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;              ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
1092              ccl_prog_stack_struct[stack_idx].ic = ic;              ccl_prog_stack_struct[stack_idx].ic = ic;
1093              stack_idx++;              stack_idx++;
1094              ccl_prog = XVECTOR (XVECTOR (slot)->contents[1])->contents;              ccl_prog = XVECTOR (AREF (slot, 1))->contents;
1095              ic = CCL_HEADER_MAIN;              ic = CCL_HEADER_MAIN;
1096            }            }
1097            break;            break;
# Line 1430  ccl_driver (ccl, source, destination, sr Line 1429  ccl_driver (ccl, source, destination, sr
1429                  for (;i < j;i++)                  for (;i < j;i++)
1430                    {                    {
1431    
1432                      size = XVECTOR (Vcode_conversion_map_vector)->size;                      size = ASIZE (Vcode_conversion_map_vector);
1433                      point = XINT (ccl_prog[ic++]);                      point = XINT (ccl_prog[ic++]);
1434                      if (point >= size) continue;                      if (point >= size) continue;
1435                      map =                      map = AREF (Vcode_conversion_map_vector, point);
                       XVECTOR (Vcode_conversion_map_vector)->contents[point];  
1436    
1437                      /* Check map varidity.  */                      /* Check map varidity.  */
1438                      if (!CONSP (map)) continue;                      if (!CONSP (map)) continue;
1439                      map = XCDR (map);                      map = XCDR (map);
1440                      if (!VECTORP (map)) continue;                      if (!VECTORP (map)) continue;
1441                      size = XVECTOR (map)->size;                      size = ASIZE (map);
1442                      if (size <= 1) continue;                      if (size <= 1) continue;
1443    
1444                      content = XVECTOR (map)->contents[0];                      content = AREF (map, 0);
1445    
1446                      /* check map type,                      /* check map type,
1447                         [STARTPOINT VAL1 VAL2 ...] or                         [STARTPOINT VAL1 VAL2 ...] or
# Line 1453  ccl_driver (ccl, source, destination, sr Line 1451  ccl_driver (ccl, source, destination, sr
1451                          point = XUINT (content);                          point = XUINT (content);
1452                          point = op - point + 1;                          point = op - point + 1;
1453                          if (!((point >= 1) && (point < size))) continue;                          if (!((point >= 1) && (point < size))) continue;
1454                          content = XVECTOR (map)->contents[point];                          content = AREF (map, point);
1455                        }                        }
1456                      else if (EQ (content, Qt))                      else if (EQ (content, Qt))
1457                        {                        {
1458                          if (size != 4) continue;                          if (size != 4) continue;
1459                          if ((op >= XUINT (XVECTOR (map)->contents[2]))                          if ((op >= XUINT (AREF (map, 2)))
1460                              && (op < XUINT (XVECTOR (map)->contents[3])))                              && (op < XUINT (AREF (map, 3))))
1461                            content = XVECTOR (map)->contents[1];                            content = AREF (map, 1);
1462                          else                          else
1463                            continue;                            continue;
1464                        }                        }
# Line 1586  ccl_driver (ccl, source, destination, sr Line 1584  ccl_driver (ccl, source, destination, sr
1584                          break;                          break;
1585                        }                        }
1586                    }                    }
1587                  map_vector_size = XVECTOR (Vcode_conversion_map_vector)->size;                  map_vector_size = ASIZE (Vcode_conversion_map_vector);
1588                                    
1589                  do {                  do {
1590                    for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--)                    for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--)
# Line 1607  ccl_driver (ccl, source, destination, sr Line 1605  ccl_driver (ccl, source, destination, sr
1605                          }                          }
1606    
1607                        if (point >= map_vector_size) continue;                        if (point >= map_vector_size) continue;
1608                        map = (XVECTOR (Vcode_conversion_map_vector)                        map = AREF (Vcode_conversion_map_vector, point);
                              ->contents[point]);  
1609    
1610                        /* Check map varidity.  */                        /* Check map varidity.  */
1611                        if (!CONSP (map)) continue;                        if (!CONSP (map)) continue;
1612                        map = XCDR (map);                        map = XCDR (map);
1613                        if (!VECTORP (map)) continue;                        if (!VECTORP (map)) continue;
1614                        size = XVECTOR (map)->size;                        size = ASIZE (map);
1615                        if (size <= 1) continue;                        if (size <= 1) continue;
1616    
1617                        content = XVECTOR (map)->contents[0];                        content = AREF (map, 0);
1618    
1619                        /* check map type,                        /* check map type,
1620                           [STARTPOINT VAL1 VAL2 ...] or                           [STARTPOINT VAL1 VAL2 ...] or
# Line 1627  ccl_driver (ccl, source, destination, sr Line 1624  ccl_driver (ccl, source, destination, sr
1624                            point = XUINT (content);                            point = XUINT (content);
1625                            point = op - point + 1;                            point = op - point + 1;
1626                            if (!((point >= 1) && (point < size))) continue;                            if (!((point >= 1) && (point < size))) continue;
1627                            content = XVECTOR (map)->contents[point];                            content = AREF (map, point);
1628                          }                          }
1629                        else if (EQ (content, Qt))                        else if (EQ (content, Qt))
1630                          {                          {
1631                            if (size != 4) continue;                            if (size != 4) continue;
1632                            if ((op >= XUINT (XVECTOR (map)->contents[2])) &&                            if ((op >= XUINT (AREF (map, 2))) &&
1633                                (op < XUINT (XVECTOR (map)->contents[3])))                                (op < XUINT (AREF (map, 3))))
1634                              content = XVECTOR (map)->contents[1];                              content = AREF (map, 1);
1635                            else                            else
1636                              continue;                              continue;
1637                          }                          }
# Line 1707  ccl_driver (ccl, source, destination, sr Line 1704  ccl_driver (ccl, source, destination, sr
1704                  int size, point;                  int size, point;
1705                  j = XINT (ccl_prog[ic++]); /* map_id */                  j = XINT (ccl_prog[ic++]); /* map_id */
1706                  op = reg[rrr];                  op = reg[rrr];
1707                  if (j >= XVECTOR (Vcode_conversion_map_vector)->size)                  if (j >= ASIZE (Vcode_conversion_map_vector))
1708                    {                    {
1709                      reg[RRR] = -1;                      reg[RRR] = -1;
1710                      break;                      break;
1711                    }                    }
1712                  map = XVECTOR (Vcode_conversion_map_vector)->contents[j];                  map = AREF (Vcode_conversion_map_vector, j);
1713                  if (!CONSP (map))                  if (!CONSP (map))
1714                    {                    {
1715                      reg[RRR] = -1;                      reg[RRR] = -1;
# Line 1724  ccl_driver (ccl, source, destination, sr Line 1721  ccl_driver (ccl, source, destination, sr
1721                      reg[RRR] = -1;                      reg[RRR] = -1;
1722                      break;                      break;
1723                    }                    }
1724                  size = XVECTOR (map)->size;                  size = ASIZE (map);
1725                  point = XUINT (XVECTOR (map)->contents[0]);                  point = XUINT (AREF (map, 0));
1726                  point = op - point + 1;                  point = op - point + 1;
1727                  reg[RRR] = 0;                  reg[RRR] = 0;
1728                  if ((size <= 1) ||                  if ((size <= 1) ||
# Line 1734  ccl_driver (ccl, source, destination, sr Line 1731  ccl_driver (ccl, source, destination, sr
1731                  else                  else
1732                    {                    {
1733                      reg[RRR] = 0;                      reg[RRR] = 0;
1734                      content = XVECTOR (map)->contents[point];                      content = AREF (map, point);
1735                      if (NILP (content))                      if (NILP (content))
1736                        reg[RRR] = -1;                        reg[RRR] = -1;
1737                      else if (NUMBERP (content))                      else if (NUMBERP (content))
# Line 1875  resolve_symbol_ccl_program (ccl) Line 1872  resolve_symbol_ccl_program (ccl)
1872    Lisp_Object result, contents, val;    Lisp_Object result, contents, val;
1873    
1874    result = ccl;    result = ccl;
1875    veclen = XVECTOR (result)->size;    veclen = ASIZE (result);
1876    
1877    for (i = 0; i < veclen; i++)    for (i = 0; i < veclen; i++)
1878      {      {
1879        contents = XVECTOR (result)->contents[i];        contents = AREF (result, i);
1880        if (INTEGERP (contents))        if (INTEGERP (contents))
1881          continue;          continue;
1882        else if (CONSP (contents)        else if (CONSP (contents)
# Line 1895  resolve_symbol_ccl_program (ccl) Line 1892  resolve_symbol_ccl_program (ccl)
1892    
1893            val = Fget (XCAR (contents), XCDR (contents));            val = Fget (XCAR (contents), XCDR (contents));
1894            if (NATNUMP (val))            if (NATNUMP (val))
1895              XVECTOR (result)->contents[i] = val;              AREF (result, i) = val;
1896            else            else
1897              unresolved = 1;              unresolved = 1;
1898            continue;            continue;
# Line 1910  resolve_symbol_ccl_program (ccl) Line 1907  resolve_symbol_ccl_program (ccl)
1907    
1908            val = Fget (contents, Qtranslation_table_id);            val = Fget (contents, Qtranslation_table_id);
1909            if (NATNUMP (val))            if (NATNUMP (val))
1910              XVECTOR (result)->contents[i] = val;              AREF (result, i) = val;
1911            else            else
1912              {              {
1913                val = Fget (contents, Qcode_conversion_map_id);                val = Fget (contents, Qcode_conversion_map_id);
1914                if (NATNUMP (val))                if (NATNUMP (val))
1915                  XVECTOR (result)->contents[i] = val;                  AREF (result, i) = val;
1916                else                else
1917                  {                  {
1918                    val = Fget (contents, Qccl_program_idx);                    val = Fget (contents, Qccl_program_idx);
1919                    if (NATNUMP (val))                    if (NATNUMP (val))
1920                      XVECTOR (result)->contents[i] = val;                      AREF (result, i) = val;
1921                    else                    else
1922                      unresolved = 1;                      unresolved = 1;
1923                  }                  }
# Line 1955  ccl_get_compiled_code (ccl_prog) Line 1952  ccl_get_compiled_code (ccl_prog)
1952    
1953    val = Fget (ccl_prog, Qccl_program_idx);    val = Fget (ccl_prog, Qccl_program_idx);
1954    if (! NATNUMP (val)    if (! NATNUMP (val)
1955        || XINT (val) >= XVECTOR (Vccl_program_table)->size)        || XINT (val) >= ASIZE (Vccl_program_table))
1956      return Qnil;      return Qnil;
1957    slot = XVECTOR (Vccl_program_table)->contents[XINT (val)];    slot = AREF (Vccl_program_table, XINT (val));
1958    if (! VECTORP (slot)    if (! VECTORP (slot)
1959        || XVECTOR (slot)->size != 3        || ASIZE (slot) != 3
1960        || ! VECTORP (XVECTOR (slot)->contents[1]))        || ! VECTORP (AREF (slot, 1)))
1961      return Qnil;      return Qnil;
1962    if (NILP (XVECTOR (slot)->contents[2]))    if (NILP (AREF (slot, 2)))
1963      {      {
1964        val = resolve_symbol_ccl_program (XVECTOR (slot)->contents[1]);        val = resolve_symbol_ccl_program (AREF (slot, 1));
1965        if (! VECTORP (val))        if (! VECTORP (val))
1966          return Qnil;          return Qnil;
1967        XVECTOR (slot)->contents[1] = val;        AREF (slot, 1) = val;
1968        XVECTOR (slot)->contents[2] = Qt;        AREF (slot, 2) = Qt;
1969      }      }
1970    return XVECTOR (slot)->contents[1];    return AREF (slot, 1);
1971  }  }
1972    
1973  /* Setup fields of the structure pointed by CCL appropriately for the  /* Setup fields of the structure pointed by CCL appropriately for the
# Line 2031  See the documentation of  `define-ccl-pr Line 2028  See the documentation of  `define-ccl-pr
2028    
2029    val = Fget (object, Qccl_program_idx);    val = Fget (object, Qccl_program_idx);
2030    return ((! NATNUMP (val)    return ((! NATNUMP (val)
2031             || XINT (val) >= XVECTOR (Vccl_program_table)->size)             || XINT (val) >= ASIZE (Vccl_program_table))
2032            ? Qnil : Qt);            ? Qnil : Qt);
2033  }  }
2034    
# Line 2061  programs.  */) Line 2058  programs.  */)
2058      error ("Invalid CCL program");      error ("Invalid CCL program");
2059    
2060    CHECK_VECTOR (reg);    CHECK_VECTOR (reg);
2061    if (XVECTOR (reg)->size != 8)    if (ASIZE (reg) != 8)
2062      error ("Length of vector REGISTERS is not 8");      error ("Length of vector REGISTERS is not 8");
2063    
2064    for (i = 0; i < 8; i++)    for (i = 0; i < 8; i++)
2065      ccl.reg[i] = (INTEGERP (XVECTOR (reg)->contents[i])      ccl.reg[i] = (INTEGERP (AREF (reg, i))
2066                    ? XINT (XVECTOR (reg)->contents[i])                    ? XINT (AREF (reg, i))
2067                    : 0);                    : 0);
2068    
2069    ccl_driver (&ccl, (unsigned char *)0, (unsigned char *)0, 0, 0, (int *)0);    ccl_driver (&ccl, (unsigned char *)0, (unsigned char *)0, 0, 0, (int *)0);
# Line 2075  programs.  */) Line 2072  programs.  */)
2072      error ("Error in CCL program at %dth code", ccl.ic);      error ("Error in CCL program at %dth code", ccl.ic);
2073    
2074    for (i = 0; i < 8; i++)    for (i = 0; i < 8; i++)
2075      XSETINT (XVECTOR (reg)->contents[i], ccl.reg[i]);      XSETINT (AREF (reg, i), ccl.reg[i]);
2076    return Qnil;    return Qnil;
2077  }  }
2078    
# Line 2119  See the documentation of `define-ccl-pro Line 2116  See the documentation of `define-ccl-pro
2116      error ("Invalid CCL program");      error ("Invalid CCL program");
2117    
2118    CHECK_VECTOR (status);    CHECK_VECTOR (status);
2119    if (XVECTOR (status)->size != 9)    if (ASIZE (status) != 9)
2120      error ("Length of vector STATUS is not 9");      error ("Length of vector STATUS is not 9");
2121    CHECK_STRING (str);    CHECK_STRING (str);
2122    
# Line 2127  See the documentation of `define-ccl-pro Line 2124  See the documentation of `define-ccl-pro
2124    
2125    for (i = 0; i < 8; i++)    for (i = 0; i < 8; i++)
2126      {      {
2127        if (NILP (XVECTOR (status)->contents[i]))        if (NILP (AREF (status, i)))
2128          XSETINT (XVECTOR (status)->contents[i], 0);          XSETINT (AREF (status, i), 0);
2129        if (INTEGERP (XVECTOR (status)->contents[i]))        if (INTEGERP (AREF (status, i)))
2130          ccl.reg[i] = XINT (XVECTOR (status)->contents[i]);          ccl.reg[i] = XINT (AREF (status, i));
2131      }      }
2132    if (INTEGERP (XVECTOR (status)->contents[i]))    if (INTEGERP (AREF (status, i)))
2133      {      {
2134        i = XFASTINT (XVECTOR (status)->contents[8]);        i = XFASTINT (AREF (status, 8));
2135        if (ccl.ic < i && i < ccl.size)        if (ccl.ic < i && i < ccl.size)
2136          ccl.ic = i;          ccl.ic = i;
2137      }      }
# Line 2145  See the documentation of `define-ccl-pro Line 2142  See the documentation of `define-ccl-pro
2142    produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf,    produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf,
2143                           STRING_BYTES (XSTRING (str)), outbufsize, (int *) 0);                           STRING_BYTES (XSTRING (str)), outbufsize, (int *) 0);
2144    for (i = 0; i < 8; i++)    for (i = 0; i < 8; i++)
2145      XSET (XVECTOR (status)->contents[i], Lisp_Int, ccl.reg[i]);      XSET (AREF (status, i), Lisp_Int, ccl.reg[i]);
2146    XSETINT (XVECTOR (status)->contents[8], ccl.ic);    XSETINT (AREF (status, 8), ccl.ic);
2147    UNGCPRO;    UNGCPRO;
2148    
2149    if (NILP (unibyte_p))    if (NILP (unibyte_p))
# Line 2178  Return index number of the registered CC Line 2175  Return index number of the registered CC
2175       (name, ccl_prog)       (name, ccl_prog)
2176       Lisp_Object name, ccl_prog;       Lisp_Object name, ccl_prog;
2177  {  {
2178    int len = XVECTOR (Vccl_program_table)->size;    int len = ASIZE (Vccl_program_table);
2179    int idx;    int idx;
2180    Lisp_Object resolved;    Lisp_Object resolved;
2181    
# Line 2203  Return index number of the registered CC Line 2200  Return index number of the registered CC
2200      {      {
2201        Lisp_Object slot;        Lisp_Object slot;
2202    
2203        slot = XVECTOR (Vccl_program_table)->contents[idx];        slot = AREF (Vccl_program_table, idx);
2204        if (!VECTORP (slot))        if (!VECTORP (slot))
2205          /* This is the first unsed slot.  Register NAME here.  */          /* This is the first unsed slot.  Register NAME here.  */
2206          break;          break;
2207    
2208        if (EQ (name, XVECTOR (slot)->contents[0]))        if (EQ (name, AREF (slot, 0)))
2209          {          {
2210            /* Update this slot.  */            /* Update this slot.  */
2211            XVECTOR (slot)->contents[1] = ccl_prog;            AREF (slot, 1) = ccl_prog;
2212            XVECTOR (slot)->contents[2] = resolved;            AREF (slot, 2) = resolved;
2213            return make_number (idx);            return make_number (idx);
2214          }          }
2215      }      }
# Line 2225  Return index number of the registered CC Line 2222  Return index number of the registered CC
2222    
2223        new_table = Fmake_vector (make_number (len * 2), Qnil);        new_table = Fmake_vector (make_number (len * 2), Qnil);
2224        for (j = 0; j < len; j++)        for (j = 0; j < len; j++)
2225          XVECTOR (new_table)->contents[j]          AREF (new_table, j)
2226            = XVECTOR (Vccl_program_table)->contents[j];            = AREF (Vccl_program_table, j);
2227        Vccl_program_table = new_table;        Vccl_program_table = new_table;
2228      }      }
2229    
# Line 2234  Return index number of the registered CC Line 2231  Return index number of the registered CC
2231      Lisp_Object elt;      Lisp_Object elt;
2232    
2233      elt = Fmake_vector (make_number (3), Qnil);      elt = Fmake_vector (make_number (3), Qnil);
2234      XVECTOR (elt)->contents[0] = name;      AREF (elt, 0) = name;
2235      XVECTOR (elt)->contents[1] = ccl_prog;      AREF (elt, 1) = ccl_prog;
2236      XVECTOR (elt)->contents[2] = resolved;      AREF (elt, 2) = resolved;
2237      XVECTOR (Vccl_program_table)->contents[idx] = elt;      AREF (Vccl_program_table, idx) = elt;
2238    }    }
2239    
2240    Fput (name, Qccl_program_idx, make_number (idx));    Fput (name, Qccl_program_idx, make_number (idx));
# Line 2261  Return index number of the registered ma Line 2258  Return index number of the registered ma
2258       (symbol, map)       (symbol, map)
2259       Lisp_Object symbol, map;       Lisp_Object symbol, map;
2260  {  {
2261    int len = XVECTOR (Vcode_conversion_map_vector)->size;    int len = ASIZE (Vcode_conversion_map_vector);
2262    int i;    int i;
2263    Lisp_Object index;    Lisp_Object index;
2264    
# Line 2270  Return index number of the registered ma Line 2267  Return index number of the registered ma
2267        
2268    for (i = 0; i < len; i++)    for (i = 0; i < len; i++)
2269      {      {
2270        Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i];        Lisp_Object slot = AREF (Vcode_conversion_map_vector, i);
2271    
2272        if (!CONSP (slot))        if (!CONSP (slot))
2273          break;          break;
# Line 2291  Return index number of the registered ma Line 2288  Return index number of the registered ma
2288        int j;        int j;
2289    
2290        for (j = 0; j < len; j++)        for (j = 0; j < len; j++)
2291          XVECTOR (new_vector)->contents[j]          AREF (new_vector, j)
2292            = XVECTOR (Vcode_conversion_map_vector)->contents[j];            = AREF (Vcode_conversion_map_vector, j);
2293        Vcode_conversion_map_vector = new_vector;        Vcode_conversion_map_vector = new_vector;
2294      }      }
2295    
2296    index = make_number (i);    index = make_number (i);
2297    Fput (symbol, Qcode_conversion_map, map);    Fput (symbol, Qcode_conversion_map, map);
2298    Fput (symbol, Qcode_conversion_map_id, index);    Fput (symbol, Qcode_conversion_map_id, index);
2299    XVECTOR (Vcode_conversion_map_vector)->contents[i] = Fcons (symbol, map);    AREF (Vcode_conversion_map_vector, i) = Fcons (symbol, map);
2300    return index;    return index;
2301  }  }
2302    

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26