mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-17 11:10:18 +02:00
Create *.i from *.c and include them.
This commit is contained in:
parent
4209716727
commit
77c04abec9
8 changed files with 59 additions and 74 deletions
|
@ -8,12 +8,10 @@ bin_SCRIPTS = guile-compile
|
||||||
lib_LTLIBRARIES = libguilevm.la
|
lib_LTLIBRARIES = libguilevm.la
|
||||||
libguilevm_la_SOURCES = vm.c
|
libguilevm_la_SOURCES = vm.c
|
||||||
libguilevm_la_LDFLAGS = -version-info 0:0:0 -export-dynamic
|
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 \
|
EXTRA_DIST = vm_engine.c vm_system.c vm_scheme.c vm_number.c \
|
||||||
test.scm guile-compile.in
|
test.scm guile-compile.in
|
||||||
BUILT_SOURCES = vm_system.inst vm_scheme.inst vm_number.inst \
|
BUILT_SOURCES = vm_system.i vm_scheme.i vm_number.i vm.x
|
||||||
vm_system.label vm_scheme.label vm_number.label \
|
|
||||||
vm_system.opcode vm_scheme.opcode vm_number.opcode vm.x
|
|
||||||
|
|
||||||
CFLAGS = -g -O2 -Wall
|
CFLAGS = -g -O2 -Wall
|
||||||
INCLUDES = $(GUILE_CFLAGS)
|
INCLUDES = $(GUILE_CFLAGS)
|
||||||
|
@ -22,24 +20,15 @@ DISTCLEANFILES = $(BUILT_SOURCES)
|
||||||
MAINTAINERCLEANFILES = Makefile.in config.h.in stamp-h.in
|
MAINTAINERCLEANFILES = Makefile.in config.h.in stamp-h.in
|
||||||
|
|
||||||
SNARF = guile-snarf
|
SNARF = guile-snarf
|
||||||
SUFFIXES = .x .inst .label .opcode
|
SUFFIXES = .x .i
|
||||||
.c.x:
|
.c.x:
|
||||||
$(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
|
$(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
|
||||||
|| { rm $@; false; }
|
|| { rm $@; false; }
|
||||||
|
|
||||||
.c.inst:
|
.c.i:
|
||||||
$(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
|
grep '^SCM_DEFINE' $< > $@
|
||||||
|| { rm $@; false; }
|
|
||||||
|
|
||||||
.c.label:
|
$(BUILT_SOURCES): config.h vm_expand.h
|
||||||
$(SNARF) -DSCM_SNARF_LABEL $(DEFS) $(INCLUDES) $(CPPFLAGS) \
|
|
||||||
$(CFLAGS) $< > $@ || { rm $@; false; }
|
|
||||||
|
|
||||||
.c.opcode:
|
|
||||||
$(SNARF) -DSCM_SNARF_OPCODE $(DEFS) $(INCLUDES) $(CPPFLAGS) \
|
|
||||||
$(CFLAGS) $< > $@ || { rm $@; false; }
|
|
||||||
|
|
||||||
$(BUILT_SOURCES): config.h vm-snarf.h
|
|
||||||
|
|
||||||
guile-compile: guile-compile.in
|
guile-compile: guile-compile.in
|
||||||
sed -e 's!\@bindir\@!$(bindir)!' -e 's!\@PACKAGE\@!$(PACKAGE)!' \
|
sed -e 's!\@bindir\@!$(bindir)!' -e 's!\@PACKAGE\@!$(PACKAGE)!' \
|
||||||
|
|
9
src/vm.c
9
src/vm.c
|
@ -117,9 +117,12 @@ init_name_property ()
|
||||||
static long scm_instruction_tag;
|
static long scm_instruction_tag;
|
||||||
|
|
||||||
static struct scm_instruction scm_instruction_table[] = {
|
static struct scm_instruction scm_instruction_table[] = {
|
||||||
#include "vm_system.inst"
|
#define VM_INSTRUCTION_TO_TABLE
|
||||||
#include "vm_scheme.inst"
|
#include "vm_expand.h"
|
||||||
#include "vm_number.inst"
|
#include "vm_system.i"
|
||||||
|
#include "vm_scheme.i"
|
||||||
|
#include "vm_number.i"
|
||||||
|
#undef VM_INSTRUCTION_TO_TABLE
|
||||||
{op_last}
|
{op_last}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
src/vm.h
10
src/vm.h
|
@ -43,6 +43,7 @@
|
||||||
#define VM_H
|
#define VM_H
|
||||||
|
|
||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,9 +52,12 @@
|
||||||
|
|
||||||
/* Opcode */
|
/* Opcode */
|
||||||
enum scm_opcode {
|
enum scm_opcode {
|
||||||
#include "vm_system.opcode"
|
#define VM_INSTRUCTION_TO_OPCODE
|
||||||
#include "vm_scheme.opcode"
|
#include "vm_expand.h"
|
||||||
#include "vm_number.opcode"
|
#include "vm_system.i"
|
||||||
|
#include "vm_scheme.i"
|
||||||
|
#include "vm_number.i"
|
||||||
|
#undef VM_INSTRUCTION_TO_OPCODE
|
||||||
op_last
|
op_last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,12 @@ VM_NAME (SCM vm, SCM program)
|
||||||
|
|
||||||
/* Jump talbe */
|
/* Jump talbe */
|
||||||
static void *jump_table[] = {
|
static void *jump_table[] = {
|
||||||
#include "vm_system.label"
|
#define VM_INSTRUCTION_TO_LABEL
|
||||||
#include "vm_scheme.label"
|
#include "vm_expand.h"
|
||||||
#include "vm_number.label"
|
#include "vm_system.i"
|
||||||
|
#include "vm_scheme.i"
|
||||||
|
#include "vm_number.i"
|
||||||
|
#undef VM_INSTRUCTION_TO_LABEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialize the VM */
|
/* Initialize the VM */
|
||||||
|
@ -101,6 +104,7 @@ VM_NAME (SCM vm, SCM program)
|
||||||
vm_start: switch (*pc++) {
|
vm_start: switch (*pc++) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "vm_expand.h"
|
||||||
#include "vm_system.c"
|
#include "vm_system.c"
|
||||||
#include "vm_scheme.c"
|
#include "vm_scheme.c"
|
||||||
#include "vm_number.c"
|
#include "vm_number.c"
|
||||||
|
|
|
@ -39,11 +39,9 @@
|
||||||
* whether to permit this exception to apply to your modifications.
|
* whether to permit this exception to apply to your modifications.
|
||||||
* If you do not wish that, delete this exception notice. */
|
* If you do not wish that, delete this exception notice. */
|
||||||
|
|
||||||
#ifndef VM_SNARF_H
|
|
||||||
#define VM_SNARF_H
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifndef VM_LABEL
|
||||||
#define VM_LABEL(TAG) l_##TAG##
|
#define VM_LABEL(TAG) l_##TAG##
|
||||||
#define VM_OPCODE(TAG) op_##TAG##
|
#define VM_OPCODE(TAG) op_##TAG##
|
||||||
|
|
||||||
|
@ -54,49 +52,42 @@
|
||||||
#define VM_TAG(TAG) case VM_OPCODE(TAG):
|
#define VM_TAG(TAG) case VM_OPCODE(TAG):
|
||||||
#define VM_ADDR(TAG) NULL
|
#define VM_ADDR(TAG) NULL
|
||||||
#endif /* not HAVE_LABELS_AS_VALUES */
|
#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 will go to scm_instruction_table in vm.c
|
||||||
|
*/
|
||||||
|
#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \
|
||||||
|
{VM_OPCODE(TAG), TYPE, NAME, SCM_PACK (0), NULL, 0, 0},
|
||||||
|
#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \
|
||||||
|
{VM_OPCODE(TAG), INST_NONE, NAME, SCM_PACK (0), SNAME, NARGS, RESTP},
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef VM_INSTRUCTION_TO_LABEL
|
||||||
|
/*
|
||||||
|
* These will go to jump_table in vm_engine.c
|
||||||
|
*/
|
||||||
|
#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 scm_opcode in vm.h
|
||||||
|
*/
|
||||||
|
#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_OPCODE(TAG),
|
||||||
|
#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_OPCODE(TAG),
|
||||||
|
|
||||||
|
#else /* Otherwise */
|
||||||
/*
|
/*
|
||||||
* These are directly included in vm_engine.c
|
* These are directly included in vm_engine.c
|
||||||
*/
|
*/
|
||||||
#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_TAG(TAG)
|
#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_TAG(TAG)
|
||||||
#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_TAG(TAG)
|
#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_TAG(TAG)
|
||||||
|
|
||||||
#else /* SCM_MAGIC_SNARFER */
|
#endif /* VM_INSTRUCTION_TO_OPCODE */
|
||||||
#ifndef SCM_SNARF_OPCODE
|
#endif /* VM_INSTRUCTION_TO_LABEL */
|
||||||
#ifndef SCM_SNARF_LABEL
|
#endif /* VM_INSTRUCTION_TO_TABLE */
|
||||||
|
|
||||||
/*
|
|
||||||
* These will go to *.inst
|
|
||||||
*/
|
|
||||||
#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \
|
|
||||||
SCM_SNARF_INIT_START {VM_OPCODE(TAG), TYPE, NAME, SCM_BOOL_F, 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 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These will go to *.label
|
|
||||||
*/
|
|
||||||
#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 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These will go to *.opcode
|
|
||||||
*/
|
|
||||||
#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),
|
|
||||||
|
|
||||||
#endif /* SCM_SNARF_OPCODE */
|
|
||||||
#endif /* SCM_MAGIC_SNARFER */
|
|
||||||
|
|
||||||
#endif /* not VM_SNARF_H */
|
|
|
@ -41,8 +41,6 @@
|
||||||
|
|
||||||
/* This file is included in vm_engine.c */
|
/* This file is included in vm_engine.c */
|
||||||
|
|
||||||
#include "vm-snarf.h"
|
|
||||||
|
|
||||||
#define FUNC2(CFUNC,SFUNC) \
|
#define FUNC2(CFUNC,SFUNC) \
|
||||||
{ \
|
{ \
|
||||||
VM_SETUP_ARGS2 (); \
|
VM_SETUP_ARGS2 (); \
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
|
|
||||||
/* This file is included in vm_engine.c */
|
/* This file is included in vm_engine.c */
|
||||||
|
|
||||||
#include "vm-snarf.h"
|
|
||||||
|
|
||||||
SCM_DEFINE_VM_FUNCTION (null_p, "null?", "null?", 1, 0)
|
SCM_DEFINE_VM_FUNCTION (null_p, "null?", "null?", 1, 0)
|
||||||
{
|
{
|
||||||
VM_SETUP_ARGS1 ();
|
VM_SETUP_ARGS1 ();
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
|
|
||||||
/* This file is included in vm_engine.c */
|
/* This file is included in vm_engine.c */
|
||||||
|
|
||||||
#include "vm-snarf.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variable access
|
* Variable access
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue