annotate src/mule-ccl.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 11cf20601dec
children 6330739388db
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 /* Terminate CCL program successfully. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
440 #define CCL_SUCCESS \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
441 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
442 ccl->status = CCL_STAT_SUCCESS; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
443 ccl->ic = CCL_HEADER_MAIN; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
444 goto ccl_finish; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
445 } while (0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
446
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
447 /* Suspend CCL program because of reading from empty input buffer or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
448 writing to full output buffer. When this program is resumed, the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
449 same I/O command is executed. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
450 #define CCL_SUSPEND \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
451 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
452 ic--; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
453 ccl->status = CCL_STAT_SUSPEND; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
454 goto ccl_finish; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
455 } while (0)
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 /* Terminate CCL program because of invalid command. Should not occur
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
458 in the normal case. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
459 #define CCL_INVALID_CMD \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
460 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
461 ccl->status = CCL_STAT_INVALID_CMD; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
462 goto ccl_error_handler; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
463 } while (0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
464
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
465 /* Encode one character CH to multibyte form and write to the current
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
466 output buffer. If CH is less than 256, CH is written as is. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
467 #define CCL_WRITE_CHAR(ch) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
468 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
469 if (!destination) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
470 CCL_INVALID_CMD; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
471 else \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
472 { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
473 Bufbyte work[MAX_EMCHAR_LEN]; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
474 int len = set_charptr_emchar (work, ch); \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
475 Dynarr_add_many (destination, work, len); \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
476 } \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
477 } while (0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
478
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
479 /* 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
480 buffer. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
481 #define CCL_WRITE_STRING(len) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
482 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
483 if (!destination) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
484 CCL_INVALID_CMD; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
485 else \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
486 for (i = 0; i < len; i++) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
487 Dynarr_add(destination, (XINT (ccl_prog[ic + (i / 3)]) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
488 >> ((2 - (i % 3)) * 8)) & 0xFF); \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
489 } while (0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
490
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
491 /* Read one byte from the current input buffer into Rth register. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
492 #define CCL_READ_CHAR(r) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
493 do { \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
494 if (!src) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
495 CCL_INVALID_CMD; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
496 else if (src < src_end) \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
497 r = *src++; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
498 else if (ccl->last_block) \
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 ic = ccl->eof_ic; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
501 goto ccl_finish; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
502 } \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
503 else \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
504 CCL_SUSPEND; \
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
505 } while (0)
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
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
508 /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
509 text goes to a place pointed by DESTINATION. The bytes actually
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
510 processed is returned as *CONSUMED. The return value is the length
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
511 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
512 are updated. If SOURCE or DESTINATION is NULL, only operations on
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
513 registers are permitted. */
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 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
516 #define CCL_DEBUG_BACKTRACE_LEN 256
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
517 int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
518 int ccl_backtrace_idx;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
519 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
520
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
521 struct ccl_prog_stack
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
522 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
523 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
524 int ic; /* Instruction Counter. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
525 };
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
526
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
527 int
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
528 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
529 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
530 int *reg = ccl->reg;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
531 int ic = ccl->ic;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
532 int code = -1; /* init to illegal value, */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
533 int field1, field2;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
534 Lisp_Object *ccl_prog = ccl->prog;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
535 CONST unsigned char *src = source, *src_end = src + src_bytes;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
536 int jump_address = 0; /* shut up the compiler */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
537
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
538 int i, j, op;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
539 int stack_idx = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
540 /* For the moment, we only support depth 256 of stack. */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
541 struct ccl_prog_stack ccl_prog_stack_struct[256];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
542
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
543 if (ic >= ccl->eof_ic)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
544 ic = CCL_HEADER_MAIN;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
545
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
546 #ifdef CCL_DEBUG
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 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
549
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
550 for (;;)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
551 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
552 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
553 ccl_backtrace_table[ccl_backtrace_idx++] = ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
554 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
555 ccl_backtrace_idx = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
556 ccl_backtrace_table[ccl_backtrace_idx] = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
557 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
558
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
559 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
560 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
561 /* We can't just signal Qquit, instead break the loop as if
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
562 the whole data is processed. Don't reset Vquit_flag, it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
563 must be handled later at a safer place. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
564 if (consumed)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
565 src = source + src_bytes;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
566 ccl->status = CCL_STAT_QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
567 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
568 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
569
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
570 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
571 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
572 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
573
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
574 #define rrr field2
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
575 #define RRR (field1 & 7)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
576 #define Rrr ((field1 >> 3) & 7)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
577 #define ADDR field1
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
578
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
579 switch (code & 0x1F)
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_SetRegister: /* 00000000000000000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
582 reg[rrr] = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
583 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
584
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
585 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
586 reg[rrr] = field1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
587 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
588
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
589 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
590 reg[rrr] = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
591 ic++;
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_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
595 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
596 j = field1 >> 3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
597 if ((unsigned int) i < j)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
598 reg[rrr] = XINT (ccl_prog[ic + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
599 ic += j;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
600 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
601
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
602 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
603 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
604 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
605
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
606 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
607 if (!reg[rrr])
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
608 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
609 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
610
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
611 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
612 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
613 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
614 ic += ADDR;
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_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
618 i = reg[rrr];
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++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
621 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
622 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
623 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
624
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
625 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
626 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
627 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
628 ic += ADDR;
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_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
632 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
633 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
634 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
635 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
636 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
637 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
638
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
639 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
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 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
642 CCL_WRITE_STRING (j);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
643 ic += ADDR - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
644 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
645
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
646 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
647 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
648 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
649 if ((unsigned int) i < j)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
650 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
651 i = XINT (ccl_prog[ic + 1 + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
652 CCL_WRITE_CHAR (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
653 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
654 ic += j + 2;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
655 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
656 ic += ADDR - (j + 2);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
657 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
658
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
659 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
660 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
661 ic += ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
662 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
663
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
664 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
665 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
666 /* fall through ... */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
667 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
668 if ((unsigned int) reg[rrr] < field1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
669 ic += XINT (ccl_prog[ic + reg[rrr]]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
670 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
671 ic += XINT (ccl_prog[ic + field1]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
672 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
673
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
674 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
675 while (1)
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 CCL_READ_CHAR (reg[rrr]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
678 if (!field1) break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
679 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
680 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
681 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
682 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
683 break;
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_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
686 rrr = 7;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
687 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
688 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
689 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
690 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
691 goto ccl_set_expr;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
692
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
693 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
694 while (1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
695 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
696 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
697 CCL_WRITE_CHAR (i);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
698 if (!field1) break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
699 code = XINT (ccl_prog[ic]); ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
700 field1 = code >> 8;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
701 field2 = (code & 0xFF) >> 5;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
702 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
703 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
704
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
705 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
706 rrr = 7;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
707 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
708 j = reg[Rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
709 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
710 goto ccl_set_expr;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
711
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
712 case CCL_Call: /* CCCCCCCCCCCCCCCCCCCC000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
713 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
714 Lisp_Object slot;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
715
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
716 if (stack_idx >= 256
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
717 || field1 < 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
718 || field1 >= XVECTOR_LENGTH (Vccl_program_table)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
719 || (slot = XVECTOR_DATA (Vccl_program_table)[field1],
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
720 !CONSP (slot))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
721 || !VECTORP (XCDR (slot)))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
722 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
723 if (stack_idx > 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
724 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
725 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
726 ic = ccl_prog_stack_struct[0].ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
727 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
728 CCL_INVALID_CMD;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
729 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
730
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
731 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
732 ccl_prog_stack_struct[stack_idx].ic = ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
733 stack_idx++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
734 ccl_prog = XVECTOR_DATA (XCDR (slot));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
735 ic = CCL_HEADER_MAIN;
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 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
738
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
739 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
740 if (!rrr)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
741 CCL_WRITE_CHAR (field1);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
742 else
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
743 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
744 CCL_WRITE_STRING (field1);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
745 ic += (field1 + 2) / 3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
746 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
747 break;
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 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
750 i = reg[rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
751 if ((unsigned int) i < field1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
752 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
753 j = XINT (ccl_prog[ic + i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
754 CCL_WRITE_CHAR (j);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
755 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
756 ic += field1;
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
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
759 case CCL_End: /* 0000000000000000000000XXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
760 if (stack_idx-- > 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
761 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
762 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
763 ic = ccl_prog_stack_struct[stack_idx].ic;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
764 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
765 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
766 CCL_SUCCESS;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
767
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
768 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
769 i = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
770 ic++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
771 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
772 goto ccl_expr_self;
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 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
775 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
776 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
777
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
778 ccl_expr_self:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
779 switch (op)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
780 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
781 case CCL_PLUS: reg[rrr] += i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
782 case CCL_MINUS: reg[rrr] -= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
783 case CCL_MUL: reg[rrr] *= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
784 case CCL_DIV: reg[rrr] /= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
785 case CCL_MOD: reg[rrr] %= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
786 case CCL_AND: reg[rrr] &= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
787 case CCL_OR: reg[rrr] |= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
788 case CCL_XOR: reg[rrr] ^= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
789 case CCL_LSH: reg[rrr] <<= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
790 case CCL_RSH: reg[rrr] >>= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
791 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
792 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
793 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
794 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
795 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
796 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
797 case CCL_LE: reg[rrr] = reg[rrr] <= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
798 case CCL_GE: reg[rrr] = reg[rrr] >= i; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
799 case CCL_NE: reg[rrr] = reg[rrr] != i; break;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
800 default: CCL_INVALID_CMD;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
801 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
802 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
803
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
804 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
805 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
806 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
807 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
808 jump_address = ++ic;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
809 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
810
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
811 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
812 i = reg[RRR];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
813 j = reg[Rrr];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
814 op = field1 >> 6;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
815 jump_address = ic;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
816 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
817
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
818 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
819 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
820 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
821 i = reg[rrr];
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
822 op = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
823 jump_address = ic++ + ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
824 j = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
825 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
826 rrr = 7;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
827 goto ccl_set_expr;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
828
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
829 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
830 CCL_READ_CHAR (reg[rrr]);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
831 case CCL_JumpCondExprReg:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
832 i = reg[rrr];
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
833 op = XINT (ccl_prog[ic]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
834 jump_address = ic++ + ADDR;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
835 j = reg[XINT (ccl_prog[ic])];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
836 ic++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
837 rrr = 7;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
838
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
839 ccl_set_expr:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
840 switch (op)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
841 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
842 case CCL_PLUS: reg[rrr] = i + j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
843 case CCL_MINUS: reg[rrr] = i - j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
844 case CCL_MUL: reg[rrr] = i * j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
845 case CCL_DIV: reg[rrr] = i / j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
846 case CCL_MOD: reg[rrr] = i % j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
847 case CCL_AND: reg[rrr] = i & j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
848 case CCL_OR: reg[rrr] = i | j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
849 case CCL_XOR: reg[rrr] = i ^ j;; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
850 case CCL_LSH: reg[rrr] = i << j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
851 case CCL_RSH: reg[rrr] = i >> j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
852 case CCL_LSH8: reg[rrr] = (i << 8) | j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
853 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
854 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
855 case CCL_LS: reg[rrr] = i < j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
856 case CCL_GT: reg[rrr] = i > j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
857 case CCL_EQ: reg[rrr] = i == j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
858 case CCL_LE: reg[rrr] = i <= j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
859 case CCL_GE: reg[rrr] = i >= j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
860 case CCL_NE: reg[rrr] = i != j; break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
861 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
862 case CCL_DECODE_SJIS: DECODE_SJIS (i, j, reg[rrr], reg[7]); break;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
863 default: CCL_INVALID_CMD;
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:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
876 CCL_INVALID_CMD;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
877 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
878 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
879
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
880 ccl_error_handler:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
881 if (destination)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
882 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
883 /* We can insert an error message only if DESTINATION is
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
884 specified and we still have a room to store the message
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
885 there. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
886 char msg[256];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
887
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
888 switch (ccl->status)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
889 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
890 case CCL_STAT_INVALID_CMD:
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
891 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
892 code & 0x1F, code, ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
893 #ifdef CCL_DEBUG
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
894 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
895 int i = ccl_backtrace_idx - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
896 int j;
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 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
899
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
900 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
901 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
902 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
903 if (ccl_backtrace_table[i] == 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
904 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
905 sprintf(msg, " %d", ccl_backtrace_table[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
906 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
907 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
908 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
909 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
910 goto ccl_finish;
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 case CCL_STAT_QUIT:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
913 sprintf(msg, "\nCCL: Quited.");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
914 break;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
915
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
916 default:
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
917 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
918 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
919
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
920 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
921 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
922
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
923 ccl_finish:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
924 ccl->ic = ic;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
925 if (consumed) *consumed = src - source;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
926 if (destination)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
927 return Dynarr_length (destination);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
928 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
929 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
930 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
931
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
932 /* Setup fields of the structure pointed by CCL appropriately for the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
933 execution of compiled CCL code in VEC (vector of integer). */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
934 void
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 241
diff changeset
935 setup_ccl_program (struct ccl_program *ccl, Lisp_Object vec)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
936 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
937 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
938
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
939 ccl->size = XVECTOR_LENGTH (vec);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
940 ccl->prog = XVECTOR_DATA (vec);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
941 ccl->ic = CCL_HEADER_MAIN;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
942 ccl->eof_ic = XINT (XVECTOR_DATA (vec)[CCL_HEADER_EOF]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
943 ccl->buf_magnification = XINT (XVECTOR_DATA (vec)[CCL_HEADER_BUF_MAG]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
944 for (i = 0; i < 8; i++)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
945 ccl->reg[i] = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
946 ccl->last_block = 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
947 ccl->status = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
948 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
949
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
950 #ifdef emacs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
951
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
952 DEFUN ("ccl-execute", Fccl_execute, 2, 2, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
953 Execute CCL-PROGRAM with registers initialized by REGISTERS.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
954 CCL-PROGRAM is a compiled code generated by `ccl-compile',
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
955 no I/O commands should appear in the CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
956 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
957 of Nth register.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
958 As side effect, each element of REGISTER holds the value of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
959 corresponding register after the execution.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
960 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
961 (ccl_prog, reg))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
962 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
963 struct ccl_program ccl;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
964 int i;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
965
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
966 CHECK_VECTOR (ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
967 CHECK_VECTOR (reg);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
968 if (XVECTOR_LENGTH (reg) != 8)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
969 signal_simple_error ("Vector should be of length 8", reg);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
970
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
971 setup_ccl_program (&ccl, ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
972 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
973 ccl.reg[i] = (INTP (XVECTOR_DATA (reg)[i])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
974 ? XINT (XVECTOR_DATA (reg)[i])
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
975 : 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
976
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
977 ccl_driver (&ccl, (CONST unsigned char *)0, (unsigned_char_dynarr *)0,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
978 0, (int *)0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
979 QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
980 if (ccl.status != CCL_STAT_SUCCESS)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
981 error ("Error in CCL program at %dth code", ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
982
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
983 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
984 XSETINT (XVECTOR_DATA (reg)[i], ccl.reg[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
985 return Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
986 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
987
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
988 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string, 3, 4, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
989 Execute CCL-PROGRAM with initial STATUS on STRING.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
990 CCL-PROGRAM is a compiled code generated by `ccl-compile'.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
991 Read buffer is set to STRING, and write buffer is allocated automatically.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
992 STATUS is a vector of [R0 R1 ... R7 IC], where
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
993 R0..R7 are initial values of corresponding registers,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
994 IC is the instruction counter specifying from where to start the program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
995 If R0..R7 are nil, they are initialized to 0.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
996 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
997 Returns the contents of write buffer as a string,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
998 and as side effect, STATUS is updated.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
999 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
1000 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
1001 CCL-PROGRAM on exit.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1002 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1003 (ccl_prog, status, str, contin))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1004 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1005 Lisp_Object val;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1006 struct ccl_program ccl;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1007 int i, produced;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1008 unsigned_char_dynarr *outbuf;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1009 struct gcpro gcpro1, gcpro2, gcpro3;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1010
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1011 CHECK_VECTOR (ccl_prog);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1012 CHECK_VECTOR (status);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1013 if (XVECTOR_LENGTH (status) != 9)
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
1014 signal_simple_error ("Vector should be of length 9", status);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1015 CHECK_STRING (str);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1016 GCPRO3 (ccl_prog, status, str);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1017
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1018 setup_ccl_program (&ccl, ccl_prog);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1019 for (i = 0; i < 8; i++)
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 if (NILP (XVECTOR_DATA (status)[i]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1022 XSETINT (XVECTOR_DATA (status)[i], 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1023 if (INTP (XVECTOR_DATA (status)[i]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1024 ccl.reg[i] = XINT (XVECTOR_DATA (status)[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1025 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1026 if (INTP (XVECTOR_DATA (status)[8]))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1027 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1028 i = XINT (XVECTOR_DATA (status)[8]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1029 if (ccl.ic < i && i < ccl.size)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1030 ccl.ic = i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1031 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1032 outbuf = Dynarr_new (unsigned_char);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1033 ccl.last_block = NILP (contin);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1034 produced = ccl_driver (&ccl, XSTRING_DATA (str), outbuf,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1035 XSTRING_LENGTH (str), (int *)0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1036 for (i = 0; i < 8; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1037 XVECTOR_DATA (status)[i] = make_int(ccl.reg[i]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1038 XSETINT (XVECTOR_DATA (status)[8], ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1039 UNGCPRO;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1040
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1041 val = make_string (Dynarr_atp (outbuf, 0), produced);
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
1042 Dynarr_free (outbuf);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1043 QUIT;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1044 if (ccl.status != CCL_STAT_SUCCESS
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1045 && ccl.status != CCL_STAT_SUSPEND)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1046 error ("Error in CCL program at %dth code", ccl.ic);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1047
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1048 return val;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1049 }
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 DEFUN ("register-ccl-program", Fregister_ccl_program, 2, 2, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1052 Register CCL program PROGRAM of NAME in `ccl-program-table'.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1053 PROGRAM should be a compiled code of CCL program, or nil.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1054 Return index number of the registered CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1055 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1056 (name, ccl_prog))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1057 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1058 int len = XVECTOR_LENGTH (Vccl_program_table);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1059 int i;
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 CHECK_SYMBOL (name);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1062 if (!NILP (ccl_prog))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1063 CHECK_VECTOR (ccl_prog);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
1064
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1065 for (i = 0; i < len; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1066 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1067 Lisp_Object slot = XVECTOR_DATA (Vccl_program_table)[i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1068
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1069 if (!CONSP (slot))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1070 break;
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 (EQ (name, XCAR (slot)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1073 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1074 XCDR (slot) = ccl_prog;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1075 return make_int (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1076 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1077 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1078
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1079 if (i == len)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1080 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1081 Lisp_Object new_table = Fmake_vector (make_int (len * 2), Qnil);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1082 int j;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1083
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1084 for (j = 0; j < len; j++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1085 XVECTOR_DATA (new_table)[j]
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1086 = XVECTOR_DATA (Vccl_program_table)[j];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1087 Vccl_program_table = new_table;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1088 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1089
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1090 XVECTOR_DATA (Vccl_program_table)[i] = Fcons (name, ccl_prog);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1091 return make_int (i);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1092 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1093
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1094 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1095 syms_of_mule_ccl (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1096 {
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1097 staticpro (&Vccl_program_table);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1098 Vccl_program_table = Fmake_vector (make_int (32), Qnil);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1099
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1100 DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1101 Alist of fontname patterns vs corresponding CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1102 Each element looks like (REGEXP . CCL-CODE),
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1103 where CCL-CODE is a compiled CCL program.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1104 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
1105 CCL-CODE is executed to calculate the code point in the font
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1106 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
1107 in CCL registers R0, R1, and R2 before the execution.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1108 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
1109 when the execution terminated.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1110 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
1111 */ );
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1112 Vfont_ccl_encoder_alist = Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1113
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1114 DEFSUBR (Fccl_execute);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1115 DEFSUBR (Fccl_execute_on_string);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1116 DEFSUBR (Fregister_ccl_program);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1117 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1118
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1119 #endif /* emacs */