* module/system/base/syntax.scm (define-record): So, in the generated
constructors, allow optional arguments, but not keyword arguments.
Conses much less in the constructors.
(define-record/keywords): And the old define-record is here.
* module/language/ghil.scm (parse-ghil):
* module/language/ghil/compile-glil.scm (codegen):
* module/language/scheme/compile-ghil.scm (translate-1, quote)
(quasiquote): Don't use keywords in this compiler hotpath.
* module/system/base/language.scm (<language>):
* module/system/repl/common.scm (<repl>):
* module/system/vm/debug.scm (<debugger>): Use define-record/keywords.
* module/language/ghil/compile-glil.scm (codegen): Record source location
for offset 0 into a lambda, if we can.
* module/language/scheme/compile-ghil.scm (translate-1)
(define-scheme-translator): In the retrans procedures, propagate the
location information from the enclosing expression if the subexpression
has no location information. Gives source information to many more
expressions.
(location): Just propagate the source properties as they are, the
glil->assembly compiler will interpret them.
* module/language/glil.scm (<glil>): Change glil-source to take "props"
and not "loc", as it's the source properties that we're interested in.
* module/language/glil/compile-assembly.scm (limn-sources): New function,
takes a list of addr-source property pairs and "compresses" them for
serialization to disk.
(glil->assembly): Limn the sources before writing them to disk. Avoid
non-tail recursion when determining total byte length of code.
* module/system/vm/program.scm (source:file, source:line, source:column):
Update for new source representation.
(program-source): Export.
(write-program): Nicer pretty-printing of anonymous procedures.
* libguile/backtrace.c (display_backtrace_get_file_line): Update for the
new VM source representation.
* libguile/programs.h:
* libguile/programs.c (scm_program_sources): Update for the new
serialized source representation, where the filename is not in the
stream unless it changes.
(scm_program_source): New exported function, looks up the source for a
given ip offset.
(scm_c_program_source): Update to return the last source information
that was <= the given IP, because we only serialize source info when it
changes.
* module/language/scheme/compile-ghil.scm (lookup-transformer): Allow
macros to be unquoted into the car of any form that results from macro
expansion. This lets modules export defmacros built on other defmacros
that are not exported.
* libguile/stacks.c (scm_make_stack): Instead of aborting when we misread
the number of stack frames, just print a warning. I'd like to figure
out what these cases are, exactly.
* module/language/scheme/compile-ghil.scm (lambda): Reindent the lambda
transformer.
* module/system/base/compile.scm (call-with-compile-error-catch): Write
the expression instead of displaying it.
(call-with-output-file/atomic): Don't actually redirect output to this
port, as it's not necessary -- the language-printer should respect the
port that we pass.
* module/system/base/language.scm (lookup-decompilation-order): New
function, like its compiling cousin, but backwards.
(compute-translation-order): Rework so that languages can be specified
either by name or by identity. Return a list of language - procedure
pairs, without the "to" language in the list, instead of a list of
languages.
(invalidate-compilation-cache!): Invalidate the decompilation cache
too.
(<language>): Add a decompiler field.
* module/system/base/compile.scm (compile-passes): Much simpler now that
lookup-compilation-order gives us the procedures directly.
* module/language/*/spec.scm: Specify compilers by name, so that we can
avoid unnecessary module loads, and so that when we specify
decompilers, we can avoid cycles.
* gdbinit: Untested attempts to get the stack fondling macros to deal
with the new program representation.
* libguile/frames.c (scm_vm_frame_arguments, scm_vm_frame_source)
(scm_vm_frame_local_ref, scm_vm_frame_local_set_x): SCM_PROGRAM_DATA is
a struct scm_objcode*.
* libguile/instructions.h:
* libguile/instructions.c: Hide the instruction table and the struct
scm_instruction structure; all access to instructions now goes through
procedures. This is because instructions are no longer in a packed
array indexed by opcode. Also, declare a mask that all instructions
should fit in.
* libguile/objcodes.h:
* libguile/objcodes.c: Rewrite so that object code directly maps its
arity and length from its bytecode. This makes it unnecessary to keep
this information in programs, allowing programs to be simple conses
between the code (objcodes) and data (the object table and the closure
variables).
* libguile/programs.c (scm_make_program): Rework so that make-program
takes objcode, an object table, and externals as arguments. It's much
clearer this way, and we avoid malloc().
* libguile/stacks.c (is_vm_bootstrap_frame): Update for program/objcode
changes.
* libguile/vm-engine.c (vm_run): Initialize the jump table on the first
run, with the opcodes declared in the instruction sources, and with bad
instructions raising an error instead of wandering off into the
Unknown.
* libguile/vm-engine.h (FETCH_LENGTH): Always represent lengths as 3
bytes. The old code was too error-prone.
(NEXT_JUMP): Mask the instruction with SCM_VM_INSTRUCTION_MASK.
(NEW_FRAME): Update for program/objcode changes.
* libguile/vm-expand.h (VM_DEFINE_FUNCTION, VM_DEFINE_INSTRUCTION)
(VM_DEFINE_LOADER): Update so that we explicitly specify opcodes, so
that we have a stable bytecode API.
* libguile/vm-i-loader.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(load-integer): Use an int instead of a long as the accumulator; still
need to revisit this code at some point, I think.
(load-program): Simplify, thankfully!! Just creates the objcode slice
and rolls with it.
* libguile/vm-i-scheme.c: Number the opcodes explicitly.
* libguile/vm-i-system.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(make-closure): Update for new program API.
* libguile/vm.c (vm_make_boot_program): Update for new program/objcode
API. Still a bit ugly.
(scm_load_compiled_with_vm): Update for new program/objcode API.
* module/language/assembly.scm (byte-length): Fix byte-length calculation
for loaders, and load-program.
(code-pack, code-unpack): Start to move things from (system vm conv)
here.
(object->code, code->object): More things from conv.scm.
* module/language/glil.scm (<glil-program>): Add a new field,
closure-level.
(make-glil-program, compute-closure-level): Calculate the "closure
level" when making a glil program. This is the maximum depth of
external binding refs in this closure.
(unparse-glil): Fix label serialization.
* module/language/glil/compile-assembly.scm (make-meta): Prepend #f for
the meta's object table, though maybe in the future we can avoid
creating assembly in the first place.
(assoc-ref-or-acons, object-index-and-alist): GRRR! Caught again by the
different sets of arguments to assoc and assoc-ref!
(glil->assembly): Attempt to make the <glil-program> case more
readable, and fix the bugs. Sorry I don't know how to comment this
change any more than this.
(glil->assembly): For <glil-module> serialize the whole key, not just
the name.
(dump-object): subprogram-code is already a list. Serialize integers as
strings, not u8vectors. Fix the order of lists and vectors.
* module/language/glil/spec.scm (glil): Switch orders, so we prefer glil
-> assembly -> objcode. Actually glil->objcode doesn't work any more,
needs to be removed I think.
* module/language/objcode/spec.scm (objcode->value):
s/objcode->program/make-program/.
* module/language/scheme/inline.scm: Add acons inline.
* module/system/vm/conv.scm (make-byte-decoder): Skip the first 8 bytes,
they are header. Handle subprograms properly. Still needs help though.
(decode-length): Lengths are always 3 bytes now.
* module/system/vm/disasm.scm: Superficial changes to keep things
working. I'd like to fix this better in the future.
* module/system/vm/frame.scm (bootstrap-frame?): Fixes for
program-bytecode.
* module/system/vm/program.scm: Export make-program. It's program-objcode
now, no more program-bytecode.
* module/system/vm/vm.scm (vm-load): Use make-program.
* test-suite/tests/asm-to-bytecode.test: New test, very minimal.
* module/system/vm/objcode.scm: Export word-size, byte-order, and
write-objcode.
* doc/ref/api-evaluation.texi: Fix some typos and xrefs.
* doc/ref/compiler.texi (The Scheme Compiler): Document the scheme
compiler, and start documenting the GHIL language.
* doc/ref/guile.texi (Guile Implementation): Whoops, put autoconf after
the implementation foo. Unless we want it before?
* doc/ref/history.texi (The Emacs Thesis): Fix typo.
* doc/ref/vm.texi (Environment Control Instructions): Rename offset to
index.
* module/language/ghil.scm (parse-ghil): Fix what I think was a bug --
the consumer in a mv-call shouldn't be a rest arg.
* module/language/scheme/Makefile.am (SOURCES):
* module/language/scheme/compile-ghil.scm: Rename this file from
translate.scm.
* module/oop/goops.scm:
* module/language/scheme/spec.scm: Deal with renaming.
* module/system/base/language.scm (<language>): Rework so that instead of
hardcoding passes in the language, we define compilers that translate
from one language to another. Add `parser' to the language fields, a
bit of a hack but useful for languages with s-expression external
representations but with record internal representations.
(define-language, *compilation-cache*, invalidate-compilation-cache!)
(compute-compilation-order, lookup-compilation-order): Add an algorithm
that does a depth-first search for a translation path from a source
language to a target language, caching the result in a lookup table.
* module/language/scheme/spec.scm:
* module/language/ghil/spec.scm: Update to the new language format.
* module/language/glil/spec.scm: Add a language specification for GLIL,
with a compiler to objcode. Also there are parsers and printers, for
repl usage, but for some reason this doesn't work yet.
* module/language/objcode/spec.scm: Define a language specification for
object code. There is some sleight of hand here, in the "compiler" to
values; but there is method behind the madness, because this way we
higher levels can pass environments (a module + externals pair) to
objcode->program.
* module/language/value/spec.scm: Define a language specification for
values. There is something intellectually dishonest about this, but it
does serve its purpose as a foundation for the language hierarchy.
* configure.in:
* module/language/Makefile.am
* module/language/ghil/Makefile.am
* module/language/glil/Makefile.am
* module/language/objcode/Makefile.am
* module/language/value/Makefile.am:
Autotomfoolery for the ghil, glil, objcode, and value languages.
* module/language/scheme/translate.scm (translate): Import the bits that
understand `compile-time-environment' here, and pass on the relevant
portions of the environment to the next compiler pass.
* module/system/base/compile.scm (current-language): New procedure, refs
the current language fluid, or lazily sets it to scheme.
(call-once, call-with-output-file/atomic): Refactor these bits to use
with-throw-handler. No functional change.
(compile-file, compile-and-load, compile-passes, compile-fold)
(compile): Refactor the public interface of the compiler to be generic
and simple. Uses `lookup-compilation-order' to find a path from the
source language to the target language.
* module/system/base/syntax.scm (define-type): Adapt to changes in
define-record.
(define-record): Instead of expecting all slots in the first form,
expect them in the body, and let the first form hold the options.
* module/system/il/compile.scm (compile): Adapt to the compilation pass
API (three in and two out).
* module/system/il/ghil.scm (<ghil-var>, <ghil-env>)
(<ghil-toplevel-env>): Adapt to define-record changes.
* module/system/il/glil.scm (<glil-vars>): Adapt to define-record
changes.
(<glil>, print-glil): Add a GLIL record printer that uses unparse.
(parse-glil, unparse-glil): Update unparse (formerly known as pprint),
and write a parse function.
* module/system/repl/common.scm (<repl>): Adapt to define-record changes.
(repl-parse): New function, parses the read form using the current
language. Something of a hack.
(repl-compile): Adapt to changes in `compile'.
(repl-eval): Fix up the does-the-language-have-a-compiler check for
changes in <language>.
* module/system/repl/repl.scm (start-repl): Parse the form before eval.
* module/system/repl/command.scm (describe): Parse.
(compile): Be more generic.
(compile-file): Adapt to changes in compile-file.
(disassemble, time, profile, trace): Parse.
* module/system/vm/debug.scm:
* module/system/vm/assemble.scm: Adapt to define-record changes.
* module/language/scheme/translate.scm (receive): Fix an important bug
that gave `receive' letrec semantics instead of let semantics. Whoops!
* module/system/repl/common.scm (repl-print): Slightly refine the meaning
of "language-printer": a language printer prints an expression of a
language, not the result of evaluation. `write' prints values.
* module/language/ghil/spec.scm (ghil): Define a language printer, and a
translator for turning s-expressions (not scheme, mind you) into GHIL.
* module/language/scheme/translate.scm (quote, quasiquote): Add some
#:keyword action, so that we can (quote #:keywords).
* module/system/base/language.scm (<language>):
* module/system/base/compile.scm (read-file-in): Don't require that a
language have a read-file; instead error when read-file is called.
(compile-passes, compile-in): Refactor to call a helper method to turn
the language + set of options into a set of compiler passes.
* module/system/base/syntax.scm (define-type): Allow the type to be a
list, with the car being the name and the cdr being keyword options.
Interpret #:printer as a printer, and pass it down to...
(define-record): Here.
* module/system/il/ghil.scm (print-ghil, <ghil>): New printer for GHIL,
yay!
(parse-ghil, unparse-ghil): New lovely functions. Will document them in
the manual.
* module/language/scheme/translate.scm (*translate-table*)
(define-scheme-translator): Rework the translator to have the clauses
defined separately via the define-scheme-translator macro, so that
external modules can define their own translators. Should be no
functional change in this commit, though.
* 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.
* ice-9/boot-9.scm (compile-time-environment): New function, with
documentation. The trick is that the compiler recognizes calls to
(compile-time-environment) and replaces it with a representation of the
*available* lexicals. Note that this might not be all the lexicals;
only the heap-allocated ones are returned.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile `compile-time-environment' to <ghil-reified-env>.
* module/system/il/compile.scm (codegen): Add <ghil-reified-env> clause,
which calls ghil-env-reify.
* module/system/il/ghil.scm (ghil-env-reify): New procedure, returns a
list of (NAME . EXTERNAL-INDEX).
(<ghil>): Add <ghil-reified-env> object.
* libguile/vm-engine.c (vm_error_wrong_num_args): Sync the registers
before calling scm_wrong_num_args. (The other cases are handled more
uniformly.)
* libguile/vm.c (vm_heapify_frames_1): Add a FIXME: I don't think we
should be modifying the stack.
(scm_vm_save_stack): If stack nulling is enabled, verify the stack here
before reifying it.
* module/language/scheme/spec.scm (scheme): Use primitive-eval here
instead of eval, because at the repl we do want to allow evaluations to
have side effects like setting the current module.
* libguile/vm-engine.c (vm_run): Add new error case for resolving @ or @@
references, but there is no such module. Possible if
module-public-interface returns #f.
* libguile/vm-i-loader.c (link-now): Allow the stack arg to be a sym, as
before, or a list, indicating an absolute reference. Could be two
separate instructions, but I'm lazy.
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): As in
link-now, allow the lazy reference to be a list, for @ and @@.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile @ and @@, and set! forms for both of them. This will ease the
non-hygienic pain for exported macros.
* module/system/il/compile.scm (make-glil-var): Translate public and
private module variable references into glil-module variables.
* module/system/il/ghil.scm (ghil-var-at-module!): New function, resolves
a variable for @ or @@.
* module/system/il/glil.scm (<glil-module>): Revival of <glil-module>,
this time with the semantics that it really links to a particular
module.
* module/system/vm/assemble.scm (<vlink-now>, <vlink-later>): Redefine as
taking a "key" as the argument, which may be a sym or a list; see the
notes on link-now for more details.
(codegen): Compile <glil-module> appropriately. Some duplication here,
probably could use some cleanup later.
* module/system/il/ghil.scm (ghil-lookup): So, it turns out this function
needed to be split into three:
(ghil-var-is-bound?, ghil-var-for-ref!, ghil-var-for-set!): The
different facets of ghil-lookup. Amply commented in the source. The
difference being that we now allocate variables that are set! on the
heap, so that other continuations see their possibly-modified values.
(force-heap-allocation!): New helper.
* testsuite/Makefile.am:
* testsuite/t-call-cc.scm: New test, that variables that are set! are
allocated on the heap, so that subsequent modifications are still
seen by the continuation. The test was distilled from test 7.3 in
r5rs_pitfall.test.
* ice-9/boot-9.scm (start-stack): Define as a defmacro instead of an acro
in C. We have a way to delay evaluation of the exp, after all: putting
it in a thunk is sufficient.
* libguile/debug.h:
* libguile/debug.c (scm_sys_start_stack): Renamed from scm_start_stack,
and exposed to the user. Takes a thunk instead of an expression +
environment.
(scm_m_start_stack): Remove this acro.
* module/language/scheme/translate.scm (custom-transformer-table): Remove
the start-stack special case.
* ice-9/boot-9.scm: Allow a compiled load of posix, networking, and
deprecated files.
* module/language/scheme/translate.scm (lookup-transformer): Lookup the
sc-macro by value, not by name. Works around the fact that compiled
macros don't have names, which is probably a bug.
* module/system/base/compile.scm (syntax-error)
(call-with-compile-error-catch): Throw and catch a key that's not used
by anyone else. Write error messages to the error port.
* module/system/repl/repl.scm (default-catch-handler): Call display-error
with the correct number of arguments.
* module/system/vm/frame.scm (frame-program-name): Guard against unbound
variables.
* ice-9/optargs.scm (let-keywords-template): Don't unquote in a helper
procedure. A bit irritating. I suppose we should fix the modules +
syncase situation at some point, and then switch to syncase.
* libguile/vm-i-system.c (call, goto/args): Add a FIXME for handling the
case in which a call to the interpreter returns a values object.
(call/cc, goto/cc): Flesh out, and handle full continuations (with the
C stack also).
* module/language/scheme/translate.scm (custom-transformer-table):
Compile call-with-current-continuation. This is necessary so that the
called procedure is called in tail position.
* module/system/il/compile.scm (codegen): Translate apply to goto/apply,
call/cc to goto/cc, etc when in tail position.
* libguile/vm-engine.c (vm_run): Add new error case,
vm_error_not_enough_values.
* libguile/vm-i-system.c (goto/nargs, call/nargs): So, in these cases, if
we get too many values, we don't truncate the values like we do in the
single-value continuation case, or in the mvbind case. What to do? I
guess we either truncate them here, or only allow the correct number of
values. Dunno. Mark the code as a fixme.
(truncate-values): New instruction, for mv-bind: checks that the number
of values on the stack is compatible with the number of bindings we
have arranged for them, truncating if necessary.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile receive as a primary form -- not so much because it is a
primary form, but more to test the mv-bind machinery. Also it's more
efficient, I think.
* module/system/il/compile.scm (lift-variables!): New helper, factored
out of `optimize'.
(optimize): Add a few more cases. Adapt `lambda' optimization, which
isn't much. I'm not happy with ghil as a mungeable language.
Add a case for call-with-values with the second argument is
a lambda: lift the lambda. Untested.
(codegen): Refactor the push-bindings! code. Compile mv-bind.
* module/system/il/ghil.scm (<ghil-mv-bind>): Add mv-bind construct,
along with its procedures.
* module/system/il/glil.scm (<glil-mv-bind>): Add mv-bind construct,
different from the high-level one. It makes sense in the source, I
think.
* module/system/vm/assemble.scm (codegen): Assemble glil-mv-bind by
pushing onto the bindings list, and actually push some code to truncate
the values.
* libguile/vm-engine.c (vm_run): Add another byte onto the bootstrap
program, as the offset passed to mv-call now takes two bytes.
* module/system/vm/frame.scm (bootstrap-frame?): Update for the new
bootstrap length. Really we should just check for 'halt though.
* libguile/vm-i-system.c (FETCH_OFFSET): New helper, used in BR().
(goto/nargs, call/nargs): Versions of goto/args and call, respectively,
that take the number of arguments from a value on the top of the stack.
(mv-call): Call FETCH_OFFSET to get the offset.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile call-with-values to <ghil-mv-call>. There is some trickery
because of the r4rs.scm call-with-values trampolines.
* module/system/il/ghil.scm: Add <ghil-mv-call> and accessors.
* module/system/il/compile.scm (codegen): Compile <ghil-mv-call>.
* module/system/il/glil.scm: Add <glil-mv-call>, which needs some special
assembly because of the label. Fix some typos.
* module/system/vm/assemble.scm (byte-length): New helper, factored out
and made more general.
(codegen): Assemble mv-call, including the label.
(check-length): New helper, makes sure that the addressing is
consistent within the produced object code.
(stack->bytes): Rewrite to be more generic -- now `br' instructions
aren't the only ones jumping around in the instruction stream.
* module/system/vm/conv.scm (make-byte-decoder): Return two values in the
#f case.
* module/system/vm/disasm.scm (disassemble-bytecode): Rewrite, because
the previous implementation depended on a guile interpreter quirk:
namely, that multiple values could be represented within one value, and
destructured later.
* libguile/vm-engine.c (vm_run): Move nvalues to the top level, to avoid
(spurious, it seems) gcc warnings about it being used uninitialized.
* libguile/vm-i-system.c (halt, return/values): Adapt to gcc silliness.
Deindent some of return/values.
(return/values*): New instruction, does what (apply values . args)
would do.
* module/language/scheme/translate.scm (custom-transformer-table): Move
the apply and @apply cases here from inline.scm, because we need some
more cleverness when dealing with cases like (apply values . args).
(lookup-apply-transformer): Define an eval transformer for `values',
turning it into ghil-values*.
* module/system/il/compile.scm (codegen): Compile <ghil-values*> into
return/values*.
* module/system/il/ghil.scm: Add <ghil-values*> and accessors.
(ghil-lookup): Add optional argument, define?, which if false tells us
not to actually cache the binding if it is not found in the toplevel.
* module/system/il/inline.scm: Remove apply clauses.
* module/system/vm/frame.scm (bootstrap-frame?): Update heuristic for
bootstrap-frame?, as the bootstrap frame is now 5 bytes since it
accepts multiple values.
* libguile/vm-engine.c (vm_run): The bootstrap program now uses mv_call,
so as to allow multiple values out of the VM. (It did before, because
multiple values were represented internally as single scm_values
objects, but now that values go on the stack, we need to note the boot
frame as accepting multiple values.)
(vm_error_no_values): New error, happens if you pass no values into a
single-value continuation. Passing more than one is OK though, it just
takes the first one.
* libguile/vm-i-system.c (halt): Assume that someone has pushed the
number of values onto the stack, and package up that number of values
as a scm_values() object, for communication with the interpreter.
(mv-call): New instruction, calls a procedure with a multiple-value
continuation, even handling calls out to the interpreter.
(return/values): New instruction, returns multiple values to the
continuation. If the continuation is single-valued, takes the first
value or errors if there are no values. Otherwise it returns to the
multiple-value return address, pushing the number of values on top of
the values.
* module/system/il/compile.scm (codegen): Compile <ghil-values> forms.
* module/system/il/ghil.scm (<ghil-values>) Add new GHIL data structure
and associated procedures.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile (values .. ) forms into <ghil-values>.
* module/language/scheme/translate.scm (custom-transformer-table): Rename
from `primitive-syntax-table', because now it will handle procedural
values as well.
(lookup-transformer): Update for renaming. Look up custom transformers
by value, not name.
(make-pmatch-transformers): Key the transformer table by value, not
name.
* libguile/vm-i-system.c (call): Rename continuation invocation from
`vm_call_cc' to `vm_call_continuation', because that's what it really
does. Add a note that it doesn't handle multiple values at the moment.
(goto/arg): Renamed from tail-call, in deference to the progenitors, on
Dale Smith's suggestion.
(goto/apply): New instruction, for `apply' in a tail context. Not yet
used, or vetted for that matter.
(call/cc): No need to pop the program, I don't think; although this
isn't tested either.
(goto/cc): New instruction, for call/cc in a tail context.
* module/language/scheme/translate.scm (*forbidden-primitives*): Rename
from %forbidden-primitives.
* module/system/il/compile.scm (codegen): Adapt to goto/args instead of
tail-call.
* module/system/il/inline.scm: Start inlining some macros used in
r4rs.scm -- not yet fully tested.
* ice-9/boot-9.scm: Allow load of a compiled r4rs file.
* module/language/scheme/translate.scm (primitive-syntax-table): In forms
like (define x y) where y is a lambda, and the lambda has no name yet,
set the lambda's name in its metadata.
* module/language/scheme/spec.scm (scheme): Specify an evaluator, `eval'.
* module/system/repl/common.scm (repl-default-options): Add option,
`interp', specifying that, if possible, the repl should interpret its
expressions rather than compile them. Defaults to #f.
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it
breaks code that may assume that ':foo is a symbol, like boot-9.
* module/*.scm: Don't use :keywords, use #:keywords. The user can decide
if she wants #:keywords in their .guile, and :keywords might make us
compile modules differently.
* module/language/scheme/translate.scm (%forbidden-primitives): Take
procedure->memoizing-macro off probation; although it's not a good
idea, there is a fair amount of existing code that uses it that can be
compiled fine. So allow it in that case.
* module/system/il/ghil.scm (<ghil-env>, <ghil-toplevel-env>): Refactor
so that all environments point (eventually) at one toplevel
environment. Instead of having potentially multiple toplevel
environments, each noting the module against which its bindings are
resolved, have each binding in the toplevel record what module it
should be resolved in. Should fix compilation units that define
multiple modules.
(ghil-lookup, ghil-define): Reworked to not be destructive. Module
variables now have the module name as their "env", and are keyed as
`(MODNAME . SYM)' in the var table.
(call-with-ghil-environment): Reindented.
* module/system/il/inline.scm (try-inline-with-env): Adapt to
env/toplevel changes.
* module/system/vm/assemble.scm (dump-object!): A vlink-later now holds
the module name, not the module itself.
* module/system/il/compile.scm (make-glil-var): The "env" of a "module"
var is now the module name, not the module.
* module/language/scheme/translate.scm (primitive-syntax-table): Update
the way we test for toplevel environments. Reindent the lambda
translator.
(lookup-transformer, trans): lookup-transformer now has 2 args, not 3.
(translate): Update the way we make toplevel environments.
* module/language/scheme/translate.scm (primitive-syntax-table): Disable
semantics of start-stack in compiled code. I think start-stack
semantics aren't bad, but they don't have vm-based implementations at
this point.
Thanks to Dale Smith.
* guilec.mk: Rework to expect the includer to define $(modpath), then
make $(moddir) from that.
* module/language/Makefile.am:
* module/language/scheme/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Define modpath instead.
* src/guilec.in: Don't import (system vm bootstrap), it is no more.
* module/language/scheme/translate.scm (translate): Adapt to lambda
having a `meta' slot now.
(primitive-syntax-table, parse-lambda-meta): Parse out a docstring from
lambda forms, putting in the <ghil-lambda>'s meta slot.
* module/system/il/compile.scm (optimize, codegen): Passthrough for the
`meta' slot to the <glil-asm> object.
* module/system/il/ghil.scm (<ghil-lambda>): Add meta slot.
* module/system/il/glil.scm (<glil-asm>): Add meta slot.
(unparse): Unparse meta.
* module/system/vm/assemble.scm (preprocess): Pass through the meta slot.
(codegen): So, set the bytespec's meta slot as a list: bindings, source
info, then the tail is the meta-info, which should be an alist.
Currently the only defined key is `documentation', but `name' could
come in the future.
* module/system/vm/core.scm (program-sources): Sources are now in the
cadr...
(program-property): And here we have access to the cddr.
* module/language/scheme/translate.scm (translate, trans)
(make-pmatch-transformers): When recursing into subexpressions, get the
appropriate source location information.
(location): Include the source filename in the location information.
* module/system/il/compile.scm (codegen): Record source locations in more
cases. (This information ends up being part of the procedure metadata,
not the actual codepath.)
* module/system/il/glil.scm (unparse): Don't destructure the source
locations (it's a vector now).
* module/system/il/inline.scm: New module, implements generic inlining of
scheme functions. It even does the right thing regarding (define
arity:nopt caddr) and such. So now there are many more inlines: the
arithmetics, `apply', the caddr family, etc. This makes the benchmarks
*much* faster.
* module/language/scheme/translate.scm (trans): Remove the
%scheme-primitives code in favor of the generic (scheme il inline)
code. Adds inlining for +, -, =, etc.
* src/vm.c (vm_puts): Fix to work.
* module/system/base/compile.scm (system): Export load/compile also.
* module/system/il/compile.scm (optimize): Further debitrotting, but I
haven't tried this function yet. It seems that <ghil-inst> was what
<ghil-inline> is.
* module/system/il/ghil.scm (*core-primitives*, *macro-module*)
(ghil-primitive-macro?, ghil-macro-expander, ghil-primitive?): Remove
these unused things.
* module/system/il/macros.scm: Removed, replaced with inline.scm.
* module/system/vm/assemble.scm (stack->bytes): Before, the final
serialization code did an (apply u8vector (apply append (map
u8vector->list ...))). Aside from the misspelling of append-map, this
ends up pushing all elements of the u8vector on the stack -- assuredly
not what you want. But besides even that, I think that pushing more
than 32k arguments on the stack brings out some other bug that I think
was hidden before, because now we actually use the `apply' VM
instruction. Further testing is needed here, I think. Fixed the code to
be more efficient, which fixes the manifestation of this particular
bug: a failure to self-compile after inlining was enabled.
* module/system/vm/bootstrap.scm: New module, serves to bootstrap
boot-9's `load-compiled'. That way when we load (system vm core), we're
loading compiled code already.
* module/system/vm/core.scm: Use (system vm bootstrap).
* src/guilec.in: Use the bootstrap code, so that we really are compiling
with an entirely compiled compiler.
* module/system/repl/repl.scm (default-catch-handler): An attempt at
making the repl print a backtrace; more work needed here.
* module/system/vm/frame.scm (make-frame-chain): Fix some misspellings --
I think, anyway.
* guilec.mk: New file, to be included when building .go files.
* module/language/scheme/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Use guilec.mk.
* module/system/base/compile.scm (compiled-file-name): Work on the
basename of a file, so that we always create files in the directory
where we run. Perhaps should add a -o option to guilec in the future.
* Makefile.am: Actually recurse into module/ in a normal build.
* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*):
Reset to compile-toplevel, which requires a patch to guile.
* module/system/base/compile.scm (compile-file): Some foo so that we load
up the scheme language before call-with-output-file. Fixes compilation
of (language scheme) modules.
* module/system/base/language.scm (define-language): Don't unquote in
make-language; refer to it by name instead, and export it.
* module/system/repl/Makefile.am (vm_DATA): Don't compile describe.scm,
because we really can't deal with goops yet.
* module/system/repl/repl.scm (compile-toplevel): If we're compiling, put
in a stub definition of start-stack, which is closely tied to the
interpreter.
* src/vm_loader.c (load-program): Fix a very tricky corruption bug!
* module/language/scheme/translate.scm (lookup-transformer): Allow for
undefined variables when doing the transformation -- it's possible that
they come from a module definition's forward declaration.
* module/system/repl/command.scm (import): Make into legal Scheme, caught
by the compiler :-)
* module/system/vm/assemble.scm (<vlink-now>): Remove the module field.
Immediate bindings will now always be relative to the current module.
Fixes some mess about process-define-module not being defined when
loading modules, probably because we destructively modified the
ghil-env.
(codegen, dump-object!): Don't dump a module name.
* src/vm_loader.c (link-now): Just use scm_lookup.
* module/language/scheme/translate.scm (lookup-transformer): When
expanding syncase macros, use the eval closure from the ghil-env.
Probably doesn't make any difference whatsoever.
* module/system/base/Makefile.am (SOURCES): Compile pmatch.scm, now that
it works :-))
* module/system/base/compile.scm (compile-in): Compile inside a
save-module-excursion, so that side effects of evaluation don't leak
out.
* module/system/base/pmatch.scm: Change from :use-syntax/:export-syntax
to simply :use-modules/:export. Also probably has no effect.
* module/system/il/ghil.scm (fix-ghil-mod!): Suppress warnings resulting
from compilation of define-module.
* src/vm_loader.c (link): So, referencing variables defined but not
exported from the current module didn't work. Fixed that, but it's
hacky. There are still some uncaught cases.
* module/system/base/compile.scm: Also import load-objcode from (system
vm core).
* module/language/scheme/translate.scm (lookup-transformer): Use
sc-expand3 in compilation mode when compiling macros. Yay, syncase
macros compile!
* module/system/vm/assemble.scm (dump-object!):
* src/vm_loader.c (VM_DEFINE_LOADER): Use scm_from_locale_keywordn, not
the krazy dash symbol stuff.
* module/language/scheme/translate.scm (lookup-transformer): Add a
special case for syncase macros.