1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

64 commits

Author SHA1 Message Date
Mark H Weaver
1e5c32054e Adapt ecmascript compiler to tree-il prompt changes, again.
* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  The body of an escape-only prompt is no longer a thunk.  Adapt.
2013-08-11 17:18:09 -04:00
Mark H Weaver
5270bb5bdb Adapt ecmascript compiler to recent tree-il changes for prompts.
* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  Adapt to the changes in 178a40928a.
  Prompt tree-il nodes now contain an explicit 'escape-only?' flag, and
  the body and handler are now both lambdas.
2013-08-07 03:13:11 -04:00
Andy Wingo
180ac9d7b0 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	module/language/bytecode/spec.scm
	module/language/tree-il/spec.scm
2013-01-31 11:52:42 +01:00
Ludovic Courtès
ed7c4a5d77 ecmascript: Fix conversion to boolean for non-numbers.
* module/language/ecmascript/base.scm (->boolean): Call `zero?' and
  `nan?' only when X is a number.
* test-suite/tests/ecmascript.test ("compiler"): Add test case.
2013-01-26 19:18:31 +01:00
Andy Wingo
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Andy Wingo
c0cfa9ef07 compile ecmascript's `return' as an abort
* module/language/ecmascript/compile-tree-il.scm (current-return-tag):
  (with-return-prompt, comp): Compile `return' as an abort instead of a
  primcall to `return'.  Fixes beta-reduction by the optimizer -- it
  doesn't make sense for `return' to move from one function to another!
2012-07-05 11:06:29 +02:00
Andy Wingo
0dd7c54075 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/deprecated.c
	libguile/ports.c
	libguile/ports.h
	libguile/strports.c
	test-suite/tests/cse.test
2012-06-22 13:18:02 +02:00
Sjoerd van Leent
6b5e918e4f Fix unbound variables and unbound values
* module/language/ecmascript/base.scm: fix two wrong variable names and a wrong
  number of arguments in a function call.
2012-06-08 21:21:08 -04:00
Andy Wingo
ca12824581 Merge remote-tracking branch 'origin/stable-2.0'
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
2011-09-29 18:02:28 +02:00
Andy Wingo
0c65f52c6d more define-syntax-rule usage
* module/ice-9/boot-9.scm:
* module/ice-9/control.scm:
* module/ice-9/futures.scm:
* module/ice-9/optargs.scm:
* module/ice-9/poll.scm:
* module/ice-9/receive.scm:
* module/ice-9/threads.scm:
* module/ice-9/vlist.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/tree-il.scm:
* module/oop/goops.scm:
* module/oop/goops/simple.scm:
* module/oop/goops/stklos.scm:
* module/srfi/srfi-1.scm:
* module/srfi/srfi-35.scm:
* module/srfi/srfi-39.scm:
* module/srfi/srfi-45.scm:
* module/srfi/srfi-67/compare.scm:
* module/sxml/match.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/repl.scm:
* module/system/vm/inspect.scm:
* module/texinfo.scm:
* module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-09-02 11:36:14 +02:00
Andy Wingo
7081d4f981 rename <application> to <call>
* doc/ref/compiler.texi (The Scheme Compiler): Update docs.

* libguile/expand.h:
* libguile/expand.c:
* module/language/tree-il.scm: Rename <application> to <call>.  Change
  the external representation from (apply proc arg ...) to (call proc
  arg ...).

* libguile/memoize.c:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/brainfuck/compile-tree-il.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* test-suite/tests/tree-il.test: Update all callers.
2011-06-02 13:42:55 +02:00
Noah Lavine
84816b3aae Parse Decimal Numbers
* module/language/ecmascript/parse.scm: handle numbers with leading
    decimals correctly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:47:29 +01:00
Noah Lavine
326298206a Fix Hex Constants
* module/language/ecmascript/tokenize.scm: hexadecimal constants can
    now use 'X' in addition to 'x'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:45:33 +01:00
Noah Lavine
110f652127 Ecmascript Syntax
* module/language/ecmascript/tokenize.scm: an unbreakable space
      counts as whitespace.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:31:12 +01:00
