annotate src/ccl.c @ 24571:9944f4ca2ee5

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Tue, 06 Apr 1999 19:06:27 +0000
parents 36e004c54eaf
children 7b170d2184a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 /* CCL (Code Conversion Language) interpreter.
18341
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 17828
diff changeset
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 17828
diff changeset
3 Licensed to the Free Software Foundation.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
5 This file is part of GNU Emacs.
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
6
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
8 it under the terms of the GNU General Public License as published by
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
10 any later version.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
15 GNU General Public License for more details.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
17 You should have received a copy of the GNU General Public License
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
20 Boston, MA 02111-1307, USA. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 #include <stdio.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 #include <config.h>
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
27
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
28 #ifdef STDC_HEADERS
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
29 #include <stdlib.h>
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
30 #endif
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
31
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 #include "lisp.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 #include "charset.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 #include "ccl.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 #include "coding.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 #else /* not emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 #include "mulelib.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 #endif /* not emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42
22718
821fecd82623 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 22525
diff changeset
43 /* This contains all code conversion map available to CCL. */
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
44 Lisp_Object Vcode_conversion_map_vector;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
45
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 /* Alist of fontname patterns vs corresponding CCL program. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 Lisp_Object Vfont_ccl_encoder_alist;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
49 /* This symbol is a property which assocates with ccl program vector.
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
50 Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector. */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
51 Lisp_Object Qccl_program;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
52
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
53 /* These symbols are properties which associate with code conversion
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
54 map and their ID respectively. */
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
55 Lisp_Object Qcode_conversion_map;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
56 Lisp_Object Qcode_conversion_map_id;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
57
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
58 /* Symbols of ccl program have this property, a value of the property
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
59 is an index for Vccl_protram_table. */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
60 Lisp_Object Qccl_program_idx;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
61
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 /* Vector of CCL program names vs corresponding program data. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 Lisp_Object Vccl_program_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 /* CCL (Code Conversion Language) is a simple language which has
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 operations on one input buffer, one output buffer, and 7 registers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 The syntax of CCL is described in `ccl.el'. Emacs Lisp function
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 `ccl-compile' compiles a CCL program and produces a CCL code which
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 is a vector of integers. The structure of this vector is as
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 follows: The 1st element: buffer-magnification, a factor for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 size of output buffer compared with the size of input buffer. The
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 2nd element: address of CCL code to be executed when encountered
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 with end of input stream. The 3rd and the remaining elements: CCL
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 /* Header of CCL compiled code */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 #define CCL_HEADER_BUF_MAG 0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 #define CCL_HEADER_EOF 1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 #define CCL_HEADER_MAIN 2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 /* CCL code is a sequence of 28-bit non-negative integers (i.e. the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 MSB is always 0), each contains CCL command and/or arguments in the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 following format:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 |----------------- integer (28-bit) ------------------|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 |--constant argument--|-register-|-register-|-command-|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ccccccccccccccccc RRR rrr XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 or
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 |------- relative address -------|-register-|-command-|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 cccccccccccccccccccc rrr XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 or
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 |------------- constant or other args ----------------|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 cccccccccccccccccccccccccccc
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 where, `cc...c' is a non-negative integer indicating constant value
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (the left most `c' is always 0) or an absolute jump address, `RRR'
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 and `rrr' are CCL register number, `XXXXX' is one of the following
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 CCL commands. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 /* CCL commands
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 Each comment fields shows one or more lines for command syntax and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 the following lines for semantics of the command. In semantics, IC
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 stands for Instruction Counter. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 #define CCL_SetRegister 0x00 /* Set register a register value:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 1:00000000000000000RRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 reg[rrr] = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 #define CCL_SetShortConst 0x01 /* Set register a short constant value:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 reg[rrr] = CCCCCCCCCCCCCCCCCCC;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 #define CCL_SetConst 0x02 /* Set register a constant value:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 1:00000000000000000000rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 2:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 reg[rrr] = CONSTANT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 IC++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 #define CCL_SetArray 0x03 /* Set register an element of array:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 1:CCCCCCCCCCCCCCCCCRRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 2:ELEMENT[0]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 3:ELEMENT[1]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 if (0 <= reg[RRR] < CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 reg[rrr] = ELEMENT[reg[RRR]];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 IC += CC..C;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 #define CCL_Jump 0x04 /* Jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 1:A--D--D--R--E--S--S-000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 /* Note: If CC..C is greater than 0, the second code is omitted. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 #define CCL_JumpCond 0x05 /* Jump conditional:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 if (!reg[rrr])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 #define CCL_WriteRegisterJump 0x06 /* Write register and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 write (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 #define CCL_WriteRegisterReadJump 0x07 /* Write register, read, and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 2:A--D--D--R--E--S--S-rrrYYYYY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 write (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 IC++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 /* Note: If read is suspended, the resumed execution starts from the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 second code (YYYYY == CCL_ReadJump). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 #define CCL_WriteConstJump 0x08 /* Write constant and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 1:A--D--D--R--E--S--S-000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 2:CONST
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 write (CONST);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 2:CONST
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 3:A--D--D--R--E--S--S-rrrYYYYY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 write (CONST);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 IC += 2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 /* Note: If read is suspended, the resumed execution starts from the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 second code (YYYYY == CCL_ReadJump). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 #define CCL_WriteStringJump 0x0A /* Write string and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 1:A--D--D--R--E--S--S-000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 2:LENGTH
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 3:0000STRIN[0]STRIN[1]STRIN[2]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 write_string (STRING, LENGTH);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 2:LENGTH
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 3:ELEMENET[0]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 4:ELEMENET[1]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 N:A--D--D--R--E--S--S-rrrYYYYY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 if (0 <= reg[rrr] < LENGTH)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 write (ELEMENT[reg[rrr]]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 IC += LENGTH + 2; (... pointing at N+1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 /* Note: If read is suspended, the resumed execution starts from the
17323
15fa68d983e7 (ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents: 17122
diff changeset
219 Nth code (YYYYY == CCL_ReadJump). */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 #define CCL_ReadJump 0x0C /* Read and jump:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 1:A--D--D--R--E--S--S-rrrYYYYY
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 #define CCL_Branch 0x0D /* Jump by branch table:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230 2:A--D--D--R--E-S-S[0]000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 3:A--D--D--R--E-S-S[1]000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 if (0 <= reg[rrr] < CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235 IC += ADDRESS[reg[rrr]];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237 IC += ADDRESS[CC..C];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 #define CCL_ReadRegister 0x0E /* Read bytes into registers:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 2:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 while (CCC--)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 #define CCL_WriteExprConst 0x0F /* write result of expression:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 1:00000OPERATION000RRR000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 2:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 write (reg[RRR] OPERATION CONSTANT);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 IC++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 /* Note: If the Nth read is suspended, the resumed execution starts
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 from the Nth code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260 #define CCL_ReadBranch 0x10 /* Read one byte into a register,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 and jump by branch table:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
263 2:A--D--D--R--E-S-S[0]000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 3:A--D--D--R--E-S-S[1]000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267 read (read[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268 if (0 <= reg[rrr] < CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 IC += ADDRESS[reg[rrr]];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 IC += ADDRESS[CC..C];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 #define CCL_WriteRegister 0x11 /* Write registers:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 1:CCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 2:CCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 while (CCC--)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 write (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 /* Note: If the Nth write is suspended, the resumed execution
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 starts from the Nth code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 #define CCL_WriteExprRegister 0x12 /* Write result of expression
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 1:00000OPERATIONRrrRRR000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 write (reg[RRR] OPERATION reg[Rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
293 #define CCL_Call 0x13 /* Call the CCL program whose ID is
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
294 (CC..C).
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 1:CCCCCCCCCCCCCCCCCCCC000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 call (CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 #define CCL_WriteConstString 0x14 /* Write a constant or a string:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 [2:0000STRIN[0]STRIN[1]STRIN[2]]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 [...]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 if (!rrr)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 write (CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 write_string (STRING, CC..C);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 IC += (CC..C + 2) / 3;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 #define CCL_WriteArray 0x15 /* Write an element of array:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 2:ELEMENT[0]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 3:ELEMENT[1]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 ...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 if (0 <= reg[rrr] < CC..C)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 write (ELEMENT[reg[rrr]]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 IC += CC..C;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 #define CCL_End 0x16 /* Terminate:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 1:00000000000000000000000XXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 terminate ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 /* The following two codes execute an assignment arithmetic/logical
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 operation. The form of the operation is like REG OP= OPERAND. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 #define CCL_ExprSelfConst 0x17 /* REG OP= constant:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 1:00000OPERATION000000rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 2:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 reg[rrr] OPERATION= CONSTANT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 #define CCL_ExprSelfReg 0x18 /* REG1 OP= REG2:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 1:00000OPERATION000RRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 reg[rrr] OPERATION= reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 /* The following codes execute an arithmetic/logical operation. The
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 form of the operation is like REG_X = REG_Y OP OPERAND2. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 #define CCL_SetExprConst 0x19 /* REG_X = REG_Y OP constant:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 1:00000OPERATION000RRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 2:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 reg[rrr] = reg[RRR] OPERATION CONSTANT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 IC++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 #define CCL_SetExprReg 0x1A /* REG1 = REG2 OP REG3:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 1:00000OPERATIONRrrRRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 reg[rrr] = reg[RRR] OPERATION reg[Rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 #define CCL_JumpCondExprConst 0x1B /* Jump conditional according to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 an operation on constant:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 2:OPERATION
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 3:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 reg[7] = reg[rrr] OPERATION CONSTANT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 if (!(reg[7]))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 IC += 2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 #define CCL_JumpCondExprReg 0x1C /* Jump conditional according to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 an operation on register:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 2:OPERATION
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 3:RRR
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 reg[7] = reg[rrr] OPERATION reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 if (!reg[7])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 IC += 2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 #define CCL_ReadJumpCondExprConst 0x1D /* Read and jump conditional according
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 to an operation on constant:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 2:OPERATION
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 3:CONSTANT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 reg[7] = reg[rrr] OPERATION CONSTANT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 if (!reg[7])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 IC += 2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 #define CCL_ReadJumpCondExprReg 0x1E /* Read and jump conditional according
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 to an operation on register:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 1:A--D--D--R--E--S--S-rrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 2:OPERATION
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 3:RRR
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 -----------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408 read (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 reg[7] = reg[rrr] OPERATION reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 if (!reg[7])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 IC += ADDRESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 IC += 2;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 #define CCL_Extention 0x1F /* Extended CCL code
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 1:ExtendedCOMMNDRrrRRRrrrXXXXX
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 2:ARGUEMENT
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 3:...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 ------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 extended_command (rrr,RRR,Rrr,ARGS)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
424 /*
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
425 Here after, Extended CCL Instructions.
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
426 Bit length of extended command is 14.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
427 Therefore, the instruction code range is 0..16384(0x3fff).
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
428 */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
429
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
430 /* Read a multibyte characeter.
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
431 A code point is stored into reg[rrr]. A charset ID is stored into
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
432 reg[RRR]. */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
433
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
434 #define CCL_ReadMultibyteChar2 0x00 /* Read Multibyte Character
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
435 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
436
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
437 /* Write a multibyte character.
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
438 Write a character whose code point is reg[rrr] and the charset ID
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
439 is reg[RRR]. */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
440
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
441 #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
442 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
443
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
444 /* Translate a character whose code point is reg[rrr] and the charset
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22122
diff changeset
445 ID is reg[RRR] by a translation table whose ID is reg[Rrr].
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
446
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
447 A translated character is set in reg[rrr] (code point) and reg[RRR]
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
448 (charset ID). */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
449
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
450 #define CCL_TranslateCharacter 0x02 /* Translate a multibyte character
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
451 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
452
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
453 /* Translate a character whose code point is reg[rrr] and the charset
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22122
diff changeset
454 ID is reg[RRR] by a translation table whose ID is ARGUMENT.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
455
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
456 A translated character is set in reg[rrr] (code point) and reg[RRR]
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
457 (charset ID). */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
458
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
459 #define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
460 1:ExtendedCOMMNDRrrRRRrrrXXXXX
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
461 2:ARGUMENT(Translation Table ID)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
462 */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
463
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
464 /* Iterate looking up MAPs for reg[rrr] starting from the Nth (N =
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
465 reg[RRR]) MAP until some value is found.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
466
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
467 Each MAP is a Lisp vector whose element is number, nil, t, or
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
468 lambda.
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
469 If the element is nil, ignore the map and proceed to the next map.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
470 If the element is t or lambda, finish without changing reg[rrr].
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
471 If the element is a number, set reg[rrr] to the number and finish.
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
472
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
473 Detail of the map structure is descibed in the comment for
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
474 CCL_MapMultiple below. */
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
475
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
476 #define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
477 1:ExtendedCOMMNDXXXRRRrrrXXXXX
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
478 2:NUMBER of MAPs
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
479 3:MAP-ID1
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
480 4:MAP-ID2
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
481 ...
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
482 */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
483
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
484 /* Map the code in reg[rrr] by MAPs starting from the Nth (N =
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
485 reg[RRR]) map.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
486
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
487 MAPs are supplied in the succeeding CCL codes as follows:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
488
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
489 When CCL program gives this nested structure of map to this command:
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
490 ((MAP-ID11
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
491 MAP-ID12
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
492 (MAP-ID121 MAP-ID122 MAP-ID123)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
493 MAP-ID13)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
494 (MAP-ID21
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
495 (MAP-ID211 (MAP-ID2111) MAP-ID212)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
496 MAP-ID22)),
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
497 the compiled CCL codes has this sequence:
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
498 CCL_MapMultiple (CCL code of this command)
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
499 16 (total number of MAPs and SEPARATORs)
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
500 -7 (1st SEPARATOR)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
501 MAP-ID11
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
502 MAP-ID12
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
503 -3 (2nd SEPARATOR)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
504 MAP-ID121
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
505 MAP-ID122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
506 MAP-ID123
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
507 MAP-ID13
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
508 -7 (3rd SEPARATOR)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
509 MAP-ID21
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
510 -4 (4th SEPARATOR)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
511 MAP-ID211
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
512 -1 (5th SEPARATOR)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
513 MAP_ID2111
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
514 MAP-ID212
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
515 MAP-ID22
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
516
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
517 A value of each SEPARATOR follows this rule:
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
518 MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
519 SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET)
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
520
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
521 (*)....Nest level of MAP-SET must not be over than MAX_MAP_SET_LEVEL.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
522
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
523 When some map fails to map (i.e. it doesn't have a value for
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
524 reg[rrr]), the mapping is treated as identity.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
525
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
526 The mapping is iterated for all maps in each map set (set of maps
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
527 separated by SEPARATOR) except in the case that lambda is
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
528 encountered. More precisely, the mapping proceeds as below:
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
529
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
530 At first, VAL0 is set to reg[rrr], and it is translated by the
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
531 first map to VAL1. Then, VAL1 is translated by the next map to
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
532 VAL2. This mapping is iterated until the last map is used. The
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
533 result of the mapping is the last value of VAL?.
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
534
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
535 But, when VALm is mapped to VALn and VALn is not a number, the
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
536 mapping proceed as below:
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
537
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
538 If VALn is nil, the lastest map is ignored and the mapping of VALm
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
539 proceed to the next map.
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
540
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
541 In VALn is t, VALm is reverted to reg[rrr] and the mapping of VALm
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
542 proceed to the next map.
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
543
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
544 If VALn is lambda, the whole mapping process terminates, and VALm
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
545 is the result of this mapping.
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
546
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
547 Each map is a Lisp vector of the following format (a) or (b):
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
548 (a)......[STARTPOINT VAL1 VAL2 ...]
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
549 (b)......[t VAL STARTPOINT ENDPOINT],
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
550 where
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
551 STARTPOINT is an offset to be used for indexing a map,
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
552 ENDPOINT is a maximum index number of a map,
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
553 VAL and VALn is a number, nil, t, or lambda.
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
554
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
555 Valid index range of a map of type (a) is:
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
556 STARTPOINT <= index < STARTPOINT + map_size - 1
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
557 Valid index range of a map of type (b) is:
22525
3dade37fd85d Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents: 22186
diff changeset
558 STARTPOINT <= index < ENDPOINT */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
559
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
560 #define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
561 1:ExtendedCOMMNDXXXRRRrrrXXXXX
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
562 2:N-2
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
563 3:SEPARATOR_1 (< 0)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
564 4:MAP-ID_1
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
565 5:MAP-ID_2
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
566 ...
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
567 M:SEPARATOR_x (< 0)
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
568 M+1:MAP-ID_y
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
569 ...
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
570 N:SEPARATOR_z (< 0)
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
571 */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
572
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
573 #define MAX_MAP_SET_LEVEL 20
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
574
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
575 typedef struct
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
576 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
577 int rest_length;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
578 int orig_val;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
579 } tr_stack;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
580
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
581 static tr_stack mapping_stack[MAX_MAP_SET_LEVEL];
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
582 static tr_stack *mapping_stack_pointer;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
583
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
584 #define PUSH_MAPPING_STACK(restlen, orig) \
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
585 { \
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
586 mapping_stack_pointer->rest_length = (restlen); \
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
587 mapping_stack_pointer->orig_val = (orig); \
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
588 mapping_stack_pointer++; \
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
589 }
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
590
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
591 #define POP_MAPPING_STACK(restlen, orig) \
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
592 { \
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
593 mapping_stack_pointer--; \
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
594 (restlen) = mapping_stack_pointer->rest_length; \
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
595 (orig) = mapping_stack_pointer->orig_val; \
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
596 } \
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
597
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
598 #define CCL_MapSingle 0x12 /* Map by single code conversion map
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
599 1:ExtendedCOMMNDXXXRRRrrrXXXXX
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
600 2:MAP-ID
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
601 ------------------------------
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
602 Map reg[rrr] by MAP-ID.
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
603 If some valid mapping is found,
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
604 set reg[rrr] to the result,
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
605 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
606 set reg[RRR] to -1.
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
607 */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 /* CCL arithmetic/logical operators. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 #define CCL_PLUS 0x00 /* X = Y + Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 #define CCL_MINUS 0x01 /* X = Y - Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 #define CCL_MUL 0x02 /* X = Y * Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 #define CCL_DIV 0x03 /* X = Y / Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 #define CCL_MOD 0x04 /* X = Y % Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 #define CCL_AND 0x05 /* X = Y & Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 #define CCL_OR 0x06 /* X = Y | Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 #define CCL_XOR 0x07 /* X = Y ^ Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 #define CCL_LSH 0x08 /* X = Y << Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 #define CCL_RSH 0x09 /* X = Y >> Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620 #define CCL_LSH8 0x0A /* X = (Y << 8) | Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 #define CCL_RSH8 0x0B /* X = Y >> 8, r[7] = Y & 0xFF */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 #define CCL_DIVMOD 0x0C /* X = Y / Z, r[7] = Y % Z */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 #define CCL_LS 0x10 /* X = (X < Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 #define CCL_GT 0x11 /* X = (X > Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 #define CCL_EQ 0x12 /* X = (X == Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 #define CCL_LE 0x13 /* X = (X <= Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 #define CCL_GE 0x14 /* X = (X >= Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 #define CCL_NE 0x15 /* X = (X != Y) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629
23428
49c7e979c16c (CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents: 23303
diff changeset
630 #define CCL_DECODE_SJIS 0x16 /* X = HIGHER_BYTE (DE-SJIS (Y, Z))
49c7e979c16c (CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents: 23303
diff changeset
631 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */
49c7e979c16c (CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents: 23303
diff changeset
632 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 r[7] = LOWER_BYTE (SJIS (Y, Z) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 /* Terminate CCL program successfully. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 #define CCL_SUCCESS \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 do { \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 ccl->status = CCL_STAT_SUCCESS; \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639 goto ccl_finish; \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 /* Suspend CCL program because of reading from empty input buffer or
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 writing to full output buffer. When this program is resumed, the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 same I/O command is executed. */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
645 #define CCL_SUSPEND(stat) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
646 do { \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
647 ic--; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
648 ccl->status = stat; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
649 goto ccl_finish; \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 /* Terminate CCL program because of invalid command. Should not occur
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 in the normal case. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 #define CCL_INVALID_CMD \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 do { \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 ccl->status = CCL_STAT_INVALID_CMD; \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 goto ccl_error_handler; \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 /* Encode one character CH to multibyte form and write to the current
17323
15fa68d983e7 (ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents: 17122
diff changeset
661 output buffer. If CH is less than 256, CH is written as is. */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
662 #define CCL_WRITE_CHAR(ch) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
663 do { \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
664 if (!dst) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
665 CCL_INVALID_CMD; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
666 else \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
667 { \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
668 unsigned char work[4], *str; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
669 int len = CHAR_STRING (ch, work, str); \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
670 if (dst + len <= (dst_bytes ? dst_end : src)) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
671 { \
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
672 while (len--) *dst++ = *str++; \
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
673 } \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
674 else \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
675 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
676 } \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 /* Write a string at ccl_prog[IC] of length LEN to the current output
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 buffer. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 #define CCL_WRITE_STRING(len) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 do { \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 if (!dst) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 CCL_INVALID_CMD; \
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
685 else if (dst + len <= (dst_bytes ? dst_end : src)) \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 for (i = 0; i < len; i++) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 *dst++ = ((XFASTINT (ccl_prog[ic + (i / 3)])) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 >> ((2 - (i % 3)) * 8)) & 0xFF; \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 else \
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
690 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 /* Read one byte from the current input buffer into Rth register. */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
694 #define CCL_READ_CHAR(r) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
695 do { \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
696 if (!src) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
697 CCL_INVALID_CMD; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
698 else if (src < src_end) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
699 r = *src++; \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
700 else if (ccl->last_block) \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
701 { \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
702 ic = ccl->eof_ic; \
23068
ae33b925b20f If eof is encounterd while processing the
Kenichi Handa <handa@m17n.org>
parents: 22718
diff changeset
703 goto ccl_repeat; \
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
704 } \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
705 else \
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
706 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 text goes to a place pointed by DESTINATION, the length of which
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 should not exceed DST_BYTES. The bytes actually processed is
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 returned as *CONSUMED. The return value is the length of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 resulting text. As a side effect, the contents of CCL registers
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 are updated. If SOURCE or DESTINATION is NULL, only operations on
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 registers are permitted. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 #ifdef CCL_DEBUG
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
719 #define CCL_DEBUG_BACKTRACE_LEN 256
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
720 int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721 int ccl_backtrace_idx;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 #endif
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724 struct ccl_prog_stack
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 {
17828
db443ea8cb36 (struct ccl_prog_stack): Declear the member ccl_prog as
Kenichi Handa <handa@m17n.org>
parents: 17728
diff changeset
726 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 int ic; /* Instruction Counter. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728 };
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
730 int
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731 ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732 struct ccl_program *ccl;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 unsigned char *source, *destination;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 int src_bytes, dst_bytes;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
735 int *consumed;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 register int *reg = ccl->reg;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
738 register int ic = ccl->ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739 register int code, field1, field2;
17370
6db43d8c9dfc (ccl_driver): Fix Lisp_Object/integer confusion.
Karl Heuer <kwzh@gnu.org>
parents: 17323
diff changeset
740 register Lisp_Object *ccl_prog = ccl->prog;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 unsigned char *src = source, *src_end = src + src_bytes;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 unsigned char *dst = destination, *dst_end = dst + dst_bytes;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 int jump_address;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 int i, j, op;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 int stack_idx = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 /* For the moment, we only support depth 256 of stack. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 struct ccl_prog_stack ccl_prog_stack_struct[256];
23303
fb38954a02d3 (ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents: 23280
diff changeset
748 /* Instruction counter of the current CCL code. */
fb38954a02d3 (ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents: 23280
diff changeset
749 int this_ic;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 if (ic >= ccl->eof_ic)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 ic = CCL_HEADER_MAIN;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
754 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
755 dst = NULL;
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
756
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 #ifdef CCL_DEBUG
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 ccl_backtrace_idx = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 #endif
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 for (;;)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 {
23068
ae33b925b20f If eof is encounterd while processing the
Kenichi Handa <handa@m17n.org>
parents: 22718
diff changeset
763 ccl_repeat:
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764 #ifdef CCL_DEBUG
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 ccl_backtrace_table[ccl_backtrace_idx++] = ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
767 ccl_backtrace_idx = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
768 ccl_backtrace_table[ccl_backtrace_idx] = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 #endif
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773 /* We can't just signal Qquit, instead break the loop as if
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 the whole data is processed. Don't reset Vquit_flag, it
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 must be handled later at a safer place. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
776 if (consumed)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 src = source + src_bytes;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778 ccl->status = CCL_STAT_QUIT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
781
23303
fb38954a02d3 (ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents: 23280
diff changeset
782 this_ic = ic;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
783 code = XINT (ccl_prog[ic]); ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 field1 = code >> 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 field2 = (code & 0xFF) >> 5;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787 #define rrr field2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788 #define RRR (field1 & 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 #define Rrr ((field1 >> 3) & 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790 #define ADDR field1
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
791 #define EXCMD (field1 >> 6)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
792
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793 switch (code & 0x1F)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 case CCL_SetRegister: /* 00000000000000000RRRrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 reg[rrr] = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 reg[rrr] = field1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
802
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
804 reg[rrr] = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
807
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 j = field1 >> 3;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
811 if ((unsigned int) i < j)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
812 reg[rrr] = XINT (ccl_prog[ic + i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
813 ic += j;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
814 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
815
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
816 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 ic += ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821 if (!reg[rrr])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 ic += ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
826 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828 ic += ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
830
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831 case CCL_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836 ic += ADDR - 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 i = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 ic += ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
844
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
845 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 i = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 ic += ADDR - 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854 j = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 CCL_WRITE_STRING (j);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857 ic += ADDR - 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 i = reg[rrr];
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
862 j = XINT (ccl_prog[ic]);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863 if ((unsigned int) i < j)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864 {
17323
15fa68d983e7 (ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents: 17122
diff changeset
865 i = XINT (ccl_prog[ic + 1 + i]);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 }
17323
15fa68d983e7 (ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents: 17122
diff changeset
868 ic += j + 2;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
870 ic += ADDR - (j + 2);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
871 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
872
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
873 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
874 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
875 ic += ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
876 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
877
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
878 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
879 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
880 /* fall through ... */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
881 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
882 if ((unsigned int) reg[rrr] < field1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
883 ic += XINT (ccl_prog[ic + reg[rrr]]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
884 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
885 ic += XINT (ccl_prog[ic + field1]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
886 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
889 while (1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
890 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
891 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 if (!field1) break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893 code = XINT (ccl_prog[ic]); ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894 field1 = code >> 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895 field2 = (code & 0xFF) >> 5;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
897 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
899 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
900 rrr = 7;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
901 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
902 j = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
903 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
904 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
905 goto ccl_set_expr;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
906
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
907 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
908 while (1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
909 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
910 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
911 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912 if (!field1) break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
913 code = XINT (ccl_prog[ic]); ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
914 field1 = code >> 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
915 field2 = (code & 0xFF) >> 5;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
916 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
919 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920 rrr = 7;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
921 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 j = reg[Rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
924 goto ccl_set_expr;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
925
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 case CCL_Call: /* CCCCCCCCCCCCCCCCCCCC000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 Lisp_Object slot;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 if (stack_idx >= 256
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 || field1 < 0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 || field1 >= XVECTOR (Vccl_program_table)->size
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 || (slot = XVECTOR (Vccl_program_table)->contents[field1],
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 !CONSP (slot))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 || !VECTORP (XCONS (slot)->cdr))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 if (stack_idx > 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 ic = ccl_prog_stack_struct[0].ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 CCL_INVALID_CMD;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
945 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946 ccl_prog_stack_struct[stack_idx].ic = ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
947 stack_idx++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 ccl_prog = XVECTOR (XCONS (slot)->cdr)->contents;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
949 ic = CCL_HEADER_MAIN;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
950 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
951 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
954 if (!rrr)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 CCL_WRITE_CHAR (field1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 CCL_WRITE_STRING (field1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 ic += (field1 + 2) / 3;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
960 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
965 if ((unsigned int) i < field1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 j = XINT (ccl_prog[ic + i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968 CCL_WRITE_CHAR (j);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
969 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
970 ic += field1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
971 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
972
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
973 case CCL_End: /* 0000000000000000000000XXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
974 if (stack_idx-- > 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
975 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
976 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
977 ic = ccl_prog_stack_struct[stack_idx].ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 }
23884
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
980 if (src)
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
981 src = src_end;
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
982 /* ccl->ic should points to this command code again to
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
983 suppress further processing. */
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
984 ic--;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
985 CCL_SUCCESS;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
987 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
988 i = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
989 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
990 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
991 goto ccl_expr_self;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
992
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
993 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
994 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
995 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
996
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
997 ccl_expr_self:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
998 switch (op)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1000 case CCL_PLUS: reg[rrr] += i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 case CCL_MINUS: reg[rrr] -= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1002 case CCL_MUL: reg[rrr] *= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 case CCL_DIV: reg[rrr] /= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 case CCL_MOD: reg[rrr] %= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1005 case CCL_AND: reg[rrr] &= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006 case CCL_OR: reg[rrr] |= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007 case CCL_XOR: reg[rrr] ^= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 case CCL_LSH: reg[rrr] <<= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 case CCL_RSH: reg[rrr] >>= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1010 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1011 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1013 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1014 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1015 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1016 case CCL_LE: reg[rrr] = reg[rrr] <= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1017 case CCL_GE: reg[rrr] = reg[rrr] >= i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 case CCL_NE: reg[rrr] = reg[rrr] != i; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1019 default: CCL_INVALID_CMD;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1020 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1021 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1022
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025 j = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1026 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1027 jump_address = ++ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1028 goto ccl_set_expr;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1030 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1031 i = reg[RRR];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1032 j = reg[Rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033 op = field1 >> 6;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1034 jump_address = ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1035 goto ccl_set_expr;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1036
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1037 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1038 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1039 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1040 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1041 op = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1042 jump_address = ic++ + ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1043 j = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1044 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1045 rrr = 7;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1046 goto ccl_set_expr;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049 CCL_READ_CHAR (reg[rrr]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1050 case CCL_JumpCondExprReg:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1051 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1052 op = XINT (ccl_prog[ic]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1053 jump_address = ic++ + ADDR;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1054 j = reg[XINT (ccl_prog[ic])];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1055 ic++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1056 rrr = 7;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1057
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1058 ccl_set_expr:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1059 switch (op)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1061 case CCL_PLUS: reg[rrr] = i + j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 case CCL_MINUS: reg[rrr] = i - j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1063 case CCL_MUL: reg[rrr] = i * j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1064 case CCL_DIV: reg[rrr] = i / j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1065 case CCL_MOD: reg[rrr] = i % j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1066 case CCL_AND: reg[rrr] = i & j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1067 case CCL_OR: reg[rrr] = i | j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 case CCL_XOR: reg[rrr] = i ^ j;; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1069 case CCL_LSH: reg[rrr] = i << j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070 case CCL_RSH: reg[rrr] = i >> j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 case CCL_LSH8: reg[rrr] = (i << 8) | j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 case CCL_LS: reg[rrr] = i < j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 case CCL_GT: reg[rrr] = i > j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 case CCL_EQ: reg[rrr] = i == j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 case CCL_LE: reg[rrr] = i <= j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1078 case CCL_GE: reg[rrr] = i >= j; break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079 case CCL_NE: reg[rrr] = i != j; break;
23428
49c7e979c16c (CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents: 23303
diff changeset
1080 case CCL_DECODE_SJIS: DECODE_SJIS (i, j, reg[rrr], reg[7]); break;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081 case CCL_ENCODE_SJIS: ENCODE_SJIS (i, j, reg[rrr], reg[7]); break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 default: CCL_INVALID_CMD;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1083 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1084 code &= 0x1F;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1085 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1086 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1087 i = reg[rrr];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1088 CCL_WRITE_CHAR (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1089 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1090 else if (!reg[rrr])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 ic = jump_address;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1093
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1094 case CCL_Extention:
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1095 switch (EXCMD)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1096 {
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1097 case CCL_ReadMultibyteChar2:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1098 if (!src)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1099 CCL_INVALID_CMD;
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1100
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1101 do {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1102 if (src >= src_end)
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1103 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1104 src++;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1105 goto ccl_read_multibyte_character_suspend;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1106 }
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1107
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1108 i = *src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1109 if (i == LEADING_CODE_COMPOSITION)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1110 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1111 if (src >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1112 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1113 if (*src == 0xFF)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1114 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1115 ccl->private_state = COMPOSING_WITH_RULE_HEAD;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1116 src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1117 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1118 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1119 ccl->private_state = COMPOSING_NO_RULE_HEAD;
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1120
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1121 continue;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1122 }
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1123 if (ccl->private_state != COMPOSING_NO)
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1124 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1125 /* composite character */
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1126 if (i < 0xA0)
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1127 ccl->private_state = COMPOSING_NO;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1128 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1129 {
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1130 if (COMPOSING_WITH_RULE_RULE == ccl->private_state)
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1131 {
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1132 ccl->private_state = COMPOSING_WITH_RULE_HEAD;
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1133 continue;
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1134 }
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1135 else if (COMPOSING_WITH_RULE_HEAD == ccl->private_state)
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1136 ccl->private_state = COMPOSING_WITH_RULE_RULE;
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1137
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1138 if (i == 0xA0)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1139 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1140 if (src >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1141 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1142 i = *src++ & 0x7F;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1143 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1144 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1145 i -= 0x20;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1146 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1147 }
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1148
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1149 if (i < 0x80)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1150 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1151 /* ASCII */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1152 reg[rrr] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1153 reg[RRR] = CHARSET_ASCII;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1154 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1155 else if (i <= MAX_CHARSET_OFFICIAL_DIMENSION1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1156 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1157 if (src >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1158 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1159 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1160 reg[rrr] = (*src++ & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1161 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1162 else if (i <= MAX_CHARSET_OFFICIAL_DIMENSION2)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1163 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1164 if ((src + 1) >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1165 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1166 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1167 i = (*src++ & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1168 reg[rrr] = ((i << 7) | (*src & 0x7F));
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1169 src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1170 }
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1171 else if ((i == LEADING_CODE_PRIVATE_11)
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1172 || (i == LEADING_CODE_PRIVATE_12))
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1173 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1174 if ((src + 1) >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1175 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1176 reg[RRR] = *src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1177 reg[rrr] = (*src++ & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1178 }
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1179 else if ((i == LEADING_CODE_PRIVATE_21)
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1180 || (i == LEADING_CODE_PRIVATE_22))
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1181 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1182 if ((src + 2) >= src_end)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1183 goto ccl_read_multibyte_character_suspend;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1184 reg[RRR] = *src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1185 i = (*src++ & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1186 reg[rrr] = ((i << 7) | (*src & 0x7F));
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1187 src++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1188 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1189 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1190 {
23884
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1191 /* INVALID CODE. Return a single byte character. */
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1192 reg[RRR] = CHARSET_ASCII;
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1193 reg[rrr] = i;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1194 }
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1195 break;
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1196 } while (1);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1197 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1198
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1199 ccl_read_multibyte_character_suspend:
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1200 src--;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1201 if (ccl->last_block)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1202 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1203 ic = ccl->eof_ic;
23072
9edc07f08118 (ccl_driver): In case
Kenichi Handa <handa@m17n.org>
parents: 23068
diff changeset
1204 goto ccl_repeat;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1205 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1206 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1207 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1208
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1209 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1210
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1211 case CCL_WriteMultibyteChar2:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1212 i = reg[RRR]; /* charset */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1213 if (i == CHARSET_ASCII)
24567
36e004c54eaf (ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents: 23884
diff changeset
1214 i = reg[rrr] & 0x8F;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1215 else if (i == CHARSET_COMPOSITION)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1216 i = MAKE_COMPOSITE_CHAR (reg[rrr]);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1217 else if (CHARSET_DIMENSION (i) == 1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1218 i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1219 else if (i < MIN_CHARSET_PRIVATE_DIMENSION2)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1220 i = ((i - 0x8F) << 14) | reg[rrr];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1221 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1222 i = ((i - 0xE0) << 14) | reg[rrr];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1223
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1224 CCL_WRITE_CHAR (i);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1225
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1226 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1227
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1228 case CCL_TranslateCharacter:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1229 i = reg[RRR]; /* charset */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1230 if (i == CHARSET_ASCII)
23768
3d079e8b2edb (ccl_driver) <CCL_TranslateCharacter>: Don't suppress MSB
Kenichi Handa <handa@m17n.org>
parents: 23428
diff changeset
1231 i = reg[rrr];
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1232 else if (i == CHARSET_COMPOSITION)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1233 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1234 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1235 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1236 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1237 else if (CHARSET_DIMENSION (i) == 1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1238 i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1239 else if (i < MIN_CHARSET_PRIVATE_DIMENSION2)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1240 i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1241 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1242 i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1243
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1244 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]),
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1245 i, -1, 0, 0);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1246 SPLIT_CHAR (op, reg[RRR], i, j);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1247 if (j != -1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1248 i = (i << 7) | j;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1249
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1250 reg[rrr] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1251 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1252
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1253 case CCL_TranslateCharacterConstTbl:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1254 op = XINT (ccl_prog[ic]); /* table */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1255 ic++;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1256 i = reg[RRR]; /* charset */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1257 if (i == CHARSET_ASCII)
23768
3d079e8b2edb (ccl_driver) <CCL_TranslateCharacter>: Don't suppress MSB
Kenichi Handa <handa@m17n.org>
parents: 23428
diff changeset
1258 i = reg[rrr];
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1259 else if (i == CHARSET_COMPOSITION)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1260 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1261 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1262 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1263 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1264 else if (CHARSET_DIMENSION (i) == 1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1265 i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1266 else if (i < MIN_CHARSET_PRIVATE_DIMENSION2)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1267 i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1268 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1269 i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1270
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1271 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1272 SPLIT_CHAR (op, reg[RRR], i, j);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1273 if (j != -1)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1274 i = (i << 7) | j;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1275
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1276 reg[rrr] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1277 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1278
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1279 case CCL_IterateMultipleMap:
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1280 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1281 Lisp_Object map, content, attrib, value;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1282 int point, size, fin_ic;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1283
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1284 j = XINT (ccl_prog[ic++]); /* number of maps. */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1285 fin_ic = ic + j;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1286 op = reg[rrr];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1287 if ((j > reg[RRR]) && (j >= 0))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1288 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1289 ic += reg[RRR];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1290 i = reg[RRR];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1291 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1292 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1293 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1294 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1295 ic = fin_ic;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1296 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1297 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1298
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1299 for (;i < j;i++)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1300 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1301
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1302 size = XVECTOR (Vcode_conversion_map_vector)->size;
21518
1b0d88d6fb42 (ccl_driver, syms_of_ccl): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents: 21514
diff changeset
1303 point = XINT (ccl_prog[ic++]);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1304 if (point >= size) continue;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1305 map =
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1306 XVECTOR (Vcode_conversion_map_vector)->contents[point];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1307
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1308 /* Check map varidity. */
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1309 if (!CONSP (map)) continue;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1310 map = XCONS(map)->cdr;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1311 if (!VECTORP (map)) continue;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1312 size = XVECTOR (map)->size;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1313 if (size <= 1) continue;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1314
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1315 content = XVECTOR (map)->contents[0];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1316
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1317 /* check map type,
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1318 [STARTPOINT VAL1 VAL2 ...] or
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1319 [t ELELMENT STARTPOINT ENDPOINT] */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1320 if (NUMBERP (content))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1321 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1322 point = XUINT (content);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1323 point = op - point + 1;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1324 if (!((point >= 1) && (point < size))) continue;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1325 content = XVECTOR (map)->contents[point];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1326 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1327 else if (EQ (content, Qt))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1328 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1329 if (size != 4) continue;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1330 if ((op >= XUINT (XVECTOR (map)->contents[2]))
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1331 && (op < XUINT (XVECTOR (map)->contents[3])))
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1332 content = XVECTOR (map)->contents[1];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1333 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1334 continue;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1335 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1336 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1337 continue;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1338
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1339 if (NILP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1340 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1341 else if (NUMBERP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1342 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1343 reg[RRR] = i;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1344 reg[rrr] = XINT(content);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1345 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1346 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1347 else if (EQ (content, Qt) || EQ (content, Qlambda))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1348 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1349 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1350 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1351 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1352 else if (CONSP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1353 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1354 attrib = XCONS (content)->car;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1355 value = XCONS (content)->cdr;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1356 if (!NUMBERP (attrib) || !NUMBERP (value))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1357 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1358 reg[RRR] = i;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1359 reg[rrr] = XUINT (value);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1360 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1361 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1362 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1363 if (i == j)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1364 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1365 ic = fin_ic;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1366 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1367 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1368
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1369 case CCL_MapMultiple:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1370 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1371 Lisp_Object map, content, attrib, value;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1372 int point, size, map_vector_size;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1373 int map_set_rest_length, fin_ic;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1374
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1375 map_set_rest_length =
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1376 XINT (ccl_prog[ic++]); /* number of maps and separators. */
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1377 fin_ic = ic + map_set_rest_length;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1378 if ((map_set_rest_length > reg[RRR]) && (reg[RRR] >= 0))
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1379 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1380 ic += reg[RRR];
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1381 i = reg[RRR];
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1382 map_set_rest_length -= i;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1383 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1384 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1385 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1386 ic = fin_ic;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1387 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1388 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1389 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1390 mapping_stack_pointer = mapping_stack;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1391 op = reg[rrr];
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1392 PUSH_MAPPING_STACK (0, op);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1393 reg[RRR] = -1;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1394 map_vector_size = XVECTOR (Vcode_conversion_map_vector)->size;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1395 for (;map_set_rest_length > 0;i++, map_set_rest_length--)
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1396 {
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1397 point = XINT(ccl_prog[ic++]);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1398 if (point < 0)
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1399 {
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1400 point = -point;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1401 if (mapping_stack_pointer
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1402 >= &mapping_stack[MAX_MAP_SET_LEVEL])
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1403 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1404 CCL_INVALID_CMD;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1405 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1406 PUSH_MAPPING_STACK (map_set_rest_length - point,
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1407 reg[rrr]);
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1408 map_set_rest_length = point + 1;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1409 reg[rrr] = op;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1410 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1411 }
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1412
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1413 if (point >= map_vector_size) continue;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1414 map = (XVECTOR (Vcode_conversion_map_vector)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1415 ->contents[point]);
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1416
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1417 /* Check map varidity. */
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1418 if (!CONSP (map)) continue;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1419 map = XCONS (map)->cdr;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1420 if (!VECTORP (map)) continue;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1421 size = XVECTOR (map)->size;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1422 if (size <= 1) continue;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1423
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1424 content = XVECTOR (map)->contents[0];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1425
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1426 /* check map type,
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1427 [STARTPOINT VAL1 VAL2 ...] or
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1428 [t ELEMENT STARTPOINT ENDPOINT] */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1429 if (NUMBERP (content))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1430 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1431 point = XUINT (content);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1432 point = op - point + 1;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1433 if (!((point >= 1) && (point < size))) continue;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1434 content = XVECTOR (map)->contents[point];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1435 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1436 else if (EQ (content, Qt))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1437 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1438 if (size != 4) continue;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1439 if ((op >= XUINT (XVECTOR (map)->contents[2])) &&
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1440 (op < XUINT (XVECTOR (map)->contents[3])))
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1441 content = XVECTOR (map)->contents[1];
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1442 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1443 continue;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1444 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1445 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1446 continue;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1447
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1448 if (NILP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1449 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1450 else if (NUMBERP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1451 {
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1452 op = XINT (content);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1453 reg[RRR] = i;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1454 i += map_set_rest_length;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1455 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1456 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1457 else if (CONSP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1458 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1459 attrib = XCONS (content)->car;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1460 value = XCONS (content)->cdr;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1461 if (!NUMBERP (attrib) || !NUMBERP (value))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1462 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1463 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1464 op = XUINT (value);
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1465 i += map_set_rest_length;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1466 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1467 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1468 else if (EQ (content, Qt))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1469 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1470 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1471 op = reg[rrr];
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1472 i += map_set_rest_length;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1473 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1474 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1475 else if (EQ (content, Qlambda))
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1476 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1477 break;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1478 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1479 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1480 CCL_INVALID_CMD;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1481 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1482 ic = fin_ic;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1483 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1484 reg[rrr] = op;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1485 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1486
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1487 case CCL_MapSingle:
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1488 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1489 Lisp_Object map, attrib, value, content;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1490 int size, point;
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1491 j = XINT (ccl_prog[ic++]); /* map_id */
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1492 op = reg[rrr];
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1493 if (j >= XVECTOR (Vcode_conversion_map_vector)->size)
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1494 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1495 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1496 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1497 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1498 map = XVECTOR (Vcode_conversion_map_vector)->contents[j];
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1499 if (!CONSP (map))
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1500 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1501 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1502 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1503 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1504 map = XCONS(map)->cdr;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1505 if (!VECTORP (map))
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1506 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1507 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1508 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1509 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1510 size = XVECTOR (map)->size;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1511 point = XUINT (XVECTOR (map)->contents[0]);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1512 point = op - point + 1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1513 reg[RRR] = 0;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1514 if ((size <= 1) ||
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1515 (!((point >= 1) && (point < size))))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1516 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1517 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1518 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1519 content = XVECTOR (map)->contents[point];
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1520 if (NILP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1521 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1522 else if (NUMBERP (content))
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1523 reg[rrr] = XINT (content);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1524 else if (EQ (content, Qt))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1525 reg[RRR] = i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1526 else if (CONSP (content))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1527 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1528 attrib = XCONS (content)->car;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1529 value = XCONS (content)->cdr;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1530 if (!NUMBERP (attrib) || !NUMBERP (value))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1531 continue;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1532 reg[rrr] = XUINT(value);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1533 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1534 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1535 else
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1536 reg[RRR] = -1;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1537 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1538 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1539 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1540
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1541 default:
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1542 CCL_INVALID_CMD;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1543 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1544 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1545
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 default:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 CCL_INVALID_CMD;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1548 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 ccl_error_handler:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 if (destination)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 /* We can insert an error message only if DESTINATION is
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555 specified and we still have a room to store the message
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1556 there. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1557 char msg[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1558 int msglen;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1559
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1560 if (!dst)
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1561 dst = destination;
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1562
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563 switch (ccl->status)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1565 case CCL_STAT_INVALID_CMD:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1566 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
23303
fb38954a02d3 (ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents: 23280
diff changeset
1567 code & 0x1F, code, this_ic);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1568 #ifdef CCL_DEBUG
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1569 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1570 int i = ccl_backtrace_idx - 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1571 int j;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1572
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1573 msglen = strlen (msg);
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1574 if (dst + msglen <= (dst_bytes ? dst_end : src))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1575 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1576 bcopy (msg, dst, msglen);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577 dst += msglen;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1578 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1581 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1582 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1583 if (ccl_backtrace_table[i] == 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1584 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 sprintf(msg, " %d", ccl_backtrace_table[i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586 msglen = strlen (msg);
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1587 if (dst + msglen > (dst_bytes ? dst_end : src))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1588 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1589 bcopy (msg, dst, msglen);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1590 dst += msglen;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1591 }
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1592 goto ccl_finish;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1593 }
17323
15fa68d983e7 (ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents: 17122
diff changeset
1594 #endif
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1595 break;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1596
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1597 case CCL_STAT_QUIT:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1598 sprintf(msg, "\nCCL: Quited.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1599 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1600
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1601 default:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1602 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1603 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1604
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1605 msglen = strlen (msg);
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1606 if (dst + msglen <= (dst_bytes ? dst_end : src))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1607 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1608 bcopy (msg, dst, msglen);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1609 dst += msglen;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 ccl_finish:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1614 ccl->ic = ic;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 if (consumed) *consumed = src - source;
23280
b4656367043f (CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents: 23072
diff changeset
1616 return (dst ? dst - destination : 0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1617 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1619 /* Setup fields of the structure pointed by CCL appropriately for the
23884
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1620 execution of compiled CCL code in VEC (vector of integer).
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1621 If VEC is nil, we skip setting ups based on VEC. */
20307
a5d72b4a642f (setup_ccl_program): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 18749
diff changeset
1622 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1623 setup_ccl_program (ccl, vec)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624 struct ccl_program *ccl;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625 Lisp_Object vec;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1628
23884
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1629 if (VECTORP (vec))
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1630 {
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1631 struct Lisp_Vector *vp = XVECTOR (vec);
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1632
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1633 ccl->size = vp->size;
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1634 ccl->prog = vp->contents;
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1635 ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]);
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1636 ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]);
179bcb86f12f (CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents: 23768
diff changeset
1637 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 ccl->ic = CCL_HEADER_MAIN;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 for (i = 0; i < 8; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 ccl->reg[i] = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 ccl->last_block = 0;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1642 ccl->private_state = 0;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 ccl->status = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1646 /* Resolve symbols in the specified CCL code (Lisp vector). This
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1647 function converts symbols of code conversion maps and character
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1648 translation tables embeded in the CCL code into their ID numbers. */
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1649
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1650 Lisp_Object
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1651 resolve_symbol_ccl_program (ccl)
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1652 Lisp_Object ccl;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1653 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1654 int i, veclen;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1655 Lisp_Object result, contents, prop;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1656
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1657 result = ccl;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1658 veclen = XVECTOR (result)->size;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1659
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1660 /* Set CCL program's table ID */
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1661 for (i = 0; i < veclen; i++)
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1662 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1663 contents = XVECTOR (result)->contents[i];
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1664 if (SYMBOLP (contents))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1665 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1666 if (EQ(result, ccl))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1667 result = Fcopy_sequence (ccl);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1668
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22122
diff changeset
1669 prop = Fget (contents, Qtranslation_table_id);
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1670 if (NUMBERP (prop))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1671 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1672 XVECTOR (result)->contents[i] = prop;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1673 continue;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1674 }
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1675 prop = Fget (contents, Qcode_conversion_map_id);
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1676 if (NUMBERP (prop))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1677 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1678 XVECTOR (result)->contents[i] = prop;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1679 continue;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1680 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1681 prop = Fget (contents, Qccl_program_idx);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1682 if (NUMBERP (prop))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1683 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1684 XVECTOR (result)->contents[i] = prop;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1685 continue;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1686 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1687 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1688 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1689
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1690 return result;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1691 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1692
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1693
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1694 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 DEFUN ("ccl-execute", Fccl_execute, Sccl_execute, 2, 2, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1697 "Execute CCL-PROGRAM with registers initialized by REGISTERS.\n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1698 \n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1699 CCL-PROGRAM is a symbol registered by register-ccl-program,\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1700 or a compiled code generated by `ccl-compile' (for backward compatibility,\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1701 in this case, the execution is slower).\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1702 No I/O commands should appear in CCL-PROGRAM.\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1703 \n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1704 REGISTERS is a vector of [R0 R1 ... R7] where RN is an initial value\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1705 of Nth register.\n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1706 \n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1707 As side effect, each element of REGISTERS holds the value of\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1708 corresponding register after the execution.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1709 (ccl_prog, reg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1710 Lisp_Object ccl_prog, reg;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1711 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1712 struct ccl_program ccl;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1713 int i;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1714 Lisp_Object ccl_id;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1716 if ((SYMBOLP (ccl_prog)) &&
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1717 (!NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx))))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1718 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1719 ccl_prog = XVECTOR (Vccl_program_table)->contents[XUINT (ccl_id)];
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1720 CHECK_LIST (ccl_prog, 0);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1721 ccl_prog = XCONS (ccl_prog)->cdr;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1722 CHECK_VECTOR (ccl_prog, 1);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1723 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1724 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1725 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1726 CHECK_VECTOR (ccl_prog, 1);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1727 ccl_prog = resolve_symbol_ccl_program (ccl_prog);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1728 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1729
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1730 CHECK_VECTOR (reg, 2);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1731 if (XVECTOR (reg)->size != 8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1732 error ("Invalid length of vector REGISTERS");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1733
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1734 setup_ccl_program (&ccl, ccl_prog);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1735 for (i = 0; i < 8; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1736 ccl.reg[i] = (INTEGERP (XVECTOR (reg)->contents[i])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1737 ? XINT (XVECTOR (reg)->contents[i])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1738 : 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1739
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1740 ccl_driver (&ccl, (char *)0, (char *)0, 0, 0, (int *)0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1741 QUIT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1742 if (ccl.status != CCL_STAT_SUCCESS)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1743 error ("Error in CCL program at %dth code", ccl.ic);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1744
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1745 for (i = 0; i < 8; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1746 XSETINT (XVECTOR (reg)->contents[i], ccl.reg[i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1747 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1748 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1749
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1750 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string, Sccl_execute_on_string,
20934
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1751 3, 5, 0,
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1752 "Execute CCL-PROGRAM with initial STATUS on STRING.\n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1753 \n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1754 CCL-PROGRAM is a symbol registered by register-ccl-program,\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1755 or a compiled code generated by `ccl-compile' (for backward compatibility,\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1756 in this case, the execution is slower).\n\
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1757 \n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1758 Read buffer is set to STRING, and write buffer is allocated automatically.\n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1759 \n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1760 STATUS is a vector of [R0 R1 ... R7 IC], where\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1761 R0..R7 are initial values of corresponding registers,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1762 IC is the instruction counter specifying from where to start the program.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1763 If R0..R7 are nil, they are initialized to 0.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1764 If IC is nil, it is initialized to head of the CCL program.\n\
20934
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1765 \n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1766 If optional 4th arg CONTINUE is non-nil, keep IC on read operation\n\
17728
25d58ba29c1b (Fccl_execute_on_string): Add 4th optional arg
Kenichi Handa <handa@m17n.org>
parents: 17370
diff changeset
1767 when read buffer is exausted, else, IC is always set to the end of\n\
21556
f239266d104c (Fccl_execute_on_string): Put \n\ at eol of docstring.
Kenichi Handa <handa@m17n.org>
parents: 21551
diff changeset
1768 CCL-PROGRAM on exit.\n\
20934
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1769 \n\
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1770 It returns the contents of write buffer as a string,\n\
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1771 and as side effect, STATUS is updated.\n\
20934
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1772 If the optional 5th arg UNIBYTE-P is non-nil, the returned string\n\
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1773 is a unibyte string. By default it is a multibyte string.")
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1774 (ccl_prog, status, str, contin, unibyte_p)
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1775 Lisp_Object ccl_prog, status, str, contin, unibyte_p;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1776 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1777 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1778 struct ccl_program ccl;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1779 int i, produced;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1780 int outbufsize;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1781 char *outbuf;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1782 struct gcpro gcpro1, gcpro2, gcpro3;
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1783 Lisp_Object ccl_id;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1784
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1785 if ((SYMBOLP (ccl_prog)) &&
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1786 (!NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx))))
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1787 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1788 ccl_prog = XVECTOR (Vccl_program_table)->contents[XUINT (ccl_id)];
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1789 CHECK_LIST (ccl_prog, 0);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1790 ccl_prog = XCONS (ccl_prog)->cdr;
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1791 CHECK_VECTOR (ccl_prog, 1);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1792 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1793 else
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1794 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1795 CHECK_VECTOR (ccl_prog, 1);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1796 ccl_prog = resolve_symbol_ccl_program (ccl_prog);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1797 }
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1798
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1799 CHECK_VECTOR (status, 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1800 if (XVECTOR (status)->size != 9)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1801 error ("Invalid length of vector STATUS");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1802 CHECK_STRING (str, 2);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1803 GCPRO3 (ccl_prog, status, str);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1805 setup_ccl_program (&ccl, ccl_prog);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1806 for (i = 0; i < 8; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1807 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1808 if (NILP (XVECTOR (status)->contents[i]))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1809 XSETINT (XVECTOR (status)->contents[i], 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1810 if (INTEGERP (XVECTOR (status)->contents[i]))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1811 ccl.reg[i] = XINT (XVECTOR (status)->contents[i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1812 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1813 if (INTEGERP (XVECTOR (status)->contents[i]))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1814 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1815 i = XFASTINT (XVECTOR (status)->contents[8]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1816 if (ccl.ic < i && i < ccl.size)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1817 ccl.ic = i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1818 }
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20945
diff changeset
1819 outbufsize = STRING_BYTES (XSTRING (str)) * ccl.buf_magnification + 256;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1820 outbuf = (char *) xmalloc (outbufsize);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1821 if (!outbuf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1822 error ("Not enough memory");
17728
25d58ba29c1b (Fccl_execute_on_string): Add 4th optional arg
Kenichi Handa <handa@m17n.org>
parents: 17370
diff changeset
1823 ccl.last_block = NILP (contin);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1824 produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20945
diff changeset
1825 STRING_BYTES (XSTRING (str)), outbufsize, (int *)0);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1826 for (i = 0; i < 8; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1827 XSET (XVECTOR (status)->contents[i], Lisp_Int, ccl.reg[i]);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1828 XSETINT (XVECTOR (status)->contents[8], ccl.ic);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1829 UNGCPRO;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1830
20934
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1831 if (NILP (unibyte_p))
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1832 val = make_string (outbuf, produced);
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1833 else
eebcbb4b56bd (Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents: 20722
diff changeset
1834 val = make_unibyte_string (outbuf, produced);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1835 free (outbuf);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1836 QUIT;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1837 if (ccl.status != CCL_STAT_SUCCESS
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1838 && ccl.status != CCL_STAT_SUSPEND_BY_SRC
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1839 && ccl.status != CCL_STAT_SUSPEND_BY_DST)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1840 error ("Error in CCL program at %dth code", ccl.ic);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1841
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1842 return val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1843 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1844
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1845 DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1846 2, 2, 0,
17122
a5feb61ebe5c (Fregister_ccl_program): Escape newlines in docstring.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1847 "Register CCL program PROGRAM of NAME in `ccl-program-table'.\n\
a5feb61ebe5c (Fregister_ccl_program): Escape newlines in docstring.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1848 PROGRAM should be a compiled code of CCL program, or nil.\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1849 Return index number of the registered CCL program.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1850 (name, ccl_prog)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1851 Lisp_Object name, ccl_prog;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1852 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1853 int len = XVECTOR (Vccl_program_table)->size;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1854 int i;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1855
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1856 CHECK_SYMBOL (name, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1857 if (!NILP (ccl_prog))
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1858 {
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1859 CHECK_VECTOR (ccl_prog, 1);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1860 ccl_prog = resolve_symbol_ccl_program (ccl_prog);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1861 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1862
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1863 for (i = 0; i < len; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1864 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1865 Lisp_Object slot = XVECTOR (Vccl_program_table)->contents[i];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1866
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1867 if (!CONSP (slot))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1869
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1870 if (EQ (name, XCONS (slot)->car))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1871 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 XCONS (slot)->cdr = ccl_prog;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 return make_number (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1875 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1877 if (i == len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1878 {
18749
d961aeafceba (Fregister_ccl_program): Convert Fmake_vector argument to Lisp_Integer.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
1879 Lisp_Object new_table = Fmake_vector (make_number (len * 2), Qnil);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1880 int j;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1881
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1882 for (j = 0; j < len; j++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1883 XVECTOR (new_table)->contents[j]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1884 = XVECTOR (Vccl_program_table)->contents[j];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1885 Vccl_program_table = new_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1886 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1887
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1888 XVECTOR (Vccl_program_table)->contents[i] = Fcons (name, ccl_prog);
21665
2f6a8ae78e88 (Fregister_ccl_program): Put ccl-program-idx property to NAME.
Kenichi Handa <handa@m17n.org>
parents: 21556
diff changeset
1889 Fput (name, Qccl_program_idx, make_number (i));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1890 return make_number (i);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1891 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1892
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1893 /* Register code conversion map.
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1894 A code conversion map consists of numbers, Qt, Qnil, and Qlambda.
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1895 The first element is start code point.
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1896 The rest elements are mapped numbers.
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1897 Symbol t means to map to an original number before mapping.
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1898 Symbol nil means that the corresponding element is empty.
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1899 Symbol lambda menas to terminate mapping here.
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1900 */
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1901
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1902 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map,
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1903 Sregister_code_conversion_map,
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1904 2, 2, 0,
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1905 "Register SYMBOL as code conversion map MAP.\n\
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1906 Return index number of the registered map.")
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1907 (symbol, map)
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1908 Lisp_Object symbol, map;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1909 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1910 int len = XVECTOR (Vcode_conversion_map_vector)->size;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1911 int i;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1912 Lisp_Object index;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1913
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1914 CHECK_SYMBOL (symbol, 0);
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1915 CHECK_VECTOR (map, 1);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1916
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1917 for (i = 0; i < len; i++)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1918 {
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1919 Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i];
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1920
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1921 if (!CONSP (slot))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1922 break;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1923
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1924 if (EQ (symbol, XCONS (slot)->car))
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1925 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1926 index = make_number (i);
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1927 XCONS (slot)->cdr = map;
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1928 Fput (symbol, Qcode_conversion_map, map);
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1929 Fput (symbol, Qcode_conversion_map_id, index);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1930 return index;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1931 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1932 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1933
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1934 if (i == len)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1935 {
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1936 Lisp_Object new_vector = Fmake_vector (make_number (len * 2), Qnil);
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1937 int j;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1938
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1939 for (j = 0; j < len; j++)
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1940 XVECTOR (new_vector)->contents[j]
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1941 = XVECTOR (Vcode_conversion_map_vector)->contents[j];
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1942 Vcode_conversion_map_vector = new_vector;
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1943 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1944
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1945 index = make_number (i);
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1946 Fput (symbol, Qcode_conversion_map, map);
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1947 Fput (symbol, Qcode_conversion_map_id, index);
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1948 XVECTOR (Vcode_conversion_map_vector)->contents[i] = Fcons (symbol, map);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1949 return index;
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1950 }
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1951
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1952
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21244
diff changeset
1953 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1954 syms_of_ccl ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1955 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1956 staticpro (&Vccl_program_table);
18749
d961aeafceba (Fregister_ccl_program): Convert Fmake_vector argument to Lisp_Integer.
Richard M. Stallman <rms@gnu.org>
parents: 18613
diff changeset
1957 Vccl_program_table = Fmake_vector (make_number (32), Qnil);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1958
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1959 Qccl_program = intern ("ccl-program");
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1960 staticpro (&Qccl_program);
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1961
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1962 Qccl_program_idx = intern ("ccl-program-idx");
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1963 staticpro (&Qccl_program_idx);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1964
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1965 Qcode_conversion_map = intern ("code-conversion-map");
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1966 staticpro (&Qcode_conversion_map);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1967
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1968 Qcode_conversion_map_id = intern ("code-conversion-map-id");
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1969 staticpro (&Qcode_conversion_map_id);
21551
f928f4d89772 Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21518
diff changeset
1970
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1971 DEFVAR_LISP ("code-conversion-map-vector", &Vcode_conversion_map_vector,
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1972 "Vector of code conversion maps.");
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1973 Vcode_conversion_map_vector = Fmake_vector (make_number (16), Qnil);
20722
cce3ef478c64 (Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents: 20613
diff changeset
1974
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1975 DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1976 "Alist of fontname patterns vs corresponding CCL program.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1977 Each element looks like (REGEXP . CCL-CODE),\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1978 where CCL-CODE is a compiled CCL program.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1979 When a font whose name matches REGEXP is used for displaying a character,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1980 CCL-CODE is executed to calculate the code point in the font\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1981 from the charset number and position code(s) of the character which are set\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1982 in CCL registers R0, R1, and R2 before the execution.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1983 The code point in the font is set in CCL registers R1 and R2\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1984 when the execution terminated.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1985 If the font is single-byte font, the register R2 is not used.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1986 Vfont_ccl_encoder_alist = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1987
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1988 defsubr (&Sccl_execute);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1989 defsubr (&Sccl_execute_on_string);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1990 defsubr (&Sregister_ccl_program);
22122
dfae9bc3731d Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents: 21665
diff changeset
1991 defsubr (&Sregister_code_conversion_map);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1992 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1993
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1994 #endif /* emacs */