annotate src/mule-ccl.c @ 5909:d138e600aa3a

Placate the C++ compiler, read_rational(). src/ChangeLog addition: 2015-05-09 Aidan Kehoe <kehoea@parhasard.net> * lread.c (read_rational): Cast the call to memchr() here to placate the C++ compiler.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 09 May 2015 01:23:45 +0100
parents 56144c8593a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* CCL (Code Conversion Language) interpreter.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
3 Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Licensed to the Free Software Foundation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 565
diff changeset
6 This file is part of XEmacs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
8 XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
9 under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
10 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
11 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
16 for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
21 /* Synched up with : FSF Emacs 21.0.90 except TranslateCharacter */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <config.h>
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
24 #include "lisp.h"
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
25
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "buffer.h"
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
27 #include "charset.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "mule-ccl.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "file-coding.h"
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
30 #include "elhash.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
565
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
32 Lisp_Object Qccl_error;
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
33
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 /* This contains all code conversion map available to CCL. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 Lisp_Object Vcode_conversion_map_vector;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
37 /* This symbol is a property which associates with ccl program vector.
3452
551c008d3777 [xemacs-hg @ 2006-06-14 06:10:08 by aidan]
aidan
parents: 3439
diff changeset
38 Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector.
551c008d3777 [xemacs-hg @ 2006-06-14 06:10:08 by aidan]
aidan
parents: 3439
diff changeset
39 Moved to general-slots.h. */
551c008d3777 [xemacs-hg @ 2006-06-14 06:10:08 by aidan]
aidan
parents: 3439
diff changeset
40 /* Lisp_Object Qccl_program; */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 /* These symbols are properties which associate with code conversion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 map and their ID respectively. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 Lisp_Object Qcode_conversion_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Lisp_Object Qcode_conversion_map_id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 /* Symbols of ccl program have this property, a value of the property
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
48 is an index for Vccl_program_table. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 Lisp_Object Qccl_program_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
51 /* Table of registered CCL programs. Each element is a vector of
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
52 NAME, CCL_PROG, and RESOLVEDP where NAME (symbol) is the name of
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
53 the program, CCL_PROG (vector) is the compiled code of the program,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
54 RESOLVEDP (t or nil) is the flag to tell if symbols in CCL_PROG is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
55 already resolved to index numbers or not. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 Lisp_Object Vccl_program_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
58 /* Vector of registered hash tables for translation. */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
59 Lisp_Object Vtranslation_hash_table_vector;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
60
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
61 /* Return a hash table of id number ID. */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
62 #define GET_HASH_TABLE(id) \
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
63 (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
64 /* Copied from fns.c. */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
65 #define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
66
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 /* CCL (Code Conversion Language) is a simple language which has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 operations on one input buffer, one output buffer, and 7 registers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 The syntax of CCL is described in `ccl.el'. Emacs Lisp function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 `ccl-compile' compiles a CCL program and produces a CCL code which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 is a vector of integers. The structure of this vector is as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 follows: The 1st element: buffer-magnification, a factor for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 size of output buffer compared with the size of input buffer. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 2nd element: address of CCL code to be executed when encountered
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 with end of input stream. The 3rd and the remaining elements: CCL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 codes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 /* Header of CCL compiled code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #define CCL_HEADER_BUF_MAG 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #define CCL_HEADER_EOF 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define CCL_HEADER_MAIN 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 /* CCL code is a sequence of 28-bit non-negative integers (i.e. the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 MSB is always 0), each contains CCL command and/or arguments in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 following format:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 |----------------- integer (28-bit) ------------------|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 |--constant argument--|-register-|-register-|-command-|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ccccccccccccccccc RRR rrr XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 |------- relative address -------|-register-|-command-|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 cccccccccccccccccccc rrr XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 |------------- constant or other args ----------------|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 cccccccccccccccccccccccccccc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 where, `cc...c' is a non-negative integer indicating constant value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (the left most `c' is always 0) or an absolute jump address, `RRR'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 and `rrr' are CCL register number, `XXXXX' is one of the following
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 CCL commands. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 /* CCL commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 Each comment fields shows one or more lines for command syntax and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 the following lines for semantics of the command. In semantics, IC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 stands for Instruction Counter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #define CCL_SetRegister 0x00 /* Set register a register value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 1:00000000000000000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 reg[rrr] = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 #define CCL_SetShortConst 0x01 /* Set register a short constant value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 reg[rrr] = CCCCCCCCCCCCCCCCCCC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 #define CCL_SetConst 0x02 /* Set register a constant value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 1:00000000000000000000rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 reg[rrr] = CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 #define CCL_SetArray 0x03 /* Set register an element of array:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 1:CCCCCCCCCCCCCCCCCRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 2:ELEMENT[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 3:ELEMENT[1]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 if (0 <= reg[RRR] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 reg[rrr] = ELEMENT[reg[RRR]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 IC += CC..C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 #define CCL_Jump 0x04 /* Jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 1:A--D--D--R--E--S--S-000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 /* Note: If CC..C is greater than 0, the second code is omitted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 #define CCL_JumpCond 0x05 /* Jump conditional:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #define CCL_WriteRegisterJump 0x06 /* Write register and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 write (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 #define CCL_WriteRegisterReadJump 0x07 /* Write register, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 2:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 write (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 second code (YYYYY == CCL_ReadJump). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #define CCL_WriteConstJump 0x08 /* Write constant and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 1:A--D--D--R--E--S--S-000XXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
177 2:CONST
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 ------------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
179 write (CONST);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 1:A--D--D--R--E--S--S-rrrXXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
185 2:CONST
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 3:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 -----------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
188 write (CONST);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 second code (YYYYY == CCL_ReadJump). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 #define CCL_WriteStringJump 0x0A /* Write string and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 1:A--D--D--R--E--S--S-000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 2:LENGTH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 3:0000STRIN[0]STRIN[1]STRIN[2]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 write_string (STRING, LENGTH);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 2:LENGTH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 3:ELEMENET[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 4:ELEMENET[1]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 N:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 if (0 <= reg[rrr] < LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 write (ELEMENT[reg[rrr]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 IC += LENGTH + 2; (... pointing at N+1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 Nth code (YYYYY == CCL_ReadJump). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 #define CCL_ReadJump 0x0C /* Read and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 1:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 #define CCL_Branch 0x0D /* Jump by branch table:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 2:A--D--D--R--E-S-S[0]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 3:A--D--D--R--E-S-S[1]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 IC += ADDRESS[reg[rrr]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 IC += ADDRESS[CC..C];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 #define CCL_ReadRegister 0x0E /* Read bytes into registers:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 2:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 while (CCC--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 #define CCL_WriteExprConst 0x0F /* write result of expression:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 1:00000OPERATION000RRR000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 write (reg[RRR] OPERATION CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 /* Note: If the Nth read is suspended, the resumed execution starts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 from the Nth code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 #define CCL_ReadBranch 0x10 /* Read one byte into a register,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 and jump by branch table:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 2:A--D--D--R--E-S-S[0]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 3:A--D--D--R--E-S-S[1]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 read (read[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 IC += ADDRESS[reg[rrr]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 IC += ADDRESS[CC..C];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 #define CCL_WriteRegister 0x11 /* Write registers:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 1:CCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 2:CCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 while (CCC--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 write (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 /* Note: If the Nth write is suspended, the resumed execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 starts from the Nth code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 #define CCL_WriteExprRegister 0x12 /* Write result of expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 1:00000OPERATIONRrrRRR000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 write (reg[RRR] OPERATION reg[Rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 #define CCL_Call 0x13 /* Call the CCL program whose ID is
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
296 CC..C or cc..c.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
297 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
298 [2:00000000cccccccccccccccccccc]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ------------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
300 if (FFF)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
301 call (cc..c)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
302 IC++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
303 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
304 call (CC..C)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 #define CCL_WriteConstString 0x14 /* Write a constant or a string:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 [2:0000STRIN[0]STRIN[1]STRIN[2]]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 [...]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 if (!rrr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 write (CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 write_string (STRING, CC..C);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 IC += (CC..C + 2) / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #define CCL_WriteArray 0x15 /* Write an element of array:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 2:ELEMENT[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 3:ELEMENT[1]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 write (ELEMENT[reg[rrr]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 IC += CC..C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 #define CCL_End 0x16 /* Terminate:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 1:00000000000000000000000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 terminate ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 /* The following two codes execute an assignment arithmetic/logical
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 operation. The form of the operation is like REG OP= OPERAND. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 #define CCL_ExprSelfConst 0x17 /* REG OP= constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 1:00000OPERATION000000rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 reg[rrr] OPERATION= CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 #define CCL_ExprSelfReg 0x18 /* REG1 OP= REG2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 1:00000OPERATION000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 reg[rrr] OPERATION= reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* The following codes execute an arithmetic/logical operation. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 form of the operation is like REG_X = REG_Y OP OPERAND2. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 #define CCL_SetExprConst 0x19 /* REG_X = REG_Y OP constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 1:00000OPERATION000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 reg[rrr] = reg[RRR] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 #define CCL_SetExprReg 0x1A /* REG1 = REG2 OP REG3:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 1:00000OPERATIONRrrRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 reg[rrr] = reg[RRR] OPERATION reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 #define CCL_JumpCondExprConst 0x1B /* Jump conditional according to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 an operation on constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 3:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 reg[7] = reg[rrr] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 if (!(reg[7]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 IC += 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 #define CCL_JumpCondExprReg 0x1C /* Jump conditional according to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 an operation on register:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 3:RRR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 reg[7] = reg[rrr] OPERATION reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 #define CCL_ReadJumpCondExprConst 0x1D /* Read and jump conditional according
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 to an operation on constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 3:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 reg[7] = reg[rrr] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 #define CCL_ReadJumpCondExprReg 0x1E /* Read and jump conditional according
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 to an operation on register:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 3:RRR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 reg[7] = reg[rrr] OPERATION reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
423 #define CCL_Extension 0x1F /* Extended CCL code
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 1:ExtendedCOMMNDRrrRRRrrrXXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
425 2:ARGUMENT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 3:...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 extended_command (rrr,RRR,Rrr,ARGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 Here after, Extended CCL Instructions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 Bit length of extended command is 14.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 Therefore, the instruction code range is 0..16384(0x3fff).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 /* Read a multibyte characeter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 A code point is stored into reg[rrr]. A charset ID is stored into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 reg[RRR]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 #define CCL_ReadMultibyteChar2 0x00 /* Read Multibyte Character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 /* Write a multibyte character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 Write a character whose code point is reg[rrr] and the charset ID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 is reg[RRR]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 /* Translate a character whose code point is reg[rrr] and the charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 ID is reg[RRR] by a translation table whose ID is reg[Rrr].
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 A translated character is set in reg[rrr] (code point) and reg[RRR]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (charset ID). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 #define CCL_TranslateCharacter 0x02 /* Translate a multibyte character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 /* Translate a character whose code point is reg[rrr] and the charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 ID is reg[RRR] by a translation table whose ID is ARGUMENT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 A translated character is set in reg[rrr] (code point) and reg[RRR]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (charset ID). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 #define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 1:ExtendedCOMMNDRrrRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 2:ARGUMENT(Translation Table ID)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 */
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
470 /* Translate a character whose code point is reg[rrr] and charset ID is
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
471 reg[RRR], into its Unicode code point, which will be written into
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
472 reg[rrr]. */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
473
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
474 #define CCL_MuleToUnicode 0x04
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
475
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
476 /* Translate a Unicode code point, in reg[rrr], into a Mule character,
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
477 writing the charset ID into reg[RRR] and the code point into reg[Rrr]. */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
478
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
479 #define CCL_UnicodeToMule 0x05
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 /* Iterate looking up MAPs for reg[rrr] starting from the Nth (N =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 reg[RRR]) MAP until some value is found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 Each MAP is a Lisp vector whose element is number, nil, t, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 lambda.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 If the element is nil, ignore the map and proceed to the next map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 If the element is t or lambda, finish without changing reg[rrr].
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 If the element is a number, set reg[rrr] to the number and finish.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
490 Detail of the map structure is described in the comment for
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 CCL_MapMultiple below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 #define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 2:NUMBER of MAPs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 3:MAP-ID1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 4:MAP-ID2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 ...
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
499 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 /* Map the code in reg[rrr] by MAPs starting from the Nth (N =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 reg[RRR]) map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 MAPs are supplied in the succeeding CCL codes as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 When CCL program gives this nested structure of map to this command:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 ((MAP-ID11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 MAP-ID12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (MAP-ID121 MAP-ID122 MAP-ID123)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 MAP-ID13)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 (MAP-ID21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (MAP-ID211 (MAP-ID2111) MAP-ID212)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 MAP-ID22)),
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
514 the compiled CCL code has this sequence:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 CCL_MapMultiple (CCL code of this command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 16 (total number of MAPs and SEPARATORs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 -7 (1st SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 MAP-ID11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 MAP-ID12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 -3 (2nd SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 MAP-ID121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 MAP-ID122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 MAP-ID123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 MAP-ID13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 -7 (3rd SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 MAP-ID21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 -4 (4th SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 MAP-ID211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 -1 (5th SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 MAP_ID2111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 MAP-ID212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 MAP-ID22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 A value of each SEPARATOR follows this rule:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (*)....Nest level of MAP-SET must not be over than MAX_MAP_SET_LEVEL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 When some map fails to map (i.e. it doesn't have a value for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 reg[rrr]), the mapping is treated as identity.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 The mapping is iterated for all maps in each map set (set of maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 separated by SEPARATOR) except in the case that lambda is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 encountered. More precisely, the mapping proceeds as below:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 At first, VAL0 is set to reg[rrr], and it is translated by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 first map to VAL1. Then, VAL1 is translated by the next map to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 VAL2. This mapping is iterated until the last map is used. The
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
550 result of the mapping is the last value of VAL?. When the mapping
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
551 process reached to the end of the map set, it moves to the next
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
552 map set. If the next does not exit, the mapping process terminates,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
553 and regard the last value as a result.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 But, when VALm is mapped to VALn and VALn is not a number, the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
556 mapping proceeds as follows:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 If VALn is nil, the lastest map is ignored and the mapping of VALm
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
559 proceeds to the next map.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 In VALn is t, VALm is reverted to reg[rrr] and the mapping of VALm
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
562 proceeds to the next map.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
564 If VALn is lambda, move to the next map set like reaching to the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
565 end of the current map set.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
566
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 5307
diff changeset
567 If VALn is a symbol, call the CCL program referred to by it.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
568 Then, use reg[rrr] as a mapped value except for -1, -2 and -3.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
569 Such special values are regarded as nil, t, and lambda respectively.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 Each map is a Lisp vector of the following format (a) or (b):
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 (a)......[STARTPOINT VAL1 VAL2 ...]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 (b)......[t VAL STARTPOINT ENDPOINT],
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 STARTPOINT is an offset to be used for indexing a map,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 ENDPOINT is a maximum index number of a map,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 VAL and VALn is a number, nil, t, or lambda.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 Valid index range of a map of type (a) is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 STARTPOINT <= index < STARTPOINT + map_size - 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 Valid index range of a map of type (b) is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 STARTPOINT <= index < ENDPOINT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 #define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 2:N-2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 3:SEPARATOR_1 (< 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 4:MAP-ID_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 5:MAP-ID_2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 M:SEPARATOR_x (< 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 M+1:MAP-ID_y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 N:SEPARATOR_z (< 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
596 #define MAX_MAP_SET_LEVEL 30
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 int rest_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 int orig_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 } tr_stack;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 static tr_stack mapping_stack[MAX_MAP_SET_LEVEL];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 static tr_stack *mapping_stack_pointer;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
606
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
607 /* If this variable is non-zero, it indicates the stack_idx
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
608 of immediately called by CCL_MapMultiple. */
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 444
diff changeset
609 static int stack_idx_of_map_multiple;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
610
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
611 #define PUSH_MAPPING_STACK(restlen, orig) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
612 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
613 mapping_stack_pointer->rest_length = (restlen); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
614 mapping_stack_pointer->orig_val = (orig); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
615 mapping_stack_pointer++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
616 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
617
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
618 #define POP_MAPPING_STACK(restlen, orig) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
619 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
620 mapping_stack_pointer--; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
621 (restlen) = mapping_stack_pointer->rest_length; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
622 (orig) = mapping_stack_pointer->orig_val; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
623 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
625 #define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
626 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
627 struct ccl_program called_ccl; \
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
628 /* We shouldn't ever call setup_ccl_program on a vector in \
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
629 this context: */ \
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
630 text_checking_assert (SYMBOLP (symbol)); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
631 if (stack_idx >= 256 \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
632 || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
633 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
634 if (stack_idx > 0) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
635 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
636 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
637 ic = ccl_prog_stack_struct[0].ic; \
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
638 eof_ic = ccl_prog_stack_struct[0].eof_ic; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
639 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
640 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
641 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
642 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
643 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
644 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
645 stack_idx++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
646 ccl_prog = called_ccl.prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
647 ic = CCL_HEADER_MAIN; \
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
648 eof_ic = XFIXNUM (ccl_prog[CCL_HEADER_EOF]); \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
649 /* The "if (1)" prevents warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
650 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
651 if (1) goto ccl_repeat; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
652 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 #define CCL_MapSingle 0x12 /* Map by single code conversion map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 2:MAP-ID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 Map reg[rrr] by MAP-ID.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 If some valid mapping is found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 set reg[rrr] to the result,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 set reg[RRR] to -1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
665 #define CCL_LookupIntConstTbl 0x13 /* Lookup multibyte character by
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
666 integer key. Afterwards R7 set
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
667 to 1 iff lookup succeeded.
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
668 1:ExtendedCOMMNDRrrRRRXXXXXXXX
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
669 2:ARGUMENT(Hash table ID) */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
670
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
671 #define CCL_LookupCharConstTbl 0x14 /* Lookup integer by multibyte
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
672 character key. Afterwards R7 set
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
673 to 1 iff lookup succeeded.
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
674 1:ExtendedCOMMNDRrrRRRrrrXXXXX
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
675 2:ARGUMENT(Hash table ID) */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
676
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
677
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 /* CCL arithmetic/logical operators. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 #define CCL_PLUS 0x00 /* X = Y + Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 #define CCL_MINUS 0x01 /* X = Y - Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 #define CCL_MUL 0x02 /* X = Y * Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 #define CCL_DIV 0x03 /* X = Y / Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 #define CCL_MOD 0x04 /* X = Y % Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 #define CCL_AND 0x05 /* X = Y & Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 #define CCL_OR 0x06 /* X = Y | Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 #define CCL_XOR 0x07 /* X = Y ^ Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 #define CCL_LSH 0x08 /* X = Y << Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 #define CCL_RSH 0x09 /* X = Y >> Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 #define CCL_LSH8 0x0A /* X = (Y << 8) | Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 #define CCL_RSH8 0x0B /* X = Y >> 8, r[7] = Y & 0xFF */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 #define CCL_DIVMOD 0x0C /* X = Y / Z, r[7] = Y % Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 #define CCL_LS 0x10 /* X = (X < Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 #define CCL_GT 0x11 /* X = (X > Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 #define CCL_EQ 0x12 /* X = (X == Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 #define CCL_LE 0x13 /* X = (X <= Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 #define CCL_GE 0x14 /* X = (X >= Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 #define CCL_NE 0x15 /* X = (X != Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 #define CCL_DECODE_SJIS 0x16 /* X = HIGHER_BYTE (DE-SJIS (Y, Z))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 r[7] = LOWER_BYTE (SJIS (Y, Z) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
704 /* Terminate CCL program successfully. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
705 #define CCL_SUCCESS \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
706 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
707 ccl->status = CCL_STAT_SUCCESS; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
708 /* The "if (1)" inhibits the warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
709 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
710 if (1) goto ccl_finish; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
711 } while (0)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
712
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 /* Suspend CCL program because of reading from empty input buffer or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 writing to full output buffer. When this program is resumed, the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
715 same I/O command is executed. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
716 #define CCL_SUSPEND(stat) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
717 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
718 ic--; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
719 ccl->status = (stat); \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
720 /* The "if (1)" inhibits the warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
721 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
722 if (1) goto ccl_finish; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
723 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 /* Terminate CCL program because of invalid command. Should not occur
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
726 in the normal case. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
727 #define CCL_INVALID_CMD \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
728 do { \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
729 ccl->status = CCL_STAT_INVALID_CMD; \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
730 /* enable this to debug invalid cmd errors */ \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
731 /* debug_break (); */ \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
732 /* The "if (1)" inhibits the warning \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
733 "end-of loop code not reached" */ \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
734 if (1) goto ccl_error_handler; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
735 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 /* Encode one character CH to multibyte form and write to the current
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
738 output buffer. At encoding time, if CH is less than 256, CH is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
739 written as is. At decoding time, if CH cannot be regarded as an
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
740 ASCII character, write it in multibyte form. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
741 #define CCL_WRITE_CHAR(ch) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
742 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
743 if (!destination) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
744 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
745 if (conversion_mode == CCL_MODE_ENCODING) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
746 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
747 if ((ch) == '\n') \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
748 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
749 if (ccl->eol_type == CCL_CODING_EOL_CRLF) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
750 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
751 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
752 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
753 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
754 else if (ccl->eol_type == CCL_CODING_EOL_CR) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
755 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
756 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
757 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
758 } \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
759 else if ((ch) < 0x100) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
760 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
761 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
762 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
763 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
764 { \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
765 Ibyte work[MAX_ICHAR_LEN]; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
766 int len; \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
767 len = non_ascii_set_itext_ichar (work, ch); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
768 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
769 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
770 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
771 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
772 { \
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
773 if (!ichar_multibyte_p(ch)) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
774 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
775 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
776 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
777 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
778 { \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
779 Ibyte work[MAX_ICHAR_LEN]; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
780 int len; \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
781 len = non_ascii_set_itext_ichar (work, ch); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
782 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
783 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
784 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
785 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 /* Write a string at ccl_prog[IC] of length LEN to the current output
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
788 buffer. But this macro treat this string as a binary. Therefore,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
789 cannot handle a multibyte string except for Control-1 characters. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
790 #define CCL_WRITE_STRING(len) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
791 do { \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
792 Ibyte work[MAX_ICHAR_LEN]; \
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
793 int ch; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
794 if (!destination) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
795 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
796 else if (conversion_mode == CCL_MODE_ENCODING) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
797 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
798 for (i = 0; i < (len); i++) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
799 { \
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
800 ch = ((XCHAR_OR_FIXNUM (ccl_prog[ic + (i / 3)])) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
801 >> ((2 - (i % 3)) * 8)) & 0xFF; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
802 if (ch == '\n') \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
803 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
804 if (ccl->eol_type == CCL_CODING_EOL_CRLF) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
805 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
806 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
807 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
808 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
809 else if (ccl->eol_type == CCL_CODING_EOL_CR) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
810 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
811 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
812 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
813 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
814 if (ch < 0x100) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
815 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
816 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
817 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
818 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
819 { \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
820 non_ascii_set_itext_ichar (work, ch); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
821 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
822 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
823 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
824 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
825 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
826 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
827 for (i = 0; i < (len); i++) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
828 { \
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
829 ch = ((XCHAR_OR_FIXNUM (ccl_prog[ic + (i / 3)])) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
830 >> ((2 - (i % 3)) * 8)) & 0xFF; \
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
831 if (!ichar_multibyte_p(ch)) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
832 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
833 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
834 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
835 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
836 { \
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 867
diff changeset
837 non_ascii_set_itext_ichar (work, ch); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
838 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
839 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
840 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
841 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
842 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 /* Read one byte from the current input buffer into Rth register. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
845 #define CCL_READ_CHAR(r) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
846 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
847 if (!src) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
848 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
849 if (src < src_end) \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
850 (r) = *src++; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
851 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
852 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
853 if (ccl->last_block) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
854 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
855 ic = ccl->eof_ic; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
856 goto ccl_repeat; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
857 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
858 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
859 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
860 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
861 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
862
2830
d7505a1267a4 [xemacs-hg @ 2005-06-26 19:05:05 by aidan]
aidan
parents: 2829
diff changeset
863 #define POSSIBLE_LEADING_BYTE_P(leading_byte) \
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
864 ((leading_byte >= MIN_LEADING_BYTE) && \
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
865 (leading_byte - MIN_LEADING_BYTE) < NUM_LEADING_BYTES)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
866
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
867 /* Set C to the character code made from CHARSET and CODE. This is
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
868 like make_ichar but check the validity of CHARSET and CODE. If they
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
869 are not valid, set C to (CODE & 0xFF) because that is usually the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
870 case that CCL_ReadMultibyteChar2 read an invalid code and it set
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
871 CODE to that invalid byte. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
872
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
873 /* On XEmacs, TranslateCharacter is not supported. Thus, this
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
874 macro is only used in the MuleToUnicode transformation. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
875 #define CCL_MAKE_CHAR(charset, code, c) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
876 do { \
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
877 \
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
878 if (!POSSIBLE_LEADING_BYTE_P(charset)) \
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
879 CCL_INVALID_CMD; \
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
880 \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
881 if ((charset) == LEADING_BYTE_ASCII) \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
882 { \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
883 c = (code) & 0xFF; \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
884 } \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
885 else if ((charset) == LEADING_BYTE_CONTROL_1) \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
886 { \
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
887 c = ((code) & 0x1F) + 0x80; \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
888 } \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
889 else if (!NILP(charset_by_leading_byte(charset)) \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
890 && ((code) >= 32) \
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
891 && ((code) < 256 || ((code >> 7) & 0x7F) >= 32)) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
892 { \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
893 int c1, c2 = 0; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
894 \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
895 if ((code) < 256) \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
896 { \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
897 c1 = (code) & 0x7F; \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
898 c2 = 0; \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
899 } \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
900 else \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
901 { \
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
902 c1 = ((code) >> 7) & 0x7F; \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
903 c2 = (code) & 0x7F; \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
904 } \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
905 c = make_ichar (charset_by_leading_byte(charset), \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
906 c1, c2); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
907 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
908 else \
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
909 { \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
910 c = (code) & 0xFF; \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
911 } \
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
912 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
916 text goes to a place pointed by DESTINATION, the length of which
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
917 should not exceed DST_BYTES. The bytes actually processed is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
918 returned as *CONSUMED. The return value is the length of the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
919 resulting text. As a side effect, the contents of CCL registers
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 are updated. If SOURCE or DESTINATION is NULL, only operations on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 registers are permitted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 #define CCL_DEBUG_BACKTRACE_LEN 256
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
925 int ccl_backtrace_table[CCL_DEBUG_BACKTRACE_LEN];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 int ccl_backtrace_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 struct ccl_prog_stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 int ic; /* Instruction Counter. */
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
933 int eof_ic; /* Instruction Counter to jump on EOF. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
936 /* For the moment, we only support depth 256 of stack. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 static struct ccl_prog_stack ccl_prog_stack_struct[256];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 int
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
940 ccl_driver (struct ccl_program *ccl,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
941 const unsigned char *source,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
942 unsigned_char_dynarr *destination,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
943 int src_bytes,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
944 int *consumed,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
945 int conversion_mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
947 register int *reg = ccl->reg;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
948 register int ic = ccl->ic;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
949 register int code = -1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
950 register int field1, field2;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
951 register Lisp_Object *ccl_prog = ccl->prog;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
952 const unsigned char *src = source, *src_end = src + src_bytes;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
953 int jump_address;
5183
f283b08ff0c9 Avoid build failure, Apple's g++-4.0.1, Mac OS 10.4.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4967
diff changeset
954 int i = 0, j, op;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 int stack_idx = ccl->stack_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 /* Instruction counter of the current CCL code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 int this_ic = 0;
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
958 int eof_ic = ccl->eof_ic;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
959 int eof_hit = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
961 if (ic >= eof_ic)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 ic = CCL_HEADER_MAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
965 destination = NULL;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
966
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
967 /* Set mapping stack pointer. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
968 mapping_stack_pointer = mapping_stack;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 ccl_backtrace_idx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 for (;;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 ccl_repeat:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 ccl_backtrace_table[ccl_backtrace_idx++] = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 ccl_backtrace_idx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 ccl_backtrace_table[ccl_backtrace_idx] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 /* We can't just signal Qquit, instead break the loop as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 the whole data is processed. Don't reset Vquit_flag, it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 must be handled later at a safer place. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 if (consumed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 src = source + src_bytes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 ccl->status = CCL_STAT_QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 this_ic = ic;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
996 code = XCHAR_OR_FIXNUM (ccl_prog[ic]); ic++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 field2 = (code & 0xFF) >> 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 #define rrr field2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 #define RRR (field1 & 7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 #define Rrr ((field1 >> 3) & 7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 #define ADDR field1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 #define EXCMD (field1 >> 6)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 switch (code & 0x1F)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 case CCL_SetRegister: /* 00000000000000000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 reg[rrr] = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 reg[rrr] = field1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1017 reg[rrr] = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 j = field1 >> 3;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1024 /* #### it's non-obvious to me that we need these casts,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1025 but the left one was already there so clearly the intention
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1026 was an unsigned comparison. --ben */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1027 if ((unsigned int) i < (unsigned int) j)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1028 reg[rrr] = XCHAR_OR_FIXNUM (ccl_prog[ic + i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 ic += j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 case CCL_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1056 i = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1062 i = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1070 j = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 CCL_WRITE_STRING (j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 i = reg[rrr];
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1078 j = XCHAR_OR_FIXNUM (ccl_prog[ic]);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1079 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1080 if ((unsigned int) i < (unsigned int) j)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1082 i = XCHAR_OR_FIXNUM (ccl_prog[ic + 1 + i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 ic += j + 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 ic += ADDR - (j + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 /* fall through ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1099 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1100 if ((unsigned int) reg[rrr] < (unsigned int) field1)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1101 ic += XCHAR_OR_FIXNUM (ccl_prog[ic + reg[rrr]]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 else
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1103 ic += XCHAR_OR_FIXNUM (ccl_prog[ic + field1]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 if (!field1) break;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1111 code = XCHAR_OR_FIXNUM (ccl_prog[ic]); ic++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 field2 = (code & 0xFF) >> 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 i = reg[RRR];
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1120 j = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 op = field1 >> 6;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1122 jump_address = ic + 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 if (!field1) break;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1131 code = XCHAR_OR_FIXNUM (ccl_prog[ic]); ic++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 field2 = (code & 0xFF) >> 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 j = reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 op = field1 >> 6;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1142 jump_address = ic;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1145 case CCL_Call: /* 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 Lisp_Object slot;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1148 int prog_id;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1149
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1150 /* If FFF is nonzero, the CCL program ID is in the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1151 following code. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1152 if (rrr)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1153 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1154 prog_id = XCHAR_OR_FIXNUM (ccl_prog[ic]);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1155 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1156 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1157 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1158 prog_id = field1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 if (stack_idx >= 256
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1161 || prog_id < 0
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1162 || prog_id >= XVECTOR (Vccl_program_table)->size
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1163 || (slot = XVECTOR (Vccl_program_table)->contents[prog_id],
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1164 !VECTORP (slot))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1165 || !VECTORP (XVECTOR (slot)->contents[1]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 if (stack_idx > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 ic = ccl_prog_stack_struct[0].ic;
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1171 eof_ic = ccl_prog_stack_struct[0].eof_ic;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1173 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 ccl_prog_stack_struct[stack_idx].ic = ic;
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1178 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 stack_idx++;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1180 ccl_prog = XVECTOR (XVECTOR (slot)->contents[1])->contents;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 ic = CCL_HEADER_MAIN;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1182 eof_ic = XFIXNUM (ccl_prog[CCL_HEADER_EOF]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 if (!rrr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 CCL_WRITE_CHAR (field1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 CCL_WRITE_STRING (field1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 ic += (field1 + 2) / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 i = reg[rrr];
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1198 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1199 if ((unsigned int) i < (unsigned int) field1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1201 j = XCHAR_OR_FIXNUM (ccl_prog[ic + i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 CCL_WRITE_CHAR (j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 ic += field1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 case CCL_End: /* 0000000000000000000000XXXXX */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1208 if (stack_idx > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1210 stack_idx--;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 ic = ccl_prog_stack_struct[stack_idx].ic;
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1213 eof_ic = ccl_prog_stack_struct[stack_idx].eof_ic;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1214 if (eof_hit)
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1215 ic = eof_ic;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 if (src)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 src = src_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 /* ccl->ic should points to this command code again to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 suppress further processing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 ic--;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1223 CCL_SUCCESS;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1226 i = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 goto ccl_expr_self;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 ccl_expr_self:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 switch (op)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 case CCL_PLUS: reg[rrr] += i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 case CCL_MINUS: reg[rrr] -= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 case CCL_MUL: reg[rrr] *= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 case CCL_DIV: reg[rrr] /= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 case CCL_MOD: reg[rrr] %= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 case CCL_AND: reg[rrr] &= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 case CCL_OR: reg[rrr] |= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 case CCL_XOR: reg[rrr] ^= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 case CCL_LSH: reg[rrr] <<= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 case CCL_RSH: reg[rrr] >>= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 case CCL_LE: reg[rrr] = reg[rrr] <= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 case CCL_GE: reg[rrr] = reg[rrr] >= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 case CCL_NE: reg[rrr] = reg[rrr] != i; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1257 default: CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 i = reg[RRR];
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1263 j = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 jump_address = ++ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 j = reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 jump_address = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 i = reg[rrr];
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1279 op = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 jump_address = ic++ + ADDR;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1281 j = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 case CCL_JumpCondExprReg:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 i = reg[rrr];
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1290 op = XCHAR_OR_FIXNUM (ccl_prog[ic]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 jump_address = ic++ + ADDR;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1292 j = reg[XCHAR_OR_FIXNUM (ccl_prog[ic])];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 ccl_set_expr:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 switch (op)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 case CCL_PLUS: reg[rrr] = i + j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 case CCL_MINUS: reg[rrr] = i - j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 case CCL_MUL: reg[rrr] = i * j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 case CCL_DIV: reg[rrr] = i / j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 case CCL_MOD: reg[rrr] = i % j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 case CCL_AND: reg[rrr] = i & j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 case CCL_OR: reg[rrr] = i | j; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1306 case CCL_XOR: reg[rrr] = i ^ j;; break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 case CCL_LSH: reg[rrr] = i << j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 case CCL_RSH: reg[rrr] = i >> j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 case CCL_LSH8: reg[rrr] = (i << 8) | j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 case CCL_LS: reg[rrr] = i < j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 case CCL_GT: reg[rrr] = i > j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 case CCL_EQ: reg[rrr] = i == j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 case CCL_LE: reg[rrr] = i <= j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 case CCL_GE: reg[rrr] = i >= j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 case CCL_NE: reg[rrr] = i != j; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1318 case CCL_DECODE_SJIS:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1319 /* DECODE_SHIFT_JIS set MSB for internal format
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1320 as opposed to Emacs. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1321 DECODE_SHIFT_JIS (i, j, reg[rrr], reg[7]);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1322 reg[rrr] &= 0x7F;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1323 reg[7] &= 0x7F;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1324 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1325 case CCL_ENCODE_SJIS:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1326 /* ENCODE_SHIFT_JIS assumes MSB of SHIFT-JIS-char is set
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1327 as opposed to Emacs. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1328 ENCODE_SHIFT_JIS (i | 0x80, j | 0x80, reg[rrr], reg[7]);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1329 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1330 default: CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 code &= 0x1F;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 CCL_WRITE_CHAR (i);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1337 ic = jump_address;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 else if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 ic = jump_address;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
1343 case CCL_Extension:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 switch (EXCMD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 case CCL_ReadMultibyteChar2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 if (!src)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 CCL_INVALID_CMD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1350 if (src >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1351 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1352 src++;
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
1353 goto ccl_read_multibyte_character_suspend;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1354 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1356 i = *src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1357 if (i < 0x80)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1358 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1359 /* ASCII */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1360 reg[rrr] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1361 reg[RRR] = LEADING_BYTE_ASCII;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1362 }
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1363 /* Previously, these next two elses were reversed in order,
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1364 which should have worked fine, but is more fragile than
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1365 this order. */
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1366 else if (LEADING_BYTE_CONTROL_1 == i)
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1367 {
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1368 if (src >= src_end)
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1369 goto ccl_read_multibyte_character_suspend;
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1370 reg[RRR] = i;
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1371 reg[rrr] = (*src++ - 0xA0);
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1372 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1373 else if (i <= MAX_LEADING_BYTE_OFFICIAL_1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1374 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1375 if (src >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1376 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1377 reg[RRR] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1378 reg[rrr] = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1379 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1380 else if (i <= MAX_LEADING_BYTE_OFFICIAL_2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1381 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1382 if ((src + 1) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1383 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1384 reg[RRR] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1385 i = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1386 reg[rrr] = ((i << 7) | (*src & 0x7F));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1387 src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1388 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1389 else if (i == PRE_LEADING_BYTE_PRIVATE_1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1390 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1391 if ((src + 1) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1392 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1393 reg[RRR] = *src++;
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1394 reg[rrr] = (*src++ & 0xFF);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1395 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1396 else if (i == PRE_LEADING_BYTE_PRIVATE_2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1397 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1398 if ((src + 2) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1399 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1400 reg[RRR] = *src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1401 i = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1402 reg[rrr] = ((i << 7) | (*src & 0x7F));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1403 src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1404 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1405 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1406 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1407 /* INVALID CODE. Return a single byte character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1408 reg[RRR] = LEADING_BYTE_ASCII;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1409 reg[rrr] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1410 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 ccl_read_multibyte_character_suspend:
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1414 if (src <= src_end && ccl->last_block)
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1415 {
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1416 /* #### Unclear when this happens. GNU use
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1417 CHARSET_8_BIT_CONTROL here, which we can't. */
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1418 if (i < 0x80)
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1419 {
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1420 reg[RRR] = LEADING_BYTE_ASCII;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1421 reg[rrr] = i;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1422 }
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1423 else if (i < 0xA0)
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1424 {
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1425 reg[RRR] = LEADING_BYTE_CONTROL_1;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1426 reg[rrr] = i - 0xA0;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1427 }
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1428 else
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1429 {
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1430 reg[RRR] = LEADING_BYTE_LATIN_ISO8859_1;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1431 reg[rrr] = i & 0x7F;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1432 }
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1433 break;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1434 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 src--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 if (ccl->last_block)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 {
4193
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1438 ic = eof_ic;
6438d53aabcf [xemacs-hg @ 2007-09-30 11:37:59 by aidan]
aidan
parents: 4150
diff changeset
1439 eof_hit = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 goto ccl_repeat;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 case CCL_WriteMultibyteChar2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 i = reg[RRR]; /* charset */
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1449 if (i == LEADING_BYTE_ASCII)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 i = reg[rrr] & 0xFF;
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1451 else if (LEADING_BYTE_CONTROL_1 == i)
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3452
diff changeset
1452 i = ((reg[rrr] & 0x1F) + 0x80);
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1453 else if (POSSIBLE_LEADING_BYTE_P(i) &&
2830
d7505a1267a4 [xemacs-hg @ 2005-06-26 19:05:05 by aidan]
aidan
parents: 2829
diff changeset
1454 !NILP(charset_by_leading_byte(i)))
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1455 {
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1456 if (XCHARSET_DIMENSION (charset_by_leading_byte (i)) == 1)
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1457 i = (((i - FIELD2_TO_OFFICIAL_LEADING_BYTE) << 7)
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1458 | (reg[rrr] & 0x7F));
4525
d64f1060cd65 Fix off-by-one error in ccl_driver. <87iqr7v7p0.fsf@uwakimon.sk.tsukuba.ac.jp>
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4295
diff changeset
1459 else if (i <= MAX_LEADING_BYTE_OFFICIAL_2)
2829
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1460 i = ((i - FIELD1_TO_OFFICIAL_LEADING_BYTE) << 14)
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1461 | reg[rrr];
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1462 else
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1463 i = ((i - FIELD1_TO_PRIVATE_LEADING_BYTE) << 14) | reg[rrr];
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1464 }
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1465 else
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1466 {
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1467 /* No charset we know about; use U+3012 GETA MARK */
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1468 i = make_ichar
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1469 (charset_by_leading_byte(LEADING_BYTE_JAPANESE_JISX0208),
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1470 34, 46);
714b354cef67 [xemacs-hg @ 2005-06-26 18:42:21 by aidan]
aidan
parents: 2712
diff changeset
1471 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1477 case CCL_TranslateCharacter:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 #if 0
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1479 /* XEmacs does not have translate_char, nor an
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1480 equivalent. We do nothing on this operation. */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1481 CCL_MAKE_CHAR(reg[RRR], reg[rrr], op);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 i, -1, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 SPLIT_CHAR (op, reg[RRR], i, j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 if (j != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 i = (i << 7) | j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1487
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 reg[rrr] = i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1489 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 case CCL_TranslateCharacterConstTbl:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1493 #if 0
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1494 /* XEmacs does not have translate_char or an equivalent. We
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1495 do nothing on this operation. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1496 op = XCHAR_OR_FIXNUM (ccl_prog[ic]); /* table */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 ic++;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1498 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 SPLIT_CHAR (op, reg[RRR], i, j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 if (j != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 i = (i << 7) | j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1503
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 reg[rrr] = i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1505 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1508 case CCL_MuleToUnicode:
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1509 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1510 Lisp_Object ucs;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1511
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1512 CCL_MAKE_CHAR (reg[rrr], reg[RRR], op);
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1513
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1514 ucs = Fchar_to_unicode(make_char(op));
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1515
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1516 if (NILP(ucs))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1517 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1518 /* Uhh, char-to-unicode doesn't return nil at the
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1519 moment, only ever -1. */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1520 reg[rrr] = 0xFFFD; /* REPLACEMENT CHARACTER */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1521 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1522 else
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1523 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1524 reg[rrr] = XCHAR_OR_FIXNUM(ucs);
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1525 if (-1 == reg[rrr])
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1526 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1527 reg[rrr] = 0xFFFD; /* REPLACEMENT CHARACTER */
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1528 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1529 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1530 break;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1531 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1532
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1533 case CCL_UnicodeToMule:
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1534 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1535 Lisp_Object scratch;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1536
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1537 scratch = Funicode_to_char(make_fixnum(reg[rrr]), Qnil);
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1538
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1539 if (!NILP(scratch))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1540 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1541 op = XCHAR(scratch);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1542 BREAKUP_ICHAR (op, scratch, i, j);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1543 reg[RRR] = XCHARSET_ID(scratch);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1544
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1545 if (j != 0)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1546 {
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1547 i = (i << 7) | j;
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1548 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1549
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1550 reg[rrr] = i;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1551 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1552 else
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1553 {
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1554 reg[rrr] = reg[RRR] = 0;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1555 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1556 break;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1557 }
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2830
diff changeset
1558
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1559 case CCL_LookupIntConstTbl:
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1560 op = XCHAR_OR_FIXNUM (ccl_prog[ic]); /* table */
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1561 ic++;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1562 {
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1563 struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1564 htentry *e = find_htentry(make_fixnum (reg[RRR]), h);
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1565 Lisp_Object scratch;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1566
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1567 if (!HTENTRY_CLEAR_P(e))
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1568 {
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1569 op = XCHARVAL (e->value);
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1570 if (!valid_ichar_p(op))
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1571 {
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1572 CCL_INVALID_CMD;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1573 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1574
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1575 BREAKUP_ICHAR (op, scratch, i, j);
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1576 reg[RRR] = XCHARSET_ID(scratch);
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1577
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1578 if (j != 0)
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1579 {
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1580 i = (i << 7) | j;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1581 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1582 reg[rrr] = i;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1583 reg[7] = 1; /* r7 true for success */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1584 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1585 else
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1586 reg[7] = 0;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1587 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1588 break;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1589
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1590 case CCL_LookupCharConstTbl:
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1591 op = XCHAR_OR_FIXNUM (ccl_prog[ic]); /* table */
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1592 ic++;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1593 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1594 {
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1595 struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1596 htentry *e = find_htentry(make_fixnum(i), h);
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1597
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1598 if (!HTENTRY_CLEAR_P(e))
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1599 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1600 if (!FIXNUMP (e->value))
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1601 CCL_INVALID_CMD;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1602 reg[RRR] = XCHAR_OR_FIXNUM (e->value);
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1603 reg[7] = 1; /* r7 true for success */
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1604 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1605 else
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1606 reg[7] = 0;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1607 }
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1608 break;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1609
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
1610
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 case CCL_IterateMultipleMap:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 Lisp_Object map, content, attrib, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 int point, size, fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1616 j = XCHAR_OR_FIXNUM (ccl_prog[ic++]); /* number of maps. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 fin_ic = ic + j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 op = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 if ((j > reg[RRR]) && (j >= 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 ic += reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 for (;i < j;i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 size = XVECTOR (Vcode_conversion_map_vector)->size;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1634 point = XCHAR_OR_FIXNUM (ccl_prog[ic++]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 if (point >= size) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 map =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 XVECTOR (Vcode_conversion_map_vector)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1639 /* Check map validity. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 if (!CONSP (map)) continue;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1641 map = XCDR (map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 if (!VECTORP (map)) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 size = XVECTOR (map)->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 if (size <= 1) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 content = XVECTOR (map)->contents[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 /* check map type,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 [STARTPOINT VAL1 VAL2 ...] or
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1650 [t ELEMENT STARTPOINT ENDPOINT] */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1651 if (FIXNUMP (content))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 point = XUINT (content);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 point = op - point + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 if (!((point >= 1) && (point < size))) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 content = XVECTOR (map)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 else if (EQ (content, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 if (size != 4) continue;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1661 /* #### see comment at CCL_SetArray; in this
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1662 case the casts are added but the XUINT was
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1663 already present */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1664 if (((unsigned int) op >=
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1665 XUINT (XVECTOR (map)->contents[2]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1666 && ((unsigned int) op <
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1667 XUINT (XVECTOR (map)->contents[3])))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 content = XVECTOR (map)->contents[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1672 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 if (NILP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 continue;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1677 else if (FIXNUMP (content))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 reg[RRR] = i;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1680 reg[rrr] = XCHAR_OR_FIXNUM(content);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 else if (EQ (content, Qt) || EQ (content, Qlambda))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 reg[RRR] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 else if (CONSP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1690 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1691 value = XCDR (content);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1692 if (!FIXNUMP (attrib) || !FIXNUMP (value))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 reg[RRR] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 reg[rrr] = XUINT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1698 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1699 CCL_CALL_FOR_MAP_INSTRUCTION (content, fin_ic);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1700 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1701 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 if (i == j)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1708
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 case CCL_MapMultiple:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 Lisp_Object map, content, attrib, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 int point, size, map_vector_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 int map_set_rest_length, fin_ic;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1714 int current_ic = this_ic;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1715
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1716 /* inhibit recursive call on MapMultiple. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1717 if (stack_idx_of_map_multiple > 0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1718 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1719 if (stack_idx_of_map_multiple <= stack_idx)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1720 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1721 stack_idx_of_map_multiple = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1722 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1723 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1724 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1725 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1726 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1727 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1728 stack_idx_of_map_multiple = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 map_set_rest_length =
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1731 XCHAR_OR_FIXNUM (ccl_prog[ic++]); /* number of maps and separators. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 fin_ic = ic + map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1733 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1734
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 if ((map_set_rest_length > reg[RRR]) && (reg[RRR] >= 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 ic += reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 map_set_rest_length -= i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 reg[RRR] = -1;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1745 mapping_stack_pointer = mapping_stack;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1748
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1749 if (mapping_stack_pointer <= (mapping_stack + 1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1751 /* Set up initial state. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1752 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1753 PUSH_MAPPING_STACK (0, op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1754 reg[RRR] = -1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1755 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1756 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1757 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1758 /* Recover after calling other ccl program. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1759 int orig_op;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1761 POP_MAPPING_STACK (map_set_rest_length, orig_op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1762 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1763 switch (op)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1765 case -1:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1766 /* Regard it as Qnil. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1767 op = orig_op;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1768 i++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1769 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1770 map_set_rest_length--;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1771 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1772 case -2:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1773 /* Regard it as Qt. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1774 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1775 i++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1776 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1777 map_set_rest_length--;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1778 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1779 case -3:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1780 /* Regard it as Qlambda. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1781 op = orig_op;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 i += map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1783 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1784 map_set_rest_length = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1785 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1786 default:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1787 /* Regard it as normal mapping. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 i += map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1789 ic += map_set_rest_length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1794 map_vector_size = XVECTOR (Vcode_conversion_map_vector)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1795
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1796 do {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1797 for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1798 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1799 point = XCHAR_OR_FIXNUM(ccl_prog[ic]);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1800 if (point < 0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1801 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1802 /* +1 is for including separator. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1803 point = -point + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1804 if (mapping_stack_pointer
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 456
diff changeset
1805 >= mapping_stack + countof (mapping_stack))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1806 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1807 PUSH_MAPPING_STACK (map_set_rest_length - point,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1808 reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1809 map_set_rest_length = point;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1810 reg[rrr] = op;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1811 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1812 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1813
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1814 if (point >= map_vector_size) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1815 map = (XVECTOR (Vcode_conversion_map_vector)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1816 ->contents[point]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1817
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1818 /* Check map validity. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1819 if (!CONSP (map)) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1820 map = XCDR (map);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1821 if (!VECTORP (map)) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1822 size = XVECTOR (map)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1823 if (size <= 1) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1824
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1825 content = XVECTOR (map)->contents[0];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1826
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1827 /* check map type,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1828 [STARTPOINT VAL1 VAL2 ...] or
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1829 [t ELEMENT STARTPOINT ENDPOINT] */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1830 if (FIXNUMP (content))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1831 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1832 point = XUINT (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1833 point = op - point + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1834 if (!((point >= 1) && (point < size))) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1835 content = XVECTOR (map)->contents[point];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1836 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1837 else if (EQ (content, Qt))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1838 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1839 if (size != 4) continue;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1840 /* #### see comment at CCL_SetArray; in this
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1841 case the casts are added but the XUINT was
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1842 already present */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1843 if (((unsigned int) op >=
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1844 XUINT (XVECTOR (map)->contents[2])) &&
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1845 ((unsigned int) op <
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1846 XUINT (XVECTOR (map)->contents[3])))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1847 content = XVECTOR (map)->contents[1];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1848 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1849 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1850 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1851 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1852 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1853
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1854 if (NILP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1855 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1856
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1857 reg[RRR] = i;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1858 if (FIXNUMP (content))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1859 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1860 op = XCHAR_OR_FIXNUM (content);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1861 i += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1862 ic += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1863 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1864 map_set_rest_length++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1865 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1866 else if (CONSP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1867 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1868 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1869 value = XCDR (content);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1870 if (!FIXNUMP (attrib) || !FIXNUMP (value))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1871 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1872 op = XUINT (value);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1873 i += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1874 ic += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1875 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1876 map_set_rest_length++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1877 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1878 else if (EQ (content, Qt))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1879 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1880 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1881 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1882 else if (EQ (content, Qlambda))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1883 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1884 i += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1885 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1886 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1887 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1888 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1889 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1890 if (mapping_stack_pointer
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 456
diff changeset
1891 >= mapping_stack + countof (mapping_stack))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1892 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1893 PUSH_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1894 PUSH_MAPPING_STACK (map_set_rest_length, op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1895 stack_idx_of_map_multiple = stack_idx + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1896 CCL_CALL_FOR_MAP_INSTRUCTION (content, current_ic);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1897 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1898 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1899 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1900 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1901 if (mapping_stack_pointer <= (mapping_stack + 1))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1902 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1903 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1904 i += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1905 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1906 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1907 } while (1);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1908
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 reg[rrr] = op;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 case CCL_MapSingle:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 Lisp_Object map, attrib, value, content;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 int size, point;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1918 j = XCHAR_OR_FIXNUM (ccl_prog[ic++]); /* map_id */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 op = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 if (j >= XVECTOR (Vcode_conversion_map_vector)->size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 map = XVECTOR (Vcode_conversion_map_vector)->contents[j];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 if (!CONSP (map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1931 map = XCDR (map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 if (!VECTORP (map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 size = XVECTOR (map)->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 point = XUINT (XVECTOR (map)->contents[0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 point = op - point + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 reg[RRR] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 if ((size <= 1) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 (!((point >= 1) && (point < size))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1946 reg[RRR] = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 content = XVECTOR (map)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 if (NILP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 reg[RRR] = -1;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1950 else if (FIXNUMP (content))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1951 reg[rrr] = XCHAR_OR_FIXNUM (content);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1952 else if (EQ (content, Qt));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 else if (CONSP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1955 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1956 value = XCDR (content);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
1957 if (!FIXNUMP (attrib) || !FIXNUMP (value))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 reg[rrr] = XUINT(value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1962 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1963 CCL_CALL_FOR_MAP_INSTRUCTION (content, ic);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1969
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 CCL_INVALID_CMD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 default:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1976 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 ccl_error_handler:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 if (destination)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 /* We can insert an error message only if DESTINATION is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 specified and we still have a room to store the message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 there. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 char msg[256];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 switch (ccl->status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 case CCL_STAT_INVALID_CMD:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 code & 0x1F, code, this_ic);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 int i = ccl_backtrace_idx - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003 if (ccl_backtrace_table[i] == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 sprintf(msg, " %d", ccl_backtrace_table[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 goto ccl_finish;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 case CCL_STAT_QUIT:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2014 sprintf(msg, "\nCCL: Exited.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 ccl_finish:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 ccl->ic = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 ccl->stack_idx = stack_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 ccl->prog = ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 if (consumed) *consumed = src - source;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2029 if (!destination)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 return 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2031 return Dynarr_length (destination);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2032 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2033
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2034 /* Resolve symbols in the specified CCL code (Lisp vector). This
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2035 function converts symbols of code conversion maps and character
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2036 translation tables embedded in the CCL code into their ID numbers.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2037
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2038 The return value is a vector (CCL itself or a new vector in which
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2039 all symbols are resolved), Qt if resolving of some symbol failed,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2040 or nil if CCL contains invalid data. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2041
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2042 static Lisp_Object
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2043 resolve_symbol_ccl_program (Lisp_Object ccl)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2044 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2045 int i, veclen, unresolved = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2046 Lisp_Object result, contents, val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2047
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2048 result = ccl;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2049 veclen = XVECTOR (result)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2050
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2051 for (i = 0; i < veclen; i++)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2052 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2053 contents = XVECTOR (result)->contents[i];
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2054 /* XEmacs change; accept characters as well as integers, on the basis
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2055 that most CCL code written doesn't make a distinction. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2056 if (FIXNUMP (contents) || CHARP(contents))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2057 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2058 else if (CONSP (contents)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2059 && SYMBOLP (XCAR (contents))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2060 && SYMBOLP (XCDR (contents)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2061 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2062 /* This is the new style for embedding symbols. The form is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2063 (SYMBOL . PROPERTY). (get SYMBOL PROPERTY) should give
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2064 an index number. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2065
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2066 if (EQ (result, ccl))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2067 result = Fcopy_sequence (ccl);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2068
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2069 val = Fget (XCAR (contents), XCDR (contents), Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2070 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2071 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2072 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2073 unresolved = 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2074 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2075 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2076 else if (SYMBOLP (contents))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2077 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2078 /* This is the old style for embedding symbols. This style
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2079 may lead to a bug if, for instance, a translation table
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2080 and a code conversion map have the same name. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2081 if (EQ (result, ccl))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2082 result = Fcopy_sequence (ccl);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2083
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2084 val = Fget (contents, Qcode_conversion_map_id, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2085 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2086 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2087 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2088 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2089 val = Fget (contents, Qccl_program_idx, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2090 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2091 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2092 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2093 unresolved = 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2094 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2095 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2096 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2097 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2098 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2099
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2100 return (unresolved ? Qt : result);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2101 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2102
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2103 /* Return the compiled code (vector) of CCL program CCL_PROG.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2104 CCL_PROG is a name (symbol) of the program or already compiled
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2105 code. If necessary, resolve symbols in the compiled code to index
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2106 numbers. If we failed to get the compiled code or to resolve
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2107 symbols, return Qnil. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2108
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2109 static Lisp_Object
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2110 ccl_get_compiled_code (Lisp_Object ccl_prog)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2111 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2112 Lisp_Object val, slot;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2113
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2114 if (VECTORP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2115 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2116 val = resolve_symbol_ccl_program (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2117 return (VECTORP (val) ? val : Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2118 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2119 if (!SYMBOLP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2120 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2121
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2122 val = Fget (ccl_prog, Qccl_program_idx, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2123 if (! NATNUMP (val)
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5183
diff changeset
2124 || -1 != bytecode_arithcompare (val, Flength (Vccl_program_table)))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2125 return Qnil;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2126 slot = XVECTOR_DATA (Vccl_program_table)[XFIXNUM (val)];
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2127 if (! VECTORP (slot)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2128 || XVECTOR (slot)->size != 3
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2129 || ! VECTORP (XVECTOR_DATA (slot)[1]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2130 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2131 if (NILP (XVECTOR_DATA (slot)[2]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2132 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2133 val = resolve_symbol_ccl_program (XVECTOR_DATA (slot)[1]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2134 if (! VECTORP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2135 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2136 XVECTOR_DATA (slot)[1] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2137 XVECTOR_DATA (slot)[2] = Qt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2138 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2139 return XVECTOR_DATA (slot)[1];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 /* Setup fields of the structure pointed by CCL appropriately for the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2143 execution of CCL program CCL_PROG. CCL_PROG is the name (symbol)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2144 of the CCL program or the already compiled code (vector).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2145 Return 0 if we succeed this setup, else return -1.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2146
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2147 If CCL_PROG is nil, we just reset the structure pointed by CCL. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2148 int
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2149 setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2151 xzero (*ccl); /* XEmacs change */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2152 if (! NILP (ccl_prog))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 {
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2154 Lisp_Object new_prog = ccl_get_compiled_code (ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2155
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2156 if (VECTORP (ccl_prog))
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2157 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2158 /* Make sure we're not allocating unreachable memory in this
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2159 function: */
4748
27b09b4219b1 Fix the union build, setup_ccl_program; thank you Robert Delius Royar.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4745
diff changeset
2160 assert (EQ (ccl_prog, new_prog));
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2161 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2162
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2163 ccl_prog = new_prog;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2164
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2165 if (! VECTORP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2166 return -1;
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2167
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2168 ccl->size = XVECTOR_LENGTH (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2169 ccl->prog = XVECTOR_DATA (ccl_prog);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2170 ccl->eof_ic = XFIXNUM (XVECTOR_DATA (ccl_prog)[CCL_HEADER_EOF]);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2171 ccl->buf_magnification = XFIXNUM (XVECTOR_DATA (ccl_prog)[CCL_HEADER_BUF_MAG]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 ccl->ic = CCL_HEADER_MAIN;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2174 ccl->eol_type = CCL_CODING_EOL_LF;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2175 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2178 static Lisp_Object
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2179 find_ccl_program (Lisp_Object object, int *unresolved_symbols)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2180 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2181 struct ccl_program test_ccl;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2182
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2183 if (NULL != unresolved_symbols)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2184 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2185 *unresolved_symbols = 0;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2186 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2187
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2188 if (VECTORP (object))
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2189 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2190 object = resolve_symbol_ccl_program (object);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2191 if (EQ (Qt, object))
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2192 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2193 if (NULL != unresolved_symbols)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2194 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2195 *unresolved_symbols = 1;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2196 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2197 return Qnil;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2198 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2199 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2200 else if (!SYMBOLP (object))
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2201 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2202 return Qnil;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2203 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2204
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2205 if (setup_ccl_program (&test_ccl, object) < 0)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2206 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2207 return Qnil;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2208 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2209
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2210 return object;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2211 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2212
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2213 Lisp_Object
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2214 get_ccl_program (Lisp_Object object)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2215 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2216 int unresolved_symbols = 0;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2217 Lisp_Object val = find_ccl_program (object, &unresolved_symbols);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2218
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2219 if (unresolved_symbols)
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2220 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2221 invalid_argument ("Unresolved symbol(s) in CCL program", object);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2222 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2223 else if (NILP (val))
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2224 {
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2225 invalid_argument ("Invalid CCL program", object);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2226 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2227
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2228 return val;
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2229 }
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2230
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2231 #ifdef emacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2233 DEFUN ("ccl-program-p", Fccl_program_p, 1, 1, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2234 Return t if OBJECT is a CCL program name or a compiled CCL program code.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2235 See the documentation of `define-ccl-program' for the detail of CCL program.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2236 */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2237 (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2238 {
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2239 return NILP (find_ccl_program (object, NULL)) ? Qnil : Qt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 DEFUN ("ccl-execute", Fccl_execute, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 Execute CCL-PROGRAM with registers initialized by REGISTERS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2245 CCL-PROGRAM is a CCL program name (symbol)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 or a compiled code generated by `ccl-compile' (for backward compatibility,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2247 in this case, the overhead of the execution is bigger than the former case).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 No I/O commands should appear in CCL-PROGRAM.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 REGISTERS is a vector of [R0 R1 ... R7] where RN is an initial value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 of Nth register.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2253 As side effect, each element of REGISTERS holds the value of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 corresponding register after the execution.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2255
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2256 See the documentation of `define-ccl-program' for the detail of CCL program.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2258 (ccl_prog, reg))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 struct ccl_program ccl;
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2261 struct gcpro gcpro1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2264 ccl_prog = get_ccl_program (ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2265 /* get_ccl_program may have consed. GCPROing shouldn't be necessary at the
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2266 moment, but maybe someday CCL will call Lisp: */
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2267 GCPRO1 (ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2268
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2269 i = setup_ccl_program (&ccl, ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2270
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2271 text_checking_assert (i >= 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 CHECK_VECTOR (reg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 if (XVECTOR_LENGTH (reg) != 8)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2275 syntax_error ("Length of vector REGISTERS is not 8", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 for (i = 0; i < 8; i++)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2278 ccl.reg[i] = (FIXNUMP (XVECTOR_DATA (reg)[i]) || CHARP (XVECTOR_DATA (reg)[i])
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2279 ? XCHAR_OR_FIXNUM (XVECTOR_DATA (reg)[i])
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 : 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2282 ccl_driver (&ccl, (const unsigned char *)0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2283 (unsigned_char_dynarr *)0, 0, (int *)0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2284 CCL_MODE_ENCODING);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 if (ccl.status != CCL_STAT_SUCCESS)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2287 signal_error (Qccl_error, "Error in CCL program at code numbered ...", make_fixnum (ccl.ic));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 for (i = 0; i < 8; i++)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2290 XVECTOR (reg)->contents[i] = make_fixnum (ccl.reg[i]);
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2291
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2292 RETURN_UNGCPRO (Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2295 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2296 3, 4, 0, /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 Execute CCL-PROGRAM with initial STATUS on STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 CCL-PROGRAM is a symbol registered by register-ccl-program,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300 or a compiled code generated by `ccl-compile' (for backward compatibility,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 in this case, the execution is slower).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 Read buffer is set to STRING, and write buffer is allocated automatically.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 STATUS is a vector of [R0 R1 ... R7 IC], where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 R0..R7 are initial values of corresponding registers,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 IC is the instruction counter specifying from where to start the program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 If R0..R7 are nil, they are initialized to 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 If IC is nil, it is initialized to head of the CCL program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 If optional 4th arg CONTINUE is non-nil, keep IC on read operation
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2312 when read buffer is exhausted, else, IC is always set to the end of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 CCL-PROGRAM on exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 It returns the contents of write buffer as a string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 and as side effect, STATUS is updated.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2317
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2318 See the documentation of `define-ccl-program' for the detail of CCL program.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2320 (ccl_prog, status, string, continue_))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 Lisp_Object val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 struct ccl_program ccl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324 int i, produced;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 unsigned_char_dynarr *outbuf;
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2326 struct gcpro gcpro1, gcpro2, gcpro3;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2328 ccl_prog = get_ccl_program (ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2329 i = setup_ccl_program (&ccl, ccl_prog);
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2330
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2331 text_checking_assert (i >= 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 CHECK_VECTOR (status);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2334 if (XVECTOR (status)->size != 9)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2335 syntax_error ("Length of vector STATUS is not 9", Qunbound);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2336 CHECK_STRING (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337
4745
0c54de4c4b9d Resolve the unregistered-CCL-programs-get-garbage-collected problem correctly
Aidan Kehoe <kehoea@parhasard.net>
parents: 4525
diff changeset
2338 GCPRO3 (status, string, ccl_prog);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2339
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 for (i = 0; i < 8; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 if (NILP (XVECTOR_DATA (status)[i]))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2343 XVECTOR_DATA (status)[i] = make_fixnum (0);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2344 if (FIXNUMP (XVECTOR_DATA (status)[i]))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2345 ccl.reg[i] = XFIXNUM (XVECTOR_DATA (status)[i]);
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2346 if (CHARP (XVECTOR_DATA (status)[i]))
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2347 ccl.reg[i] = XCHAR (XVECTOR_DATA (status)[i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 }
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2349 if (FIXNUMP (XVECTOR (status)->contents[i]) ||
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2350 CHARP (XVECTOR (status)->contents[i]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2352 i = XCHAR_OR_FIXNUM (XVECTOR_DATA (status)[8]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 if (ccl.ic < i && i < ccl.size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 ccl.ic = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 outbuf = Dynarr_new (unsigned_char);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2357 ccl.last_block = NILP (continue_);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2358 produced = ccl_driver (&ccl, XSTRING_DATA (string), outbuf,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2359 XSTRING_LENGTH (string),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2360 (int *) 0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2361 CCL_MODE_DECODING);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 for (i = 0; i < 8; i++)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2363 XVECTOR_DATA (status)[i] = make_fixnum (ccl.reg[i]);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2364 XVECTOR_DATA (status)[8] = make_fixnum (ccl.ic);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366
4967
0d4c9d0f6a8d rewrite dynarr code
Ben Wing <ben@xemacs.org>
parents: 4748
diff changeset
2367 val = make_string (Dynarr_begin (outbuf), produced);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 Dynarr_free (outbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 QUIT;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2370 if (ccl.status == CCL_STAT_SUSPEND_BY_DST)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2371 signal_error (Qccl_error, "Output buffer for the CCL programs overflow", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 if (ccl.status != CCL_STAT_SUCCESS
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2373 && ccl.status != CCL_STAT_SUSPEND_BY_SRC)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2374 signal_error (Qccl_error, "Error in CCL program at code numbered...", make_fixnum (ccl.ic));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2379 DEFUN ("register-ccl-program", Fregister_ccl_program,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2380 2, 2, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2381 Register CCL program CCL-PROG as NAME in `ccl-program-table'.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2382 CCL-PROG should be a compiled CCL program (vector), or nil.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2383 If it is nil, just reserve NAME as a CCL program name.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 Return index number of the registered CCL program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2386 (name, ccl_prog))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2388 int len = XVECTOR_LENGTH (Vccl_program_table);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2389 int idx;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2390 Lisp_Object resolved;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 CHECK_SYMBOL (name);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2393 resolved = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 if (!NILP (ccl_prog))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 CHECK_VECTOR (ccl_prog);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2397 resolved = resolve_symbol_ccl_program (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2398 if (! NILP (resolved))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2400 ccl_prog = resolved;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2401 resolved = Qt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2405 for (idx = 0; idx < len; idx++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2407 Lisp_Object slot;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2408
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2409 slot = XVECTOR_DATA (Vccl_program_table)[idx];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2410 if (!VECTORP (slot))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2411 /* This is the first unused slot. Register NAME here. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2412 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2413
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2414 if (EQ (name, XVECTOR_DATA (slot)[0]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2415 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2416 /* Update this slot. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2417 XVECTOR_DATA (slot)[1] = ccl_prog;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2418 XVECTOR_DATA (slot)[2] = resolved;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2419 return make_fixnum (idx);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2420 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2421 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2422
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2423 if (idx == len)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2424 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2425 /* Extend the table. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2426 Lisp_Object new_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2429 new_table = Fmake_vector (make_fixnum (len * 2), Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 for (j = 0; j < len; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 XVECTOR_DATA (new_table)[j]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 = XVECTOR_DATA (Vccl_program_table)[j];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 Vccl_program_table = new_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2436 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2437 Lisp_Object elt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2438
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2439 elt = Fmake_vector (make_fixnum (3), Qnil);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2440 XVECTOR_DATA (elt)[0] = name;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2441 XVECTOR_DATA (elt)[1] = ccl_prog;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2442 XVECTOR_DATA (elt)[2] = resolved;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2443 XVECTOR_DATA (Vccl_program_table)[idx] = elt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2444 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2445
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2446 Fput (name, Qccl_program_idx, make_fixnum (idx));
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2447 return make_fixnum (idx);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 /* Register code conversion map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 A code conversion map consists of numbers, Qt, Qnil, and Qlambda.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 The first element is start code point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 The rest elements are mapped numbers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 Symbol t means to map to an original number before mapping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 Symbol nil means that the corresponding element is empty.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2456 Symbol lambda means to terminate mapping here.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2460 2, 2, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2461 Register SYMBOL as code conversion map MAP.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2462 Return index number of the registered map.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2463 */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2464 (symbol, map))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2466 int len = XVECTOR_LENGTH (Vcode_conversion_map_vector);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 int i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2468 Lisp_Object idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2470 CHECK_SYMBOL (symbol);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2471 CHECK_VECTOR (map);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2472
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 for (i = 0; i < len; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2475 Lisp_Object slot = XVECTOR_DATA (Vcode_conversion_map_vector)[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 if (!CONSP (slot))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2480 if (EQ (symbol, XCAR (slot)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2482 idx = make_fixnum (i);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2483 XCDR (slot) = map;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 Fput (symbol, Qcode_conversion_map, map);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2485 Fput (symbol, Qcode_conversion_map_id, idx);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2486 return idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 if (i == len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2492 Lisp_Object new_vector = Fmake_vector (make_fixnum (len * 2), Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 for (j = 0; j < len; j++)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2496 XVECTOR_DATA (new_vector)[j]
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2497 = XVECTOR_DATA (Vcode_conversion_map_vector)[j];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 Vcode_conversion_map_vector = new_vector;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2501 idx = make_fixnum (i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 Fput (symbol, Qcode_conversion_map, map);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2503 Fput (symbol, Qcode_conversion_map_id, idx);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2504 XVECTOR_DATA (Vcode_conversion_map_vector)[i] = Fcons (symbol, map);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2505 return idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 syms_of_mule_ccl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 {
565
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
2512 DEFERROR_STANDARD (Qccl_error, Qconversion_error);
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
2513
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2514 DEFSUBR (Fccl_program_p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 DEFSUBR (Fccl_execute);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 DEFSUBR (Fccl_execute_on_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 DEFSUBR (Fregister_ccl_program);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2518 DEFSUBR (Fregister_code_conversion_map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2519 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2521 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2522 vars_of_mule_ccl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 {
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2524
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 staticpro (&Vccl_program_table);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2526 Vccl_program_table = Fmake_vector (make_fixnum (32), Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2528 #ifdef DEBUG_XEMACS
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2529 DEFVAR_LISP ("ccl-program-table",
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2530 &Vccl_program_table /*
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2531 Vector containing all registered CCL programs.
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2532 */ );
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2533 #endif
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2534 DEFSYMBOL (Qccl_program);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2535 DEFSYMBOL (Qccl_program_idx);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2536 DEFSYMBOL (Qcode_conversion_map);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2537 DEFSYMBOL (Qcode_conversion_map_id);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 DEFVAR_LISP ("code-conversion-map-vector", &Vcode_conversion_map_vector /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2540 Vector of code conversion maps.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2541 */ );
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5474
diff changeset
2542 Vcode_conversion_map_vector = Fmake_vector (make_fixnum (16), Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2544 DEFVAR_LISP ("translation-hash-table-vector",
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2545 &Vtranslation_hash_table_vector /*
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2546 Vector containing all translation hash tables ever defined.
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2547 Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2548 to `define-translation-hash-table'. The vector is indexed by the table id
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2549 used by CCL.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2550 */ );
4072
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2551 Vtranslation_hash_table_vector = Qnil;
aa28d959af41 [xemacs-hg @ 2007-07-22 22:03:29 by aidan]
aidan
parents: 3690
diff changeset
2552
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2553 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2555 #endif /* emacs */