Create *.i from *.c and include them.
authorKeisuke Nishida <kxn30@po.cwru.edu>
Fri, 29 Sep 2000 18:08:00 +0000 (18:08 +0000)
committerKeisuke Nishida <kxn30@po.cwru.edu>
Fri, 29 Sep 2000 18:08:00 +0000 (18:08 +0000)
src/Makefile.am
src/vm.c
src/vm.h
src/vm_engine.c
src/vm_expand.h [moved from src/vm-snarf.h with 72% similarity]
src/vm_number.c
src/vm_scheme.c
src/vm_system.c

index c5b9b30..56b7249 100644 (file)
@@ -8,12 +8,10 @@ bin_SCRIPTS = guile-compile
 lib_LTLIBRARIES = libguilevm.la
 libguilevm_la_SOURCES = vm.c
 libguilevm_la_LDFLAGS = -version-info 0:0:0 -export-dynamic
-noinst_HEADERS = vm.h vm_engine.h vm-snarf.h
+noinst_HEADERS = vm.h vm_engine.h vm_expand.h
 EXTRA_DIST = vm_engine.c vm_system.c vm_scheme.c vm_number.c \
             test.scm guile-compile.in
-BUILT_SOURCES = vm_system.inst vm_scheme.inst vm_number.inst \
-               vm_system.label vm_scheme.label vm_number.label \
-               vm_system.opcode vm_scheme.opcode vm_number.opcode vm.x
+BUILT_SOURCES = vm_system.i vm_scheme.i vm_number.i vm.x
 
 CFLAGS = -g -O2 -Wall
 INCLUDES = $(GUILE_CFLAGS)
@@ -22,24 +20,15 @@ DISTCLEANFILES = $(BUILT_SOURCES)
 MAINTAINERCLEANFILES = Makefile.in config.h.in stamp-h.in
 
 SNARF = guile-snarf
