This was a pretty big merge involving a fair amount of porting,
especially to peval and its tests. I did not update psyntax-pp.scm,
that comes in the next commit.
Conflicts:
module/ice-9/boot-9.scm
module/ice-9/psyntax-pp.scm
module/language/ecmascript/compile-tree-il.scm
module/language/tree-il.scm
module/language/tree-il/analyze.scm
module/language/tree-il/inline.scm
test-suite/tests/tree-il.test
Followup to 8891bd1b16 ("Fix ECMAScript
object creation.").
* module/language/ecmascript/compile-tree-il.scm (comp): Use `@implv'
for `new-object'. Suggested by Kan-Ru Chen <kanru@kanru.info>.
* module/language/ecmascript/compile-tree-il.scm (compile-tree-il):
generate correct tree-il for construction of new objects.
* test-suite/tests/ecmascript.test (ecompile): Add pattern with EXPECTED
omitted.
("compiler"): test whether we generate new objects correctly.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/language/ecmascript/tokenize.scm (syntax-error): Reorder args
to throw vals in the right order.
(make-tokenizer/1): Fix. Broken since the lalr refactor...
* module/system/base/language.scm (<language>): Remove the `version'
field from languages. It just wasn't useful.
* module/language/assembly/spec.scm:
* module/language/brainfuck/spec.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/spec.scm:
* module/language/elisp/spec.scm:
* module/language/glil/spec.scm:
* module/language/objcode/spec.scm:
* module/language/scheme/spec.scm:
* module/language/tree-il/spec.scm:
* module/language/value/spec.scm: Remove #:version from all language
definitions. Shorten some language names (e.g. "Guile Scheme" ->
"Scheme").
* module/language/ecmascript/tokenize.scm: Use `make-lexical-token' and
related procedures instead of pairs as tokens passed to the parser.
Pass source location information in the form of `source-location'
objects.
* module/language/ecmascript/parse.scm (read-ecmascript,
read-ecmascript/1): Instantiate a new parser at each call.
(parse-ecmascript): Rename to...
(make-parser): ... this. Change `->' to `:' in the grammar syntax.
* module/language/ecmascript/parse-lalr.scm: Remove.
* module/Makefile.am (ECMASCRIPT_LANG_SOURCES): Remove
`language/ecmascript/parse-lalr.scm'.
Turns out this was not a very useful idea, and semantically tricky to
boot.
This reverts commit 24bf130fd1, and makes
the following additional changes:
* module/ice-9/optargs.scm (parse-lambda-case, let-optional)
(let-optional*, let-keywords, let-keywords*):
* module/language/tree-il.scm: (<lambda-case>, parse-tree-il)
(unparse-tree-il, tree-il->scheme, tree-il-fold,
make-tree-il-folder)
(post-order!, pre-order!):
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (compile-glil):
* module/language/tree-il/inline.scm (inline!): Remove all traces of
#:predicate from tree-il.
* module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case)
(chi-lambda-case): Adapt to tree-il change.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/language/brainfuck/compile-tree-il.scm (compile-body):
* module/language/ecmascript/compile-tree-il.scm (comp, comp-body):
* test-suite/tests/tree-il.test: Adapt to tree-il change.
* doc/ref/api-procedures.texi (Case-lambda): Remove mention of
#:predicate.
* module/language/ecmascript/compile-tree-il.scm: Fix a number of bugs,
fallen out from the ghil->tree-il conversion.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add a hack
for "return" for javascript. Scheme shouldn't see this because it's
not an "interesting primitive".
* module/language/tree-il.scm (<lambda-case>): Add "inits" field, so we
don't have to parse it out of opt and kw. Adapt the traversal
procedures.
* module/language/tree-il/analyze.scm (analyze-lexicals): Analyze
lexicals in the <lambda-case> init expressions as well. Fix keyword
allocation.
* module/language/tree-il/compile-glil.scm (compile-glil): Adapt to
make-lambda-case change.
(flatten): Adapt to "inits" slot, actually init uninitialized args,
and fix bugs related to keyword arguments.
* module/language/tree-il/inline.scm (inline!): Adapt a little bit --
but with no effect.
* module/language/glil/compile-assembly.scm (glil->assembly): Flesh out
<glil-kw-prelude> compilation some more. Add a "bound?" op for
<glil-lexical>, which will push #t if the local is bound.
* module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case):
Update for new signature of make-lambda-case.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/language/brainfuck/compile-tree-il.scm (compile-body):
* module/language/ecmascript/compile-tree-il.scm (comp):
* test-suite/tests/tree-il.test ("lambda"): Update for new lambda-case
syntax.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (br-if-nargs-ne, br-if-args-lt)
(br-if-nargs-gt): New instructions, for use by different lambda cases.
(bind-optionals, bind-optionals/shuffle, bind-kwargs): New
instructions, for binding optional and keyword arguments. Renumber
other ops.
* module/language/ecmascript/compile-tree-il.scm (comp, comp-body):
Update for new tree-il. Use the new optional argument mechanism
instead of emulating it with rest arguments.
* module/language/glil/compile-assembly.scm (glil->assembly): Tweaks for
optional and keyword argument compilation.
* module/language/tree-il.scm (parse-tree-il, unparse-tree-il): Make the
else case optional, in the s-expression serialization of tree-il.
* module/language/tree-il/compile-glil.scm (flatten): Handle all of the
lambda-case capabilities.
* module/language/assembly/spec.scm:
* module/language/brainfuck/spec.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/spec.scm:
* module/language/glil/spec.scm:
* module/language/scheme/spec.scm:
* module/language/tree-il/spec.scm: Language-readers now take two
arguments: the port and the environment. This should allow for
compile-environment-specific reader behavior.
* module/system/base/compile.scm (read-and-compile):
* module/system/repl/common.scm (repl-read): Pass the environment to the
language-reader.
* module/system/repl/repl.scm (meta-reader, prompting-meta-read):
* module/system/repl/command.scm (define-meta-command): Use the second
argument to repl-reader, so we avoid frobbing current-reader.
* module/Makefile.am (ECMASCRIPT_LANG_SOURCES):
* module/language/ecmascript/compile-ghil.scm:
* module/language/ecmascript/compile-tree-il.scm: SOURCES): Replace the
GHIL compiler with a ->tree-il compiler. Not fully functional, but the
basics work.
* module/language/ecmascript/spec.scm: Only include the tree-il compiler.
* module/language/ecmascript/tokenize.scm (read-punctuation): Avoid
mutating a constant.
* module/language/ecmascript/compile-ghil.scm (comp): Just use pmatch,
not ormatch. Now with syncase running over everything, it doesn't
matter.
* module/ice-9/boot-9.scm (false-if-exception): Avoid saving stacks
inside false-if-exception. There's probably a more general solution to
this, though. Fixes getting bogus backtraces sometimes.
* module/Makefile.am (ECMASCRIPT_LANG_SOURCES): Reorder things so that
spec comes last.
* doc/ref/api-procedures.texi (Compiled Procedures): Fix for API changes.
* doc/ref/compiler.texi (Compiling to the Virtual Machine): Replace GHIL
docs with Tree-IL docs. Update the bits about the Scheme compiler to
talk about Tree-IL and the expander instead of GHIL. Remove
<glil-argument>. Add placeholder sections for assembly and bytecode.
* doc/ref/vm.texi: Update examples with what currently happens. Reword
some things. Fix a couple errors.
* libguile/vm-i-system.c (externals): Remove this instruction, it's not
used.
* module/ice-9/documentation.scm (object-documentation): If the object is
a macro, try to return documentation on the macro transformer.
* module/language/assembly/disassemble.scm (disassemble-load-program):
Fix problem in which we skipped the first element of the object vector,
because of changes to procedure layouts a few months ago.
* module/language/scheme/spec.scm (read-file): Remove read-file
definition.
* module/language/tree-il.scm: Reorder exports. Remove <lexical>, it was
a compat shim to something that was never released. Fix `location'.
* module/language/tree-il/primitives.scm (/): Fix expander for more than
two args to /.
* module/system/base/compile.scm (read-file-in): Remove unused
definition.
* module/system/base/language.scm (system): Remove language-read-file.
* module/language/ecmascript/spec.scm (ecmascript): Remove read-file
definition.
* module/system/base/compile.scm: Expect compile passes to produce three
values, not two. The third is the "continuation environment", the
environment that can be used to compile a subsequent expression from
the same source language. For example, expansion-time side effects can
set the current module, which would be reflected appropriately in the
continuation environment.
* module/language/assembly/compile-bytecode.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/compile-ghil.scm:
* module/language/ghil/compile-glil.scm:
* module/language/glil/spec.scm:
* module/language/objcode/spec.scm:
* module/language/scheme/compile-ghil.scm:
* module/system/base/compile.scm: Update compile passes to return a
continuation environment.
* module/language/ecmascript/compile-ghil.scm: Use -> to make the ES
compiler more readable. Fix bugs in do, while, and for, whereby we were
missing ->boolean calls.
* 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/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..