summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-10-30 10:57:36 +0100
committerAndy Wingo <wingo@pobox.com>2008-10-30 10:57:36 +0100
commit3de80ed52f7482faee2ce883d3df21eb8a38ee7a (patch)
treef33bf42499307ad99a5c78031e6497cddf47d89e /libguile
parent21497600d23534b2878f82401ffaf5551fdb6efd (diff)
downloadguile-3de80ed52f7482faee2ce883d3df21eb8a38ee7a.tar.gz
recompiling with compile environments, fluid languages, cleanups
* ice-9/boot-9.scm (compile-time-environment): Remove definition from boot-9 -- instead, autoload it and `compile' from (system base compile). * libguile/objcodes.h: * libguile/objcodes.c (scm_objcode_to_program): Add an optional argument, `external', the external list to set on the returned program. * libguile/vm-i-system.c (externals): New instruction, returns the external list. Only used by (compile-time-environment). * libguile/vm.c (scm_load_compiled_with_vm): Adapt to scm_objcode_to_program change. * module/language/scheme/translate.scm (translate): Actually pay attention to the environment passed as an argument. (custom-transformer-table): Expand out (compile-time-environment) to something that can be passed to `compile'. * module/system/base/compile.scm (*current-language*): Instead of hard-coding `scheme' in various places, use a current language fluid, initialized to `scheme'. (compile-file, load-source-file): Adapt to *current-language*. (load-source-file): Ada (scheme-eval): Removed, no one used this. (compiled-file-name): Don't hard-code "scm" and "go"; instead use the %load-extensions and %load-compiled-extensions. (cenv-module, cenv-ghil-env, cenv-externals): Some accessors for compile-time environments. (compile-time-environment): Here we define (compile-time-environment) to something that will return #f; the compiler however produces different code as noted above. (compile): New function, compiles an expression into a thunk, then runs the thunk to get the value. Useful for procedures. The optional second argument can be either a module or a compile-time-environment; in the latter case, we can recompile even with lexical bindings. (compile-in): If the env specifies a module, set that module for the duration of the compilation. * module/system/base/syntax.scm (%compute-initargs): Fix a bug where the default value for a field would always replace a user-supplied value. Whoops. * module/system/il/ghil.scm (ghil-env-dereify): New function, takes the result of ghil-env-reify and turns it back into a GHIL environment. * scripts/compile (compile): Remove some of the tricky error handling, as the library procedures handle this for us. * test-suite/tests/compiler.test: Add a test for the dynamic compilation bits.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/objcodes.c9
-rw-r--r--libguile/objcodes.h2
-rw-r--r--libguile/vm-i-system.c6
-rw-r--r--libguile/vm.c2
4 files changed, 15 insertions, 4 deletions
diff --git a/libguile/objcodes.c b/libguile/objcodes.c
index 6891e8a6a..bb2810ff5 100644
--- a/libguile/objcodes.c
+++ b/libguile/objcodes.c
@@ -254,8 +254,8 @@ SCM_DEFINE (scm_objcode_to_u8vector, "objcode->u8vector", 1, 0, 0,
}
#undef FUNC_NAME
-SCM_DEFINE (scm_objcode_to_program, "objcode->program", 1, 0, 0,
- (SCM objcode),
+SCM_DEFINE (scm_objcode_to_program, "objcode->program", 1, 1, 0,
+ (SCM objcode, SCM external),
"")
#define FUNC_NAME s_scm_objcode_to_program
{
@@ -265,6 +265,10 @@ SCM_DEFINE (scm_objcode_to_program, "objcode->program", 1, 0, 0,
struct scm_program *p;
SCM_VALIDATE_OBJCODE (1, objcode);
+ if (SCM_UNBNDP (external))
+ external = SCM_EOL;
+ else
+ SCM_VALIDATE_LIST (2, external);
base = SCM_OBJCODE_BASE (objcode);
size = SCM_OBJCODE_SIZE (objcode);
@@ -272,6 +276,7 @@ SCM_DEFINE (scm_objcode_to_program, "objcode->program", 1, 0, 0,
p = SCM_PROGRAM_DATA (prog);
p->nlocs = base[8];
p->nexts = base[9];
+ p->external = external;
return prog;
}
#undef FUNC_NAME
diff --git a/libguile/objcodes.h b/libguile/objcodes.h
index 2cedefa98..5e4808b4c 100644
--- a/libguile/objcodes.h
+++ b/libguile/objcodes.h
@@ -61,7 +61,7 @@ extern scm_t_bits scm_tc16_objcode;
#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 SCM scm_objcode_to_program (SCM objcode, SCM external);
extern SCM scm_objcode_p (SCM obj);
extern SCM scm_bytecode_to_objcode (SCM bytecode, SCM nlocs, SCM nexts);
extern SCM scm_objcode_to_u8vector (SCM objcode);
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 2da2d4249..ca1dbcaf8 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -413,6 +413,12 @@ VM_DEFINE_INSTRUCTION (late_variable_set, "late-variable-set", 1, 1, 0)
NEXT;
}
+VM_DEFINE_INSTRUCTION (externals, "externals", 0, 0, 1)
+{
+ PUSH (external);
+ NEXT;
+}
+
/*
* branch and jump
diff --git a/libguile/vm.c b/libguile/vm.c
index c0cf672d5..08629f0b7 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -743,7 +743,7 @@ SCM_DEFINE (scm_vm_fetch_stack, "vm-fetch-stack", 1, 0, 0,
SCM scm_load_compiled_with_vm (SCM file)
{
- SCM program = scm_objcode_to_program (scm_load_objcode (file));
+ SCM program = scm_objcode_to_program (scm_load_objcode (file), SCM_EOL);
return vm_run (scm_the_vm (), program, SCM_EOL);
}