annotate src/mule-ccl.c @ 235:85a06df23a9a r20-5b16

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