vm-expand.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef VM_LABEL
  19. #define VM_LABEL(tag) l_##tag
  20. #define VM_OPCODE(tag) scm_op_##tag
  21. #ifdef HAVE_LABELS_AS_VALUES
  22. #define VM_TAG(tag) VM_LABEL(tag):
  23. #define VM_ADDR(tag) &&VM_LABEL(tag)
  24. #else /* not HAVE_LABELS_AS_VALUES */
  25. #define VM_TAG(tag) case VM_OPCODE(tag):
  26. #define VM_ADDR(tag) NULL
  27. #endif /* not HAVE_LABELS_AS_VALUES */
  28. #endif /* VM_LABEL */
  29. #undef VM_DEFINE_FUNCTION
  30. #undef VM_DEFINE_LOADER
  31. #define VM_DEFINE_FUNCTION(code,tag,name,nargs) \
  32. VM_DEFINE_INSTRUCTION(code,tag,name,0,nargs,1)
  33. #define VM_DEFINE_LOADER(code,tag,name) \
  34. VM_DEFINE_INSTRUCTION(code,tag,name,-1,0,1)
  35. #undef VM_DEFINE_INSTRUCTION
  36. /*
  37. * These will go to scm_instruction_table in instructions.c
  38. */
  39. #ifdef VM_INSTRUCTION_TO_TABLE
  40. #define VM_DEFINE_INSTRUCTION(code_,tag_,name_,len_,npop_,npush_) \
  41. table[VM_OPCODE (tag_)].opcode = code_; \
  42. table[VM_OPCODE (tag_)].name = name_; \
  43. table[VM_OPCODE (tag_)].len = len_; \
  44. table[VM_OPCODE (tag_)].npop = npop_; \
  45. table[VM_OPCODE (tag_)].npush = npush_;
  46. #else
  47. #ifdef VM_INSTRUCTION_TO_LABEL
  48. /*
  49. * These will go to jump_table in vm_engine.c
  50. */
  51. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag);
  52. #else
  53. #ifdef VM_INSTRUCTION_TO_OPCODE
  54. /*
  55. * These will go to scm_opcode in instructions.h
  56. */
  57. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code,
  58. #else /* Otherwise */
  59. /*
  60. * These are directly included in vm_engine.c
  61. */
  62. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag)
  63. #endif /* VM_INSTRUCTION_TO_OPCODE */
  64. #endif /* VM_INSTRUCTION_TO_LABEL */
  65. #endif /* VM_INSTRUCTION_TO_TABLE */
  66. /*
  67. Local Variables:
  68. c-file-style: "gnu"
  69. End:
  70. */