Noah Lavine
eacbe34618 Ecmascript Syntax Fix
* module/language/ecmascript/parse.scm: allow empty function bodies.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:30:44 +01:00
Noah Lavine
b1846b7fb3 Add ECMAScript Unicode literal support
* module/language/ecmascript/tokenize.scm: add unicode literals

* test-suite/tests/ecmascript.test ("parser"): Add new tests for Latin-1
  and Unicode escapes in string literals.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-17 23:03:32 +01:00
Ludovic Courtès
8a41c56af1 Tiny style improvement in the ECMAScript compiler.
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>.
2011-01-05 22:22:15 +01:00
Noah Lavine
8891bd1b16 Fix ECMAScript object creation.
* 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>
2011-01-04 18:36:58 +01:00
Andy Wingo
96fa68966d better errors for ecmascript parser too
* module/language/ecmascript/parse.scm (syntax-error): Better errors
  here too.
2010-11-18 13:03:49 +01:00
Andy Wingo
b8b6343318 ecmascript tokenization errors report source location
* module/language/ecmascript/tokenize.scm (syntax-error): Report source
  locations. Adapt all callers to pass source locations.
2010-11-18 12:55:25 +01:00
Andy Wingo
a608cad27e fix ecmascript at the repl
* 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...
2010-11-18 12:24:01 +01:00
Andy Wingo
1811d0332f ecmascript syntax errors throw to 'syntax-error
* module/language/ecmascript/parse.scm (syntax-error):
* module/language/ecmascript/tokenize.scm (syntax-error): Throw to
  'syntax-error as psyntax does.
2010-11-16 02:57:27 +01:00
Andy Wingo
246ea9e16a remove `version' field from <language>
* 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").
2010-05-02 11:19:13 +02:00
Andy Wingo
92d33877d9 fix array bugs in ecmascript
* module/language/ecmascript/array.scm (pput, *array-prototype*): Fix
  bugs in ecmascript array runtime.
2010-03-31 22:31:11 +02:00
Ludovic Courtès
0ecd70a271 Adapt ECMAScript parser and lexer to `(system base lalr)'.
* 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'.
2010-03-31 00:42:01 +02:00
Andy Wingo
1e2a8edb8b Revert "implement #:predicate" and remove predicate from <lambda-case>
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.
2009-11-15 21:02:26 +01:00
Andy Wingo
d61e866c76 fix bugs in ecmascript compiler
* 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".
2009-11-14 13:46:56 +01:00
Andy Wingo
b0c8c187d9 separate "inits" field in <lambda-case>; compile fixes for inits, kwargs
* 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.
2009-10-23 16:48:05 +02:00
Andy Wingo
7e01997e88 finish support for optional & keyword args; update ecmascript compiler
* 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.
2009-10-23 15:10:25 +02:00
Ludovic Courtès
84012ef4b1 Fix typos leading to unbound variable references.
* module/ice-9/session.scm (help): Fix unbound reference to `env'.

* module/system/vm/program.scm (program-property): Fix typo.

* module/system/vm/frame.scm: Add missing `#:use-module (system vm
  objcode)'.

* module/system/repl/command.scm (guile:load): New.
  (load): Use either `primitive-load' or `load'.

* module/srfi/srfi-18.scm (thread-sleep!): Fix typo.

* module/srfi/srfi-19.scm: Use `(ice-9 rdelim)'.
  (date->broken-down-time, priv:year-day, priv:char->int): Fix typo.
  (time-*->time-*, time-*->time-*!): Fix reference to unbound variable
  `caller'.

* module/oop/goops.scm (bound-check-get): Fix typo.

* module/language/glil/compile-assembly.scm (glil->assembly): Fix typo.

* module/language/glil.scm (parse-glil): Fix typo.

* module/language/ecmascript/base.scm (object->value/string,
  object->value/number, ->number): Fix typos.

* module/language/assembly/disassemble.scm (disassemble-free-vars): Fix
  typo.
2009-10-22 22:57:25 +02:00
Andy Wingo
4b2afc6258 language-readers receive environment as an arg
* 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.
2009-10-16 13:39:24 +02:00
Ludovic Courtès
e5f5113c21 Remove unused variables in system/language.
* module/language/assembly.scm (byte-length): Don't match unused
  record slots.

