1 /* Copyright (C) 2001 Free Software Foundation, Inc.
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.
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.
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
19 #define VM_LABEL(tag) l_##tag
20 #define VM_OPCODE(tag) scm_op_##tag
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 */
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)
38 #undef VM_DEFINE_INSTRUCTION
40 * These will go to scm_instruction_table in instructions.c
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_;
51 #ifdef VM_INSTRUCTION_TO_LABEL
53 * These will go to jump_table in vm_engine.c
55 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag);
58 #ifdef VM_INSTRUCTION_TO_OPCODE
60 * These will go to scm_opcode in instructions.h
62 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code,
66 * These are directly included in vm_engine.c
68 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag)
70 #endif /* VM_INSTRUCTION_TO_OPCODE */
71 #endif /* VM_INSTRUCTION_TO_LABEL */
72 #endif /* VM_INSTRUCTION_TO_TABLE */