annotate src/mule-ccl.c @ 665:fdefd0186b75

[xemacs-hg @ 2001-09-20 06:28:42 by ben] The great integral types renaming. The purpose of this is to rationalize the names used for various integral types, so that they match their intended uses and follow consist conventions, and eliminate types that were not semantically different from each other. The conventions are: -- All integral types that measure quantities of anything are signed. Some people disagree vociferously with this, but their arguments are mostly theoretical, and are vastly outweighed by the practical headaches of mixing signed and unsigned values, and more importantly by the far increased likelihood of inadvertent bugs: Because of the broken "viral" nature of unsigned quantities in C (operations involving mixed signed/unsigned are done unsigned, when exactly the opposite is nearly always wanted), even a single error in declaring a quantity unsigned that should be signed, or even the even more subtle error of comparing signed and unsigned values and forgetting the necessary cast, can be catastrophic, as comparisons will yield wrong results. -Wsign-compare is turned on specifically to catch this, but this tends to result in a great number of warnings when mixing signed and unsigned, and the casts are annoying. More has been written on this elsewhere. -- All such quantity types just mentioned boil down to EMACS_INT, which is 32 bits on 32-bit machines and 64 bits on 64-bit machines. This is guaranteed to be the same size as Lisp objects of type `int', and (as far as I can tell) of size_t (unsigned!) and ssize_t. The only type below that is not an EMACS_INT is Hashcode, which is an unsigned value of the same size as EMACS_INT. -- Type names should be relatively short (no more than 10 characters or so), with the first letter capitalized and no underscores if they can at all be avoided. -- "count" == a zero-based measurement of some quantity. Includes sizes, offsets, and indexes. -- "bpos" == a one-based measurement of a position in a buffer. "Charbpos" and "Bytebpos" count text in the buffer, rather than bytes in memory; thus Bytebpos does not directly correspond to the memory representation. Use "Membpos" for this. -- "Char" refers to internal-format characters, not to the C type "char", which is really a byte. -- For the actual name changes, see the script below. I ran the following script to do the conversion. (NOTE: This script is idempotent. You can safely run it multiple times and it will not screw up previous results -- in fact, it will do nothing if nothing has changed. Thus, it can be run repeatedly as necessary to handle patches coming in from old workspaces, or old branches.) There are two tags, just before and just after the change: `pre-integral-type-rename' and `post-integral-type-rename'. When merging code from the main trunk into a branch, the best thing to do is first merge up to `pre-integral-type-rename', then apply the script and associated changes, then merge from `post-integral-type-change' to the present. (Alternatively, just do the merging in one operation; but you may then have a lot of conflicts needing to be resolved by hand.) Script `fixtypes.sh' follows: ----------------------------------- cut ------------------------------------ files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]" gr Memory_Count Bytecount $files gr Lstream_Data_Count Bytecount $files gr Element_Count Elemcount $files gr Hash_Code Hashcode $files gr extcount bytecount $files gr bufpos charbpos $files gr bytind bytebpos $files gr memind membpos $files gr bufbyte intbyte $files gr Extcount Bytecount $files gr Bufpos Charbpos $files gr Bytind Bytebpos $files gr Memind Membpos $files gr Bufbyte Intbyte $files gr EXTCOUNT BYTECOUNT $files gr BUFPOS CHARBPOS $files gr BYTIND BYTEBPOS $files gr MEMIND MEMBPOS $files gr BUFBYTE INTBYTE $files gr MEMORY_COUNT BYTECOUNT $files gr LSTREAM_DATA_COUNT BYTECOUNT $files gr ELEMENT_COUNT ELEMCOUNT $files gr HASH_CODE HASHCODE $files ----------------------------------- cut ------------------------------------ `fixtypes.sh' is a Bourne-shell script; it uses 'gr': ----------------------------------- cut ------------------------------------ #!/bin/sh # Usage is like this: # gr FROM TO FILES ... # globally replace FROM with TO in FILES. FROM and TO are regular expressions. # backup files are stored in the `backup' directory. from="$1" to="$2" shift 2 echo ${1+"$@"} | xargs global-replace "s/$from/$to/g" ----------------------------------- cut ------------------------------------ `gr' in turn uses a Perl script to do its real work, `global-replace', which follows: ----------------------------------- cut ------------------------------------ : #-*- Perl -*- ### global-modify --- modify the contents of a file by a Perl expression ## Copyright (C) 1999 Martin Buchholz. ## Copyright (C) 2001 Ben Wing. ## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org> ## Maintainer: Ben Wing <ben@xemacs.org> ## Current Version: 1.0, May 5, 2001 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XEmacs; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. eval 'exec perl -w -S $0 ${1+"$@"}' if 0; use strict; use FileHandle; use Carp; use Getopt::Long; use File::Basename; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode] PERLEXPR FILE ... Globally modify a file, either line by line or in one big hunk. Typical usage is like this: [with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc. in file names] find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n [with non-GNU print, xargs] find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n The file is read in, either line by line (with --line-mode specified) or in one big hunk (with --hunk-mode specified; it's the default), and the Perl expression is then evalled with \$_ set to the line or hunk of text, including the terminating newline if there is one. It should destructively modify the value there, storing the changed result in \$_. Files in which any modifications are made are backed up to the directory specified using --backup-dir, or to `backup' by default. To disable this, use --backup-dir= with no argument. Hunk mode is the default because it is MUCH MUCH faster than line-by-line. Use line-by-line only when it matters, e.g. you want to do a replacement only once per line (the default without the `g' argument). Conversely, when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one replacement in the entire file! "; my %options = (); $Getopt::Long::ignorecase = 0; &GetOptions ( \%options, 'help', 'backup-dir=s', 'line-mode', 'hunk-mode', ); die $usage if $options{"help"} or @ARGV <= 1; my $code = shift; die $usage if grep (-d || ! -w, @ARGV); sub SafeOpen { open ((my $fh = new FileHandle), $_[0]); confess "Can't open $_[0]: $!" if ! defined $fh; return $fh; } sub SafeClose { close $_[0] or confess "Can't close $_[0]: $!"; } sub FileContents { my $fh = SafeOpen ("< $_[0]"); my $olddollarslash = $/; local $/ = undef; my $contents = <$fh>; $/ = $olddollarslash; return $contents; } sub WriteStringToFile { my $fh = SafeOpen ("> $_[0]"); binmode $fh; print $fh $_[1] or confess "$_[0]: $!\n"; SafeClose $fh; } foreach my $file (@ARGV) { my $changed_p = 0; my $new_contents = ""; if ($options{"line-mode"}) { my $fh = SafeOpen $file; while (<$fh>) { my $save_line = $_; eval $code; $changed_p = 1 if $save_line ne $_; $new_contents .= $_; } } else { my $orig_contents = $_ = FileContents $file; eval $code; if ($_ ne $orig_contents) { $changed_p = 1; $new_contents = $_; } } if ($changed_p) { my $backdir = $options{"backup-dir"}; $backdir = "backup" if !defined ($backdir); if ($backdir) { my ($name, $path, $suffix) = fileparse ($file, ""); my $backfulldir = $path . $backdir; my $backfile = "$backfulldir/$name"; mkdir $backfulldir, 0755 unless -d $backfulldir; print "modifying $file (original saved in $backfile)\n"; rename $file, $backfile; } WriteStringToFile ($file, $new_contents); } } ----------------------------------- cut ------------------------------------ In addition to those programs, I needed to fix up a few other things, particularly relating to the duplicate definitions of types, now that some types merged with others. Specifically: 1. in lisp.h, removed duplicate declarations of Bytecount. The changed code should now look like this: (In each code snippet below, the first and last lines are the same as the original, as are all lines outside of those lines. That allows you to locate the section to be replaced, and replace the stuff in that section, verifying that there isn't anything new added that would need to be kept.) --------------------------------- snip ------------------------------------- /* Counts of bytes or chars */ typedef EMACS_INT Bytecount; typedef EMACS_INT Charcount; /* Counts of elements */ typedef EMACS_INT Elemcount; /* Hash codes */ typedef unsigned long Hashcode; /* ------------------------ dynamic arrays ------------------- */ --------------------------------- snip ------------------------------------- 2. in lstream.h, removed duplicate declaration of Bytecount. Rewrote the comment about this type. The changed code should now look like this: --------------------------------- snip ------------------------------------- #endif /* The have been some arguments over the what the type should be that specifies a count of bytes in a data block to be written out or read in, using Lstream_read(), Lstream_write(), and related functions. Originally it was long, which worked fine; Martin "corrected" these to size_t and ssize_t on the grounds that this is theoretically cleaner and is in keeping with the C standards. Unfortunately, this practice is horribly error-prone due to design flaws in the way that mixed signed/unsigned arithmetic happens. In fact, by doing this change, Martin introduced a subtle but fatal error that caused the operation of sending large mail messages to the SMTP server under Windows to fail. By putting all values back to be signed, avoiding any signed/unsigned mixing, the bug immediately went away. The type then in use was Lstream_Data_Count, so that it be reverted cleanly if a vote came to that. Now it is Bytecount. Some earlier comments about why the type must be signed: This MUST BE SIGNED, since it also is used in functions that return the number of bytes actually read to or written from in an operation, and these functions can return -1 to signal error. Note that the standard Unix read() and write() functions define the count going in as a size_t, which is UNSIGNED, and the count going out as an ssize_t, which is SIGNED. This is a horrible design flaw. Not only is it highly likely to lead to logic errors when a -1 gets interpreted as a large positive number, but operations are bound to fail in all sorts of horrible ways when a number in the upper-half of the size_t range is passed in -- this number is unrepresentable as an ssize_t, so code that checks to see how many bytes are actually written (which is mandatory if you are dealing with certain types of devices) will get completely screwed up. --ben */ typedef enum lstream_buffering --------------------------------- snip ------------------------------------- 3. in dumper.c, there are four places, all inside of switch() statements, where XD_BYTECOUNT appears twice as a case tag. In each case, the two case blocks contain identical code, and you should *REMOVE THE SECOND* and leave the first.
author ben
date Thu, 20 Sep 2001 06:31:11 +0000
parents b39c14581166
children 943eaba38521
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.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Licensed to the Free Software Foundation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 565
diff changeset
5 This file is part of XEmacs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 565
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 565
diff changeset
12 XEmacs is distributed in the hope that it will be useful,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 565
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
22 /* Synched up with : FSF Emacs 21.0.90 except TranslateCharacter */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
26 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
28 #include <stdio.h>
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
29
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
30 #ifdef emacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "mule-charset.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "mule-ccl.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "file-coding.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #else /* not emacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "mulelib.h"
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 #endif /* not emacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
565
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
44 Lisp_Object Qccl_error;
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
45
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 /* This contains all code conversion map available to CCL. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 Lisp_Object Vcode_conversion_map_vector;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 /* Alist of fontname patterns vs corresponding CCL program. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 Lisp_Object Vfont_ccl_encoder_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
52 /* This symbol is a property which associates with ccl program vector.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Lisp_Object Qccl_program;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 /* These symbols are properties which associate with code conversion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 map and their ID respectively. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 Lisp_Object Qcode_conversion_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Lisp_Object Qcode_conversion_map_id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* 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
62 is an index for Vccl_program_table. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 Lisp_Object Qccl_program_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
65 /* Table of registered CCL programs. Each element is a vector of
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
66 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
67 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
68 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
69 already resolved to index numbers or not. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 Lisp_Object Vccl_program_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 /* CCL (Code Conversion Language) is a simple language which has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 operations on one input buffer, one output buffer, and 7 registers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 The syntax of CCL is described in `ccl.el'. Emacs Lisp function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 `ccl-compile' compiles a CCL program and produces a CCL code which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 is a vector of integers. The structure of this vector is as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 follows: The 1st element: buffer-magnification, a factor for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 size of output buffer compared with the size of input buffer. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 2nd element: address of CCL code to be executed when encountered
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 with end of input stream. The 3rd and the remaining elements: CCL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 codes. */
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 /* Header of CCL compiled code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define CCL_HEADER_BUF_MAG 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define CCL_HEADER_EOF 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #define CCL_HEADER_MAIN 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 /* 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
89 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
90 following format:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 |----------------- integer (28-bit) ------------------|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 |--constant argument--|-register-|-register-|-command-|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 ccccccccccccccccc RRR rrr XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 |------- relative address -------|-register-|-command-|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 cccccccccccccccccccc rrr XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 |------------- constant or other args ----------------|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 cccccccccccccccccccccccccccc
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 where, `cc...c' is a non-negative integer indicating constant value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (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
105 and `rrr' are CCL register number, `XXXXX' is one of the following
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 CCL commands. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 /* CCL commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 Each comment fields shows one or more lines for command syntax and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 the following lines for semantics of the command. In semantics, IC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 stands for Instruction Counter. */
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 #define CCL_SetRegister 0x00 /* Set register a register value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 1:00000000000000000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 reg[rrr] = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 */
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 #define CCL_SetShortConst 0x01 /* Set register a short constant value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 reg[rrr] = CCCCCCCCCCCCCCCCCCC;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 #define CCL_SetConst 0x02 /* Set register a constant value:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 1:00000000000000000000rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 reg[rrr] = CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 */
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 #define CCL_SetArray 0x03 /* Set register an element of array:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 1:CCCCCCCCCCCCCCCCCRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 2:ELEMENT[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 3:ELEMENT[1]
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 if (0 <= reg[RRR] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 reg[rrr] = ELEMENT[reg[RRR]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 IC += CC..C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 */
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 #define CCL_Jump 0x04 /* Jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 1:A--D--D--R--E--S--S-000XXXXX
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 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 */
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 /* 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
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 #define CCL_JumpCond 0x05 /* Jump conditional:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 1:A--D--D--R--E--S--S-rrrXXXXX
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 if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 IC += ADDRESS;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 #define CCL_WriteRegisterJump 0x06 /* Write register and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 write (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 IC += ADDRESS;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 #define CCL_WriteRegisterReadJump 0x07 /* Write register, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 2:A--D--D--R--E--S--S-rrrYYYYY
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 write (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 second code (YYYYY == CCL_ReadJump). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 #define CCL_WriteConstJump 0x08 /* Write constant and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 1:A--D--D--R--E--S--S-000XXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
182 2:CONST
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 ------------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
184 write (CONST);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 1:A--D--D--R--E--S--S-rrrXXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
190 2:CONST
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 3:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 -----------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
193 write (CONST);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 second code (YYYYY == CCL_ReadJump). */
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 #define CCL_WriteStringJump 0x0A /* Write string and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 1:A--D--D--R--E--S--S-000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 2:LENGTH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 3:0000STRIN[0]STRIN[1]STRIN[2]
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 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 write_string (STRING, LENGTH);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 2:LENGTH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 3:ELEMENET[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 4:ELEMENET[1]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 N:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 if (0 <= reg[rrr] < LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 write (ELEMENT[reg[rrr]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 IC += LENGTH + 2; (... pointing at N+1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 /* Note: If read is suspended, the resumed execution starts from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 Nth code (YYYYY == CCL_ReadJump). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 #define CCL_ReadJump 0x0C /* Read and jump:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 1:A--D--D--R--E--S--S-rrrYYYYY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 */
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 #define CCL_Branch 0x0D /* Jump by branch table:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 2:A--D--D--R--E-S-S[0]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 3:A--D--D--R--E-S-S[1]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 ...
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 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 IC += ADDRESS[reg[rrr]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 IC += ADDRESS[CC..C];
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 #define CCL_ReadRegister 0x0E /* Read bytes into registers:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 2:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
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 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 while (CCC--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 read (reg[rrr]);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 #define CCL_WriteExprConst 0x0F /* write result of expression:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 1:00000OPERATION000RRR000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 write (reg[RRR] OPERATION CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 /* Note: If the Nth read is suspended, the resumed execution starts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 from the Nth code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 #define CCL_ReadBranch 0x10 /* Read one byte into a register,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 and jump by branch table:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 2:A--D--D--R--E-S-S[0]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 3:A--D--D--R--E-S-S[1]000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 read (read[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 IC += ADDRESS[reg[rrr]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 IC += ADDRESS[CC..C];
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 #define CCL_WriteRegister 0x11 /* Write registers:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 1:CCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 2:CCCCCCCCCCCCCCCCCCCrrrXXXXX
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 while (CCC--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 write (reg[rrr]);
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 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 /* Note: If the Nth write is suspended, the resumed execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 starts from the Nth code. */
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 #define CCL_WriteExprRegister 0x12 /* Write result of expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 1:00000OPERATIONRrrRRR000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 write (reg[RRR] OPERATION reg[Rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 #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
301 CC..C or cc..c.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
302 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
303 [2:00000000cccccccccccccccccccc]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 ------------------------------
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
305 if (FFF)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
306 call (cc..c)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
307 IC++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
308 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
309 call (CC..C)
428
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 #define CCL_WriteConstString 0x14 /* Write a constant or a string:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 [2:0000STRIN[0]STRIN[1]STRIN[2]]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 [...]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 if (!rrr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 write (CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 write_string (STRING, CC..C);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 IC += (CC..C + 2) / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 */
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 #define CCL_WriteArray 0x15 /* Write an element of array:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 2:ELEMENT[0]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 3:ELEMENT[1]
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 if (0 <= reg[rrr] < CC..C)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 write (ELEMENT[reg[rrr]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 IC += CC..C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 */
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 #define CCL_End 0x16 /* Terminate:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 1:00000000000000000000000XXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 terminate ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 /* The following two codes execute an assignment arithmetic/logical
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 operation. The form of the operation is like REG OP= OPERAND. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 #define CCL_ExprSelfConst 0x17 /* REG OP= constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 1:00000OPERATION000000rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 reg[rrr] OPERATION= CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 */
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 #define CCL_ExprSelfReg 0x18 /* REG1 OP= REG2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 1:00000OPERATION000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 reg[rrr] OPERATION= reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* The following codes execute an arithmetic/logical operation. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 form of the operation is like REG_X = REG_Y OP OPERAND2. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 #define CCL_SetExprConst 0x19 /* REG_X = REG_Y OP constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 1:00000OPERATION000RRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 2:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 reg[rrr] = reg[RRR] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 IC++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 */
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 #define CCL_SetExprReg 0x1A /* REG1 = REG2 OP REG3:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 1:00000OPERATIONRrrRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 reg[rrr] = reg[RRR] OPERATION reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 #define CCL_JumpCondExprConst 0x1B /* Jump conditional according to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 an operation on constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 3:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 reg[7] = reg[rrr] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 if (!(reg[7]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 IC += 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 #define CCL_JumpCondExprReg 0x1C /* Jump conditional according to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 an operation on register:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 3:RRR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 reg[7] = reg[rrr] OPERATION reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 #define CCL_ReadJumpCondExprConst 0x1D /* Read and jump conditional according
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 to an operation on constant:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 3:CONSTANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 reg[7] = reg[rrr] OPERATION CONSTANT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 #define CCL_ReadJumpCondExprReg 0x1E /* Read and jump conditional according
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 to an operation on register:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 1:A--D--D--R--E--S--S-rrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 2:OPERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 3:RRR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 -----------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 read (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 reg[7] = reg[rrr] OPERATION reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 if (!reg[7])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 IC += ADDRESS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 IC += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
428 #define CCL_Extension 0x1F /* Extended CCL code
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 1:ExtendedCOMMNDRrrRRRrrrXXXXX
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
430 2:ARGUMENT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 3:...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 extended_command (rrr,RRR,Rrr,ARGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 Here after, Extended CCL Instructions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 Bit length of extended command is 14.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 Therefore, the instruction code range is 0..16384(0x3fff).
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 /* Read a multibyte characeter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 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
444 reg[RRR]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 #define CCL_ReadMultibyteChar2 0x00 /* Read Multibyte Character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 /* Write a multibyte character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 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
451 is reg[RRR]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 /* Translate a character whose code point is reg[rrr] and the charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 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
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 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
460 (charset ID). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 #define CCL_TranslateCharacter 0x02 /* Translate a multibyte character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 /* Translate a character whose code point is reg[rrr] and the charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 ID is reg[RRR] by a translation table whose ID is ARGUMENT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 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
469 (charset ID). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 #define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 1:ExtendedCOMMNDRrrRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 2:ARGUMENT(Translation Table ID)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 /* Iterate looking up MAPs for reg[rrr] starting from the Nth (N =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 reg[RRR]) MAP until some value is found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 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
480 lambda.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 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
482 If the element is t or lambda, finish without changing reg[rrr].
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 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
484
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
485 Detail of the map structure is described in the comment for
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 CCL_MapMultiple below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 #define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 2:NUMBER of MAPs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 3:MAP-ID1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 4:MAP-ID2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 ...
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
494 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 /* 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
497 reg[RRR]) map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 MAPs are supplied in the succeeding CCL codes as follows:
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 When CCL program gives this nested structure of map to this command:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 ((MAP-ID11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 MAP-ID12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (MAP-ID121 MAP-ID122 MAP-ID123)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 MAP-ID13)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (MAP-ID21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (MAP-ID211 (MAP-ID2111) MAP-ID212)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 MAP-ID22)),
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
509 the compiled CCL code has this sequence:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 CCL_MapMultiple (CCL code of this command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 16 (total number of MAPs and SEPARATORs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 -7 (1st SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 MAP-ID11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 MAP-ID12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 -3 (2nd SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 MAP-ID121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 MAP-ID122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 MAP-ID123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 MAP-ID13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 -7 (3rd SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 MAP-ID21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 -4 (4th SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 MAP-ID211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 -1 (5th SEPARATOR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 MAP_ID2111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 MAP-ID212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 MAP-ID22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 A value of each SEPARATOR follows this rule:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (*)....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
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 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
536 reg[rrr]), the mapping is treated as identity.
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 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
539 separated by SEPARATOR) except in the case that lambda is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 encountered. More precisely, the mapping proceeds as below:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 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
543 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
544 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
545 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
546 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
547 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
548 and regard the last value as a result.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 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
551 mapping proceeds as follows:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 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
554 proceeds to the next map.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 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
557 proceeds to the next map.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
559 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
560 end of the current map set.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
561
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
562 If VALn is a symbol, call the CCL program refered by it.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
563 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
564 Such special values are regarded as nil, t, and lambda respectively.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 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
567 (a)......[STARTPOINT VAL1 VAL2 ...]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 (b)......[t VAL STARTPOINT ENDPOINT],
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 STARTPOINT is an offset to be used for indexing a map,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 ENDPOINT is a maximum index number of a map,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 VAL and VALn is a number, nil, t, or lambda.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 Valid index range of a map of type (a) is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 STARTPOINT <= index < STARTPOINT + map_size - 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 Valid index range of a map of type (b) is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 STARTPOINT <= index < ENDPOINT */
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 #define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 2:N-2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 3:SEPARATOR_1 (< 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 4:MAP-ID_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 5:MAP-ID_2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 M:SEPARATOR_x (< 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 M+1:MAP-ID_y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 N:SEPARATOR_z (< 0)
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
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
592 #define MAX_MAP_SET_LEVEL 30
428
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 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 int rest_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 int orig_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 } tr_stack;
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 static tr_stack mapping_stack[MAX_MAP_SET_LEVEL];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 static tr_stack *mapping_stack_pointer;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
602
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
603 /* If this variable is non-zero, it indicates the stack_idx
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
604 of immediately called by CCL_MapMultiple. */
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 444
diff changeset
605 static int stack_idx_of_map_multiple;
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 #define PUSH_MAPPING_STACK(restlen, orig) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
608 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
609 mapping_stack_pointer->rest_length = (restlen); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
610 mapping_stack_pointer->orig_val = (orig); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
611 mapping_stack_pointer++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
612 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
613
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
614 #define POP_MAPPING_STACK(restlen, orig) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
615 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
616 mapping_stack_pointer--; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
617 (restlen) = mapping_stack_pointer->rest_length; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
618 (orig) = mapping_stack_pointer->orig_val; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
619 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
621 #define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
622 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
623 struct ccl_program called_ccl; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
624 if (stack_idx >= 256 \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
625 || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
626 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
627 if (stack_idx > 0) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
628 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
629 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
630 ic = ccl_prog_stack_struct[0].ic; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
631 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
632 CCL_INVALID_CMD; \
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 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
635 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
636 stack_idx++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
637 ccl_prog = called_ccl.prog; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
638 ic = CCL_HEADER_MAIN; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
639 /* The "if (1)" prevents warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
640 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
641 if (1) goto ccl_repeat; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
642 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 #define CCL_MapSingle 0x12 /* Map by single code conversion map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 1:ExtendedCOMMNDXXXRRRrrrXXXXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 2:MAP-ID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 ------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 Map reg[rrr] by MAP-ID.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 If some valid mapping is found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 set reg[rrr] to the result,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 set reg[RRR] to -1.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 /* CCL arithmetic/logical operators. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 #define CCL_PLUS 0x00 /* X = Y + Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 #define CCL_MINUS 0x01 /* X = Y - Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 #define CCL_MUL 0x02 /* X = Y * Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 #define CCL_DIV 0x03 /* X = Y / Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 #define CCL_MOD 0x04 /* X = Y % Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 #define CCL_AND 0x05 /* X = Y & Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 #define CCL_OR 0x06 /* X = Y | Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 #define CCL_XOR 0x07 /* X = Y ^ Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 #define CCL_LSH 0x08 /* X = Y << Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 #define CCL_RSH 0x09 /* X = Y >> Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 #define CCL_LSH8 0x0A /* X = (Y << 8) | Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 #define CCL_RSH8 0x0B /* X = Y >> 8, r[7] = Y & 0xFF */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 #define CCL_DIVMOD 0x0C /* X = Y / Z, r[7] = Y % Z */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 #define CCL_LS 0x10 /* X = (X < Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 #define CCL_GT 0x11 /* X = (X > Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 #define CCL_EQ 0x12 /* X = (X == Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 #define CCL_LE 0x13 /* X = (X <= Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 #define CCL_GE 0x14 /* X = (X >= Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 #define CCL_NE 0x15 /* X = (X != Y) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 #define CCL_DECODE_SJIS 0x16 /* X = HIGHER_BYTE (DE-SJIS (Y, Z))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 r[7] = LOWER_BYTE (SJIS (Y, Z) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
681 /* Terminate CCL program successfully. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
682 #define CCL_SUCCESS \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
683 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
684 ccl->status = CCL_STAT_SUCCESS; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
685 /* The "if (1)" inhibits the warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
686 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
687 if (1) goto ccl_finish; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
688 } while (0)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
689
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 /* Suspend CCL program because of reading from empty input buffer or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 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
692 same I/O command is executed. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
693 #define CCL_SUSPEND(stat) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
694 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
695 ic--; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
696 ccl->status = (stat); \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
697 /* The "if (1)" inhibits the warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
698 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
699 if (1) goto ccl_finish; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
700 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 /* Terminate CCL program because of invalid command. Should not occur
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
703 in the normal case. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
704 #define CCL_INVALID_CMD \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
705 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
706 ccl->status = CCL_STAT_INVALID_CMD; \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
707 /* The "if (1)" inhibits the warning \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
708 "end-of loop code not reached" */ \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
709 if (1) goto ccl_error_handler; \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
710 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 /* 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
713 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
714 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
715 ASCII character, write it in multibyte form. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
716 #define CCL_WRITE_CHAR(ch) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
717 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
718 if (!destination) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
719 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
720 if (conversion_mode == CCL_MODE_ENCODING) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
721 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
722 if ((ch) == '\n') \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
723 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
724 if (ccl->eol_type == CCL_CODING_EOL_CRLF) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
725 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
726 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
727 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
728 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
729 else if (ccl->eol_type == CCL_CODING_EOL_CR) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
730 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
731 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
732 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
733 } \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
734 else if ((ch) < 0x100) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
735 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
736 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
737 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
738 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
739 { \
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
740 Intbyte work[MAX_EMCHAR_LEN]; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
741 int len; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
742 len = non_ascii_set_charptr_emchar (work, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
743 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
744 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
745 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
746 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
747 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
748 if (!CHAR_MULTIBYTE_P(ch)) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
749 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
750 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
751 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
752 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
753 { \
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
754 Intbyte work[MAX_EMCHAR_LEN]; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
755 int len; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
756 len = non_ascii_set_charptr_emchar (work, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
757 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
758 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
759 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
760 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 /* 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
763 buffer. But this macro treat this string as a binary. Therefore,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
764 cannot handle a multibyte string except for Control-1 characters. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
765 #define CCL_WRITE_STRING(len) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
766 do { \
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
767 Intbyte work[MAX_EMCHAR_LEN]; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
768 int ch, bytes; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
769 if (!destination) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
770 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
771 else if (conversion_mode == CCL_MODE_ENCODING) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
772 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
773 for (i = 0; i < (len); i++) \
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 ch = ((XINT (ccl_prog[ic + (i / 3)])) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
776 >> ((2 - (i % 3)) * 8)) & 0xFF; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
777 if (ch == '\n') \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
778 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
779 if (ccl->eol_type == CCL_CODING_EOL_CRLF) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
780 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
781 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
782 Dynarr_add (destination, '\n'); \
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 else if (ccl->eol_type == CCL_CODING_EOL_CR) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
785 Dynarr_add (destination, '\r'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
786 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
787 Dynarr_add (destination, '\n'); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
788 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
789 if (ch < 0x100) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
790 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
791 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
792 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
793 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
794 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
795 bytes = non_ascii_set_charptr_emchar (work, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
796 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
797 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
798 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
799 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
800 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
801 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
802 for (i = 0; i < (len); i++) \
444
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 ch = ((XINT (ccl_prog[ic + (i / 3)])) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
805 >> ((2 - (i % 3)) * 8)) & 0xFF; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
806 if (!CHAR_MULTIBYTE_P(ch)) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
807 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
808 Dynarr_add (destination, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
809 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
810 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
811 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
812 bytes = non_ascii_set_charptr_emchar (work, ch); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
813 Dynarr_add_many (destination, work, len); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
814 } \
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 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
817 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 /* 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
820 #define CCL_READ_CHAR(r) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
821 do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
822 if (!src) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
823 CCL_INVALID_CMD; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
824 if (src < src_end) \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
825 (r) = *src++; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
826 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
827 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
828 if (ccl->last_block) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
829 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
830 ic = ccl->eof_ic; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
831 goto ccl_repeat; \
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 else \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
834 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
835 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
836 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
837
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
838
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
839 /* Set C to the character code made from CHARSET and CODE. This is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
840 like MAKE_CHAR but check the validity of CHARSET and CODE. If they
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
841 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
842 case that CCL_ReadMultibyteChar2 read an invalid code and it set
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
843 CODE to that invalid byte. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
844
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
845 /* On XEmacs, TranslateCharacter is not supported. Thus, this
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
846 macro is not used. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
847 #if 0
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
848 #define CCL_MAKE_CHAR(charset, code, c) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
849 do { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
850 if ((charset) == CHARSET_ASCII) \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
851 (c) = (code) & 0xFF; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
852 else if (CHARSET_DEFINED_P (charset) \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
853 && ((code) & 0x7F) >= 32 \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
854 && ((code) < 256 || ((code >> 7) & 0x7F) >= 32)) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
855 { \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
856 int c1 = (code) & 0x7F, c2 = 0; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
857 \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
858 if ((code) >= 256) \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
859 c2 = c1, c1 = ((code) >> 7) & 0x7F; \
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
860 (c) = MAKE_CHAR (charset, c1, c2); \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
861 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
862 else \
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
863 (c) = (code) & 0xFF; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
864 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
865 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 /* 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
869 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
870 should not exceed DST_BYTES. The bytes actually processed is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
871 returned as *CONSUMED. The return value is the length of the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
872 resulting text. As a side effect, the contents of CCL registers
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 are updated. If SOURCE or DESTINATION is NULL, only operations on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 registers are permitted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 #define CCL_DEBUG_BACKTRACE_LEN 256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 int ccl_backtrace_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 struct ccl_prog_stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 int ic; /* Instruction Counter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 /* For the moment, we only support depth 256 of stack. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 static struct ccl_prog_stack ccl_prog_stack_struct[256];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 int
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
892 ccl_driver (struct ccl_program *ccl,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
893 const unsigned char *source,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
894 unsigned_char_dynarr *destination,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
895 int src_bytes,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
896 int *consumed,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
897 int conversion_mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
899 register int *reg = ccl->reg;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
900 register int ic = ccl->ic;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
901 register int code = -1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
902 register int field1, field2;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
903 register Lisp_Object *ccl_prog = ccl->prog;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 const unsigned char *src = source, *src_end = src + src_bytes;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
905 int jump_address;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 int i, j, op;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 int stack_idx = ccl->stack_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 /* Instruction counter of the current CCL code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 int this_ic = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 if (ic >= ccl->eof_ic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 ic = CCL_HEADER_MAIN;
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 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
915 destination = NULL;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
916
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
917 /* Set mapping stack pointer. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
918 mapping_stack_pointer = mapping_stack;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 ccl_backtrace_idx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 for (;;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 ccl_repeat:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 ccl_backtrace_table[ccl_backtrace_idx++] = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 ccl_backtrace_idx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 ccl_backtrace_table[ccl_backtrace_idx] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 /* We can't just signal Qquit, instead break the loop as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 the whole data is processed. Don't reset Vquit_flag, it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 must be handled later at a safer place. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 if (consumed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 src = source + src_bytes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 ccl->status = CCL_STAT_QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 this_ic = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 code = XINT (ccl_prog[ic]); ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 field2 = (code & 0xFF) >> 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 #define rrr field2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 #define RRR (field1 & 7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 #define Rrr ((field1 >> 3) & 7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 #define ADDR field1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 #define EXCMD (field1 >> 6)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 switch (code & 0x1F)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 case CCL_SetRegister: /* 00000000000000000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 reg[rrr] = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 reg[rrr] = field1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 reg[rrr] = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 j = field1 >> 3;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
974 /* #### 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
975 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
976 was an unsigned comparison. --ben */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
977 if ((unsigned int) i < (unsigned int) j)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 reg[rrr] = XINT (ccl_prog[ic + i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 ic += j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 break;
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 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 case CCL_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 i = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 i = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 j = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 CCL_WRITE_STRING (j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 ic += ADDR - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 j = XINT (ccl_prog[ic]);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1029 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1030 if ((unsigned int) i < (unsigned int) j)
428
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 i = XINT (ccl_prog[ic + 1 + i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 ic += j + 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 ic += ADDR - (j + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 ic += ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 /* fall through ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1049 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1050 if ((unsigned int) reg[rrr] < (unsigned int) field1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 ic += XINT (ccl_prog[ic + reg[rrr]]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 ic += XINT (ccl_prog[ic + field1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 if (!field1) break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 code = XINT (ccl_prog[ic]); ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 field2 = (code & 0xFF) >> 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 j = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 op = field1 >> 6;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1072 jump_address = ic + 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 if (!field1) break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 code = XINT (ccl_prog[ic]); ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 field1 = code >> 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 field2 = (code & 0xFF) >> 5;
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 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 j = reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 op = field1 >> 6;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1092 jump_address = ic;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1095 case CCL_Call: /* 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 Lisp_Object slot;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1098 int prog_id;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1099
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1100 /* If FFF is nonzero, the CCL program ID is in the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1101 following code. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1102 if (rrr)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1103 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1104 prog_id = XINT (ccl_prog[ic]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1105 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1106 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1107 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1108 prog_id = field1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 if (stack_idx >= 256
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1111 || prog_id < 0
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1112 || prog_id >= XVECTOR (Vccl_program_table)->size
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1113 || (slot = XVECTOR (Vccl_program_table)->contents[prog_id],
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1114 !VECTORP (slot))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1115 || !VECTORP (XVECTOR (slot)->contents[1]))
428
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 if (stack_idx > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 ic = ccl_prog_stack_struct[0].ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1122 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 }
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 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 ccl_prog_stack_struct[stack_idx].ic = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 stack_idx++;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1128 ccl_prog = XVECTOR (XVECTOR (slot)->contents[1])->contents;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 ic = CCL_HEADER_MAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 if (!rrr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 CCL_WRITE_CHAR (field1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 CCL_WRITE_STRING (field1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 ic += (field1 + 2) / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 i = reg[rrr];
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1145 /* #### see comment at CCL_SetArray */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1146 if ((unsigned int) i < (unsigned int) field1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 j = XINT (ccl_prog[ic + i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 CCL_WRITE_CHAR (j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 ic += field1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 case CCL_End: /* 0000000000000000000000XXXXX */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1155 if (stack_idx > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1157 stack_idx--;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 ic = ccl_prog_stack_struct[stack_idx].ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 if (src)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 src = src_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 /* ccl->ic should points to this command code again to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 suppress further processing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 ic--;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1167 CCL_SUCCESS;
428
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 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 i = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 goto ccl_expr_self;
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 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 ccl_expr_self:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 switch (op)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 case CCL_PLUS: reg[rrr] += i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 case CCL_MINUS: reg[rrr] -= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 case CCL_MUL: reg[rrr] *= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 case CCL_DIV: reg[rrr] /= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 case CCL_MOD: reg[rrr] %= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 case CCL_AND: reg[rrr] &= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 case CCL_OR: reg[rrr] |= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 case CCL_XOR: reg[rrr] ^= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 case CCL_LSH: reg[rrr] <<= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 case CCL_RSH: reg[rrr] >>= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 case CCL_LE: reg[rrr] = reg[rrr] <= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 case CCL_GE: reg[rrr] = reg[rrr] >= i; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 case CCL_NE: reg[rrr] = reg[rrr] != i; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1201 default: CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 j = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 jump_address = ++ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 j = reg[Rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 op = field1 >> 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 jump_address = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 op = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 jump_address = ic++ + ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 j = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 goto ccl_set_expr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 CCL_READ_CHAR (reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 case CCL_JumpCondExprReg:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 op = XINT (ccl_prog[ic]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 jump_address = ic++ + ADDR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 j = reg[XINT (ccl_prog[ic])];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 ic++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 rrr = 7;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 ccl_set_expr:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 switch (op)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 case CCL_PLUS: reg[rrr] = i + j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 case CCL_MINUS: reg[rrr] = i - j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 case CCL_MUL: reg[rrr] = i * j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 case CCL_DIV: reg[rrr] = i / j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 case CCL_MOD: reg[rrr] = i % j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 case CCL_AND: reg[rrr] = i & j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 case CCL_OR: reg[rrr] = i | j; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1250 case CCL_XOR: reg[rrr] = i ^ j;; break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 case CCL_LSH: reg[rrr] = i << j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 case CCL_RSH: reg[rrr] = i >> j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 case CCL_LSH8: reg[rrr] = (i << 8) | j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 case CCL_LS: reg[rrr] = i < j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 case CCL_GT: reg[rrr] = i > j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 case CCL_EQ: reg[rrr] = i == j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 case CCL_LE: reg[rrr] = i <= j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 case CCL_GE: reg[rrr] = i >= j; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 case CCL_NE: reg[rrr] = i != j; break;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1262 case CCL_DECODE_SJIS:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1263 /* DECODE_SJIS set MSB for internal format
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1264 as opposed to Emacs. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1265 DECODE_SJIS (i, j, reg[rrr], reg[7]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1266 reg[rrr] &= 0x7F;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1267 reg[7] &= 0x7F;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1268 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1269 case CCL_ENCODE_SJIS:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1270 /* ENCODE_SJIS assumes MSB of SJIS-char is set
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1271 as opposed to Emacs. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1272 ENCODE_SJIS (i | 0x80, j | 0x80, reg[rrr], reg[7]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1273 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1274 default: CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 code &= 0x1F;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 i = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 CCL_WRITE_CHAR (i);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1281 ic = jump_address;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 else if (!reg[rrr])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 ic = jump_address;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
1287 case CCL_Extension:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 switch (EXCMD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 case CCL_ReadMultibyteChar2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 if (!src)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 CCL_INVALID_CMD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1294 if (src >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1295 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1296 src++;
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 450
diff changeset
1297 goto ccl_read_multibyte_character_suspend;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1298 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1299
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1300 i = *src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1301 if (i < 0x80)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1302 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1303 /* ASCII */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1304 reg[rrr] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1305 reg[RRR] = LEADING_BYTE_ASCII;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1306 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1307 else if (i <= MAX_LEADING_BYTE_OFFICIAL_1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1308 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1309 if (src >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1310 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1311 reg[RRR] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1312 reg[rrr] = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1313 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1314 else if (i <= MAX_LEADING_BYTE_OFFICIAL_2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1315 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1316 if ((src + 1) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1317 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1318 reg[RRR] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1319 i = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1320 reg[rrr] = ((i << 7) | (*src & 0x7F));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1321 src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1322 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1323 else if (i == PRE_LEADING_BYTE_PRIVATE_1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1324 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1325 if ((src + 1) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1326 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1327 reg[RRR] = *src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1328 reg[rrr] = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1329 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1330 else if (i == PRE_LEADING_BYTE_PRIVATE_2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1331 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1332 if ((src + 2) >= src_end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1333 goto ccl_read_multibyte_character_suspend;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1334 reg[RRR] = *src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1335 i = (*src++ & 0x7F);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1336 reg[rrr] = ((i << 7) | (*src & 0x7F));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1337 src++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1338 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1339 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1340 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1341 /* INVALID CODE. Return a single byte character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1342 reg[RRR] = LEADING_BYTE_ASCII;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1343 reg[rrr] = i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
1344 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 ccl_read_multibyte_character_suspend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 src--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 if (ccl->last_block)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 ic = ccl->eof_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 goto ccl_repeat;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 case CCL_WriteMultibyteChar2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 i = reg[RRR]; /* charset */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 if (i == LEADING_BYTE_ASCII)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 i = reg[rrr] & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 else if (XCHARSET_DIMENSION (CHARSET_BY_LEADING_BYTE (i)) == 1)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1364 i = (((i - FIELD2_TO_OFFICIAL_LEADING_BYTE) << 7)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1365 | (reg[rrr] & 0x7F));
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1366 else if (i < MAX_LEADING_BYTE_OFFICIAL_2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 i = ((i - FIELD1_TO_OFFICIAL_LEADING_BYTE) << 14) | reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 i = ((i - FIELD1_TO_PRIVATE_LEADING_BYTE) << 14) | reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 CCL_WRITE_CHAR (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1375 case CCL_TranslateCharacter:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 #if 0
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1377 /* XEmacs does not have translate_char, and its
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1378 equivalent nor. We do nothing on this operation. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1379 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 i, -1, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 SPLIT_CHAR (op, reg[RRR], i, j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 if (j != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 i = (i << 7) | j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1385
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 reg[rrr] = i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1387 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 case CCL_TranslateCharacterConstTbl:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1391 #if 0
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1392 /* XEmacs does not have translate_char, and its
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1393 equivalent nor. We do nothing on this operation. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 op = XINT (ccl_prog[ic]); /* table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 ic++;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1396 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 SPLIT_CHAR (op, reg[RRR], i, j);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 if (j != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 i = (i << 7) | j;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1401
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 reg[rrr] = i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1403 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 case CCL_IterateMultipleMap:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 Lisp_Object map, content, attrib, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 int point, size, fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 j = XINT (ccl_prog[ic++]); /* number of maps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 fin_ic = ic + j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 op = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 if ((j > reg[RRR]) && (j >= 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 ic += reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 for (;i < j;i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 size = XVECTOR (Vcode_conversion_map_vector)->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 point = XINT (ccl_prog[ic++]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 if (point >= size) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 map =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 XVECTOR (Vcode_conversion_map_vector)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1435 /* Check map validity. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 if (!CONSP (map)) continue;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1437 map = XCDR (map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 if (!VECTORP (map)) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 size = XVECTOR (map)->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 if (size <= 1) continue;
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 content = XVECTOR (map)->contents[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 /* check map type,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 [STARTPOINT VAL1 VAL2 ...] or
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1446 [t ELEMENT STARTPOINT ENDPOINT] */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1447 if (INTP (content))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 point = XUINT (content);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 point = op - point + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 if (!((point >= 1) && (point < size))) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 content = XVECTOR (map)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 else if (EQ (content, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 if (size != 4) continue;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1457 /* #### see comment at CCL_SetArray; in this
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1458 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
1459 already present */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1460 if (((unsigned int) op >=
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1461 XUINT (XVECTOR (map)->contents[2]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1462 && ((unsigned int) op <
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1463 XUINT (XVECTOR (map)->contents[3])))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 content = XVECTOR (map)->contents[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1468 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 if (NILP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 continue;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1473 else if (INTP (content))
428
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 reg[RRR] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 reg[rrr] = XINT(content);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 else if (EQ (content, Qt) || EQ (content, Qlambda))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 reg[RRR] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 else if (CONSP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1486 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1487 value = XCDR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1488 if (!INTP (attrib) || !INTP (value))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 reg[RRR] = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 reg[rrr] = XUINT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1494 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1495 CCL_CALL_FOR_MAP_INSTRUCTION (content, fin_ic);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1496 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1497 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 if (i == j)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1504
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 case CCL_MapMultiple:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 Lisp_Object map, content, attrib, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 int point, size, map_vector_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 int map_set_rest_length, fin_ic;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1510 int current_ic = this_ic;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1511
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1512 /* inhibit recursive call on MapMultiple. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1513 if (stack_idx_of_map_multiple > 0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1514 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1515 if (stack_idx_of_map_multiple <= stack_idx)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1516 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1517 stack_idx_of_map_multiple = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1518 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1519 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1520 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1521 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1522 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1523 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1524 stack_idx_of_map_multiple = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 map_set_rest_length =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 XINT (ccl_prog[ic++]); /* number of maps and separators. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 fin_ic = ic + map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1529 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1530
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 if ((map_set_rest_length > reg[RRR]) && (reg[RRR] >= 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 ic += reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 i = reg[RRR];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 map_set_rest_length -= i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 ic = fin_ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 reg[RRR] = -1;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1541 mapping_stack_pointer = mapping_stack;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1544
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1545 if (mapping_stack_pointer <= (mapping_stack + 1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1547 /* Set up initial state. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1548 mapping_stack_pointer = mapping_stack;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1549 PUSH_MAPPING_STACK (0, op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1550 reg[RRR] = -1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1551 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1552 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1553 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1554 /* Recover after calling other ccl program. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1555 int orig_op;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1557 POP_MAPPING_STACK (map_set_rest_length, orig_op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1558 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1559 switch (op)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1561 case -1:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1562 /* Regard it as Qnil. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1563 op = orig_op;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1564 i++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1565 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1566 map_set_rest_length--;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1567 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1568 case -2:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1569 /* Regard it as Qt. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1570 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1571 i++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1572 ic++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1573 map_set_rest_length--;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1574 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1575 case -3:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1576 /* Regard it as Qlambda. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1577 op = orig_op;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 i += map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1579 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1580 map_set_rest_length = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1581 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1582 default:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1583 /* Regard it as normal mapping. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 i += map_set_rest_length;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1585 ic += map_set_rest_length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1590 map_vector_size = XVECTOR (Vcode_conversion_map_vector)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1591
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1592 do {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1593 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
1594 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1595 point = XINT(ccl_prog[ic]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1596 if (point < 0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1597 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1598 /* +1 is for including separator. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1599 point = -point + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1600 if (mapping_stack_pointer
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 456
diff changeset
1601 >= mapping_stack + countof (mapping_stack))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1602 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1603 PUSH_MAPPING_STACK (map_set_rest_length - point,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1604 reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1605 map_set_rest_length = point;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1606 reg[rrr] = op;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1607 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1608 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1609
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1610 if (point >= map_vector_size) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1611 map = (XVECTOR (Vcode_conversion_map_vector)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1612 ->contents[point]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1613
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1614 /* Check map validity. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1615 if (!CONSP (map)) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1616 map = XCDR (map);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1617 if (!VECTORP (map)) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1618 size = XVECTOR (map)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1619 if (size <= 1) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1620
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1621 content = XVECTOR (map)->contents[0];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1622
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1623 /* check map type,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1624 [STARTPOINT VAL1 VAL2 ...] or
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1625 [t ELEMENT STARTPOINT ENDPOINT] */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1626 if (INTP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1627 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1628 point = XUINT (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1629 point = op - point + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1630 if (!((point >= 1) && (point < size))) continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1631 content = XVECTOR (map)->contents[point];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1632 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1633 else if (EQ (content, Qt))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1634 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1635 if (size != 4) continue;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1636 /* #### see comment at CCL_SetArray; in this
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1637 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
1638 already present */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1639 if (((unsigned int) op >=
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1640 XUINT (XVECTOR (map)->contents[2])) &&
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1641 ((unsigned int) op <
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
1642 XUINT (XVECTOR (map)->contents[3])))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1643 content = XVECTOR (map)->contents[1];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1644 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1645 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1646 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1647 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1648 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1649
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1650 if (NILP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1651 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1652
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1653 reg[RRR] = i;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1654 if (INTP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1655 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1656 op = XINT (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1657 i += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1658 ic += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1659 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1660 map_set_rest_length++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1661 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1662 else if (CONSP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1663 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1664 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1665 value = XCDR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1666 if (!INTP (attrib) || !INTP (value))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1667 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1668 op = XUINT (value);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1669 i += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1670 ic += map_set_rest_length - 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1671 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1672 map_set_rest_length++;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1673 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1674 else if (EQ (content, Qt))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1675 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1676 op = reg[rrr];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1677 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1678 else if (EQ (content, Qlambda))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1679 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1680 i += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1681 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1682 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1683 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1684 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1685 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1686 if (mapping_stack_pointer
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 456
diff changeset
1687 >= mapping_stack + countof (mapping_stack))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1688 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1689 PUSH_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1690 PUSH_MAPPING_STACK (map_set_rest_length, op);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1691 stack_idx_of_map_multiple = stack_idx + 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1692 CCL_CALL_FOR_MAP_INSTRUCTION (content, current_ic);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1693 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1694 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1695 CCL_INVALID_CMD;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1696 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1697 if (mapping_stack_pointer <= (mapping_stack + 1))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1698 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1699 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1700 i += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1701 ic += map_set_rest_length;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1702 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1703 } while (1);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1704
428
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 reg[rrr] = op;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 case CCL_MapSingle:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 Lisp_Object map, attrib, value, content;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 int size, point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 j = XINT (ccl_prog[ic++]); /* map_id */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 op = reg[rrr];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 if (j >= XVECTOR (Vcode_conversion_map_vector)->size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 map = XVECTOR (Vcode_conversion_map_vector)->contents[j];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 if (!CONSP (map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1727 map = XCDR (map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 if (!VECTORP (map))
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 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 size = XVECTOR (map)->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 point = XUINT (XVECTOR (map)->contents[0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 point = op - point + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 reg[RRR] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 if ((size <= 1) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 (!((point >= 1) && (point < size))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1742 reg[RRR] = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 content = XVECTOR (map)->contents[point];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 if (NILP (content))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 reg[RRR] = -1;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1746 else if (INTP (content))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 reg[rrr] = XINT (content);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1748 else if (EQ (content, Qt));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 else if (CONSP (content))
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 attrib = XCAR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1752 value = XCDR (content);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1753 if (!INTP (attrib) || !INTP (value))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 reg[rrr] = XUINT(value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1758 else if (SYMBOLP (content))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1759 CCL_CALL_FOR_MAP_INSTRUCTION (content, ic);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 reg[RRR] = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1765
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 CCL_INVALID_CMD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 default:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1772 CCL_INVALID_CMD;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 ccl_error_handler:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 if (destination)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 /* We can insert an error message only if DESTINATION is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 specified and we still have a room to store the message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 there. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 char msg[256];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 switch (ccl->status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 case CCL_STAT_INVALID_CMD:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 code & 0x1F, code, this_ic);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 #ifdef CCL_DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 int i = ccl_backtrace_idx - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 if (ccl_backtrace_table[i] == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 sprintf(msg, " %d", ccl_backtrace_table[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 goto ccl_finish;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 case CCL_STAT_QUIT:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1810 sprintf(msg, "\nCCL: Exited.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 Dynarr_add_many (destination, (unsigned char *) msg, strlen (msg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 ccl_finish:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 ccl->ic = ic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 ccl->stack_idx = stack_idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 ccl->prog = ccl_prog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 if (consumed) *consumed = src - source;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1825 if (!destination)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 return 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1827 return Dynarr_length (destination);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1828 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1829
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1830 /* Resolve symbols in the specified CCL code (Lisp vector). This
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1831 function converts symbols of code conversion maps and character
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1832 translation tables embedded in the CCL code into their ID numbers.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1833
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1834 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
1835 all symbols are resolved), Qt if resolving of some symbol failed,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1836 or nil if CCL contains invalid data. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1837
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1838 static Lisp_Object
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1839 resolve_symbol_ccl_program (Lisp_Object ccl)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1840 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1841 int i, veclen, unresolved = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1842 Lisp_Object result, contents, val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1843
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1844 result = ccl;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1845 veclen = XVECTOR (result)->size;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1846
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1847 for (i = 0; i < veclen; i++)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1848 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1849 contents = XVECTOR (result)->contents[i];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1850 if (INTP (contents))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1851 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1852 else if (CONSP (contents)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1853 && SYMBOLP (XCAR (contents))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1854 && SYMBOLP (XCDR (contents)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1855 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1856 /* This is the new style for embedding symbols. The form is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1857 (SYMBOL . PROPERTY). (get SYMBOL PROPERTY) should give
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1858 an index number. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1859
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1860 if (EQ (result, ccl))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1861 result = Fcopy_sequence (ccl);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1862
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1863 val = Fget (XCAR (contents), XCDR (contents), Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1864 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1865 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1866 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1867 unresolved = 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1868 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1869 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1870 else if (SYMBOLP (contents))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1871 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1872 /* This is the old style for embedding symbols. This style
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1873 may lead to a bug if, for instance, a translation table
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1874 and a code conversion map have the same name. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1875 if (EQ (result, ccl))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1876 result = Fcopy_sequence (ccl);
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 val = Fget (contents, Qcode_conversion_map_id, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1879 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1880 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1881 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1882 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1883 val = Fget (contents, Qccl_program_idx, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1884 if (NATNUMP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1885 XVECTOR (result)->contents[i] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1886 else
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1887 unresolved = 1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1888 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1889 continue;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1890 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1891 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1892 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1893
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1894 return (unresolved ? Qt : result);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1895 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1896
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1897 /* Return the compiled code (vector) of CCL program CCL_PROG.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1898 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
1899 code. If necessary, resolve symbols in the compiled code to index
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1900 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
1901 symbols, return Qnil. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1902
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1903 static Lisp_Object
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1904 ccl_get_compiled_code (Lisp_Object ccl_prog)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1905 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1906 Lisp_Object val, slot;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1907
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1908 if (VECTORP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1909 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1910 val = resolve_symbol_ccl_program (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1911 return (VECTORP (val) ? val : Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1912 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1913 if (!SYMBOLP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1914 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1915
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1916 val = Fget (ccl_prog, Qccl_program_idx, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1917 if (! NATNUMP (val)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1918 || XINT (val) >= XVECTOR_LENGTH (Vccl_program_table))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1919 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1920 slot = XVECTOR_DATA (Vccl_program_table)[XINT (val)];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1921 if (! VECTORP (slot)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1922 || XVECTOR (slot)->size != 3
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1923 || ! VECTORP (XVECTOR_DATA (slot)[1]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1924 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1925 if (NILP (XVECTOR_DATA (slot)[2]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1926 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1927 val = resolve_symbol_ccl_program (XVECTOR_DATA (slot)[1]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1928 if (! VECTORP (val))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1929 return Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1930 XVECTOR_DATA (slot)[1] = val;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1931 XVECTOR_DATA (slot)[2] = Qt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1932 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1933 return XVECTOR_DATA (slot)[1];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 /* 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
1937 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
1938 of the CCL program or the already compiled code (vector).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1939 Return 0 if we succeed this setup, else return -1.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1940
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1941 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
1942 int
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1943 setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1947 if (! NILP (ccl_prog))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1949 ccl_prog = ccl_get_compiled_code (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1950 if (! VECTORP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1951 return -1;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1952 ccl->size = XVECTOR_LENGTH (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1953 ccl->prog = XVECTOR_DATA (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1954 ccl->eof_ic = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_EOF]);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1955 ccl->buf_magnification = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_BUF_MAG]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 ccl->ic = CCL_HEADER_MAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 for (i = 0; i < 8; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 ccl->reg[i] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 ccl->last_block = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 ccl->private_state = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 ccl->status = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 ccl->stack_idx = 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1964 ccl->eol_type = CCL_CODING_EOL_LF;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1965 return 0;
428
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
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1968 #ifdef emacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1970 DEFUN ("ccl-program-p", Fccl_program_p, 1, 1, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1971 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
1972 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
1973 */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1974 (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1975 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1976 Lisp_Object val;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1978 if (VECTORP (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1979 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1980 val = resolve_symbol_ccl_program (object);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1981 return (VECTORP (val) ? Qt : Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1983 if (!SYMBOLP (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1984 return Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1986 val = Fget (object, Qccl_program_idx, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1987 return ((! NATNUMP (val)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1988 || XINT (val) >= XVECTOR_LENGTH (Vccl_program_table))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1989 ? Qnil : Qt);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 DEFUN ("ccl-execute", Fccl_execute, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 Execute CCL-PROGRAM with registers initialized by REGISTERS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1995 CCL-PROGRAM is a CCL program name (symbol)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 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
1997 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
1998 No I/O commands should appear in CCL-PROGRAM.
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 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
2001 of Nth register.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2003 As side effect, each element of REGISTERS holds the value of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 corresponding register after the execution.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2005
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2006 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
2007 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2008 (ccl_prog, reg))
428
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 struct ccl_program ccl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2013 if (setup_ccl_program (&ccl, ccl_prog) < 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2014 syntax_error ("Invalid CCL program", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 CHECK_VECTOR (reg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 if (XVECTOR_LENGTH (reg) != 8)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2018 syntax_error ("Length of vector REGISTERS is not 8", Qunbound);
428
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 for (i = 0; i < 8; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 ccl.reg[i] = (INTP (XVECTOR_DATA (reg)[i])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 ? XINT (XVECTOR_DATA (reg)[i])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 : 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2025 ccl_driver (&ccl, (const unsigned char *)0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2026 (unsigned_char_dynarr *)0, 0, (int *)0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2027 CCL_MODE_ENCODING);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 if (ccl.status != CCL_STAT_SUCCESS)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2030 signal_error (Qccl_error, "Error in CCL program at code numbered ...", make_int (ccl.ic));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 for (i = 0; i < 8; i++)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2033 XSETINT (XVECTOR (reg)->contents[i], ccl.reg[i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2037 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2038 3, 4, 0, /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 Execute CCL-PROGRAM with initial STATUS on STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 CCL-PROGRAM is a symbol registered by register-ccl-program,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 or a compiled code generated by `ccl-compile' (for backward compatibility,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 in this case, the execution is slower).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 Read buffer is set to STRING, and write buffer is allocated automatically.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 STATUS is a vector of [R0 R1 ... R7 IC], where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 R0..R7 are initial values of corresponding registers,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 IC is the instruction counter specifying from where to start the program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 If R0..R7 are nil, they are initialized to 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 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
2052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 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
2054 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
2055 CCL-PROGRAM on exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 It returns the contents of write buffer as a string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 and as side effect, STATUS is updated.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2059
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2060 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
2061 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2062 (ccl_prog, status, string, continue_))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 Lisp_Object val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 struct ccl_program ccl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 int i, produced;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 unsigned_char_dynarr *outbuf;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2068 struct gcpro gcpro1, gcpro2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2070 if (setup_ccl_program (&ccl, ccl_prog) < 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2071 syntax_error ("Invalid CCL program", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 CHECK_VECTOR (status);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2074 if (XVECTOR (status)->size != 9)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2075 syntax_error ("Length of vector STATUS is not 9", Qunbound);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2076 CHECK_STRING (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2078 GCPRO2 (status, string);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2079
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 for (i = 0; i < 8; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 if (NILP (XVECTOR_DATA (status)[i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 XSETINT (XVECTOR_DATA (status)[i], 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 if (INTP (XVECTOR_DATA (status)[i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 ccl.reg[i] = XINT (XVECTOR_DATA (status)[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2087 if (INTP (XVECTOR (status)->contents[i]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 i = XINT (XVECTOR_DATA (status)[8]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 if (ccl.ic < i && i < ccl.size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 ccl.ic = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 outbuf = Dynarr_new (unsigned_char);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2094 ccl.last_block = NILP (continue_);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2095 produced = ccl_driver (&ccl, XSTRING_DATA (string), outbuf,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2096 XSTRING_LENGTH (string),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2097 (int *) 0,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2098 CCL_MODE_DECODING);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 for (i = 0; i < 8; i++)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2100 XSETINT (XVECTOR_DATA (status)[i], ccl.reg[i]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 XSETINT (XVECTOR_DATA (status)[8], ccl.ic);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 val = make_string (Dynarr_atp (outbuf, 0), produced);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 Dynarr_free (outbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 QUIT;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2107 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
2108 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
2109 if (ccl.status != CCL_STAT_SUCCESS
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2110 && ccl.status != CCL_STAT_SUSPEND_BY_SRC)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2111 signal_error (Qccl_error, "Error in CCL program at code numbered...", make_int (ccl.ic));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2116 DEFUN ("register-ccl-program", Fregister_ccl_program,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2117 2, 2, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2118 Register CCL program CCL-PROG as NAME in `ccl-program-table'.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2119 CCL-PROG should be a compiled CCL program (vector), or nil.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2120 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
2121 Return index number of the registered CCL program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2123 (name, ccl_prog))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 int len = XVECTOR_LENGTH (Vccl_program_table);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2126 int idx;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2127 Lisp_Object resolved;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 CHECK_SYMBOL (name);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2130 resolved = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 if (!NILP (ccl_prog))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 CHECK_VECTOR (ccl_prog);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2134 resolved = resolve_symbol_ccl_program (ccl_prog);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2135 if (! NILP (resolved))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2137 ccl_prog = resolved;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2138 resolved = Qt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 }
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
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2142 for (idx = 0; idx < len; idx++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2144 Lisp_Object slot;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2145
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2146 slot = XVECTOR_DATA (Vccl_program_table)[idx];
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2147 if (!VECTORP (slot))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2148 /* This is the first unused slot. Register NAME here. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2149 break;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2150
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2151 if (EQ (name, XVECTOR_DATA (slot)[0]))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2152 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2153 /* Update this slot. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2154 XVECTOR_DATA (slot)[1] = ccl_prog;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2155 XVECTOR_DATA (slot)[2] = resolved;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2156 return make_int (idx);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2157 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2158 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2159
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2160 if (idx == len)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2161 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2162 /* Extend the table. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2163 Lisp_Object new_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2166 new_table = Fmake_vector (make_int (len * 2), Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 for (j = 0; j < len; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 XVECTOR_DATA (new_table)[j]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 = XVECTOR_DATA (Vccl_program_table)[j];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170 Vccl_program_table = new_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2173 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2174 Lisp_Object elt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2175
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2176 elt = Fmake_vector (make_int (3), Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2177 XVECTOR_DATA (elt)[0] = name;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2178 XVECTOR_DATA (elt)[1] = ccl_prog;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2179 XVECTOR_DATA (elt)[2] = resolved;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2180 XVECTOR_DATA (Vccl_program_table)[idx] = elt;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2181 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2182
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2183 Fput (name, Qccl_program_idx, make_int (idx));
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2184 return make_int (idx);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 /* Register code conversion map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 A code conversion map consists of numbers, Qt, Qnil, and Qlambda.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 The first element is start code point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 The rest elements are mapped numbers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 Symbol t means to map to an original number before mapping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 Symbol nil means that the corresponding element is empty.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2193 Symbol lambda means to terminate mapping here.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2197 2, 2, 0, /*
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2198 Register SYMBOL as code conversion map MAP.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2199 Return index number of the registered map.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2200 */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2201 (symbol, map))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2203 int len = XVECTOR_LENGTH (Vcode_conversion_map_vector);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 int i;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2205 Lisp_Object idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2207 CHECK_SYMBOL (symbol);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2208 CHECK_VECTOR (map);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2209
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 for (i = 0; i < len; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2212 Lisp_Object slot = XVECTOR_DATA (Vcode_conversion_map_vector)[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 if (!CONSP (slot))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2217 if (EQ (symbol, XCAR (slot)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2219 idx = make_int (i);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2220 XCDR (slot) = map;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 Fput (symbol, Qcode_conversion_map, map);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2222 Fput (symbol, Qcode_conversion_map_id, idx);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2223 return idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 if (i == len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 Lisp_Object new_vector = Fmake_vector (make_int (len * 2), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 int j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 for (j = 0; j < len; j++)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2233 XVECTOR_DATA (new_vector)[j]
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2234 = XVECTOR_DATA (Vcode_conversion_map_vector)[j];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 Vcode_conversion_map_vector = new_vector;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2238 idx = make_int (i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 Fput (symbol, Qcode_conversion_map, map);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2240 Fput (symbol, Qcode_conversion_map_id, idx);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2241 XVECTOR_DATA (Vcode_conversion_map_vector)[i] = Fcons (symbol, map);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2242 return idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 syms_of_mule_ccl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 {
565
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
2249 DEFERROR_STANDARD (Qccl_error, Qconversion_error);
e9162e1ea200 [xemacs-hg @ 2001-05-24 09:53:05 by yoshiki]
yoshiki
parents: 563
diff changeset
2250
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2251 DEFSUBR (Fccl_program_p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 DEFSUBR (Fccl_execute);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 DEFSUBR (Fccl_execute_on_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 DEFSUBR (Fregister_ccl_program);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2255 DEFSUBR (Fregister_code_conversion_map);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 vars_of_mule_ccl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 staticpro (&Vccl_program_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 Vccl_program_table = Fmake_vector (make_int (32), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2264 DEFSYMBOL (Qccl_program);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2265 DEFSYMBOL (Qccl_program_idx);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2266 DEFSYMBOL (Qcode_conversion_map);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2267 DEFSYMBOL (Qcode_conversion_map_id);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 DEFVAR_LISP ("code-conversion-map-vector", &Vcode_conversion_map_vector /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2270 Vector of code conversion maps.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2271 */ );
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 Vcode_conversion_map_vector = Fmake_vector (make_int (16), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 Alist of fontname patterns vs corresponding CCL program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 Each element looks like (REGEXP . CCL-CODE),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 where CCL-CODE is a compiled CCL program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 When a font whose name matches REGEXP is used for displaying a character,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 CCL-CODE is executed to calculate the code point in the font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 from the charset number and position code(s) of the character which are set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 in CCL registers R0, R1, and R2 before the execution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 The code point in the font is set in CCL registers R1 and R2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 when the execution terminated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 If the font is single-byte font, the register R2 is not used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 Vfont_ccl_encoder_alist = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 }
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 #endif /* emacs */