* module/language/tree-il.scm (tree-il->scheme, post-order!,
  pre-order!): Likewise.

* module/language/tree-il/analyze.scm (analyze-lexicals): Likewise.

* module/language/tree-il/compile-glil.scm (flatten): Likewise.

* module/language/assembly/disassemble.scm (disassemble-load-program):
  Don't match unused list elements.

* module/language/glil/decompile-assembly.scm (decompile-toplevel,
  decompile-load-program): Likewise.

* module/system/xref.scm (program-callee-rev-vars): Likewise.

* module/language/assembly/compile-bytecode.scm
  (write-bytecode)[write-sized-loader]: Remove.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Factorize `pad' variables.

* module/language/ecmascript/base.scm (object->value/string,
  object->value/number)[v]: Remove.

* module/language/ecmascript/tokenize.scm (read-slash)[c0]: Remove.

* module/language/objcode/spec.scm (decompile-value)[nargs]: Remove.

* module/system/repl/command.scm (time)[vms-start, vms-end]: Remove.

* module/system/repl/repl.scm (prompting-meta-read): Use `prompt'.
2009-09-21 00:36:31 +02:00
Andy Wingo
eb1482ac46 debitrot the ecmascript compiler
* 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.
2009-08-12 00:14:44 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Andy Wingo
8f9b968329 some attempts to solve the ecmascript stack overflow problem
* 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.
2009-06-09 23:42:05 +02:00
Andy Wingo
81fd315299 update docs, clean up VM vestiges, macro docs, fix (/ a b c)
* 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.
2009-05-24 13:09:01 +02:00
Andy Wingo
b41b92c9d1 compilation passes return third value: the continuation environment
* 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.
2009-04-16 15:20:40 +02:00
Andy Wingo
6d8182ea1b make the ES compiler more readable via use of ->
* 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.
2009-02-27 16:25:32 +01:00
Andy Wingo
68776b1d94 parse division vs regexps properly
* module/language/ecmascript/tokenize.scm (make-tokenizer/1): Whoops, fix
  the cases in which we detect that division is valid.
2009-02-22 17:37:59 +01:00
Andy Wingo
e05320fa54 compile for-in
* 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) {}...
2009-02-22 16:01:11 +01:00
Andy Wingo
bb67fe27ab fix "for" compilation
* module/language/ecmascript/compile-ghil.scm (comp): Whoops, fix `for'
  compilation.
2009-02-22 12:07:09 +01:00
Andy Wingo
143177ed9e add scheme integration to js via `require'
* 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.
2009-02-22 11:55:20 +01:00
Andy Wingo
a3e34104db ecmascript tokens have source info
* 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...
2009-02-22 11:37:55 +01:00
Andy Wingo
0b229e81a7 throw SyntaxError on bad syntax
* module/language/ecmascript/parse.scm (syntax-error):
* module/language/ecmascript/tokenize.scm (syntax-error): Throw an error
  on bad syntax.
2009-02-22 11:20:15 +01:00
Andy Wingo
af6c20b731 more arithmetic on non-numbers
* module/language/ecmascript/compile-ghil.scm (comp): Convert to number
  on unary +.

* module/language/ecmascript/impl.scm: Define -, *, /, <, <=, >=, >
  operations on non-numbers.
2009-02-22 11:06:13 +01:00
Andy Wingo
8c306808c2 + for strings, global js object, new Foo() works
* 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.
2009-02-22 10:51:49 +01:00
Andy Wingo
aec8febc46 compile ecmascript's parser. yay! instant load-time!
* 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.
2009-02-21 20:28:29 +01:00
Andy Wingo
594d9d4c48 be smarter about allocating local variables, reusing slots if possible
* 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.
2009-02-21 20:28:29 +01:00
Andy Wingo
81d677eb12 implement break and continue, work around overly recursive pmatch expansion
* 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.
2009-02-21 20:28:28 +01:00
Andy Wingo
3bef3ae428 implement do, while, for
* 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.
2009-02-21 00:33:04 +01:00