annotate src/mule-ccl.c @ 337:fbbf69b4e8a7 r21-0-66

Import from CVS: tag r21-0-66
author cvs
date Mon, 13 Aug 2007 10:51:02 +0200
parents 90d73dddcdc4
children 7c94d56991e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1 /* CCL (Code Conversion Language) interpreter.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
3 Licensed to the Free Software Foundation.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
8 it under the terms of the GNU General Public License as published by
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
10 any later version.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
15 GNU General Public License for more details.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
22 /* Synched up with : FSF Emacs 20.2 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
23
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
24 #ifdef emacs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 #include <config.h>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #include "lisp.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 #include "buffer.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
29 #include "mule-charset.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
30 #include "mule-ccl.h"
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
31 #include "file-coding.h"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
33 #else /* not emacs */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
34
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
35 #include <stdio.h>
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
36 #include "mulelib.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
37
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
38 #endif /* not emacs */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
39
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
40 /* Alist of fontname patterns vs corresponding CCL program. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
41 Lisp_Object Vfont_ccl_encoder_alist;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
43 /* Vector of CCL program names vs corresponding program data. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
44 Lisp_Object Vccl_program_table;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
45
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
46 /* CCL (Code Conversion Language) is a simple language which has
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
47 operations on one input buffer, one output buffer, and 7 registers.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
48 The syntax of CCL is described in `ccl.el'. Emacs Lisp function
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
49 `ccl-compile' compiles a CCL program and produces a CCL code which
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
50 is a vector of integers. The structure of this vector is as
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
51 follows: The 1st element: buffer-magnification, a factor for the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
52 size of output buffer compared with the size of input buffer. The
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
53 2nd element: address of CCL code to be executed when encountered
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
54 with end of input stream. The 3rd and the remaining elements: CCL
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
55 codes. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 /* Header of CCL compiled code */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
58 #define CCL_HEADER_BUF_MAG 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
59 #define CCL_HEADER_EOF 1
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
60 #define CCL_HEADER_MAIN 2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
62 /* CCL code is a sequence of 28-bit non-negative integers (i.e. the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
63 MSB is always 0), each contains CCL command and/or arguments in the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
64 following format:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
66 |----------------- integer (28-bit) ------------------|
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
67 |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -|
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
68 |--constant argument--|-register-|-register-|-command-|
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
69 ccccccccccccccccc RRR rrr XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
70 or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
71 |------- relative address -------|-register-|-command-|
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
72 cccccccccccccccccccc rrr XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
73 or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
74 |------------- constant or other args ----------------|
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
75 cccccccccccccccccccccccccccc
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
76
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
77 where, `cc...c' is a non-negative integer indicating constant value
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
78 (the left most `c' is always 0) or an absolute jump address, `RRR'
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
79 and `rrr' are CCL register number, `XXXXX' is one of the following
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
80 CCL commands. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
81
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
82 /* CCL commands
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
83
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
84 Each comment fields shows one or more lines for command syntax and
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
85 the following lines for semantics of the command. In semantics, IC
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
86 stands for Instruction Counter. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
87
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
88 #define CCL_SetRegister 0x00 /* Set register a register value:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
89 1:00000000000000000RRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
90 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
91 reg[rrr] = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
92 */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
94 #define CCL_SetShortConst 0x01 /* Set register a short constant value:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
95 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
96 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
97 reg[rrr] = CCCCCCCCCCCCCCCCCCC;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
98 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
99
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
100 #define CCL_SetConst 0x02 /* Set register a constant value:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
101 1:00000000000000000000rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
102 2:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
103 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
104 reg[rrr] = CONSTANT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
105 IC++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
106 */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
108 #define CCL_SetArray 0x03 /* Set register an element of array:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
109 1:CCCCCCCCCCCCCCCCCRRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
110 2:ELEMENT[0]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
111 3:ELEMENT[1]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
112 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
113 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
114 if (0 <= reg[RRR] < CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
115 reg[rrr] = ELEMENT[reg[RRR]];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
116 IC += CC..C;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
117 */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
119 #define CCL_Jump 0x04 /* Jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
120 1:A--D--D--R--E--S--S-000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
121 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
122 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
123 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
124
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
125 /* Note: If CC..C is greater than 0, the second code is omitted. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
126
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
127 #define CCL_JumpCond 0x05 /* Jump conditional:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
128 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
129 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
130 if (!reg[rrr])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
131 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
132 */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
135 #define CCL_WriteRegisterJump 0x06 /* Write register and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
136 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
137 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
138 write (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
139 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
140 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
141
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
142 #define CCL_WriteRegisterReadJump 0x07 /* Write register, read, and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
143 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
144 2:A--D--D--R--E--S--S-rrrYYYYY
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
145 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
146 write (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
147 IC++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
148 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
149 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
150 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
151 /* Note: If read is suspended, the resumed execution starts from the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
152 second code (YYYYY == CCL_ReadJump). */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
153
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
154 #define CCL_WriteConstJump 0x08 /* Write constant and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
155 1:A--D--D--R--E--S--S-000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
156 2:CONST
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
157 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
158 write (CONST);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
159 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
160 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
161
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
162 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
163 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
164 2:CONST
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
165 3:A--D--D--R--E--S--S-rrrYYYYY
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
166 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
167 write (CONST);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
168 IC += 2;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
169 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
170 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
171 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
172 /* Note: If read is suspended, the resumed execution starts from the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
173 second code (YYYYY == CCL_ReadJump). */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
174
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
175 #define CCL_WriteStringJump 0x0A /* Write string and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
176 1:A--D--D--R--E--S--S-000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
177 2:LENGTH
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
178 3:0000STRIN[0]STRIN[1]STRIN[2]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
179 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
180 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
181 write_string (STRING, LENGTH);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
182 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
183 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
184
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
185 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
186 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
187 2:LENGTH
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
188 3:ELEMENET[0]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
189 4:ELEMENET[1]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
190 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
191 N:A--D--D--R--E--S--S-rrrYYYYY
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
192 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
193 if (0 <= reg[rrr] < LENGTH)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
194 write (ELEMENT[reg[rrr]]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
195 IC += LENGTH + 2; (... pointing at N+1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
196 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
197 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
198 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
199 /* Note: If read is suspended, the resumed execution starts from the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
200 Nth code (YYYYY == CCL_ReadJump). */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
201
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
202 #define CCL_ReadJump 0x0C /* Read and jump:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
203 1:A--D--D--R--E--S--S-rrrYYYYY
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
204 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
205 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
206 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
207 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
208
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
209 #define CCL_Branch 0x0D /* Jump by branch table:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
210 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
211 2:A--D--D--R--E-S-S[0]000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
212 3:A--D--D--R--E-S-S[1]000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
213 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
214 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
215 if (0 <= reg[rrr] < CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
216 IC += ADDRESS[reg[rrr]];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
217 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
218 IC += ADDRESS[CC..C];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
219 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
220
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
221 #define CCL_ReadRegister 0x0E /* Read bytes into registers:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
222 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
223 2:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
224 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
225 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
226 while (CCC--)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
227 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
228 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
229
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
230 #define CCL_WriteExprConst 0x0F /* write result of expression:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
231 1:00000OPERATION000RRR000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
232 2:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
233 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
234 write (reg[RRR] OPERATION CONSTANT);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
235 IC++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
236 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
237
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
238 /* Note: If the Nth read is suspended, the resumed execution starts
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
239 from the Nth code. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
240
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
241 #define CCL_ReadBranch 0x10 /* Read one byte into a register,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
242 and jump by branch table:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
243 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
244 2:A--D--D--R--E-S-S[0]000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
245 3:A--D--D--R--E-S-S[1]000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
246 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
247 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
248 read (read[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
249 if (0 <= reg[rrr] < CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
250 IC += ADDRESS[reg[rrr]];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
251 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
252 IC += ADDRESS[CC..C];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
253 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
254
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
255 #define CCL_WriteRegister 0x11 /* Write registers:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
256 1:CCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
257 2:CCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
258 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
259 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
260 while (CCC--)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
261 write (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
262 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
263 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
264
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
265 /* Note: If the Nth write is suspended, the resumed execution
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
266 starts from the Nth code. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
267
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
268 #define CCL_WriteExprRegister 0x12 /* Write result of expression
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
269 1:00000OPERATIONRrrRRR000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
270 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
271 write (reg[RRR] OPERATION reg[Rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
272 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
273
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
274 #define CCL_Call 0x13 /* Write a constant:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
275 1:CCCCCCCCCCCCCCCCCCCC000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
276 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
277 call (CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
278 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
279
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
280 #define CCL_WriteConstString 0x14 /* Write a constant or a string:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
281 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
282 [2:0000STRIN[0]STRIN[1]STRIN[2]]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
283 [...]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
284 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
285 if (!rrr)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
286 write (CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
287 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
288 write_string (STRING, CC..C);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
289 IC += (CC..C + 2) / 3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
290 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
291
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
292 #define CCL_WriteArray 0x15 /* Write an element of array:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
293 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
294 2:ELEMENT[0]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
295 3:ELEMENT[1]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
296 ...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
297 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
298 if (0 <= reg[rrr] < CC..C)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
299 write (ELEMENT[reg[rrr]]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
300 IC += CC..C;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
301 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
302
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
303 #define CCL_End 0x16 /* Terminate:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
304 1:00000000000000000000000XXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
305 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
306 terminate ();
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
307 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
308
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
309 /* The following two codes execute an assignment arithmetic/logical
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
310 operation. The form of the operation is like REG OP= OPERAND. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
311
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
312 #define CCL_ExprSelfConst 0x17 /* REG OP= constant:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
313 1:00000OPERATION000000rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
314 2:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
315 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
316 reg[rrr] OPERATION= CONSTANT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
317 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
318
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
319 #define CCL_ExprSelfReg 0x18 /* REG1 OP= REG2:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
320 1:00000OPERATION000RRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
321 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
322 reg[rrr] OPERATION= reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
323 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
324
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
325 /* The following codes execute an arithmetic/logical operation. The
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
326 form of the operation is like REG_X = REG_Y OP OPERAND2. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
327
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
328 #define CCL_SetExprConst 0x19 /* REG_X = REG_Y OP constant:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
329 1:00000OPERATION000RRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
330 2:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
331 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
332 reg[rrr] = reg[RRR] OPERATION CONSTANT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
333 IC++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
334 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
335
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
336 #define CCL_SetExprReg 0x1A /* REG1 = REG2 OP REG3:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
337 1:00000OPERATIONRrrRRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
338 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
339 reg[rrr] = reg[RRR] OPERATION reg[Rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
340 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
341
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
342 #define CCL_JumpCondExprConst 0x1B /* Jump conditional according to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
343 an operation on constant:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
344 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
345 2:OPERATION
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
346 3:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
347 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
348 reg[7] = reg[rrr] OPERATION CONSTANT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
349 if (!(reg[7]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
350 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
351 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
352 IC += 2
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
353 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
354
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
355 #define CCL_JumpCondExprReg 0x1C /* Jump conditional according to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
356 an operation on register:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
357 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
358 2:OPERATION
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
359 3:RRR
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
360 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
361 reg[7] = reg[rrr] OPERATION reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
362 if (!reg[7])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
363 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
364 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
365 IC += 2;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
366 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
367
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
368 #define CCL_ReadJumpCondExprConst 0x1D /* Read and jump conditional according
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
369 to an operation on constant:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
370 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
371 2:OPERATION
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
372 3:CONSTANT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
373 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
374 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
375 reg[7] = reg[rrr] OPERATION CONSTANT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
376 if (!reg[7])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
377 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
378 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
379 IC += 2;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
380 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
381
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
382 #define CCL_ReadJumpCondExprReg 0x1E /* Read and jump conditional according
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
383 to an operation on register:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
384 1:A--D--D--R--E--S--S-rrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
385 2:OPERATION
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
386 3:RRR
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
387 -----------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
388 read (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
389 reg[7] = reg[rrr] OPERATION reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
390 if (!reg[7])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
391 IC += ADDRESS;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
392 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
393 IC += 2;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
394 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
395
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
396 #define CCL_Extention 0x1F /* Extended CCL code
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
397 1:ExtendedCOMMNDRrrRRRrrrXXXXX
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
398 2:ARGUEMENT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
399 3:...
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
400 ------------------------------
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
401 extended_command (rrr,RRR,Rrr,ARGS)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
402 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
403
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
404
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
405 /* CCL arithmetic/logical operators. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
406 #define CCL_PLUS 0x00 /* X = Y + Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
407 #define CCL_MINUS 0x01 /* X = Y - Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
408 #define CCL_MUL 0x02 /* X = Y * Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
409 #define CCL_DIV 0x03 /* X = Y / Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
410 #define CCL_MOD 0x04 /* X = Y % Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
411 #define CCL_AND 0x05 /* X = Y & Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
412 #define CCL_OR 0x06 /* X = Y | Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
413 #define CCL_XOR 0x07 /* X = Y ^ Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
414 #define CCL_LSH 0x08 /* X = Y << Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
415 #define CCL_RSH 0x09 /* X = Y >> Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
416 #define CCL_LSH8 0x0A /* X = (Y << 8) | Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
417 #define CCL_RSH8 0x0B /* X = Y >> 8, r[7] = Y & 0xFF */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
418 #define CCL_DIVMOD 0x0C /* X = Y / Z, r[7] = Y % Z */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
419 #define CCL_LS 0x10 /* X = (X < Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
420 #define CCL_GT 0x11 /* X = (X > Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
421 #define CCL_EQ 0x12 /* X = (X == Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
422 #define CCL_LE 0x13 /* X = (X <= Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
423 #define CCL_GE 0x14 /* X = (X >= Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
424 #define CCL_NE 0x15 /* X = (X != Y) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
425
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
426 #define CCL_ENCODE_SJIS 0x16 /* X = HIGHER_BYTE (SJIS (Y, Z))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
427 r[7] = LOWER_BYTE (SJIS (Y, Z) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
428 #define CCL_DECODE_SJIS 0x17 /* X = HIGHER_BYTE (DE-SJIS (Y, Z))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
429 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
430
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
431 /* Macros for exit status of CCL program. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
432 #define CCL_STAT_SUCCESS 0 /* Terminated successfully. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
433 #define CCL_STAT_SUSPEND 1 /* Terminated because of empty input
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
434 buffer or full output buffer. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
435 #define CCL_STAT_INVALID_CMD 2 /* Terminated because of invalid
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
436 command. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
437 #define CCL_STAT_QUIT 3 /* Terminated because of quit. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
438
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
439 /* Encode one character CH to multibyte form and write to the current
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
440 output buffer. If CH is less than 256, CH is written as is. */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
441 #define CCL_WRITE_CHAR(ch) do { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
442 if (!destination) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
443 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
444 ccl->status = CCL_STAT_INVALID_CMD; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
445 goto ccl_error_handler; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
446 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
447 else \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
448 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
449 Bufbyte work[MAX_EMCHAR_LEN]; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
450 int len = ( ch < 256 ) ? \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
451 simple_set_charptr_emchar (work, ch) : \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
452 non_ascii_set_charptr_emchar (work, ch); \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
453 Dynarr_add_many (destination, work, len); \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
454 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
455 } while (0)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
456
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
457 /* Write a string at ccl_prog[IC] of length LEN to the current output
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
458 buffer. */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
459 #define CCL_WRITE_STRING(len) do { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
460 if (!destination) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
461 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
462 ccl->status = CCL_STAT_INVALID_CMD; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
463 goto ccl_error_handler; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
464 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
465 else \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
466 for (i = 0; i < len; i++) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
467 Dynarr_add(destination, \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
468 (XINT (ccl_prog[ic + (i / 3)]) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
469 >> ((2 - (i % 3)) * 8)) & 0xFF); \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
470 } while (0)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
471
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
472 /* Read one byte from the current input buffer into Rth register. */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
473 #define CCL_READ_CHAR(r) do { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
474 if (!src) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
475 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
476 ccl->status = CCL_STAT_INVALID_CMD; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
477 goto ccl_error_handler; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
478 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
479 else if (src < src_end) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
480 r = *src++; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
481 else if (ccl->last_block) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
482 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
483 ic = ccl->eof_ic; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
484 goto ccl_finish; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
485 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
486 else \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
487 /* Suspend CCL program because of \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
488 reading from empty input buffer or \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
489 writing to full output buffer. \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
490 When this program is resumed, the \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
491 same I/O command is executed. */ \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
492 { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
493 ic--; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
494 ccl->status = CCL_STAT_SUSPEND; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
495 goto ccl_finish; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
496 } \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
497 } while (0)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
498
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
499
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
500 /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
501 text goes to a place pointed by DESTINATION. The bytes actually
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
502 processed is returned as *CONSUMED. The return value is the length
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
503 of the resulting text. As a side effect, the contents of CCL registers
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
504 are updated. If SOURCE or DESTINATION is NULL, only operations on
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
505 registers are permitted. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
506
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
507 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
508 #define CCL_DEBUG_BACKTRACE_LEN 256
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
509 int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
510 int ccl_backtrace_idx;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
511 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
512
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
513 struct ccl_prog_stack
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
514 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
515 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
516 int ic; /* Instruction Counter. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
517 };
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
518
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
519 int
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
520 ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, unsigned_char_dynarr *destination, int src_bytes, int *consumed)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
521 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
522 int *reg = ccl->reg;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
523 int ic = ccl->ic;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
524 int code = -1; /* init to illegal value, */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
525 int field1, field2;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
526 Lisp_Object *ccl_prog = ccl->prog;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
527 CONST unsigned char *src = source, *src_end = src + src_bytes;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
528 int jump_address = 0; /* shut up the compiler */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
529
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
530 int i, j, op;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
531 int stack_idx = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
532 /* For the moment, we only support depth 256 of stack. */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
533 struct ccl_prog_stack ccl_prog_stack_struct[256];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
534
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
535 if (ic >= ccl->eof_ic)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
536 ic = CCL_HEADER_MAIN;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
537
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
538 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
539 ccl_backtrace_idx = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
540 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
541
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
542 for (;;)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
543 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
544 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
545 ccl_backtrace_table[ccl_backtrace_idx++] = ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
546 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
547 ccl_backtrace_idx = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
548 ccl_backtrace_table[ccl_backtrace_idx] = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
549 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
550
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
551 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
552 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
553 /* We can't just signal Qquit, instead break the loop as if
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
554 the whole data is processed. Don't reset Vquit_flag, it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
555 must be handled later at a safer place. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
556 if (consumed)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
557 src = source + src_bytes;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
558 ccl->status = CCL_STAT_QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
559 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
560 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
561
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
562 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
563 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
564 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
565
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
566 #define rrr field2
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
567 #define RRR (field1 & 7)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
568 #define Rrr ((field1 >> 3) & 7)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
569 #define ADDR field1
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
570
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
571 switch (code & 0x1F)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
572 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
573 case CCL_SetRegister: /* 00000000000000000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
574 reg[rrr] = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
575 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
576
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
577 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
578 reg[rrr] = field1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
579 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
580
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
581 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
582 reg[rrr] = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
583 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
584 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
585
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
586 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
587 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
588 j = field1 >> 3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
589 if ((unsigned int) i < j)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
590 reg[rrr] = XINT (ccl_prog[ic + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
591 ic += j;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
592 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
593
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
594 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
595 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
596 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
597
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
598 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
599 if (!reg[rrr])
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
600 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
601 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
602
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
603 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
604 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
605 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
606 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
607 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
608
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
609 case CCL_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
610 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
611 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
612 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
613 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
614 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
615 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
616
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
617 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
618 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
619 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
620 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
621 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
622
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
623 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
624 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
625 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
626 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
627 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
628 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
629 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
630
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
631 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
632 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
633 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
634 CCL_WRITE_STRING (j);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
635 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
636 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
637
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
638 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
639 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
640 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
641 if ((unsigned int) i < j)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
642 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
643 i = XINT (ccl_prog[ic + 1 + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
644 CCL_WRITE_CHAR (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
645 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
646 ic += j + 2;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
647 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
648 ic += ADDR - (j + 2);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
649 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
650
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
651 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
652 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
653 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
654 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
655
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
656 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
657 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
658 /* fall through ... */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
659 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
660 if ((unsigned int) reg[rrr] < field1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
661 ic += XINT (ccl_prog[ic + reg[rrr]]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
662 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
663 ic += XINT (ccl_prog[ic + field1]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
664 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
665
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
666 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
667 while (1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
668 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
669 CCL_READ_CHAR (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
670 if (!field1) break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
671 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
672 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
673 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
674 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
675 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
676
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
677 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
678 rrr = 7;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
679 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
680 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
681 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
682 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
683 goto ccl_set_expr;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
684
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
685 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
686 while (1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
687 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
688 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
689 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
690 if (!field1) break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
691 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
692 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
693 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
694 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
695 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
696
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
697 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
698 rrr = 7;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
699 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
700 j = reg[Rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
701 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
702 goto ccl_set_expr;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
703
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
704 case CCL_Call: /* CCCCCCCCCCCCCCCCCCCC000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
705 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
706 Lisp_Object slot;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
707
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
708 if (stack_idx >= 256
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
709 || field1 < 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
710 || field1 >= XVECTOR_LENGTH (Vccl_program_table)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
711 || (slot = XVECTOR_DATA (Vccl_program_table)[field1],
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
712 !CONSP (slot))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
713 || !VECTORP (XCDR (slot)))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
714 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
715 if (stack_idx > 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
716 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
717 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
718 ic = ccl_prog_stack_struct[0].ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
719 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
720 ccl->status = CCL_STAT_INVALID_CMD;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
721 goto ccl_error_handler;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
722 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
723
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
724 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
725 ccl_prog_stack_struct[stack_idx].ic = ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
726 stack_idx++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
727 ccl_prog = XVECTOR_DATA (XCDR (slot));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
728 ic = CCL_HEADER_MAIN;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
729 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
730 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
731
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
732 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
733 if (!rrr)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
734 CCL_WRITE_CHAR (field1);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
735 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
736 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
737 CCL_WRITE_STRING (field1);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
738 ic += (field1 + 2) / 3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
739 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
740 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
741
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
742 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
743 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
744 if ((unsigned int) i < field1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
745 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
746 j = XINT (ccl_prog[ic + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
747 CCL_WRITE_CHAR (j);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
748 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
749 ic += field1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
750 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
751
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
752 case CCL_End: /* 0000000000000000000000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
753 if (stack_idx-- > 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
754 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
755 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
756 ic = ccl_prog_stack_struct[stack_idx].ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
757 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
758 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
759 /* Terminate CCL program successfully. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
760 ccl->status = CCL_STAT_SUCCESS;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
761 ccl->ic = CCL_HEADER_MAIN;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
762 goto ccl_finish;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
763
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
764 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
765 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
766 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
767 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
768 goto ccl_expr_self;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
769
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
770 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
771 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
772 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
773
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
774 ccl_expr_self:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
775 switch (op)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
776 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
777 case CCL_PLUS: reg[rrr] += i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
778 case CCL_MINUS: reg[rrr] -= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
779 case CCL_MUL: reg[rrr] *= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
780 case CCL_DIV: reg[rrr] /= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
781 case CCL_MOD: reg[rrr] %= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
782 case CCL_AND: reg[rrr] &= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
783 case CCL_OR: reg[rrr] |= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
784 case CCL_XOR: reg[rrr] ^= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
785 case CCL_LSH: reg[rrr] <<= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
786 case CCL_RSH: reg[rrr] >>= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
787 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
788 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
789 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
790 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
791 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
792 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
793 case CCL_LE: reg[rrr] = reg[rrr] <= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
794 case CCL_GE: reg[rrr] = reg[rrr] >= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
795 case CCL_NE: reg[rrr] = reg[rrr] != i; break;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
796 default:
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
797 ccl->status = CCL_STAT_INVALID_CMD;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
798 goto ccl_error_handler;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
799 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
800 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
801
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
802 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
803 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
804 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
805 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
806 jump_address = ++ic;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
807 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
808
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
809 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
810 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
811 j = reg[Rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
812 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
813 jump_address = ic;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
814 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
815
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
816 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
817 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
818 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
819 i = reg[rrr];
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
820 op = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
821 jump_address = ic++ + ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
822 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
823 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
824 rrr = 7;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
825 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
826
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
827 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
828 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
829 case CCL_JumpCondExprReg:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
830 i = reg[rrr];
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
831 op = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
832 jump_address = ic++ + ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
833 j = reg[XINT (ccl_prog[ic])];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
834 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
835 rrr = 7;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
836
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
837 ccl_set_expr:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
838 switch (op)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
839 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
840 case CCL_PLUS: reg[rrr] = i + j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
841 case CCL_MINUS: reg[rrr] = i - j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
842 case CCL_MUL: reg[rrr] = i * j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
843 case CCL_DIV: reg[rrr] = i / j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
844 case CCL_MOD: reg[rrr] = i % j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
845 case CCL_AND: reg[rrr] = i & j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
846 case CCL_OR: reg[rrr] = i | j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
847 case CCL_XOR: reg[rrr] = i ^ j;; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
848 case CCL_LSH: reg[rrr] = i << j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
849 case CCL_RSH: reg[rrr] = i >> j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
850 case CCL_LSH8: reg[rrr] = (i << 8) | j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
851 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
852 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
853 case CCL_LS: reg[rrr] = i < j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
854 case CCL_GT: reg[rrr] = i > j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
855 case CCL_EQ: reg[rrr] = i == j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
856 case CCL_LE: reg[rrr] = i <= j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
857 case CCL_GE: reg[rrr] = i >= j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
858 case CCL_NE: reg[rrr] = i != j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
859 case CCL_ENCODE_SJIS: ENCODE_SJIS (i, j, reg[rrr], reg[7]); break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
860 case CCL_DECODE_SJIS: DECODE_SJIS (i, j, reg[rrr], reg[7]); break;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
861 default:
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
862 ccl->status = CCL_STAT_INVALID_CMD;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
863 goto ccl_error_handler;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
864 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
865 code &= 0x1F;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
866 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
867 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
868 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
869 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
870 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
871 else if (!reg[rrr])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
872 ic = jump_address;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
873 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
874
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
875 default:
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
876 ccl->status = CCL_STAT_INVALID_CMD;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
877 goto ccl_error_handler;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
878 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
879 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
880
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
881 ccl_error_handler:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
882 if (destination)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
883 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
884 /* We can insert an error message only if DESTINATION is
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
885 specified and we still have a room to store the message
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
886 there. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
887 char msg[256];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
888
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
889 switch (ccl->status)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
890 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
891 /* Terminate CCL program because of invalid command.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
892 Should not occur in the normal case. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
893 case CCL_STAT_INVALID_CMD:
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
894 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
895 code & 0x1F, code, ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
896 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
897 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
898 int i = ccl_backtrace_idx - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
899 int j;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
900
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
901 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
902
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
903 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
904 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
905 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
906 if (ccl_backtrace_table[i] == 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
907 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
908 sprintf(msg, " %d", ccl_backtrace_table[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
909 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
910 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
911 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
912 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
913 goto ccl_finish;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
914
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
915 case CCL_STAT_QUIT:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
916 sprintf(msg, "\nCCL: Quited.");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
917 break;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
918
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
919 default:
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
920 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
921 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
922
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
923 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
924 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
925
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
926 ccl_finish:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
927 ccl->ic = ic;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
928 if (consumed) *consumed = src - source;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
929 if (destination)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
930 return Dynarr_length (destination);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
931 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
932 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
933 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
934
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
935 /* Setup fields of the structure pointed by CCL appropriately for the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
936 execution of compiled CCL code in VEC (vector of integer). */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
937 void
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 241
diff changeset
938 setup_ccl_program (struct ccl_program *ccl, Lisp_Object vec)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
939 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
940 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
941
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
942 ccl->size = XVECTOR_LENGTH (vec);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
943 ccl->prog = XVECTOR_DATA (vec);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
944 ccl->ic = CCL_HEADER_MAIN;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
945 ccl->eof_ic = XINT (XVECTOR_DATA (vec)[CCL_HEADER_EOF]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
946 ccl->buf_magnification = XINT (XVECTOR_DATA (vec)[CCL_HEADER_BUF_MAG]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
947 for (i = 0; i < 8; i++)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
948 ccl->reg[i] = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
949 ccl->last_block = 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
950 ccl->status = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
951 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
952
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
953 #ifdef emacs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
954
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
955 DEFUN ("ccl-execute", Fccl_execute, 2, 2, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
956 Execute CCL-PROGRAM with registers initialized by REGISTERS.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
957 CCL-PROGRAM is a compiled code generated by `ccl-compile',
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
958 no I/O commands should appear in the CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
959 REGISTERS is a vector of [R0 R1 ... R7] where RN is an initial value
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
960 of Nth register.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
961 As side effect, each element of REGISTER holds the value of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
962 corresponding register after the execution.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
963 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
964 (ccl_prog, reg))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
965 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
966 struct ccl_program ccl;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
967 int i;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
968
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
969 CHECK_VECTOR (ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
970 CHECK_VECTOR (reg);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
971 if (XVECTOR_LENGTH (reg) != 8)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
972 signal_simple_error ("Vector should be of length 8", reg);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
973
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
974 setup_ccl_program (&ccl, ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
975 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
976 ccl.reg[i] = (INTP (XVECTOR_DATA (reg)[i])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
977 ? XINT (XVECTOR_DATA (reg)[i])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
978 : 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
979
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
980 ccl_driver (&ccl, (CONST unsigned char *)0, (unsigned_char_dynarr *)0,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
981 0, (int *)0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
982 QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
983 if (ccl.status != CCL_STAT_SUCCESS)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
984 error ("Error in CCL program at %dth code", ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
985
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
986 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
987 XSETINT (XVECTOR_DATA (reg)[i], ccl.reg[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
988 return Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
989 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
990
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
991 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string, 3, 4, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
992 Execute CCL-PROGRAM with initial STATUS on STRING.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
993 CCL-PROGRAM is a compiled code generated by `ccl-compile'.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
994 Read buffer is set to STRING, and write buffer is allocated automatically.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
995 STATUS is a vector of [R0 R1 ... R7 IC], where
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
996 R0..R7 are initial values of corresponding registers,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
997 IC is the instruction counter specifying from where to start the program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
998 If R0..R7 are nil, they are initialized to 0.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
999 If IC is nil, it is initialized to head of the CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1000 Returns the contents of write buffer as a string,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1001 and as side effect, STATUS is updated.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1002 If optional 4th arg CONTINUE is non-nil, keep IC on read operation
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1003 when read buffer is exausted, else, IC is always set to the end of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1004 CCL-PROGRAM on exit.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1005 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1006 (ccl_prog, status, str, contin))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1007 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1008 Lisp_Object val;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1009 struct ccl_program ccl;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1010 int i, produced;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1011 unsigned_char_dynarr *outbuf;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1012 struct gcpro gcpro1, gcpro2, gcpro3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1013
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1014 CHECK_VECTOR (ccl_prog);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1015 CHECK_VECTOR (status);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1016 if (XVECTOR_LENGTH (status) != 9)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
1017 signal_simple_error ("Vector should be of length 9", status);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1018 CHECK_STRING (str);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1019 GCPRO3 (ccl_prog, status, str);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1020
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1021 setup_ccl_program (&ccl, ccl_prog);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1022 for (i = 0; i < 8; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1023 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1024 if (NILP (XVECTOR_DATA (status)[i]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1025 XSETINT (XVECTOR_DATA (status)[i], 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1026 if (INTP (XVECTOR_DATA (status)[i]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1027 ccl.reg[i] = XINT (XVECTOR_DATA (status)[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1028 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1029 if (INTP (XVECTOR_DATA (status)[8]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1030 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1031 i = XINT (XVECTOR_DATA (status)[8]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1032 if (ccl.ic < i && i < ccl.size)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1033 ccl.ic = i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1034 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1035 outbuf = Dynarr_new (unsigned_char);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1036 ccl.last_block = NILP (contin);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1037 produced = ccl_driver (&ccl, XSTRING_DATA (str), outbuf,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1038 XSTRING_LENGTH (str), (int *)0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1039 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1040 XVECTOR_DATA (status)[i] = make_int(ccl.reg[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1041 XSETINT (XVECTOR_DATA (status)[8], ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1042 UNGCPRO;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1043
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1044 val = make_string (Dynarr_atp (outbuf, 0), produced);
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
1045 Dynarr_free (outbuf);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1046 QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1047 if (ccl.status != CCL_STAT_SUCCESS
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1048 && ccl.status != CCL_STAT_SUSPEND)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1049 error ("Error in CCL program at %dth code", ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1050
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1051 return val;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1052 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1053
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1054 DEFUN ("register-ccl-program", Fregister_ccl_program, 2, 2, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1055 Register CCL program PROGRAM of NAME in `ccl-program-table'.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1056 PROGRAM should be a compiled code of CCL program, or nil.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1057 Return index number of the registered CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1058 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1059 (name, ccl_prog))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1060 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1061 int len = XVECTOR_LENGTH (Vccl_program_table);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1062 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1063
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1064 CHECK_SYMBOL (name);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1065 if (!NILP (ccl_prog))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1066 CHECK_VECTOR (ccl_prog);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
1067
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1068 for (i = 0; i < len; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1069 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1070 Lisp_Object slot = XVECTOR_DATA (Vccl_program_table)[i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1071
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1072 if (!CONSP (slot))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1073 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1074
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1075 if (EQ (name, XCAR (slot)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1076 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1077 XCDR (slot) = ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1078 return make_int (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1079 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1080 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1081
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1082 if (i == len)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1083 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1084 Lisp_Object new_table = Fmake_vector (make_int (len * 2), Qnil);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1085 int j;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1086
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1087 for (j = 0; j < len; j++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1088 XVECTOR_DATA (new_table)[j]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1089 = XVECTOR_DATA (Vccl_program_table)[j];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1090 Vccl_program_table = new_table;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1091 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1092
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1093 XVECTOR_DATA (Vccl_program_table)[i] = Fcons (name, ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1094 return make_int (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1095 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1096
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1097 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1098 syms_of_mule_ccl (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1099 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1100 staticpro (&Vccl_program_table);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1101 Vccl_program_table = Fmake_vector (make_int (32), Qnil);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1102
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1103 DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1104 Alist of fontname patterns vs corresponding CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1105 Each element looks like (REGEXP . CCL-CODE),
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1106 where CCL-CODE is a compiled CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1107 When a font whose name matches REGEXP is used for displaying a character,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1108 CCL-CODE is executed to calculate the code point in the font
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1109 from the charset number and position code(s) of the character which are set
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1110 in CCL registers R0, R1, and R2 before the execution.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1111 The code point in the font is set in CCL registers R1 and R2
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1112 when the execution terminated.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1113 If the font is single-byte font, the register R2 is not used.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1114 */ );
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1115 Vfont_ccl_encoder_alist = Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1116
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1117 DEFSUBR (Fccl_execute);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1118 DEFSUBR (Fccl_execute_on_string);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1119 DEFSUBR (Fregister_ccl_program);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1120 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1121
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1122 #endif /* emacs */