| 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 License |
| 5 | * as published by the Free Software Foundation; either version 3 of |
| 6 | * the License, or (at your option) any later version. |
| 7 | * |
| 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. |
| 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 |
| 16 | * 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #ifndef VM_LABEL |
| 20 | #define VM_LABEL(tag) l_##tag |
| 21 | #define VM_OPCODE(tag) scm_op_##tag |
| 22 | |
| 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 */ |
| 30 | #endif /* VM_LABEL */ |
| 31 | |
| 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) |
| 38 | |
| 39 | #undef VM_DEFINE_INSTRUCTION |
| 40 | /* |
| 41 | * These will go to scm_instruction_table in instructions.c |
| 42 | */ |
| 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_; |
| 50 | |
| 51 | #else |
| 52 | #ifdef VM_INSTRUCTION_TO_LABEL |
| 53 | /* |
| 54 | * These will go to jump_table in vm_engine.c |
| 55 | */ |
| 56 | #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag); |
| 57 | |
| 58 | #else |
| 59 | #ifdef VM_INSTRUCTION_TO_OPCODE |
| 60 | /* |
| 61 | * These will go to scm_opcode in instructions.h |
| 62 | */ |
| 63 | #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code, |
| 64 | |
| 65 | #else /* Otherwise */ |
| 66 | /* |
| 67 | * These are directly included in vm_engine.c |
| 68 | */ |
| 69 | #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag) |
| 70 | |
| 71 | #endif /* VM_INSTRUCTION_TO_OPCODE */ |
| 72 | #endif /* VM_INSTRUCTION_TO_LABEL */ |
| 73 | #endif /* VM_INSTRUCTION_TO_TABLE */ |
| 74 | |
| 75 | /* |
| 76 | Local Variables: |
| 77 | c-file-style: "gnu" |
| 78 | End: |
| 79 | */ |