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

4577 commits

Author SHA1 Message Date
Andy Wingo
40af975ba8 Merge commit 'ad5f5ada1d' into vm-check 2009-03-17 16:06:44 +01:00
Andy Wingo
df22662f5d Merge commit '53d81399be' into vm-check
Also cherry-picks the changes from 1405f1b60fa178303484cd428068ecd01ff6d322

Conflicts:

	module/ice-9/session.scm
2009-03-17 15:59:40 +01:00
Andy Wingo
deca2251b9 revert annotation support in syncase. another day perhaps.
* module/ice-9/syncase.scm: Revert support for annotations, as I'm seeing
  wierd problems whereby syntax-object->datum does not fully strip its
  input.
2009-03-17 15:47:03 +01:00
Andy Wingo
979933ab5b Fix errors when stripping annotations
* module/ice-9/annotate.scm (set-annotation-stripped!): Fix prototype to
  correspond to what syncase needs.

* module/ice-9/psyntax.scm (strip-annotation): Use `if', not `when', for
  portability.

* module/ice-9/psyntax-pp.scm: Regenerate.
2009-03-08 23:51:12 +01:00
Andy Wingo
7118c8050c actually use syncase's source information tracking. rock!
* module/ice-9/annotate.scm (deannotate/source-properties): Version of
  deannotate that sets source properties on the resulting expressions.

* module/ice-9/syncase.scm (sc-macro, syncase): Annotate expressions
  before they go into syncase, and deannotate/source-properties when they
  come out. The upshot is that syncase now understands source
  information, yay!
2009-03-06 19:50:11 +01:00
Andy Wingo
35289f24ee modify psyntax so it produced annotated source if given annotated source
* module/ice-9/psyntax.scm (build-annotated): New helper, used by the
  output constructors.
  (build-application, build-conditional, build-lexical-reference)
  (build-lexical-assignment, build-global-reference)
  (build-global-assignment, build-global-definition, build-lambda)
  (build-primref, build-data, build-sequence, build-let)
  (build-named-let, build-letrec, build-lexical-var): Use
  build-annotated, so we produce annotated source if we have source
  information.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-03-06 19:37:44 +01:00
Andy Wingo
52381a17c4 support source-level annotations in syncase
* module/ice-9/annotate.scm (<annotation>): Slightly more concise
  printing.
  (annotate): Don't create annotations if we have no source info.

* module/ice-9/psyntax.scm (annotation?): Remove this definition, as we
  now provide annotation support.

* module/ice-9/psyntax-pp.scm: Regenerated.

* module/ice-9/syncase.scm: Use (ice-9 annotate).

* module/language/scheme/expand.scm (eval-when): Define the eval-when
  transformer.
2009-03-06 17:01:47 +01:00
Andy Wingo
25d8cd3a0c fix eval-when statements in boot-9
* module/ice-9/boot-9.scm: Fix a couple eval-when statements.
2009-03-06 16:57:17 +01:00
Andy Wingo
b15dea6857 Replace eval-case with eval-when
* module/ice-9/boot-9.scm (eval-when): Replace eval-case with eval-when.
  Eval-when is *much* simpler, and more expressive to boot. Perhaps in
  the future we'll get 'visit and 'revisit too.

* module/ice-9/deprecated.scm (eval-case): Provide mostly-working
  deprecated version of eval-case.

