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 License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * 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
20 #define VM_LABEL(tag) l_##tag
21 #define VM_OPCODE(tag) scm_op_##tag
23 #ifdef HAVE_LABELS_AS_VALUES
24 #define VM_TAG(tag) VM_LABEL(tag):
25 #define VM_ADDR(tag) &&VM_LABEL(tag)
26 #else /* not HAVE_LABELS_AS_VALUES */
27 #define VM_TAG(tag) case VM_OPCODE(tag):
28 #define VM_ADDR(tag) NULL
29 #endif /* not HAVE_LABELS_AS_VALUES */
32 #undef VM_DEFINE_FUNCTION
33 #undef VM_DEFINE_LOADER
34 #define VM_DEFINE_FUNCTION(code,tag,name,nargs) \
35 VM_DEFINE_INSTRUCTION(code,tag,name,0,nargs,1)
36 #define VM_DEFINE_LOADER(code,tag,name) \
37 VM_DEFINE_INSTRUCTION(code,tag,name,-1,0,1)
39 #undef VM_DEFINE_INSTRUCTION
41 * These will go to scm_instruction_table in instructions.c
43 #ifdef VM_INSTRUCTION_TO_TABLE
44 #define VM_DEFINE_INSTRUCTION(code_,tag_,name_,len_,npop_,npush_) \
45 table[VM_OPCODE (tag_)].opcode = code_; \
46 table[VM_OPCODE (tag_)].name = name_; \
47 table[VM_OPCODE (tag_)].len = len_; \
48 table[VM_OPCODE (tag_)].npop = npop_; \
49 table[VM_OPCODE (tag_)].npush = npush_;
52 #ifdef VM_INSTRUCTION_TO_LABEL
54 * These will go to jump_table in vm_engine.c
56 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag);
59 #ifdef VM_INSTRUCTION_TO_OPCODE
61 * These will go to scm_opcode in instructions.h
63 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code,
67 * These are directly included in vm_engine.c
69 #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag)
71 #endif /* VM_INSTRUCTION_TO_OPCODE */
72 #endif /* VM_INSTRUCTION_TO_LABEL */
73 #endif /* VM_INSTRUCTION_TO_TABLE */