-SUFFIXES = .x .inst .label .opcode
+SUFFIXES = .x .i
 .c.x:
        $(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
        || { rm $@; false; }
 
-.c.inst:
-       $(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
-       || { rm $@; false; }
-
-.c.label:
-       $(SNARF) -DSCM_SNARF_LABEL $(DEFS) $(INCLUDES) $(CPPFLAGS) \
-       $(CFLAGS) $< > $@ || { rm $@; false; }
-
-.c.opcode:
-       $(SNARF) -DSCM_SNARF_OPCODE $(DEFS) $(INCLUDES) $(CPPFLAGS) \
-       $(CFLAGS) $< > $@ || { rm $@; false; }
+.c.i:
+       grep '^SCM_DEFINE' $< > $@
 
-$(BUILT_SOURCES): config.h vm-snarf.h
+$(BUILT_SOURCES): config.h vm_expand.h
 
 guile-compile: guile-compile.in
        sed -e 's!\@bindir\@!$(bindir)!' -e 's!\@PACKAGE\@!$(PACKAGE)!' \
index 43e554f..a784fae 100644 (file)
--- a/src/vm.c
+++ b/src/vm.c
@@ -117,9 +117,12 @@ init_name_property ()
 static long scm_instruction_tag;
 
 static struct scm_instruction scm_instruction_table[] = {
-#include "vm_system.inst"
-#include "vm_scheme.inst"
-#include "vm_number.inst"
+#define VM_INSTRUCTION_TO_TABLE
+#include "vm_expand.h"
+#include "vm_system.i"
+#include "vm_scheme.i"
+#include "vm_number.i"
+#undef VM_INSTRUCTION_TO_TABLE
   {op_last}
 };
 
index a1320f1..80f8246 100644 (file)
--- a/src/vm.h
+++ b/src/vm.h
@@ -43,6 +43,7 @@
 #define VM_H
 
 #include <libguile.h>
+#include "config.h"
 
 \f
 /*
 
 /* Opcode */
 enum scm_opcode {
-#include "vm_system.opcode"
-#include "vm_scheme.opcode"
-#include "vm_number.opcode"
+#define VM_INSTRUCTION_TO_OPCODE
+#include "vm_expand.h"
+#include "vm_system.i"
+#include "vm_scheme.i"
+#include "vm_number.i"
+#undef VM_INSTRUCTION_TO_OPCODE
   op_last
 };
 
index 9d459b1..ab68ce0 100644 (file)
@@ -78,9 +78,12 @@ VM_NAME (SCM vm, SCM program)
 
   /* Jump talbe */
   static void *jump_table[] = {
-#include "vm_system.label"
-#include "vm_scheme.label"
-#include "vm_number.label"
+#define VM_INSTRUCTION_TO_LABEL
+#include "vm_expand.h"
+#include "vm_system.i"
+#include "vm_scheme.i"
+#include "vm_number.i"
+#undef VM_INSTRUCTION_TO_LABEL
   };
 
   /* Initialize the VM */
@@ -101,6 +104,7 @@ VM_NAME (SCM vm, SCM program)
   vm_start: switch (*pc++) {
 #endif
 
+#include "vm_expand.h"
 #include "vm_system.c"
 #include "vm_scheme.c"
 #include "vm_number.c"
similarity index 72%
rename from src/vm-snarf.h
rename to src/vm_expand.h
index 8e35ac1..1eeea81 100644 (file)
  * whether to permit this exception to apply to your modifications.
  * If you do not wish that, delete this exception notice.  */
 
-#ifndef VM_SNARF_H
-#define VM_SNARF_H
-
 #include "config.h"
 
+#ifndef VM_LABEL
 #define VM_LABEL(TAG) l_##TAG## 
 #define VM_OPCODE(TAG) op_##TAG## 
 
 #define VM_TAG(TAG) case VM_OPCODE(TAG):
 #define VM_ADDR(TAG) NULL
 #endif /* not HAVE_LABELS_AS_VALUES */
+#endif /* VM_LABEL */
 
-#ifndef SCM_MAGIC_SNARFER
-
+#undef SCM_DEFINE_INSTRUCTION
+#undef SCM_DEFINE_VM_FUNCTION
+#ifdef VM_INSTRUCTION_TO_TABLE
 /*
- * These are directly included in vm_engine.c
- */
-#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_TAG(TAG)
-#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_TAG(TAG)
-
-#else /* SCM_MAGIC_SNARFER */
-#ifndef SCM_SNARF_OPCODE
-#ifndef SCM_SNARF_LABEL
-
-/*
- * These will go to *.inst
+ * These will go to scm_instruction_table in vm.c
  */
 #define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \
-  SCM_SNARF_INIT_START {VM_OPCODE(TAG), TYPE, NAME, SCM_BOOL_F, NULL, 0, 0},
+  {VM_OPCODE(TAG), TYPE, NAME, SCM_PACK (0), NULL, 0, 0},
 #define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \
-  SCM_SNARF_INIT_START {VM_OPCODE(TAG), INST_NONE, NAME, SCM_BOOL_F, SNAME, NARGS, RESTP},
-
-#else /* SCM_SNARF_LABEL */
+  {VM_OPCODE(TAG), INST_NONE, NAME, SCM_PACK (0), SNAME, NARGS, RESTP},
 
+#else
+#ifdef VM_INSTRUCTION_TO_LABEL
 /*
- * These will go to *.label
+ * These will go to jump_table in vm_engine.c
  */
-#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \
-  SCM_SNARF_INIT_START VM_ADDR(TAG),
-#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \
-  SCM_SNARF_INIT_START VM_ADDR(TAG),
-
-#endif /* SCM_SNARF_LABEL */
-#else /* SCM_SNARF_OPCODE */
+#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE)             VM_ADDR(TAG),
+#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_ADDR(TAG),
 
+#else
+#ifdef VM_INSTRUCTION_TO_OPCODE
 /*
- * These will go to *.opcode
+ * These will go to scm_opcode in vm.h
  */
-#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \
-  SCM_SNARF_INIT_START VM_OPCODE(TAG),
-#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \
-  SCM_SNARF_INIT_START VM_OPCODE(TAG),
+#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE)             VM_OPCODE(TAG),
+#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_OPCODE(TAG),
 
-#endif /* SCM_SNARF_OPCODE */
-#endif /* SCM_MAGIC_SNARFER */
+#else /* Otherwise */
+/*
+ * These are directly included in vm_engine.c
+ */
+#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE)             VM_TAG(TAG)
+#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_TAG(TAG)
 
-#endif /* not VM_SNARF_H */
+#endif /* VM_INSTRUCTION_TO_OPCODE */
+#endif /* VM_INSTRUCTION_TO_LABEL */
+#endif /* VM_INSTRUCTION_TO_TABLE */
index de7d7dd..cc7b63a 100644 (file)
@@ -41,8 +41,6 @@
 
 /* This file is included in vm_engine.c */
 
-#include "vm-snarf.h"
-
 #define FUNC2(CFUNC,SFUNC)                             \
 {                                                      \
   VM_SETUP_ARGS2 ();                                   \
index 3ab57f6..3b3c6e5 100644 (file)
@@ -41,8 +41,6 @@
 
 /* This file is included in vm_engine.c */
 
-#include "vm-snarf.h"
-
 SCM_DEFINE_VM_FUNCTION (null_p, "null?", "null?", 1, 0)
 {
   VM_SETUP_ARGS1 ();
index a7cd193..de8041d 100644 (file)
@@ -41,8 +41,6 @@
 
 /* This file is included in vm_engine.c */
 
-#include "vm-snarf.h"
-
 /*
  * Variable access
  */