* module/ice-9/boot-9.scm (defmacro, define-macro): Relax condition: we
  can make defmacros that are not at the toplevel now. But in the future
  we should replace this implementation of defmacros with one written in
  syntax-case.
  (define-module, use-modules, use-syntax): Allow at non-toplevel.
  (define-public, defmacro-public, export, re-export): Don't evaluate at
  compile-time, I can't see how that helps things. Allow `export' and
  `re-export' at non-toplevel.

* module/ice-9/getopt-long.scm:
* module/ice-9/i18n.scm:
* module/oop/goops.scm:
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm: Switch to use eval-when, not
  eval-case.

* module/language/scheme/compile-ghil.scm (eval-when): Replace eval-case
  transformer with eval-when transformer. Sooooo much simpler, and it
  will get better once we separate expansion from compilation.

* module/language/scheme/expand.scm (quasiquote): Hm, expand quasiquote
  properly. Not hygienic. Syncase needed.
  (lambda): Handle internal defines with docstrings propertly.
2009-03-06 13:29:13 +01:00
Andy Wingo
07e01c4cf9 fixups to expand.scm
* module/language/scheme/expand.scm: Some changes to avoid unnecessary
  begins or empty lets, and properly handle internal defines (finally).
2009-03-02 22:15:27 +01:00
Andy Wingo
237f96e7f0 add separate expansion phase, to detwingle things a bit
* module/language/scheme/expand.scm: New module, implements a separate
  expansion phase, not interleaved with compilation.

* module/language/scheme/amatch.scm: Helper for expand.scm, it's pmatch
  with support for annotated source.

* module/ice-9/Makefile.am (SOURCES): Add annotate.scm to build list --
  early on because it will be used in the compiler.

* module/ice-9/annotate.scm: Fix the printer, default to unstripped
  (whatever that is), and add a deannotator.

* module/system/base/compile.scm (call-with-compile-error-catch): Fix for
  new representation of source locations.

* module/Makefile.am (SCHEME_LANG_SOURCES): Add amatch and expand.
2009-03-02 17:27:45 +01:00
Andy Wingo
b0e4051e9e add annotation module
* module/ice-9/annotate.scm: Add annotation module, for source location
  tracking with syncase, and for internal use in the compiler.
2009-03-02 11:23:03 +01: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
3ac6d9f37e use -> macro in scheme->ghil compiler
* module/language/scheme/compile-ghil.scm (->): New macro, makes GHIL
  generation a bit more palatable. Use it in all the transformers.
2009-02-27 15:17:01 +01:00
Andy Wingo
3ca8401113 slight optimization in transform-record, note in optimize*
* module/language/ghil/compile-glil.scm (optimize*): Add a note.

* module/system/base/syntax.scm (transform-record): Access the common
  slots once at the beginning. Cuts down on the number of toplevel refs
  needed by the generated code.
2009-02-27 13:37:35 +01:00
Andy Wingo
89522052e2 introduce -> binding inside transform-record body expressions
* module/system/base/syntax.scm (transform-record): Introduce a ->
  binding inside the body, that produces records of the same type.

* module/language/ghil/compile-glil.scm (optimize*): Remove our ->ghil
  definition, as transform-record introduces a -> binding for us. Nice.
2009-02-27 13:24:38 +01:00
Andy Wingo
b106a3eddc first stabs as s-expression-driven transformation of GHIL
* module/language/ghil/compile-glil.scm (optimize*): Rewritten optimizer
  -- not yet in use, but it's closer to the code that I'd like to write.

* module/system/base/syntax.scm (transform-record): New crazy macro,
  makes GHIL a little less painful to work with.
2009-02-27 12:36:58 +01:00
Andy Wingo
246be37e48 common slot accessors are procedures-with-setters
* module/system/base/syntax.scm (define-type): Common slot accessors are
  also procedures-with-setters.
2009-02-27 10:56:15 +01:00
Andy Wingo
2c65f2d5a7 use common slots mechanism in ghil
* module/system/base/syntax.scm (define-type): Fix getter for common
  slot.

* module/language/ghil.scm (<ghil>): Use the common slots mechanism.
2009-02-27 10:53:00 +01:00
Andy Wingo
43e0c29305 define-type has #:common-slots
* module/system/base/syntax.scm (define-type): Accept a #:common-slots
  argument, defining slots that are in all instances of this type.
2009-02-27 10:44:47 +01:00
Andy Wingo
0704c81395 export procedure-arguments from ice-9 session
* module/system/vm/program.scm (program-arguments): New function, used by
  procedure-arguments.

* module/ice-9/session.scm (procedure-arguments): New exported function,
  returns an alist describing the given procedure.
2009-02-25 00:07:10 +01:00
Ludovic Courtès
3bb299b3f0 Aggregate makefiles for module/system' and module/language'.
* am/guilec (.scm.go): Create the target's directory, in case
  $(builddir) != $(srcdir).

* configure.in: Don't output any makefile under `module/system' or
  `module/language'.

* module/Makefile.am (SUBDIRS): Remove `language' and `system'.  Add `.'
  to the front.
  (modpath, SOURCES, SCHEME_LANG_SOURCES, ECMASCRIPT_LANG_SOURCES,
  GHIL_LANG_SOURCES, GLIL_LANG_SOURCES, ASSEMBLY_LANG_SOURCES,
  BYTECODE_LANG_SOURCES, OBJCODE_LANG_SOURCES, VALUE_LANG_SOURCES): New
  variables, taken from former `Makefile.am' files in sub-directories.
