Merge branch 'master' of git://git.savannah.gnu.org/guile
[bpt/guile.git] / libguile / vm-expand.h
1 /* Copyright (C) 2001 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #ifndef VM_LABEL
19 #define VM_LABEL(tag) l_##tag
20 #define VM_OPCODE(tag) scm_op_##tag
21
22 #ifdef HAVE_LABELS_AS_VALUES
23 #define VM_TAG(tag) VM_LABEL(tag):
24 #define VM_ADDR(tag) &&VM_LABEL(tag)
25 #else /* not HAVE_LABELS_AS_VALUES */
26 #define VM_TAG(tag) case VM_OPCODE(tag):
27 #define VM_ADDR(tag) NULL
28 #endif /* not HAVE_LABELS_AS_VALUES */
29 #endif /* VM_LABEL */
30
31 #undef VM_DEFINE_FUNCTION
32 #undef VM_DEFINE_LOADER
33 #define VM_DEFINE_FUNCTION(code,tag,name,nargs) \
34 VM_DEFINE_INSTRUCTION(code,tag,name,0,nargs,1)
35 #define VM_DEFINE_LOADER(code,tag,name) \
36 VM_DEFINE_INSTRUCTION(code,tag,name,-1,0,1)
37
38 #undef VM_DEFINE_INSTRUCTION
39 /*
40 * These will go to scm_instruction_table in instructions.c
41 */
42 #ifdef VM_INSTRUCTION_TO_TABLE
43 #define VM_DEFINE_INSTRUCTION(code_,tag_,name_,len_,npop_,npush_) \
44 table[VM_OPCODE (tag_)].opcode = code_; \
45 table[VM_OPCODE (tag_)].name = name_; \
46 table[VM_OPCODE (tag_)].len = len_; \
47 table[VM_OPCODE (tag_)].npop = npop_; \
48 table[VM_OPCODE (tag_)].npush = npush_;
49
50 #else
51 #ifdef VM_INSTRUCTION_TO_LABEL
52 /*
53 * These will go to jump_table in vm_engine.c
54 */
55 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag);
56
57 #else
58 #ifdef VM_INSTRUCTION_TO_OPCODE
59 /*
60 * These will go to scm_opcode in instructions.h
61 */
62 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code,
63
64 #else /* Otherwise */
65 /*
66 * These are directly included in vm_engine.c
67 */
68 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag)
69
70 #endif /* VM_INSTRUCTION_TO_OPCODE */
71 #endif /* VM_INSTRUCTION_TO_LABEL */
72 #endif /* VM_INSTRUCTION_TO_TABLE */
73
74 /*
75 Local Variables:
76 c-file-style: "gnu"
77 End:
78 */