* module/language/ecmascript/base.scm (prop-keys): New method, returns
the list of keys of props of this instance.
* module/language/ecmascript/impl.scm: Refactor the global object into a
special kind of module object. Provide a prop-keys implementation for
module objects.
* module/language/ecmascript/compile-ghil.scm (comp): Compile for-in.
* module/language/ecmascript/impl.scm: Reshuffly things, and implement
make-enumerator, a helper for use in for-in statements.
* module/language/ecmascript/parse.scm (parse-ecmascript): Fix parsing of
for (var foo in bar) {}...
* module/language/ecmascript/impl.scm: Add <js-module-object>, that wraps
a module. Add js-require, a javascript-happy function that returns an
object that wraps a Guile module. Bind it to `require' in the default
environment.
* module/language/ecmascript/tokenize.scm: Attach source information to
tokens. We have to enhance the lalr parser to actually let this
information propagate through, though...
* module/language/ecmascript/array.scm (*array-prototype*): Declare the
constructor.
* module/language/ecmascript/base.scm (pput, pdel): Remove some needless
checks.
(new): Move definition of new here, and use the constructor.
* module/language/ecmascript/compile-ghil.scm (compile-ghil): Add a stub
so that when we load a compiled JS program, we make sure the runtime
has been booted.
* module/language/ecmascript/function.scm (js-constructor): Export a
js-constructor method instead of a new method.
* module/language/ecmascript/impl.scm (<js-global-object>): Define a new
class for the global "this" object, wrapping bindings from the current
module.
(init-js-bindings!): Define the dozen or so global properties, in the
current module.
(+): Define addition operations for non-numbers. This is efficient
because the generics are only dispatched if the fast-path fails.
* module/language/ghil/compile-glil.scm (codegen): If there are more than
255 arguments, make a list and use apply instead of calling directly.
* module/language/Makefile.am: Now we can compile parse.scm. Yay!
* module/language/scheme/compile-ghil.scm: Add a note.
* module/language/ecmascript/compile-ghil.scm: Add a note.
* module/language/Makefile.am: OK, we can compile compile-ghil.scm now,
thankfully.
* module/language/ecmascript/compile-ghil.scm (ormatch): New macro, a
wrapper around pmatch to avoid some of the more egregious
non-tail recursiveness.
(comp): Use ormatch.
* module/language/ghil.scm (unparse-ghil): The body of bind and mv-bind
is a single expression, not a list of expressions.
* module/language/ghil/compile-glil.scm (codegen): Be more clever when
allocating "local" variables -- if a variable goes out of scope, its
index can be re-used later.
* module/language/glil.scm (parse-glil, unparse-ghil): The "rest" of a
mv-bind is a flag, not a list. The "ra" of an mv-call is a label, not a
GLIL expression.
* module/language/objcode/spec.scm (collapse-locals, decompile-value):
When decompiling a value, process the bindings list differently.
Comments in the code.
* module/language/scheme/compile-ghil.scm (define-scheme-translator): Fix
the generated error procedure.
(let): Re-indent.
(letrec): Re-indent.
* module/system/base/syntax.scm (record-case): If the body of a clause is
null, fill it with the unspecified value.
* libguile/vm-i-system.c (goto/args): On a tail call to a different
procedure, init the locals to valid scheme values. Shouldn't matter for
well-compiled scheme, but inspecting uninitialized locals could give
garbage, or badly-compiled code could cause a crash.
* module/language/Makefile.am (NOCOMP_SOURCES): For the moment, don't
compile compile-ghil.scm. I need to fix this.
* module/language/ecmascript/compile-ghil.scm (load-toplevel): Sigh, and
disable stack checking in the evaluator too. Grr.
(comp): Implement (unnamed) break and continue.
* module/language/ecmascript/parse.scm (parse-ecmascript): Fix var
statements in `for' -- though it still doesn't work.
* module/language/ecmascript/compile-ghil.scm (comp): Use ghil-bind when
making temp vars, so that disassembly understands things. Implement do,
while, and for.
* module/language/ecmascript/parse.scm (parse-ecmascript): Some tweaks.
* module/language/ecmascript/impl.scm (language): Export ->boolean.
* module/language/ecmascript/base.scm: Implement some more robust
property getters that convert strings to symbols. Implement
has-property?.
* module/language/ecmascript/compile-ghil.scm (comp): Implement lots more
mathematical operators. We now do all expressions; on to statements.
* module/language/ecmascript/impl.scm: Define some math helpers. They
probably need to call ->number on some things.
* module/language/ecmascript/parse.scm (parse-ecmascript): Fix a typo.
* module/language/ecmascript/compile-ghil.scm (@impl): Implement with
@implv.
(comp): Implement ++ and -- (pre- and post-). Quite a pain. I'll be
looking for ways to simplify this notation. Also implement new, delete,
and void.
* module/language/ecmascript/impl.scm: Implement typeof.
* module/language/ecmascript/base.scm:
* module/language/ecmascript/compile-ghil.scm:
* module/language/ecmascript/impl.scm:
* module/language/ecmascript/parse.scm: Compile "method calls" in such a
way that "this" gets propagated correctly.
* module/language/Makefile.am:
* module/language/ecmascript/impl.scm:
* module/language/ecmascript/array.scm:
* module/language/ecmascript/base.scm:
* module/language/ecmascript/function.scm: Split out the runtime into
different files. Implement more of the spec's runtime.
* module/ice-9/getopt-long.scm (define-one-option-spec-field-accessor,
define-one-option-spec-field-modifier): Eval-case for `load-toplevel'
as well so that the interpreter can load this module.
* module/ice-9/getopt-long.scm (option-spec-fields): Enclose in a
`(load-toplevel compile-toplevel)' `eval-case'.
(define-one-option-spec-field-accessor,
define-one-option-spec-field-modifier): Enclose in a
`compile-toplevel'-only `eval-case'.
* module/language/ecmascript/parse.scm (parse-ecmascript): And update the
function declaration forms for the new var syntax.
* module/language/ecmascript/compile-ghil.scm (comp): Support foo["bar"]
in addition to foo.bar.
* module/language/ecmascript/impl.scm (pget, pput): Some fixes for when
we get non-symbols -- it can happen, yo. I suppose we should allow for
non-string keys too..
* module/language/ecmascript/compile-ghil.scm (@impl): Ok, don't recurse
on args here.
(comp): Implement property gets and puts and lexical assignment.
(comp-body): Fix scanning of var forms.
* module/language/ecmascript/impl.scm (prop-attrs): Allow for the prop
attr array to be #f.
* module/language/ecmascript/parse.scm (parse-ecmascript): Fix assignment
parsing.
* libguile/vm-i-system.c (drop, return): Declare drop and return as
popping one arg from the stack.
* module/language/ghil/compile-glil.scm:
* module/language/glil/compile-assembly.scm (make-meta): Adjust so that
we declare 'drop and 'return calls as popping one arg from the stack.
* module/language/ecmascript/compile-ghil.scm (comp, comp-body): Flesh
out a bit more. Most significantly, scoping within functions obeys
javascript semantics better, modulo bits about with() forms.
* module/language/ecmascript/impl.scm: Define some runtime helper
routines.
* module/language/Makefile.am (SOURCES): Add impl.scm.
* module/language/ecmascript/parse.scm (parse-ecmascript): Minor tweaks.
* module/language/ecmascript/tokenize.scm (read-identifier): Identifiers
now read as symbols, not strings.
* module/language/ecmascript/parse.scm (parse-ecmascript): Lambdas always
just have one member in their bodies.
* module/language/ecmascript/compile-ghil.scm (comp): Add some more silly
compilers.
* module/language/ecmascript/parse-lalr.scm: Add the Boucher/Bison lalr
parser. This is from guile-lib, but with : changed to -> so as not to
molest `prefix' keywords. Should probably be elsewhere.
* module/language/ecmascript/parse.scm: Add parser for ECMAScript. Rules
from the spec, 3rd edition.
* module/language/ecmascript/tokenize.scm: Add ECMAScript tokenizer,
hand-written. Neat stuff.
* module/language/Makefile.am: Autofoo.
* module/language/assembly.scm (align-program): Whoops, align programs
properly.
* module/language/glil/compile-assembly.scm (compile-assembly): Start
with addr=-1, for the unserialized load-program byte.
(glil->assembly): Align programs in all cases.
* module/system/base/compile.scm (compiled-file-name): Prepend "(dirname
file)" so that "guile-tools compile foo/bar.scm" produces
"foo/bar.go", not "bar.go".
* module/language/assembly.scm (addr+): New helper.
(align-program): New function, aligns a (load-program) form, currently
to 8-byte boundaries.
* module/language/glil/compile-assembly.scm (<subprogram>): Record the
object table and the program code separately, so that we can align the
program after the object table has been written.
(glil->assembly): Use addr+.
(dump-object): Rework to fold `addr' through dumping of compound
objects, so that procedures can be aligned properly.
* module/language/scheme/compile-ghil.scm (define-scheme-translator):
Only add an else clause if the transformer didn't have one.
* module/oop/goops.scm (min-fixnum, max-fixnum): Define at compile-time
as well.
(@slot-ref, @slot-set!): Only define transformers for these at
compile-time. Avoids loading up the compiler unnecessarily. Also, allow
for the `n' to be determined lexically, in which case we dispatch to
the primitive.
(num-standard-pre-cache, define-standard-accessor-method)
(bound-check-get, standard-get, standard-set): Rework the fixed-offset
getters and setters so that they can be computed at compile-time.
Accessors to fields with n > num-standard-pre-cache will be dispatched
to the primitive instead of within the VM.
* libguile/goops.c (scm_make): In the pre-inst `make', default
`procedure' to #f, and read a `make-procedure' instead of
`compile-env'.
* libguile/goops.h (scm_si_make_procedure): This instead of
scm_si_compile_env.
* module/oop/goops.scm (make-method): Remove this unused function. Users
should use (make <method> ...) directly.
(method): Capture `make-procedure' instead of `procedure' in the case
that the body calls a next-method. Allows for the kind of
"recompilation" that we were using before, but with closures instead of
re-entering the compiler. Type-specific compilation is still
interesting, but probably should be implemented in another way.
(initialize): Default #:procedure to #f, and
s/compile-env/make-procedure/.
* module/oop/goops/compile.scm (code-table-lookup): Just return the
cmethod, not the entry -- since the entry is now just (append types
cmethod).
(compile-make-procedure): New procedure, returns a form that, when
evaluated/compiled, will yield a procedure of one argument, the
next-method. When called with a next-method, the procedure returns an
actual method implementation. compile-make-procedure returns #f if the
body doesn't call next-method.
(compile-method): Unify to always return procedures. Much cleaner and
*much* faster in the compiled case. In the interpreted case, there
might be a slight slowdown, but if there is one it should be slight.
* module/oop/goops/dispatch.scm (method-cache-install!): Adapt to removal
of compute-entry-with-cmethod.
* module/system/base/compile.scm (call-with-output-file/atomic): Close
the port we are writing to before renaming it, so that we flush output.
Might fix some 0-length write errors that Jao was seeing.
* 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.scm: Whoops, export some unquote-splicing
accessors that we didn't have exported before.
* module/system/base/syntax.scm: Speed up record-case, by syntactically
determining the predicates and accessors. Nasty, in a way; but also
much faster.
* module/system/base/pmatch.scm (ppat): Match atoms with eq?, not equal?.
This speeds up compilation considerably, as we never match against
numbers or strings or what-have-you. Note, you can match against
literals with equal? via quoting the literal in the pattern.
* 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.
* libguile/objects.c (scm_apply_generic): Inline the case when the
generic is a program.
* libguile/vm-i-system.c (return): Tick when functions return.
* module/oop/goops.scm (object-eqv?, object-equal?): Remove these
historical methods.