2009-02-24 23:54:16 +01:00
Andy Wingo
c15fa41c0c unbork the repl
* module/system/repl/repl.scm (meta-reader): Whoops, unbork the repl.
2009-02-24 23:34:26 +01:00
Andy Wingo
abf780e45e in meta-reader, return directly if the peeked char is EOF
* module/system/repl/repl.scm (meta-reader): If the (next-char #t)
  returns EOF, return that EOF directly, as it seems that with guile -q,
  the subsequent `read' actually waits for another C-d. Dunno why.
2009-02-24 23:16:58 +01:00
Andy Wingo
a56db0f67e use umask when making permissions on .go files
* module/system/base/compile.scm (call-with-output-file/atomic): Temp
  files get created 0600. After we're done writing, chmod them to
  something in line with the user's umask.
2009-02-24 23:02:33 +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
Ludovic Courtès
73f4d8d1d2 Add -o'/--output' option to "guile-tools compile".
* module/system/base/compile.scm (compile-file): Add optional
  OUTPUT-FILE argument.

* scripts/compile (fail): New procedure.
  (%options): Add `-o'/`--output' option.
  (compile): Handle `-o'.
2009-02-21 00:38:06 +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
Andy Wingo
b358fe6502 implement more operations
* 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.
2009-02-21 00:33:04 +01:00
Andy Wingo
45c10edb74 clean up ++ and -- a little bit
* module/language/ecmascript/compile-ghil.scm (comp): Define let1 and
  begin1 helpers. Use them in pre- and post- increment and decrement.
2009-02-21 00:33:04 +01:00
Andy Wingo
a287987818 implement ++, --, new, delete, void, typeof
* 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.
2009-02-21 00:33:04 +01:00
Andy Wingo
785fb107ef handle "this" in ecmascript
* 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.
2009-02-21 00:33:03 +01:00
Andy Wingo
e80ce73d20 implement more of the standard runtime
* 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.
2009-02-21 00:33:03 +01:00
Ludovic Courtès
8f4e84855e Fix interpretation of `(ice-9 getopt-long)'.
* 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.
2009-02-20 17:38:32 +01:00
Ludovic Courtès
d39b967642 Fix compilation of `(ice-9 getopt-long)'.
* 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'.
2009-02-20 17:12:47 +01:00
Ludovic Courtès
03d6cddc55 Make the `module-defer-observers-mutex' recursive.
* module/ice-9/boot-9.scm (module-defer-observers-mutex): Made
  recursive.  See
  http://lists.gnu.org/archive/html/guile-devel/2009-02/msg00068.html
  for an example where it matters.
2009-02-20 14:23:55 +01:00
Andy Wingo
cdad2166e7 support foo["bar"] in addition to foo.bar
* 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..
2009-02-19 17:25:52 +01:00
Andy Wingo
b72880eb17 implement object literals
* module/language/ecmascript/impl.scm:
* module/language/ecmascript/compile-ghil.scm (comp): Object literals.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix some
  object literal parsing.
2009-02-19 17:14:16 +01:00
Andy Wingo
984dce236b var at toplevel works too
* module/language/ecmascript/compile-ghil.scm (comp): Fix the var form at
  toplevel.
2009-02-19 16:59:21 +01:00
Andy Wingo
7fb4230060 property gets and puts implemented, yays
* 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.
2009-02-19 16:40:22 +01:00