Mercurial > hg > xemacs-beta
comparison src/mule-ccl.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
179 /* Note: If read is suspended, the resumed execution starts from the | 179 /* Note: If read is suspended, the resumed execution starts from the |
180 second code (YYYYY == CCL_ReadJump). */ | 180 second code (YYYYY == CCL_ReadJump). */ |
181 | 181 |
182 #define CCL_WriteConstJump 0x08 /* Write constant and jump: | 182 #define CCL_WriteConstJump 0x08 /* Write constant and jump: |
183 1:A--D--D--R--E--S--S-000XXXXX | 183 1:A--D--D--R--E--S--S-000XXXXX |
184 2:CONST | 184 2:const |
185 ------------------------------ | 185 ------------------------------ |
186 write (CONST); | 186 write (const); |
187 IC += ADDRESS; | 187 IC += ADDRESS; |
188 */ | 188 */ |
189 | 189 |
190 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump: | 190 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump: |
191 1:A--D--D--R--E--S--S-rrrXXXXX | 191 1:A--D--D--R--E--S--S-rrrXXXXX |
192 2:CONST | 192 2:const |
193 3:A--D--D--R--E--S--S-rrrYYYYY | 193 3:A--D--D--R--E--S--S-rrrYYYYY |
194 ----------------------------- | 194 ----------------------------- |
195 write (CONST); | 195 write (const); |
196 IC += 2; | 196 IC += 2; |
197 read (reg[rrr]); | 197 read (reg[rrr]); |
198 IC += ADDRESS; | 198 IC += ADDRESS; |
199 */ | 199 */ |
200 /* Note: If read is suspended, the resumed execution starts from the | 200 /* Note: If read is suspended, the resumed execution starts from the |
428 3:... | 428 3:... |
429 ------------------------------ | 429 ------------------------------ |
430 extended_command (rrr,RRR,Rrr,ARGS) | 430 extended_command (rrr,RRR,Rrr,ARGS) |
431 */ | 431 */ |
432 | 432 |
433 /* | 433 /* |
434 Here after, Extended CCL Instructions. | 434 Here after, Extended CCL Instructions. |
435 Bit length of extended command is 14. | 435 Bit length of extended command is 14. |
436 Therefore, the instruction code range is 0..16384(0x3fff). | 436 Therefore, the instruction code range is 0..16384(0x3fff). |
437 */ | 437 */ |
438 | 438 |
487 1:ExtendedCOMMNDXXXRRRrrrXXXXX | 487 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
488 2:NUMBER of MAPs | 488 2:NUMBER of MAPs |
489 3:MAP-ID1 | 489 3:MAP-ID1 |
490 4:MAP-ID2 | 490 4:MAP-ID2 |
491 ... | 491 ... |
492 */ | 492 */ |
493 | 493 |
494 /* Map the code in reg[rrr] by MAPs starting from the Nth (N = | 494 /* Map the code in reg[rrr] by MAPs starting from the Nth (N = |
495 reg[RRR]) map. | 495 reg[RRR]) map. |
496 | 496 |
497 MAPs are supplied in the succeeding CCL codes as follows: | 497 MAPs are supplied in the succeeding CCL codes as follows: |
558 (a)......[STARTPOINT VAL1 VAL2 ...] | 558 (a)......[STARTPOINT VAL1 VAL2 ...] |
559 (b)......[t VAL STARTPOINT ENDPOINT], | 559 (b)......[t VAL STARTPOINT ENDPOINT], |
560 where | 560 where |
561 STARTPOINT is an offset to be used for indexing a map, | 561 STARTPOINT is an offset to be used for indexing a map, |
562 ENDPOINT is a maximum index number of a map, | 562 ENDPOINT is a maximum index number of a map, |
563 VAL and VALn is a number, nil, t, or lambda. | 563 VAL and VALn is a number, nil, t, or lambda. |
564 | 564 |
565 Valid index range of a map of type (a) is: | 565 Valid index range of a map of type (a) is: |
566 STARTPOINT <= index < STARTPOINT + map_size - 1 | 566 STARTPOINT <= index < STARTPOINT + map_size - 1 |
567 Valid index range of a map of type (b) is: | 567 Valid index range of a map of type (b) is: |
568 STARTPOINT <= index < ENDPOINT */ | 568 STARTPOINT <= index < ENDPOINT */ |
750 { | 750 { |
751 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */ | 751 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */ |
752 int ic; /* Instruction Counter. */ | 752 int ic; /* Instruction Counter. */ |
753 }; | 753 }; |
754 | 754 |
755 /* For the moment, we only support depth 256 of stack. */ | 755 /* For the moment, we only support depth 256 of stack. */ |
756 static struct ccl_prog_stack ccl_prog_stack_struct[256]; | 756 static struct ccl_prog_stack ccl_prog_stack_struct[256]; |
757 | 757 |
758 int | 758 int |
759 ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, | 759 ccl_driver (struct ccl_program *ccl, const unsigned char *source, |
760 unsigned_char_dynarr *destination, int src_bytes, | 760 unsigned_char_dynarr *destination, int src_bytes, |
761 int *consumed, int conversion_mode) | 761 int *consumed, int conversion_mode) |
762 { | 762 { |
763 int *reg = ccl->reg; | 763 int *reg = ccl->reg; |
764 int ic = ccl->ic; | 764 int ic = ccl->ic; |
765 int code = -1; /* init to illegal value, */ | 765 int code = -1; /* init to illegal value, */ |
766 int field1, field2; | 766 int field1, field2; |
767 Lisp_Object *ccl_prog = ccl->prog; | 767 Lisp_Object *ccl_prog = ccl->prog; |
768 CONST unsigned char *src = source, *src_end = src + src_bytes; | 768 const unsigned char *src = source, *src_end = src + src_bytes; |
769 int jump_address = 0; /* shut up the compiler */ | 769 int jump_address = 0; /* shut up the compiler */ |
770 int i, j, op; | 770 int i, j, op; |
771 int stack_idx = ccl->stack_idx; | 771 int stack_idx = ccl->stack_idx; |
772 /* Instruction counter of the current CCL code. */ | 772 /* Instruction counter of the current CCL code. */ |
773 int this_ic = 0; | 773 int this_ic = 0; |
1135 if (src >= src_end) | 1135 if (src >= src_end) |
1136 { | 1136 { |
1137 src++; | 1137 src++; |
1138 goto ccl_read_multibyte_character_suspend; | 1138 goto ccl_read_multibyte_character_suspend; |
1139 } | 1139 } |
1140 | 1140 |
1141 i = *src++; | 1141 i = *src++; |
1142 #if 0 | 1142 #if 0 |
1143 if (i == LEADING_CODE_COMPOSITION) | 1143 if (i == LEADING_CODE_COMPOSITION) |
1144 { | 1144 { |
1145 if (src >= src_end) | 1145 if (src >= src_end) |
1281 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), | 1281 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), |
1282 i, -1, 0, 0); | 1282 i, -1, 0, 0); |
1283 SPLIT_CHAR (op, reg[RRR], i, j); | 1283 SPLIT_CHAR (op, reg[RRR], i, j); |
1284 if (j != -1) | 1284 if (j != -1) |
1285 i = (i << 7) | j; | 1285 i = (i << 7) | j; |
1286 | 1286 |
1287 reg[rrr] = i; | 1287 reg[rrr] = i; |
1288 break; | 1288 break; |
1289 | 1289 |
1290 case CCL_TranslateCharacterConstTbl: | 1290 case CCL_TranslateCharacterConstTbl: |
1291 op = XINT (ccl_prog[ic]); /* table */ | 1291 op = XINT (ccl_prog[ic]); /* table */ |
1307 | 1307 |
1308 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); | 1308 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); |
1309 SPLIT_CHAR (op, reg[RRR], i, j); | 1309 SPLIT_CHAR (op, reg[RRR], i, j); |
1310 if (j != -1) | 1310 if (j != -1) |
1311 i = (i << 7) | j; | 1311 i = (i << 7) | j; |
1312 | 1312 |
1313 reg[rrr] = i; | 1313 reg[rrr] = i; |
1314 break; | 1314 break; |
1315 | 1315 |
1316 case CCL_IterateMultipleMap: | 1316 case CCL_IterateMultipleMap: |
1317 { | 1317 { |
1368 && (op < XUINT (XVECTOR (map)->contents[3]))) | 1368 && (op < XUINT (XVECTOR (map)->contents[3]))) |
1369 content = XVECTOR (map)->contents[1]; | 1369 content = XVECTOR (map)->contents[1]; |
1370 else | 1370 else |
1371 continue; | 1371 continue; |
1372 } | 1372 } |
1373 else | 1373 else |
1374 continue; | 1374 continue; |
1375 | 1375 |
1376 if (NILP (content)) | 1376 if (NILP (content)) |
1377 continue; | 1377 continue; |
1378 else if (NUMBERP (content)) | 1378 else if (NUMBERP (content)) |
1400 if (i == j) | 1400 if (i == j) |
1401 reg[RRR] = -1; | 1401 reg[RRR] = -1; |
1402 ic = fin_ic; | 1402 ic = fin_ic; |
1403 } | 1403 } |
1404 break; | 1404 break; |
1405 | 1405 |
1406 case CCL_MapMultiple: | 1406 case CCL_MapMultiple: |
1407 { | 1407 { |
1408 Lisp_Object map, content, attrib, value; | 1408 Lisp_Object map, content, attrib, value; |
1409 int point, size, map_vector_size; | 1409 int point, size, map_vector_size; |
1410 int map_set_rest_length, fin_ic; | 1410 int map_set_rest_length, fin_ic; |
1477 (op < XUINT (XVECTOR (map)->contents[3]))) | 1477 (op < XUINT (XVECTOR (map)->contents[3]))) |
1478 content = XVECTOR (map)->contents[1]; | 1478 content = XVECTOR (map)->contents[1]; |
1479 else | 1479 else |
1480 continue; | 1480 continue; |
1481 } | 1481 } |
1482 else | 1482 else |
1483 continue; | 1483 continue; |
1484 | 1484 |
1485 if (NILP (content)) | 1485 if (NILP (content)) |
1486 continue; | 1486 continue; |
1487 else if (NUMBERP (content)) | 1487 else if (NUMBERP (content)) |
1573 reg[RRR] = -1; | 1573 reg[RRR] = -1; |
1574 } | 1574 } |
1575 } | 1575 } |
1576 break; | 1576 break; |
1577 #endif | 1577 #endif |
1578 | 1578 |
1579 default: | 1579 default: |
1580 CCL_INVALID_CMD; | 1580 CCL_INVALID_CMD; |
1581 } | 1581 } |
1582 break; | 1582 break; |
1583 | 1583 |
1766 for (i = 0; i < 8; i++) | 1766 for (i = 0; i < 8; i++) |
1767 ccl.reg[i] = (INTP (XVECTOR_DATA (reg)[i]) | 1767 ccl.reg[i] = (INTP (XVECTOR_DATA (reg)[i]) |
1768 ? XINT (XVECTOR_DATA (reg)[i]) | 1768 ? XINT (XVECTOR_DATA (reg)[i]) |
1769 : 0); | 1769 : 0); |
1770 | 1770 |
1771 ccl_driver (&ccl, (CONST unsigned char *)0, (unsigned_char_dynarr *)0, | 1771 ccl_driver (&ccl, (const unsigned char *)0, (unsigned_char_dynarr *)0, |
1772 0, (int *)0, CCL_MODE_ENCODING); | 1772 0, (int *)0, CCL_MODE_ENCODING); |
1773 QUIT; | 1773 QUIT; |
1774 if (ccl.status != CCL_STAT_SUCCESS) | 1774 if (ccl.status != CCL_STAT_SUCCESS) |
1775 error ("Error in CCL program at %dth code", ccl.ic); | 1775 error ("Error in CCL program at %dth code", ccl.ic); |
1776 | 1776 |
1917 A code conversion map consists of numbers, Qt, Qnil, and Qlambda. | 1917 A code conversion map consists of numbers, Qt, Qnil, and Qlambda. |
1918 The first element is start code point. | 1918 The first element is start code point. |
1919 The rest elements are mapped numbers. | 1919 The rest elements are mapped numbers. |
1920 Symbol t means to map to an original number before mapping. | 1920 Symbol t means to map to an original number before mapping. |
1921 Symbol nil means that the corresponding element is empty. | 1921 Symbol nil means that the corresponding element is empty. |
1922 Symbol lambda menas to terminate mapping here. | 1922 Symbol lambda means to terminate mapping here. |
1923 */ | 1923 */ |
1924 | 1924 |
1925 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, | 1925 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, |
1926 Sregister_code_conversion_map, | 1926 Sregister_code_conversion_map, |
1927 2, 2, 0, | 1927 2, 2, 0, |
1934 int i; | 1934 int i; |
1935 Lisp_Object index; | 1935 Lisp_Object index; |
1936 | 1936 |
1937 CHECK_SYMBOL (symbol, 0); | 1937 CHECK_SYMBOL (symbol, 0); |
1938 CHECK_VECTOR (map, 1); | 1938 CHECK_VECTOR (map, 1); |
1939 | 1939 |
1940 for (i = 0; i < len; i++) | 1940 for (i = 0; i < len; i++) |
1941 { | 1941 { |
1942 Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i]; | 1942 Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i]; |
1943 | 1943 |
1944 if (!CONSP (slot)) | 1944 if (!CONSP (slot)) |