summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/bootstrap.h53
-rw-r--r--src/frames.c9
-rw-r--r--src/frames.h1
-rw-r--r--src/instructions.c8
-rw-r--r--src/instructions.h1
-rw-r--r--src/objcodes.c9
-rw-r--r--src/objcodes.h4
-rw-r--r--src/programs.c9
-rw-r--r--src/programs.h1
-rw-r--r--src/vm.c35
-rw-r--r--src/vm.h2
12 files changed, 125 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cc2617e8..32de942fa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ CFLAGS:=$(filter-out -Wmissing-prototypes,$(CFLAGS))
lib_LTLIBRARIES = libguile-vm.la
libguile_vm_la_SOURCES = \
+ bootstrap.h \
envs.c frames.c instructions.c objcodes.c programs.c vm.c \
envs.h frames.h instructions.h objcodes.h programs.h vm.h \
vm_engine.h vm_expand.h
diff --git a/src/bootstrap.h b/src/bootstrap.h
new file mode 100644
index 000000000..beecf0fc2
--- /dev/null
+++ b/src/bootstrap.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ *
+ * As a special exception, the Free Software Foundation gives permission
+ * for additional uses of the text contained in its release of GUILE.
+ *
+ * The exception is that, if you link the GUILE library with other files
+ * to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the GUILE library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by the
+ * Free Software Foundation under the name GUILE. If you copy
+ * code from other Free Software Foundation releases into a copy of
+ * GUILE, as the General Public License permits, the exception does
+ * not apply to the code that you add in this way. To avoid misleading
+ * anyone as to the status of such modified files, you must delete
+ * this exception notice from them.
+ *
+ * If you write modifications of your own for GUILE, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice. */
+
+#ifndef _SCM_VM_BOOTSTRAP_H_
+#define _SCM_VM_BOOTSTRAP_H_
+
+extern void scm_bootstrap_vm (void);
+
+#endif /* _SCM_VM_BOOTSTRAP_H_ */
+
+/*
+ Local Variables:
+ c-file-style: "gnu"
+ End:
+*/
diff --git a/src/frames.c b/src/frames.c
index c25c9f677..a3c9b9705 100644
--- a/src/frames.c
+++ b/src/frames.c
@@ -44,6 +44,7 @@
#endif
#include <string.h>
+#include "bootstrap.h"
#include "frames.h"
@@ -172,11 +173,17 @@ SCM_DEFINE (scm_frame_external_link, "frame-external-link", 1, 0, 0,
void
-scm_init_frames (void)
+scm_bootstrap_frames (void)
{
scm_tc16_heap_frame = scm_make_smob_type ("frame", 0);
scm_set_smob_mark (scm_tc16_heap_frame, heap_frame_mark);
scm_set_smob_free (scm_tc16_heap_frame, heap_frame_free);
+}
+
+void
+scm_init_frames (void)
+{
+ scm_bootstrap_vm ();
#ifndef SCM_MAGIC_SNARFER
#include "frames.x"
diff --git a/src/frames.h b/src/frames.h
index 3803ffdc2..b0ac0c79a 100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -105,6 +105,7 @@ extern scm_t_bits scm_tc16_heap_frame;
#define SCM_VALIDATE_HEAP_FRAME(p,x) SCM_MAKE_VALIDATE (p, x, HEAP_FRAME_P)
extern SCM scm_c_make_heap_frame (SCM *fp);
+extern void scm_bootstrap_frames (void);
extern void scm_init_frames (void);
#endif /* _SCM_FRAMES_H_ */
diff --git a/src/instructions.c b/src/instructions.c
index 2ed70f381..f7ec70182 100644
--- a/src/instructions.c
+++ b/src/instructions.c
@@ -44,6 +44,7 @@
#endif
#include <string.h>
+#include "bootstrap.h"
#include "instructions.h"
struct scm_instruction scm_instruction_table[] = {
@@ -159,8 +160,15 @@ SCM_DEFINE (scm_opcode_to_instruction, "opcode->instruction", 1, 0, 0,
#undef FUNC_NAME
void
+scm_bootstrap_instructions (void)
+{
+}
+
+void
scm_init_instructions (void)
{
+ scm_bootstrap_vm ();
+
#ifndef SCM_MAGIC_SNARFER
#include "instructions.x"
#endif
diff --git a/src/instructions.h b/src/instructions.h
index 71b3f511f..d3f183761 100644
--- a/src/instructions.h
+++ b/src/instructions.h
@@ -79,6 +79,7 @@ struct scm_instruction {
extern struct scm_instruction scm_instruction_table[];
extern struct scm_instruction *scm_lookup_instruction (SCM name);
+extern void scm_bootstrap_instructions (void);
extern void scm_init_instructions (void);
#endif /* _SCM_INSTRUCTIONS_H_ */
diff --git a/src/objcodes.c b/src/objcodes.c
index 4306d3f47..603a0873c 100644
--- a/src/objcodes.c
+++ b/src/objcodes.c
@@ -51,6 +51,7 @@
#include <sys/types.h>
#include <assert.h>
+#include "bootstrap.h"
#include "programs.h"
#include "objcodes.h"
@@ -277,10 +278,16 @@ SCM_DEFINE (scm_objcode_to_program, "objcode->program", 1, 0, 0,
void
-scm_init_objcodes (void)
+scm_bootstrap_objcodes (void)
{
scm_tc16_objcode = scm_make_smob_type ("objcode", 0);
scm_set_smob_free (scm_tc16_objcode, objcode_free);
+}
+
+void
+scm_init_objcodes (void)
+{
+ scm_bootstrap_vm ();
#ifndef SCM_MAGIC_SNARFER
#include "objcodes.x"
diff --git a/src/objcodes.h b/src/objcodes.h
index ee3b0956e..9acdbcc0f 100644
--- a/src/objcodes.h
+++ b/src/objcodes.h
@@ -60,6 +60,10 @@ extern scm_t_bits scm_tc16_objcode;
#define SCM_OBJCODE_BASE(x) (SCM_OBJCODE_DATA (x)->base)
#define SCM_OBJCODE_FD(x) (SCM_OBJCODE_DATA (x)->fd)
+extern SCM scm_load_objcode (SCM file);
+extern SCM scm_objcode_to_program (SCM objcode);
+
+extern void scm_bootstrap_objcodes (void);
extern void scm_init_objcodes (void);
#endif /* _SCM_OBJCODES_H_ */
diff --git a/src/programs.c b/src/programs.c
index 388b8cad6..9f0bde738 100644
--- a/src/programs.c
+++ b/src/programs.c
@@ -44,6 +44,7 @@
#endif
#include <string.h>
+#include "bootstrap.h"
#include "instructions.h"
#include "programs.h"
#include "vm.h"
@@ -227,7 +228,7 @@ SCM_DEFINE (scm_program_bytecode, "program-bytecode", 1, 0, 0,
void
-scm_init_programs (void)
+scm_bootstrap_programs (void)
{
zero_vector = scm_permanent_object (scm_c_make_vector (0, SCM_BOOL_F));
@@ -235,7 +236,13 @@ scm_init_programs (void)
scm_set_smob_mark (scm_tc16_program, program_mark);
scm_set_smob_free (scm_tc16_program, program_free);
scm_set_smob_apply (scm_tc16_program, program_apply, 0, 0, 1);
+}
+void
+scm_init_programs (void)
+{
+ scm_bootstrap_vm ();
+
#ifndef SCM_MAGIC_SNARFER
#include "programs.x"
#endif
diff --git a/src/programs.h b/src/programs.h
index 238fae939..8bc3f8ad5 100644
--- a/src/programs.h
+++ b/src/programs.h
@@ -72,6 +72,7 @@ extern scm_t_bits scm_tc16_program;
extern SCM scm_c_make_program (void *addr, size_t size, SCM holder);
extern SCM scm_c_make_closure (SCM program, SCM external);
+extern void scm_bootstrap_programs (void);
extern void scm_init_programs (void);
#endif /* _SCM_PROGRAMS_H_ */
diff --git a/src/vm.c b/src/vm.c
index d9535ba48..53457287d 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -561,13 +561,25 @@ SCM_DEFINE (scm_vm_fetch_stack, "vm-fetch-stack", 1, 0, 0,
* Initialize
*/
+SCM scm_load_compiled_with_vm (SCM file)
+{
+ SCM program = scm_objcode_to_program (scm_load_objcode (file));
+
+ return vm_run (the_vm, program, SCM_EOL);
+}
+
void
-scm_init_vm (void)
+scm_bootstrap_vm (void)
{
- scm_init_frames ();
- scm_init_instructions ();
- scm_init_objcodes ();
- scm_init_programs ();
+ static int strappage = 0;
+
+ if (strappage)
+ return;
+
+ scm_bootstrap_frames ();
+ scm_bootstrap_instructions ();
+ scm_bootstrap_objcodes ();
+ scm_bootstrap_programs ();
scm_tc16_vm_cont = scm_make_smob_type ("vm-cont", 0);
scm_set_smob_mark (scm_tc16_vm_cont, vm_cont_mark);
@@ -580,6 +592,19 @@ scm_init_vm (void)
the_vm = scm_permanent_object (make_vm ());
+ /* a bit heavy-handed, this */
+ scm_variable_set_x (scm_c_lookup ("load-compiled"),
+ scm_c_make_gsubr ("load-compiled/vm", 1, 0, 0,
+ scm_load_compiled_with_vm));
+
+ strappage = 1;
+}
+
+void
+scm_init_vm (void)
+{
+ scm_bootstrap_vm ();
+
#ifndef SCM_MAGIC_SNARFER
#include "vm.x"
#endif
diff --git a/src/vm.h b/src/vm.h
index e3cdc25ef..ef3022916 100644
--- a/src/vm.h
+++ b/src/vm.h
@@ -79,6 +79,8 @@ extern SCM scm_vm_apply (SCM vm, SCM program, SCM args);
extern SCM scm_vm_option_ref (SCM vm, SCM key);
extern SCM scm_vm_option_set_x (SCM vm, SCM key, SCM val);
+extern SCM scm_load_compiled_with_vm (SCM file);
+
extern void scm_init_vm (void);
#endif /* _SCM_VM_H_ */